前端开发
在 wot-ui 项目中生成单文件品牌主题 SCSS…
当需要为 wot-ui 项目创建单文件语义变量主题 SCSS,并仅在用户明确要求时通过 App.vue 的 @use 接入时使用。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 60/100 ×0.15
适用场景
在 wot-ui 项目中生成单文件品牌主特定
解决思路
- 先查看项目中是否已存在 `src/themes/styles/*.scss` 与 `src/App.vue`,确认接入位置和现有主题 `@use` 顺序。
- 若用户未给足主题信息,先收集:主题名称(如 `antd`、`ocean`、`forest`);主题风格描述(如品牌化、偏中性、偏高对比);主色 10 阶是否全部自定义;`danger`、`success`、`warning` 是否沿用默认值;文本、边框、填充、反馈态是否需要整体调性调整;是否需要同步接入 `src/App.vue`。
- 只创建一个主题文件:`src/themes/styles/{主题名}.scss`,不生成 `dark.scss`,不扩展为 light/dark 双文件结构。
- 主题文件内必须同时包含一个 `@mixin {主题名}-theme-vars`,以及 `page`、`.wot-theme-{主题名}`、`.wot-theme-{主题名} .wd-root-portal` 的挂载选择器。
- 在主题文件内直接写挂载选择器,选择器块使用 `@include {主题名}-theme-vars();` 调用 mixin。
- 所有语义变量必须填写固定色值或 `transparent`,不要写成 `var(--wot-xxx)`。
- 不修改 `uni_modules/wot-ui/styles/theme/index.scss`。
- 如果用户没有明确要求接入 `App.vue`,默认只生成主题文件并给出应追加的 `@use` 语句,不主动改 `App.vue`。
- 主题文件只保留一个 mixin,命名为 `{主题名}-theme-vars`;注释风格尽量贴近 `antd.scss` 这种语义分组写法;mixin 调用形式固定为 `@include {主题名}-theme-vars();`。
- `App.vue` 若需接入,仅在 `style lang=scss` 中追加 `@use './themes/styles/{主题名}.scss' as {主题名};`。
- 不在 `App.vue` 里重复写 `page, .wot-theme-{主题名}` 这些挂载块。
- 如果已有其他主题 `@use`,保持原有顺序和已有块不被破坏,只追加当前主题。
- 按完整变量模板输出全部语义变量,包含:主色 `--wot-primary-1` 到 `--wot-primary-10`;Danger 的 `--wot-danger-main`、`--wot-danger-hover`、`--wot-danger-clicked`、`--wot-danger-disabled`、`--wot-danger-particular`、`--wot-danger-surface`;Success 的 `--wot-success-main`、`--wot-success-hover`、`--wot-success-clicked`、`--wot-success-disabled`、`--wot-success-particular`、`--wot-success-surface`;Warning 的 `--wot-warning-main`、`--wot-warning-hover`、`--wot-warning-clicked`、`--wot-warning-disabled`、`--wot-warning-particular`、`--wot-warning-surface`;Text 的 `--wot-text-main`、`--wot-text-secondary`、`--wot-text-auxiliary`、`--wot-text-disabled`、`--wot-text-placeholder`、`--wot-text-white`;Icon 的 `--wot-icon-main`、`--wot-icon-secondary`、`--wot-icon-auxiliary`、`--wot-icon-disabled`、`--wot-icon-placeholder`、`--wot-icon-white`;Border 的 `--wot-border-extra-strong`、`--wot-border-strong`、`--wot-border-main`、`--wot-border-light`、`--wot-border-white`、`--wot-border-zero`;Filled 的 `--wot-filled-extra-strong`、`--wot-filled-strong`、`--wot-filled-content`、`--wot-filled-bottom`、`--wot-filled-oppo`、`--wot-filled-zero`;Divider 的 `--wot-divider-main`、`--wot-divider-light`、`--wot-divider-strong`、`--wot-divider-white`;Feedback 的 `--wot-feedback-hover`、`--wot-feedback-active`、`--wot-feedback-accent`;Opacity filled 的 `--wot-opacfilled-tooltip-toast-cover`、`--wot-opacfilled-main-cover`、`--wot-opacfilled-light-cover`;Picker view mask 的 `--wot-picker-view-mask-start-color`、`--wot-picker-view-mask-end-color`;Classify application 的 yellow/cyan/purple/grape/pink 各三组 background/border/content 变量(`--wot-classifyapplication-yellow-background`、`--wot-classifyapplication-yellow-border`、`--wot-classifyapplication-yellow-content`、`--wot-classifyapplication-Cyan-background`、`--wot-classifyapplication-Cyan-border`、`--wot-classifyapplication-Cyan-content`、`--wot-classifyapplication-Purple-background`、`--wot-classifyapplication-Purple-border`、`--wot-classifyapplication-Purple-content`、`--wot-classifyapplication-Grape-background`、`--wot-classifyapplication-Grape-border`、`--wot-classifyapplication-Grape-content`、`--wot-classifyapplication-Pink-background`、`--wot-classifyapplication-Pink-border`、`--wot-classifyapplication-Pink-content`)。
- 完成后按检查清单核对:主题文件位于 `src/themes/styles/{主题名}.scss`;文件包含一个 `@mixin {主题名}-theme-vars`;文件内完成 `page`、`.wot-theme-{主题名}`、`.wot-theme-{主题名} .wd-root-portal` 挂载;包含主色、功能色、文字、图标、边框、填充、分割线、反馈、透明填充、Picker View 遮罩、分类色全部变量;所有值都是固定色值或 `transparent`;`App.vue` 中若接入只追加 `@use './themes/styles/{主题名}.scss' as {主题名};`;mixin 调用形式为 `@include {主题名}-theme-vars();`。
- 用户未明确要求时,不要顺手生成 dark 主题、变量映射层或额外目录结构。
- 生成代码时优先保持最小改动,不破坏现有主题文件顺序、选择器范围和项目风格。
- 如果发现项目里已有不同主题体系,先说明差异,再确认是否仍按本单文件结构落地。
适用边界 · 注意事项
- 用户只是想知道 `wd-config-provider` 或普通 CSS 变量怎么用时,优先使用 `wot-ui-v2` skill。
- 用户要做 light/dark 双主题、动态换肤系统或运行时 token 注入时,不按本单文件结构处理。
- 当前仓库没有实际业务 `src/App.vue` 或主题目录时,不要臆造文件;应基于用户目标项目路径执行,或先向用户确认目标工程位置。