feat(companion): 全面确立以陪吃·陪喝·陪唱为主的核心架构,重构首屏推荐阵容与歌声试听
这个提交包含在:
116
pwuniapp/common/theme.js
普通文件
116
pwuniapp/common/theme.js
普通文件
@@ -0,0 +1,116 @@
|
||||
/**
|
||||
* 前端双主题设计系统核心管理模块
|
||||
* 严格遵照 UI/UX 规范:无 Emoji、纯矢量、高对比度与 WCAG AA 标准
|
||||
*/
|
||||
|
||||
export const THEME_KEYS = {
|
||||
COOL: 'cool',
|
||||
WARM: 'warm'
|
||||
};
|
||||
|
||||
export const THEMES = {
|
||||
[THEME_KEYS.COOL]: {
|
||||
key: THEME_KEYS.COOL,
|
||||
name: '冷光暗夜',
|
||||
description: '深邃暗夜黑与电竞靛蓝流光,专业沉浸质感',
|
||||
tokens: {
|
||||
bgPrimary: '#0A0F1D',
|
||||
bgSurface: '#151D30',
|
||||
bgSurfaceElevated: '#1E2942',
|
||||
bgSurfaceGlass: 'rgba(21, 29, 48, 0.85)',
|
||||
colorBrand: '#6366F1',
|
||||
colorBrandLight: '#818CF8',
|
||||
colorBrandGold: '#F59E0B',
|
||||
colorBrandGlow: 'rgba(99, 102, 241, 0.35)',
|
||||
colorBrandGradient: 'linear-gradient(135deg, #6366F1, #8B5CF6)',
|
||||
borderSubtle: '#1E293B',
|
||||
borderFocus: '#4F46E5',
|
||||
textPrimary: '#F8FAFC',
|
||||
textSecondary: '#94A3B8',
|
||||
textMuted: '#64748B',
|
||||
shadowBrand: '0 8rpx 24rpx rgba(99, 102, 241, 0.35)'
|
||||
}
|
||||
},
|
||||
[THEME_KEYS.WARM]: {
|
||||
key: THEME_KEYS.WARM,
|
||||
name: '暖阳赤焰',
|
||||
description: '深邃暖焦糖褐与暖阳曜橙流光,热情温馨有活力',
|
||||
tokens: {
|
||||
bgPrimary: '#140E0A',
|
||||
bgSurface: '#221711',
|
||||
bgSurfaceElevated: '#2E1F17',
|
||||
bgSurfaceGlass: 'rgba(34, 23, 17, 0.85)',
|
||||
colorBrand: '#F97316',
|
||||
colorBrandLight: '#FB923C',
|
||||
colorBrandGold: '#F59E0B',
|
||||
colorBrandGlow: 'rgba(249, 115, 22, 0.35)',
|
||||
colorBrandGradient: 'linear-gradient(135deg, #F97316, #F59E0B)',
|
||||
borderSubtle: '#342217',
|
||||
borderFocus: '#EA580C',
|
||||
textPrimary: '#FFF7ED',
|
||||
textSecondary: '#C7B5A7',
|
||||
textMuted: '#8C7565',
|
||||
shadowBrand: '0 8rpx 24rpx rgba(249, 115, 22, 0.35)'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'peiwan_app_theme';
|
||||
|
||||
/**
|
||||
* 获取当前持久化的主题标识
|
||||
*/
|
||||
export function getCurrentThemeKey() {
|
||||
try {
|
||||
const saved = uni.getStorageSync(STORAGE_KEY);
|
||||
if (saved && THEMES[saved]) {
|
||||
return saved;
|
||||
}
|
||||
} catch (e) {
|
||||
// 忽略异常,降级到默认
|
||||
}
|
||||
return THEME_KEYS.COOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前主题配置对象
|
||||
*/
|
||||
export function getCurrentTheme() {
|
||||
const key = getCurrentThemeKey();
|
||||
return THEMES[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前主题 Tokens
|
||||
*/
|
||||
export function getCurrentTokens() {
|
||||
return getCurrentTheme().tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换全局主题并持久化,广播全局事件
|
||||
*/
|
||||
export function setTheme(themeKey) {
|
||||
const targetKey = THEMES[themeKey] ? themeKey : THEME_KEYS.COOL;
|
||||
try {
|
||||
uni.setStorageSync(STORAGE_KEY, targetKey);
|
||||
} catch (e) {
|
||||
// 忽略持久化异常
|
||||
}
|
||||
|
||||
// 广播主题变更事件
|
||||
try {
|
||||
uni.$emit('theme-change', targetKey);
|
||||
} catch (e) {
|
||||
// 忽略事件抛出异常
|
||||
}
|
||||
|
||||
return THEMES[targetKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有可选主题列表
|
||||
*/
|
||||
export function getAvailableThemes() {
|
||||
return Object.values(THEMES);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户