diff --git a/.cursor/rules/css-style-guide.mdc b/.cursor/rules/css-style-guide.mdc
new file mode 100644
index 0000000..bff9f3d
--- /dev/null
+++ b/.cursor/rules/css-style-guide.mdc
@@ -0,0 +1,250 @@
+---
+alwaysApply: true
+---
+
+# CSS样式与UnoCSS使用规范
+
+## 样式选择原则
+
+### UnoCSS原子类使用规则
+
+- **≤5个原子类**: 直接使用UnoCSS原子类
+- **>5个原子类**: 必须提取为语义化CSS类,避免模板膨胀
+
+```vue
+
+
+```
+
+### 优先使用UnoCSS预设shortcuts
+
+参考 [unocss.config.ts](mdc:unocss.config.ts) 中定义的shortcuts:
+
+```typescript
+// 已定义的shortcuts,优先使用
+"flex-center": "flex justify-center items-center"
+"flex-start": "flex justify-start items-center"
+"flex-between": "flex justify-between items-center"
+"flex-col-center": "flex flex-col items-center"
+```
+
+## CSS类命名规范
+
+### BEM命名规范
+
+严格遵循BEM (Block\_\_Element--Modifier) 命名规范:
+
+```scss
+// Block: 独立的功能组件
+.user-profile {
+}
+
+// Element: Block的子元素
+.user-profile__avatar {
+}
+.user-profile__action {
+}
+.user-profile__badge {
+}
+
+// Modifier: Block或Element的状态/变体
+.user-profile--dark {
+}
+.user-profile__action--active {
+}
+```
+
+### 命名要求
+
+1. **使用简短、易理解的英文单词**
+2. **符合业务场景语义**
+3. **避免缩写,除非是通用缩写**
+
+```scss
+// ✅ 好的命名
+.user-profile__action
+.stats-card
+.service-icon
+.tool-item
+
+// ❌ 坏的命名
+.up-act
+.sc
+.si
+.ti
+```
+
+## 样式组织原则
+
+### 1. 复用性判断
+
+- 同一组合在项目中出现 >3次 → 提取为语义化类
+- 具备明确语义的区域 → 提取为语义化类
+- 需要主题适配的样式 → 提取为语义化类
+
+### 2. 常用组合添加到shortcuts
+
+当发现重复的原子类组合时,添加到 [unocss.config.ts](mdc:unocss.config.ts):
+
+```typescript
+shortcuts: [
+ {
+ // 现有shortcuts...
+
+ // 新增常用组合
+ "card-container": "mx-30rpx my-20rpx bg-white rounded-16rpx shadow-sm",
+ "action-button": "flex-center w-70rpx h-70rpx bg-white bg-opacity-90 rounded-full",
+ },
+];
+```
+
+### 3. 主题适配
+
+使用wot-design-uni的CSS变量或自定义变量:
+
+```scss
+// ✅ 使用主题变量
+.service-icon {
+ background-color: var(--wot-color-bg-light, #f3f4f6);
+}
+
+// ✅ 响应式主题色
+:color="themeStore.isDark ? '#fff' : '#333'";
+```
+
+### 4. 暗黑模式适配规则
+
+#### 优先级顺序
+
+1. **优先使用wot-design-uni内置变量** - 自动适配暗黑模式
+2. **使用项目 [theme.scss](mdc:src/styles/theme.scss) 定义的变量** - 统一管理主题色
+3. **最后考虑组件内部定义** - 仅用于特殊场景
+
+#### 自定义主题变量定义
+
+当需要自定义颜色时,必须在 [theme.scss](mdc:src/styles/theme.scss) 中定义:
+
+```scss
+/* 在 theme.scss 中添加自定义变量 */
+:root,
+page {
+ --custom-text-color: #333333;
+ --custom-bg-color: #ffffff;
+ --custom-border-color: #e5e7eb;
+}
+
+.wot-theme-dark {
+ --custom-text-color: #ffffff;
+ --custom-bg-color: #1a1a1a;
+ --custom-border-color: #374151;
+}
+```
+
+#### 组件中使用主题变量
+
+```scss
+// ✅ 推荐:使用wot内置变量
+.my-component {
+ background-color: var(--wot-card-bg);
+ color: var(--wot-color-text);
+}
+
+// ✅ 推荐:使用theme.scss定义的变量
+.my-component {
+ background-color: var(--custom-bg-color);
+ border-color: var(--custom-border-color);
+}
+
+// ❌ 避免:组件内部硬编码暗黑模式
+.my-component {
+ background-color: #ffffff;
+}
+.wot-theme-dark .my-component {
+ background-color: #1a1a1a;
+}
+```
+
+#### 图标和文字颜色适配
+
+```vue
+
+
+
+
+
+ 文本
+
+
+
+```
+
+## 实践示例
+
+### 数据统计卡片
+
+```vue
+
+
+
+
+ 0.00
+ 我的余额
+
+
+
+```
+
+### 用户操作按钮
+
+```vue
+
+
+
+
+
+
+
+```
+
+## 禁止项
+
+❌ **不要在SCSS中重复定义UnoCSS已提供的工具类**
+❌ **不要使用 `@apply` 指令**
+❌ **不要把一次性样式放到全局**
+❌ **不要使用非语义化的类名**
+❌ **不要在模板中堆叠超过5个原子类**
+
+## 组件库样式覆盖
+
+使用wot-design-uni组件时:
+
+- 使用 `custom-class` 传入类名
+- 使用 `:deep()` 进行样式穿透
+- 添加 `!important` 提升优先级
+
+```vue
+
+ 退出登录
+
+
+
+```
diff --git a/components.d.ts b/components.d.ts
index 5e5fb83..255c169 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -26,7 +26,6 @@ declare module 'vue' {
WdConfigProvider: typeof import('wot-design-uni/components/wd-config-provider/wd-config-provider.vue')['default']
WdDivider: typeof import('wot-design-uni/components/wd-divider/wd-divider.vue')['default']
WdForm: typeof import('wot-design-uni/components/wd-form/wd-form.vue')['default']
- WdFormItem: typeof import('wot-design-uni/components/wd-form-item/wd-form-item.vue')['default']
WdGrid: typeof import('wot-design-uni/components/wd-grid/wd-grid.vue')['default']
WdGridItem: typeof import('wot-design-uni/components/wd-grid-item/wd-grid-item.vue')['default']
WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
@@ -35,10 +34,10 @@ declare module 'vue' {
WdInput: typeof import('wot-design-uni/components/wd-input/wd-input.vue')['default']
WdLoading: typeof import('wot-design-uni/components/wd-loading/wd-loading.vue')['default']
WdMessageBox: typeof import('wot-design-uni/components/wd-message-box/wd-message-box.vue')['default']
- WdNavbar: typeof import('wot-design-uni/components/wd-navbar/wd-navbar.vue')['default']
WdNoticeBar: typeof import('wot-design-uni/components/wd-notice-bar/wd-notice-bar.vue')['default']
WdNotify: typeof import('wot-design-uni/components/wd-notify/wd-notify.vue')['default']
WdPopup: typeof import('wot-design-uni/components/wd-popup/wd-popup.vue')['default']
+ WdProgress: typeof import('wot-design-uni/components/wd-progress/wd-progress.vue')['default']
WdRadio: typeof import('wot-design-uni/components/wd-radio/wd-radio.vue')['default']
WdRadioGroup: typeof import('wot-design-uni/components/wd-radio-group/wd-radio-group.vue')['default']
WdStatusTip: typeof import('wot-design-uni/components/wd-status-tip/wd-status-tip.vue')['default']
@@ -47,9 +46,6 @@ declare module 'vue' {
WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default']
WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default']
WdTag: typeof import('wot-design-uni/components/wd-tag/wd-tag.vue')['default']
- WdText: typeof import('wot-design-uni/components/wd-text/wd-text.vue')['default']
- WdTextarea: typeof import('wot-design-uni/components/wd-textarea/wd-textarea.vue')['default']
WdToast: typeof import('wot-design-uni/components/wd-toast/wd-toast.vue')['default']
- WdUpload: typeof import('wot-design-uni/components/wd-upload/wd-upload.vue')['default']
}
}
diff --git a/package.json b/package.json
index 78e3089..6958544 100644
--- a/package.json
+++ b/package.json
@@ -95,7 +95,7 @@
"@vueuse/core": "9.13.0",
"pinia": "^2.2.2",
"vue": "^3.5.13",
- "wot-design-uni": "^1.9.1"
+ "wot-design-uni": "^1.13.0"
},
"devDependencies": {
"@commitlint/cli": "^19.5.0",
diff --git a/pages.config.ts b/pages.config.ts
index dc26193..1f068ad 100644
--- a/pages.config.ts
+++ b/pages.config.ts
@@ -7,7 +7,7 @@ export default defineUniPages({
globalStyle: {
navigationBarBackgroundColor: "@navBgColor",
navigationBarTextStyle: "@navTxtStyle",
- navigationBarTitleText: "Wot-Demo",
+ navigationBarTitleText: "vue-uniapp-template",
backgroundColor: "@bgColor",
backgroundTextStyle: "@bgTxtStyle",
backgroundColorTop: "@bgColorTop",
diff --git a/src/api/file.ts b/src/api/file.ts
index 118880f..9cce1e7 100644
--- a/src/api/file.ts
+++ b/src/api/file.ts
@@ -1,5 +1,5 @@
import { getToken } from "@/utils/storage";
-import { ApiCode } from "@/enums/api-code.enum";
+import { ApiCode } from "@/enums/api-code-enum";
// H5 使用 VITE_APP_BASE_API 作为代理路径,其他平台使用 VITE_APP_API_URL 作为请求路径
let baseApi = import.meta.env.VITE_APP_API_URL;
diff --git a/src/enums/api-code.enum.ts b/src/enums/api-code-enum.ts
similarity index 100%
rename from src/enums/api-code.enum.ts
rename to src/enums/api-code-enum.ts
diff --git a/src/layouts/tabbar.vue b/src/layouts/tabbar.vue
index 47c417e..239a9b3 100644
--- a/src/layouts/tabbar.vue
+++ b/src/layouts/tabbar.vue
@@ -66,7 +66,17 @@ export default {
diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue
index 158359f..c5a182f 100644
--- a/src/pages/mine/index.vue
+++ b/src/pages/mine/index.vue
@@ -30,125 +30,144 @@
-
-
-
+
+
+
-
-
- 2
+
+
+ 2
-
-
- 0.00
- 我的余额
-
-
-
- 0
- 我的收藏
-
-
-
- 0
- 浏览历史
-
-
+
+
+
+
+ 0.00
+ 我的余额
+
+
+
+
+ 0
+ 我的收藏
+
+
+
+
+ 0
+ 浏览历史
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ 个人资料
- 个人资料
-
-
-
-
+
+
+
+
+
+
+ 常见问题
- 常见问题
-
-
-
-
+
+
+
+
+
+
+ 问题反馈
- 问题反馈
-
-
-
-
+
+
+
+
+
+
+ 关于我们
- 关于我们
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
- 会员中心
- 解锁更多特权
-
-
-
-
-
-
-
+
+
+
+
+
+
-
- 优惠券
- 查看我的优惠券
-
-
-
-
-
+
+
+
-
-
+
+
-
- 邀请有礼
- 邀请好友得奖励
-
-
-
-
-
-
+
+
+
+
-
+
退出登录
@@ -299,156 +318,35 @@ const navigateToSection = (section: string, subSection?: string) => {
}
}
- .actions {
+ // BEM命名规范的用户操作按钮
+ .user-profile__action {
display: flex;
-
- .action-btn {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 70rpx;
- height: 70rpx;
- margin-left: 16rpx;
- background-color: rgba(255, 255, 255, 0.9);
- border-radius: 50%;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
-
- .badge {
- position: absolute;
- top: -6rpx;
- right: -6rpx;
- z-index: 2;
- min-width: 32rpx;
- height: 32rpx;
- padding: 0 6rpx;
- font-size: 20rpx;
- line-height: 32rpx;
- color: #fff;
- text-align: center;
- background-color: var(--wot-color-danger);
- border: 2rpx solid #fff;
- border-radius: 16rpx;
- }
- }
+ align-items: center;
+ justify-content: center;
+ width: 70rpx;
+ height: 70rpx;
+ background-color: rgba(255, 255, 255, 0.9);
+ border-radius: 50%;
+ // 移除无效果的box-shadow
}
- }
-}
-// 卡片容器
-.card-container {
- margin: 24rpx 30rpx;
- overflow: hidden;
- background-color: #fff;
- border-radius: 16rpx;
- box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
-}
-
-// 卡片头部
-.card-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 20rpx 24rpx;
- border-bottom: 1rpx solid #e5e7eb;
-}
-
-// 暗色模式下的卡片样式
-:deep(.dark) .card-container {
- background-color: #1f2937;
-}
-
-:deep(.dark) .card-header {
- border-bottom-color: #374151;
-}
-
-// 工具项
-.tool-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 25%;
- margin-bottom: 30rpx;
-}
-
-// 工具图标
-.tool-icon {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 90rpx;
- height: 90rpx;
- margin-bottom: 12rpx;
- background-color: #f3f4f6;
- border-radius: 18rpx;
- transition: transform 0.15s ease;
-
- &:active {
- transform: scale(0.95);
- }
-}
-
-// 暗色模式下的工具图标样式
-:deep(.dark) .tool-icon {
- background-color: #374151;
-}
-
-// 数据统计卡片(减少原子类堆叠)
-.stats-card {
- display: flex;
- align-items: center;
- padding: 30rpx;
- margin: 20rpx 30rpx;
- background-color: #ffffff;
- border-radius: 16rpx;
- box-shadow: 0 1rpx 3rpx rgba(0, 0, 0, 0.1);
-}
-
-:deep(.dark) .stats-card {
- background-color: #1f2937;
-}
-
-.stats-item {
- display: flex;
- flex: 1;
- flex-direction: column;
- align-items: center;
-}
-
-.stats-divider {
- width: 1px;
- margin: 0 20rpx;
- background-color: #e5e7eb;
-}
-
-:deep(.dark) .stats-divider {
- background-color: #374151;
-}
-
-// 服务项
-.service-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 24rpx;
- border-bottom: 1rpx solid #e5e7eb;
- transition: background-color 0.15s ease;
-
- &:active {
- background-color: #f3f4f6;
- }
-
- &.service-item-last {
- border-bottom: none;
- }
-}
-
-// 暗色模式下的服务项样式
-:deep(.dark) .service-item {
- border-bottom-color: #374151;
-
- &:active {
- background-color: rgba(255, 255, 255, 0.1);
+ // 通知徽章 - 超过5个原子类,使用CSS类
+ .user-profile__badge {
+ position: absolute;
+ top: -6rpx;
+ right: -6rpx;
+ z-index: 2;
+ min-width: 32rpx;
+ height: 32rpx;
+ padding: 0 6rpx;
+ font-size: 20rpx;
+ line-height: 32rpx;
+ color: #fff;
+ text-align: center;
+ background-color: #ff4757; // 明确的红色
+ border: 2rpx solid #fff;
+ border-radius: 16rpx;
+ }
}
}
@@ -459,14 +357,24 @@ const navigateToSection = (section: string, subSection?: string) => {
justify-content: center;
width: 80rpx;
height: 80rpx;
- margin-right: 20rpx;
- background-color: #f3f4f6;
+ background-color: var(--wot-color-bg-light, #f3f4f6);
border-radius: 16rpx;
}
-// 暗色模式下的服务图标样式
-:deep(.dark) .service-icon {
- background-color: #374151;
+// 工具图标
+.tool-icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 90rpx;
+ height: 90rpx;
+ background-color: var(--wot-color-bg-light, #f3f4f6);
+ border-radius: 18rpx;
+ transition: transform 0.15s ease;
+
+ &:active {
+ transform: scale(0.95);
+ }
}
// 登录按钮样式
diff --git a/src/pages/mine/settings/theme/index.vue b/src/pages/mine/settings/theme/index.vue
index fc7f9d4..0945ebe 100644
--- a/src/pages/mine/settings/theme/index.vue
+++ b/src/pages/mine/settings/theme/index.vue
@@ -1,132 +1,134 @@
-
-
-
-
+
-
-
+
+
+
+
+ 外观模式
+
+
+
-
-
+
+
+
+
+ 主题色彩
+
+
-
- 预设主题色
-
-
+ 预设主题色
+
+
-
- ✓
+
+
+
+ ✓
+
+
+ {{ color.name }}
- {{ color.name }}
-
-
+
+
-
-
- 当前主题色
-
+
+
+
- {{ currentThemeColor }}
+ 当前主题色
+ {{ currentThemeColor }}
-
+
+
+
-
-
-
-
-
-
-
+
+
+
- 主要按钮
+
+ 主要按钮
+
- 主题色文本
+
+
+ 主题色文本
+
+
- 主题色边框
-
-
- 标签
+
+ 标签
+
-
+
重置为默认主题
-
+