From e87c2cad531ad2d57fecd5e0a313edd77b660cf2 Mon Sep 17 00:00:00 2001 From: "Ray.Hao" <1490493387@qq.com> Date: Tue, 14 Apr 2026 14:46:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE=E4=B8=8E=E6=A0=B7=E5=BC=8F=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 +- package.json | 4 +- pages.config.ts | 2 +- src/App.vue | 8 + src/api/file.ts | 4 +- src/components/custom-navbar/index.vue | 6 +- src/composables/useNavbar.ts | 21 +- src/manifest.json | 6 +- src/pages.json | 3 +- src/pages/index/index.vue | 55 ++-- src/pages/login/index.vue | 340 +++++++++++++------------ src/pages/mine/index.vue | 2 +- src/pages/mine/settings/index.vue | 8 +- src/pages/work/index.vue | 15 +- src/router/index.ts | 44 ++-- src/static/icons/browser.svg | 6 - src/static/icons/pv.svg | 1 + src/static/icons/uv.svg | 1 + src/static/icons/visitor.svg | 8 - src/store/modules/theme.ts | 22 +- src/store/modules/user.ts | 7 +- src/styles/index.scss | 3 +- src/theme.json | 26 +- src/types/auto-imports.d.ts | 4 - src/types/global.d.ts | 2 +- src/uni.scss | 26 +- src/utils/request.ts | 58 +++-- src/utils/storage.ts | 44 +--- 28 files changed, 370 insertions(+), 359 deletions(-) delete mode 100644 src/static/icons/browser.svg create mode 100644 src/static/icons/pv.svg create mode 100644 src/static/icons/uv.svg delete mode 100644 src/static/icons/visitor.svg diff --git a/.env.development b/.env.development index 918c77c..0f1526e 100644 --- a/.env.development +++ b/.env.development @@ -7,7 +7,8 @@ VITE_APP_PORT = 4096 VITE_APP_BASE_API = '/dev-api' # API 服务器的 URL -VITE_APP_API_URL = http://localhost:8000 +# VITE_APP_API_URL = http://localhost:8000 +VITE_APP_API_URL = https://api.youlai.tech # WebSocket 服务器的 URL,不配置默认关闭 WebSocket #VITE_APP_WS_ENDPOINT= ws://localhost:4096/ws diff --git a/package.json b/package.json index 5ff97b8..cde8483 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "stylelint-config-recommended-scss": "^14.1.0", "stylelint-config-recommended-vue": "^1.6.1", "stylelint-prettier": "^5.0.3", - "typescript": "^4.9.5", + "typescript": "^5.7.0", "typescript-eslint": "^8.46.0", "uni-mini-router": "^0.1.6", "unocss": "^0.62.4", @@ -141,6 +141,6 @@ "unplugin-auto-import": "^0.18.6", "vite": "6.3.2", "vue-eslint-parser": "^9.4.3", - "vue-tsc": "^1.8.27" + "vue-tsc": "^2.2.0" } } diff --git a/pages.config.ts b/pages.config.ts index 3c490fd..b0d8eb8 100644 --- a/pages.config.ts +++ b/pages.config.ts @@ -7,7 +7,7 @@ export default defineUniPages({ globalStyle: { navigationBarBackgroundColor: "@navBgColor", navigationBarTextStyle: "@navTxtStyle", - navigationBarTitleText: "vue-uniapp-template", + navigationBarTitleText: "youlai-app", backgroundColor: "@bgColor", backgroundTextStyle: "@bgTxtStyle", backgroundColorTop: "@bgColorTop", diff --git a/src/App.vue b/src/App.vue index de40390..d18088c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,3 +1,11 @@ diff --git a/src/api/file.ts b/src/api/file.ts index daf20a4..5a4687b 100644 --- a/src/api/file.ts +++ b/src/api/file.ts @@ -1,4 +1,4 @@ -import { getToken } from "@/utils/storage"; +import { getAccessToken } from "@/utils/auth"; import { ApiCode } from "@/enums/api-code-enum"; // H5 使用 VITE_APP_BASE_API 作为代理路径,其他平台使用 VITE_APP_API_URL 作为请求路径 @@ -25,7 +25,7 @@ const FileAPI = { filePath: filePath, name: "file", header: { - Authorization: getToken() ? `Bearer ${getToken()}` : "", + Authorization: getAccessToken() ? `Bearer ${getAccessToken()}` : "", }, formData: {}, success: (response) => { diff --git a/src/components/custom-navbar/index.vue b/src/components/custom-navbar/index.vue index ea3132c..d62d206 100644 --- a/src/components/custom-navbar/index.vue +++ b/src/components/custom-navbar/index.vue @@ -57,13 +57,13 @@ interface Props { const props = withDefaults(defineProps(), { title: "", - titleColor: "#333333", - bgColor: "#ffffff", + titleColor: "var(--color-text)", + bgColor: "var(--color-bg)", showBack: true, showHome: false, backIcon: "arrow-left", backIconSize: "20px", - iconColor: "#333333", + iconColor: "var(--color-text)", fixed: true, placeholder: false, navBarHeight: 44, diff --git a/src/composables/useNavbar.ts b/src/composables/useNavbar.ts index a765ea6..d16e264 100644 --- a/src/composables/useNavbar.ts +++ b/src/composables/useNavbar.ts @@ -1,4 +1,4 @@ -import { ref, computed, onMounted } from "vue"; +import { ref, computed, type Ref, type ComputedRef } from "vue"; /** * 微信小程序导航栏高度计算 @@ -175,6 +175,15 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { }, delayMs); } else { console.warn("getMenuButtonBoundingClientRect 返回值无效,使用默认值"); + // 兜底:设置合理的默认胶囊按钮尺寸,避免导航栏高度为 0 + menuButton.value = { + width: 87, + height: 32, + top: statusBarHeight.value + 6, + right: windowWidth.value - 10, + bottom: statusBarHeight.value + 38, + left: windowWidth.value - 97, + }; } } catch (e) { console.warn("获取胶囊按钮位置失败,使用默认值", e); @@ -208,10 +217,8 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { } }; - // 在 onMounted 中调用,确保页面渲染完成 - onMounted(() => { - init(); - }); + // setup 阶段同步调用,避免首次渲染闪烁 + init(); return { // 高度信息 @@ -236,7 +243,3 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { init, }; } - -// 类型导出 -type Ref = import("vue").Ref; -type ComputedRef = import("vue").ComputedRef; diff --git a/src/manifest.json b/src/manifest.json index 492dfcf..e38f0ec 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,5 +1,5 @@ { - "name": "vue-uniapp-template", + "name": "youlai-app", "appid": "", "description": "有来移动端跨端解决方案开发模板", "versionName": "1.0.0", @@ -44,7 +44,9 @@ "mp-weixin": { "appid": "wx99a151dc43d2637b", "setting": { - "urlCheck": false + "urlCheck": false, + "ignoreDevUnusedFiles": false, + "ignoreUploadUnusedFiles": false }, "usingComponents": true, "darkMode": true, diff --git a/src/pages.json b/src/pages.json index 4d7ffcd..0b42a76 100644 --- a/src/pages.json +++ b/src/pages.json @@ -40,6 +40,7 @@ "type": "page", "name": "work", "style": { + "navigationStyle": "custom", "navigationBarTitleText": "工作台" }, "layout": "tabbar" @@ -200,7 +201,7 @@ "globalStyle": { "navigationBarBackgroundColor": "@navBgColor", "navigationBarTextStyle": "@navTxtStyle", - "navigationBarTitleText": "vue-uniapp-template", + "navigationBarTitleText": "youlai-app", "backgroundColor": "@bgColor", "backgroundTextStyle": "@bgTxtStyle", "backgroundColorTop": "@bgColorTop", diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 9326238..b70c4bf 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -45,23 +45,23 @@ - - + + 访客数 - + - + {{ visitOverviewData.todayUvCount }} - - + + 浏览量 - + - + {{ visitOverviewData.todayPvCount }} @@ -69,7 +69,7 @@ - +