refactor(app): 重构应用主题和页面结构

- 移除动态主题切换功能,改为全局统一深色主题
- 实现自定义TabBar组件替换原生tabBar,解决iOS闪白问题
- 创建main容器页面统一管理三个tab页面的生命周期和状态
- 将所有页面的onShow/onHide等生命周期方法迁移到子组件内部
- 更新页面路径从index改为main,并调整路由跳转逻辑
- 移除theme-mixin和相关主题工具函数
- 统一页面背景色设置,优化用户体验一致性
This commit is contained in:
cg
2026-09-23 20:56:14 +08:00
parent a628b73a80
commit d335ec290a
24 changed files with 399 additions and 357 deletions
+24 -23
View File
@@ -1,5 +1,5 @@
<template>
<view :class="themeClass" class="page-container profile-page">
<view class="page-container profile-page">
<!-- 沉浸式头部 -->
<view class="hero-header" :style="{ paddingTop: headerPaddingTop }">
<view class="hero-bg">
@@ -176,11 +176,11 @@ import AchievementBadge from '../../components/AchievementBadge.vue'
import client, { clearAuth, GetAchievements, isLoggedIn, requireLogin } from '../../common/api'
import { checkAchievements, getCatIcon, isIconPath, calcLocalStreak, isValidAvatar } from '../../common/utils'
import { ACHIEVEMENTS, DRINK_CATEGORIES } from '../../common/constants'
import themeMixin from '../../common/theme-mixin'
export default {
mixins: [themeMixin],
components: { AchievementBadge },
// Vue3 组件事件必须显式声明
emits: ['switch-tab'],
data() {
// 获取胶囊按钮位置,动态计算分享按钮偏移和头部内边距
const sysInfo = uni.getSystemInfoSync()
@@ -252,25 +252,26 @@ export default {
return '百天老友,酒中见真章'
}
},
onShow() {
this.checkLoginState()
this.loadData()
},
onShareAppMessage() {
const name = this.user.nickname || '我'
return {
title: `${name}的饮酒名片 - 碰盏日记`,
path: `/pages/share-profile/share-profile?${this.buildShareQuery()}`
}
},
onShareTimeline() {
const name = this.user.nickname || '我'
return {
title: `${name}的饮酒名片 - 碰盏日记`,
query: this.buildShareQuery()
}
},
methods: {
// === 子组件生命周期(由 main.vue 容器通过 ref 调用)===
pageShow() {
this.checkLoginState()
this.loadData()
},
getShareAppMessage() {
const name = this.user.nickname || '我'
return {
title: `${name}的饮酒名片 - 碰盏日记`,
path: `/pages/share-profile/share-profile?${this.buildShareQuery()}`
}
},
getShareTimeline() {
const name = this.user.nickname || '我'
return {
title: `${name}的饮酒名片 - 碰盏日记`,
query: this.buildShareQuery()
}
},
isValidAvatar,
isIconPath,
// 构建分享名片的 query 参数(携带公开档案数据)
@@ -382,13 +383,13 @@ export default {
return ACHIEVEMENTS[index % ACHIEVEMENTS.length].icon
},
goCircle() {
uni.switchTab({ url: '/pages/circle/circle' })
this.$emit('switch-tab', 1)
},
goGames() {
uni.navigateTo({ url: '/pages/games/games' })
},
goHome() {
uni.switchTab({ url: '/pages/index/index' })
this.$emit('switch-tab', 0)
},
goRecord() {
if (!requireLogin()) return