feat: 增加主题色功能

This commit is contained in:
2026-09-01 11:15:00 +08:00
parent bb5a9b3c0f
commit bc6512f668
12 changed files with 386 additions and 229 deletions

View File

@@ -1,67 +1,73 @@
<template>
<view class="min-h-screen bg-[#f2f4f3] pb-10">
<wd-card title="个人信息" type="rectangle">
<view class="flex items-center gap-4">
<wd-avatar :text="profile.name ? profile.name.charAt(0).toUpperCase() : '我'" bg-color="#8b5cf6" />
<wd-config-provider :theme-vars="getTheme(appStore.themeColor)">
<view class="min-h-screen bg-[#f2f4f3] pb-10">
<wd-card title="个人信息" type="rectangle">
<view class="flex items-center gap-4">
<wd-avatar :text="profile.name ? profile.name.charAt(0).toUpperCase() : '我'"
:bg-color="getThemePrimaryColor[appStore.themeColor]" />
<view class="flex flex-col">
<text class="text-lg text-gray-800 font-semibold">
{{ profile.name || '未设置姓名' }}
</text>
<text class="mt-0.5 text-xs text-gray-400">
{{ genderText }} · {{ profile.height ? `${profile.height} cm` : '身高未填' }}
</text>
<view class="flex flex-col">
<text class="text-lg text-gray-800 font-semibold">
{{ profile.name || '未设置姓名' }}
</text>
<text class="mt-0.5 text-xs text-gray-400">
{{ genderText }} · {{ profile.height ? `${profile.height} cm` : '身高未填' }}
</text>
</view>
<view class="ml-auto">
<wd-button size="small" plain type="primary" @click="openProfile">
编辑
</wd-button>
</view>
</view>
<view class="ml-auto">
<wd-button size="small" plain type="primary" @click="openProfile">
编辑
</wd-card>
<wd-card title="积分成就" type="rectangle">
<view class="flex items-center justify-between">
<view class="mt-2 space-y-1 text-gray-600">
<view> 当前积分{{ appStore.points }}</view>
<view>📊 记录次数{{ appStore.recordCount }}</view>
<view>🏆 当前成就{{ appStore.achievement }}</view>
</view>
<wd-button size="small" plain type="primary" @click="openPointPopup">
查看说明
</wd-button>
</view>
</view>
</wd-card>
<wd-card title="积分成就" type="rectangle">
<view class="flex items-center justify-between">
<view class="mt-2 space-y-1 text-gray-600">
<view> 当前积分{{ appStore.points }}</view>
<view>📊 记录次数{{ appStore.recordCount }}</view>
<view>🏆 当前成就{{ appStore.achievement }}</view>
<view class="mt-2 text-xs text-gray-400">
坚持记录健康数据解锁更多成就
</view>
</wd-card>
<wd-button size="small" plain type="primary" @click="openPointPopup">
查看说明
</wd-button>
</view>
<wd-cell-group>
<wd-cell size="large" title="记录默认值" is-link @click="openDefaultPopup"/>
<wd-cell size="large" title="今日概览" is-link @click="openOverviewPopup"/>
<wd-cell size="large" title="今日计划" is-link @click="openPlanPopup"/>
<wd-cell size="large" title="数据统计" is-link @click="openStatsPopup"/>
<wd-cell size="large" title="主题色" is-link @click="openThemePopup"/>
<wd-cell size="large" title="存储详情" is-link @click="openStoragePopup"/>
</wd-cell-group>
<view class="mt-2 text-xs text-gray-400">
坚持记录健康数据解锁更多成就
</view>
</wd-card>
<wd-text :text="`版本号:${appStore.version}`" custom-style="margin-top: 5px;display:block; text-align:center;"></wd-text>
<wd-cell-group>
<wd-cell size="large" title="记录默认值" is-link @click="openDefaultPopup"/>
<wd-cell size="large" title="今日概览" is-link @click="openOverviewPopup"/>
<wd-cell size="large" title="今日计划" is-link @click="openPlanPopup"/>
<wd-cell size="large" title="数据统计" is-link @click="openStatsPopup"/>
<wd-cell size="large" title="存储详情" is-link @click="openStoragePopup"/>
</wd-cell-group>
<profile-popup />
<wd-text :text="`版本号:${appStore.version}`" custom-style="margin-top: 5px;display:block; text-align:center;"></wd-text>
<storage-popup />
<profile-popup />
<overview-popup />
<storage-popup />
<plan-popup />
<overview-popup />
<stats-popup />
<plan-popup />
<default-popup />
<stats-popup />
<point-popup />
<default-popup />
<point-popup />
</view>
<theme-popup />
</view>
</wd-config-provider>
</template>
<script lang="ts" setup>
@@ -74,12 +80,13 @@ import { getDefaultRecordValue, getOverview, getPlan, getProfile, getStats } fro
import { useProfileStore } from '@/store/profile'
import { useAppStore } from "@/store/app";
import type { IProfile } from "@/type/profile";
import { countRecordsByMonth, getMaxRecord, getTotalCount } from "@/utils/record";
import DefaultPopup from "@/components/Profile/DefaultPopup.vue";
import { getAchievement, getPoints, getRecordCount } from "@/utils/points";
import { onShow } from "@dcloudio/uni-app";
import PointPopup from "@/components/Profile/PointPopup.vue";
import StatsPopup from "@/components/Profile/StatsPopup.vue";
import { getTheme, getThemePrimaryColor } from "@/utils/themes";
import ThemePopup from "@/components/Profile/ThemePopup.vue";
const profileStore = useProfileStore()
const appStore = useAppStore()
@@ -131,6 +138,10 @@ function openStatsPopup() {
profileStore.showStatsPopup = true
}
function openThemePopup() {
profileStore.showThemePopup = true
}
function openStoragePopup() {
profileStore.refreshStorage()
profileStore.showStoragePopup = true