1 line
2.5 KiB
Plaintext
1 line
2.5 KiB
Plaintext
{"version":3,"file":"config.js","sources":["../../../../src/store/config.js"],"sourcesContent":["import { defineStore } from 'pinia'\r\nimport { ref } from 'vue'\r\nimport i18n from '@/locale'\r\n\r\n// 定义主题颜色\r\nconst themeColors = {\r\n primary: '#3498db',\r\n secondary: '#2ecc71',\r\n success: '#28a745',\r\n danger: '#dc3545',\r\n warning: '#ffc107',\r\n info: '#17a2b8',\r\n light: '#f8f9fa',\r\n dark: '#343a40',\r\n}\r\n\r\n// 定义支持的语言\r\nconst languages = {\r\n en: 'English',\r\n 'zh-Hans': '中文',\r\n es: 'Español',\r\n fr: 'Français',\r\n de: 'Deutsch',\r\n}\r\n\r\nconst getDefaultTheme = () => uni.getStorageSync('theme') || themeColors.primary\r\nconst getDefaultLanguage = () => uni.getStorageSync('language') || i18n.global.locale.value\r\n\r\nexport const useConfigStore = defineStore('config', () => {\r\n const currentTheme = ref(getDefaultTheme())\r\n const currentLanguage = ref(getDefaultLanguage())\r\n\r\n const changeTheme = (color) => {\r\n if (themeColors[color]) {\r\n currentTheme.value = themeColors[color]\r\n uni.setStorageSync('theme', themeColors[color]) // 保存主题到本地存储\r\n }\r\n }\r\n\r\n const changeLanguage = (lang) => {\r\n if (languages[lang]) {\r\n currentLanguage.value = lang\r\n i18n.global.locale = lang\r\n uni.setStorageSync('language', lang) // 保存语言设置到本地存储\r\n }\r\n }\r\n\r\n return {\r\n themeColors,\r\n currentTheme,\r\n languages,\r\n currentLanguage,\r\n changeTheme,\r\n changeLanguage,\r\n }\r\n})\r\n\r\nexport default i18n\r\n"],"names":["uni","i18n","defineStore","ref"],"mappings":";;;AAKA,MAAM,cAAc;AAAA,EAClB,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;AAGA,MAAM,YAAY;AAAA,EAChB,IAAI;AAAA,EACJ,WAAW;AAAA,EACX,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,kBAAkB,MAAMA,cAAAA,MAAI,eAAe,OAAO,KAAK,YAAY;AACzE,MAAM,qBAAqB,MAAMA,cAAG,MAAC,eAAe,UAAU,KAAKC,kBAAK,OAAO,OAAO;AAE1E,MAAC,iBAAiBC,cAAAA,YAAY,UAAU,MAAM;AACxD,QAAM,eAAeC,kBAAI,iBAAiB;AAC1C,QAAM,kBAAkBA,kBAAI,oBAAoB;AAEhD,QAAM,cAAc,CAAC,UAAU;AAC7B,QAAI,YAAY,KAAK,GAAG;AACtB,mBAAa,QAAQ,YAAY,KAAK;AACtCH,oBAAAA,MAAI,eAAe,SAAS,YAAY,KAAK,CAAC;AAAA,IAC/C;AAAA,EACF;AAED,QAAM,iBAAiB,CAAC,SAAS;AAC/B,QAAI,UAAU,IAAI,GAAG;AACnB,sBAAgB,QAAQ;AACxBC,wBAAK,OAAO,SAAS;AACrBD,0BAAI,eAAe,YAAY,IAAI;AAAA,IACpC;AAAA,EACF;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACH,CAAC;;"} |