chore:
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view :style="themeColor" class="vr-page">
|
||||
<web-view :src="src" class="vr-webview"></web-view>
|
||||
<web-view :src="src" class="vr-webview" @titleUpdate="forceCustomTitle"></web-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -10,52 +10,60 @@ export default {
|
||||
return {
|
||||
src: '',
|
||||
title: '',
|
||||
customTitle: '',
|
||||
titleTimer: null
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
this.title = option?.title || '工厂展示';
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
this.$api.sendRequest({
|
||||
url: '/api/config/defaultvr',
|
||||
success: res => {
|
||||
if (res.code == 0) {
|
||||
this.title = res.data.title;
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
this.src = res.data.url;
|
||||
this.startTitleGuard();
|
||||
}
|
||||
},
|
||||
this.customTitle = option?.title || '工厂展示';
|
||||
this.title = this.customTitle;
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
this.$api.sendRequest({
|
||||
url: '/api/config/defaultvr',
|
||||
success: res => {
|
||||
if (res.code == 0) {
|
||||
this.customTitle = res.data.title;
|
||||
this.title = this.customTitle;
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
this.src = res.data.url;
|
||||
this.startTitleGuard();
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
}
|
||||
});
|
||||
},
|
||||
onShow() {
|
||||
if (this.title) {
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
}
|
||||
},
|
||||
|
||||
if (this.customTitle) {
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
this.clearTitleGuard();
|
||||
},
|
||||
methods: {
|
||||
startTitleGuard() {
|
||||
this.clearTitleGuard();
|
||||
let count = 0;
|
||||
this.titleTimer = setInterval(() => {
|
||||
uni.setNavigationBarTitle({ title: this.title });
|
||||
count++;
|
||||
if (count >= 10) {
|
||||
this.clearTitleGuard();
|
||||
}
|
||||
}, 100);
|
||||
},
|
||||
clearTitleGuard() {
|
||||
if (this.titleTimer) {
|
||||
clearInterval(this.titleTimer);
|
||||
this.titleTimer = null;
|
||||
forceCustomTitle() {
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
},
|
||||
startTitleGuard() {
|
||||
this.clearTitleGuard();
|
||||
let count = 0;
|
||||
this.titleTimer = setInterval(() => {
|
||||
uni.setNavigationBarTitle({ title: this.customTitle });
|
||||
count++;
|
||||
if (count >= 10) {
|
||||
this.clearTitleGuard();
|
||||
}
|
||||
}, 100);
|
||||
},
|
||||
clearTitleGuard() {
|
||||
if (this.titleTimer) {
|
||||
clearInterval(this.titleTimer);
|
||||
this.titleTimer = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user