初始化移动端提交
This commit is contained in:
205
sheep/utils/avatar.js
Normal file
205
sheep/utils/avatar.js
Normal file
File diff suppressed because it is too large
Load Diff
38
sheep/utils/theme-init.js
Normal file
38
sheep/utils/theme-init.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import themeConfig from '@/sheep/config/theme.js';
|
||||
|
||||
/**
|
||||
* 初始化主题系统 - 简化版
|
||||
* 在应用启动时调用,应用统一的主题色 #0055A2
|
||||
*/
|
||||
export function initTheme() {
|
||||
// 应用CSS变量到根元素
|
||||
const cssVars = themeConfig.getCSSVars();
|
||||
|
||||
// 在 uni-app 中设置CSS变量
|
||||
if (typeof uni !== 'undefined' && uni.setStorageSync) {
|
||||
// 存储主题配置
|
||||
uni.setStorageSync('theme-config', cssVars);
|
||||
}
|
||||
|
||||
console.log('主题已初始化,使用主题色:', themeConfig.primary.main);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前主题色
|
||||
*/
|
||||
export function getCurrentTheme() {
|
||||
return themeConfig.primary.main;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主题渐变配置
|
||||
*/
|
||||
export function getThemeGradients() {
|
||||
return themeConfig.gradients;
|
||||
}
|
||||
|
||||
export default {
|
||||
initTheme,
|
||||
getCurrentTheme,
|
||||
getThemeGradients
|
||||
};
|
||||
49
sheep/utils/theme.js
Normal file
49
sheep/utils/theme.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import themeConfig from '@/sheep/config/theme.js';
|
||||
|
||||
/**
|
||||
* 主题管理工具类 - 简化版,只提供主题色配置
|
||||
*/
|
||||
class ThemeManager {
|
||||
constructor() {
|
||||
this.config = themeConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前主题色
|
||||
*/
|
||||
getCurrentThemeColor() {
|
||||
return this.config.primary.main;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主题渐变
|
||||
* @param {string} type - 渐变类型 horizontal|vertical|diagonal
|
||||
*/
|
||||
getGradient(type = 'horizontal') {
|
||||
return this.config.gradients[type] || this.config.gradients.horizontal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主题色变体
|
||||
*/
|
||||
getThemeColors() {
|
||||
return {
|
||||
main: this.config.primary.main,
|
||||
light: this.config.primary.light,
|
||||
dark: this.config.primary.dark,
|
||||
gradient: this.config.primary.gradient
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CSS变量
|
||||
*/
|
||||
getCSSVars() {
|
||||
return this.config.getCSSVars();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建全局实例
|
||||
const themeManager = new ThemeManager();
|
||||
|
||||
export default themeManager;
|
||||
Reference in New Issue
Block a user