bugfix(webcam): display the wrong webcam if you connect to a remote printer with relativ webcam url (#345)

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej authored and GitHub committed 2021-08-31 21:33:31 +02:00
1 parent 41b21aa66e
commit 005ed8814b
5 files changed
+11 -9

No files matched your search

+4
View File
@@ -8,6 +8,10 @@ export default class BaseMixin extends Vue {
return this.$store.getters['socket/getUrl']
}
get hostUrl(): boolean {
return this.$store.getters['socket/getHostUrl']
}
get remoteMode() {
return this.$store.state.socket.remoteMode
}
+1 -3
View File
@@ -35,9 +35,7 @@ export default class Mjpegstreamer extends Mixins(BaseMixin) {
get url() {
const baseUrl = this.camSettings.url
const hostUrl = new URL(this.printerUrl === undefined ? document.URL : this.printerUrl)
const url = new URL(baseUrl, hostUrl.origin)
const url = new URL(baseUrl, this.printerUrl === undefined ? this.hostUrl.toString() : this.printerUrl)
url.searchParams.append('bypassCache', this.refresh.toString())
return decodeURIComponent(url.toString())
@@ -95,9 +95,7 @@ export default class MjpegstreamerAdaptive extends Mixins(BaseMixin) {
async setFrame() {
const baseUrl = this.camSettings.url
const hostUrl = new URL(this.printerUrl === undefined ? document.URL : this.printerUrl)
const url = new URL(baseUrl, hostUrl.origin)
const url = new URL(baseUrl, this.printerUrl === undefined ? this.hostUrl.toString() : this.printerUrl)
url.searchParams.append('bypassCache', this.refresh.toString())
url.searchParams.set('action', 'snapshot')
+1 -3
View File
@@ -32,9 +32,7 @@ export default class Uv4lMjpeg extends Mixins(BaseMixin) {
get url() {
const baseUrl = this.camSettings.url
const hostUrl = new URL(this.printerUrl === null ? document.URL : this.printerUrl)
const url = new URL(baseUrl, hostUrl.origin)
const url = new URL(baseUrl, this.printerUrl === null ? this.hostUrl.toString() : this.printerUrl)
return decodeURIComponent(url.toString())
}
+4
View File
@@ -8,6 +8,10 @@ export const getters: GetterTree<SocketState, RootState> = {
return "//" + state.hostname + (state.port !== 80 ? ":"+state.port : "")
},
getHostUrl: (state) => {
return (state.protocol === 'wss' ? 'https' : 'http')+"://" + state.hostname + '/'
},
getWebsocketUrl: (state, getters) => {
return state.protocol + ":" + getters['getUrl'] + "/websocket"
},