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 2021-08-31 21:33:31 +02:00 committed by GitHub
parent 41b21aa66e
commit 005ed8814b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 9 deletions

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
}

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())

View File

@ -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')

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())
}

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"
},