From e632a6dd8f4fd0d98dc49411ab18749388fec336 Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 18 May 2026 10:23:19 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8DsetNavigationBarT?= =?UTF-8?q?itle=E8=B0=83=E7=94=A8=E5=90=8E=E5=AF=BC=E8=87=B4=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E9=A2=9C=E8=89=B2=E8=A2=AB=E9=87=8D=E7=BD=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 18 ++++++++++---- src/config.js | 4 ++-- src/main.js | 9 ------- src/pages.json | 40 +++++++++++-------------------- src/pages/index.vue | 4 ---- src/pages/mine.vue | 4 ---- src/utils/navigationBar.js | 48 -------------------------------------- 7 files changed, 29 insertions(+), 98 deletions(-) delete mode 100644 src/utils/navigationBar.js diff --git a/src/App.vue b/src/App.vue index 793ed2d..cfec83f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,17 +2,19 @@ import { getToken } from '@/utils/auth' import { initializeLocale, translateLiteral } from '@/locales' import useUserStore from '@/store/modules/user' -import { applyNavigationBarTheme } from '@/utils/navigationBar' let wrapped = false function wrapUniTextApi() { if (wrapped) return wrapped = true + const rawShowToast = uni.showToast const rawShowModal = uni.showModal const rawShowLoading = uni.showLoading const rawSetNavigationBarTitle = uni.setNavigationBarTitle + const rawSetNavigationBarColor = uni.setNavigationBarColor + uni.showToast = (options = {}) => { const next = { ...options } if (typeof next.title === 'string') { @@ -49,7 +51,17 @@ function wrapUniTextApi() { next.title = translateLiteral(next.title) } const result = rawSetNavigationBarTitle(next) - applyNavigationBarTheme() + setTimeout(() => { + const pages = getCurrentPages() + if (pages && pages.length > 0) { + const route = pages[pages.length - 1].route || '' + if (route === 'pages/login') { + rawSetNavigationBarColor({ frontColor: '#000000', backgroundColor: '#ffffff' }) + } else { + rawSetNavigationBarColor({ frontColor: '#ffffff', backgroundColor: '#22486e' }) + } + } + }, 150) return result } } @@ -58,7 +70,6 @@ export default { onLaunch: function () { initializeLocale() wrapUniTextApi() - applyNavigationBarTheme() if (getToken()) { useUserStore().getInfo().catch(() => {}) } @@ -66,7 +77,6 @@ export default { onShow: function () { initializeLocale() wrapUniTextApi() - applyNavigationBarTheme() }, onHide: function () { } diff --git a/src/config.js b/src/config.js index e5e6951..8d5322b 100644 --- a/src/config.js +++ b/src/config.js @@ -1,8 +1,8 @@ // 应用全局配置 const config = { // baseUrl: 'http://47.106.185.127:48080',127.0.0.1 - baseUrl: 'https://besure.ngsk.tech:7001', - // baseUrl: 'http://192.168.5.167:48081', + // baseUrl: 'https://besure.ngsk.tech:7001', + baseUrl: 'http://192.168.5.106:48081', // baseUrl: '', // 应用信息 appInfo: { diff --git a/src/main.js b/src/main.js index 7cf7f96..8783c34 100644 --- a/src/main.js +++ b/src/main.js @@ -11,9 +11,6 @@ import { translateLiteral } from '@/locales' import { useDict } from '@/utils/dict' import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi' -import { applyNavigationBarTheme } from '@/utils/navigationBar' - - export function createApp() { const app = createSSRApp(App) @@ -33,12 +30,6 @@ export function createApp() { app.config.globalProperties.selectDictLabels = selectDictLabels app.config.globalProperties.$tl = translateLiteral - app.mixin({ - onShow() { - applyNavigationBarTheme() - } - }) - return { app } diff --git a/src/pages.json b/src/pages.json index 05b6bd4..cb855e6 100644 --- a/src/pages.json +++ b/src/pages.json @@ -11,14 +11,17 @@ "^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue" } }, + "globalStyle": { + "navigationBarTextStyle": "white", + "navigationBarTitleText": "BESURE", + "navigationBarBackgroundColor": "#22486e" + }, "pages": [ { "path": "pages/index", "style": { "navigationBarTitleText": "首页", - "enablePullDownRefresh": false, - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "enablePullDownRefresh": false } }, { @@ -33,43 +36,32 @@ "path": "pages/work", "style": { "navigationBarTitleText": "管理", - "enablePullDownRefresh": false, - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "enablePullDownRefresh": false } }, - { "path": "pages/mine", "style": { - "navigationBarTitleText": "个人中心", - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "navigationBarTitleText": "个人中心" } }, { "path": "pages/common/webview/index", "style": { - "navigationBarTitleText": "浏览网页", - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "navigationBarTitleText": "浏览网页" } }, { "path": "pages/common/textview/index", "style": { - "navigationBarTitleText": "浏览文本", - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "navigationBarTitleText": "浏览文本" } }, { "path": "pages/report", "style": { "navigationBarTitleText": "报表", - "enablePullDownRefresh": false, - "navigationBarBackgroundColor": "#22486e", - "navigationBarTextStyle": "white" + "enablePullDownRefresh": false } } ], @@ -88,8 +80,7 @@ "style": { "navigationBarTitleText": "代报工" } - } - , + }, { "path": "planProgress", "style": { @@ -649,10 +640,5 @@ "text": "我的" } ] - }, - "globalStyle": { - "navigationBarTextStyle": "white", - "navigationBarTitleText": "BESURE", - "navigationBarBackgroundColor": "#22486e" } -} +} \ No newline at end of file diff --git a/src/pages/index.vue b/src/pages/index.vue index 3b52d42..1c839fd 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -19,7 +19,6 @@