refactor(common,webview): remove redundant console logs and simplify api call

清理了两处页面和工具类中的调试日志,同时简化了uni.setNavigationBarTitle的调用代码,移除了不必要的success/fail回调,只保留核心调用逻辑
This commit is contained in:
2026-07-15 16:24:35 +08:00
parent 2c1703acc5
commit 616fac0312
2 changed files with 8 additions and 15 deletions

View File

@@ -1486,7 +1486,6 @@ export default {
},
title(str) {
console.log(`lang.js setNavigationBarTitle ---------------->`, str);
if (str) {
uni.setNavigationBarTitle({
title: str,

View File

@@ -11,6 +11,13 @@
<script>
import { decodeEntity } from '@/common/js/util.js';
/**
* 必须真机调试
* 在微信模拟器中,行为和真机不一样
* 1. 模拟器中,设置标题不生效,但是,在真机是可以的。
*/
export default {
data() {
return {
@@ -20,12 +27,9 @@ export default {
};
},
onLoad(option) {
console.log(`webview .......................................`)
this.title = decodeURIComponent(option?.title ?? '');
this.enableSetTitle = decodeURIComponent(option?.enable_set_title) == 1;
console.log(`webview -------------------`, { title: this.title, enableSetTitle: this.enableSetTitle });
// #ifdef H5
this.src = decodeEntity(decodeURIComponent(option.src));
// #endif
@@ -35,7 +39,6 @@ export default {
// #endif
},
onShow() {
console.log('webview onShow ------------------------');
this.updateNavbarTitle();
},
watch: {
@@ -54,17 +57,8 @@ export default {
},
updateNavbarTitle(newTitle) {
const title = newTitle ?? this.title;
console.log('webview updateNavbarTitle', title);
if (this.enableSetTitle) {
uni.setNavigationBarTitle({
title: title,
success: function (res) {
console.log('webview updateNavbarTitle success !!')
},
fail: function (err) {
console.error('webview updateNavbarTitle fail !!', err);
}
});
uni.setNavigationBarTitle({title});
}
}
}