| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import type { AppConfig } from "@@/types/AppConfig"
- import apis from "@a"
- export const LS_APP_CONFIG_NAME_KEY = `app_config_${import.meta.env.VITE_APP_NAME}_${
- import.meta.env.VITE_APP_VERSION
- }`
- export const useAppConfigStore = defineStore("appConfig", () => {
- const config = ref<AppConfig>(
- localCache.getJSON(LS_APP_CONFIG_NAME_KEY) ?? {
- registerEnabled: false,
- captchaEnabled: true,
- workflowEnabled: true,
- ossPreviewEnabled: true
- }
- )
- function loadConfig() {
- return new Promise((resolve) => {
- apis.loginApi.getAppConfig().then((res: any) => {
- config.value = res.data
- localCache.setJSON(LS_APP_CONFIG_NAME_KEY, res.data)
- resolve(true)
- })
- })
- }
- function getConfig(): AppConfig {
- return config.value
- }
- function getPlatformName() {
- return getConfig().platformName
- }
- function isTenant() {
- return getConfig().tenantEnabled
- }
- function isRegister() {
- return getConfig().registerEnabled
- }
- function isCaptcha() {
- return getConfig().captchaEnabled
- }
- function isWorkflow() {
- return getConfig().workflowEnabled
- }
- function isOssPreview() {
- return getConfig().ossPreviewEnabled
- }
- return {
- loadConfig,
- getConfig,
- getPlatformName,
- isTenant,
- isRegister,
- isCaptcha,
- isWorkflow,
- isOssPreview
- }
- })
|