acdr-ui/dist/dev/mp-weixin/store/config.js

50 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
const common_vendor = require("../common/vendor.js");
const locale_index = require("../locale/index.js");
const themeColors = {
primary: "#3498db",
secondary: "#2ecc71",
success: "#28a745",
danger: "#dc3545",
warning: "#ffc107",
info: "#17a2b8",
light: "#f8f9fa",
dark: "#343a40"
};
const languages = {
en: "English",
"zh-Hans": "中文",
es: "Español",
fr: "Français",
de: "Deutsch"
};
const getDefaultTheme = () => common_vendor.index.getStorageSync("theme") || themeColors.primary;
const getDefaultLanguage = () => common_vendor.index.getStorageSync("language") || locale_index.i18n.global.locale.value;
const useConfigStore = common_vendor.defineStore("config", () => {
const currentTheme = common_vendor.ref(getDefaultTheme());
const currentLanguage = common_vendor.ref(getDefaultLanguage());
const changeTheme = (color) => {
if (themeColors[color]) {
currentTheme.value = themeColors[color];
common_vendor.index.setStorageSync("theme", themeColors[color]);
}
};
const changeLanguage = (lang) => {
if (languages[lang]) {
currentLanguage.value = lang;
locale_index.i18n.global.locale = lang;
common_vendor.index.setStorageSync("language", lang);
}
};
return {
themeColors,
currentTheme,
languages,
currentLanguage,
changeTheme,
changeLanguage
};
});
exports.useConfigStore = useConfigStore;
//# sourceMappingURL=config.js.map