2024-02-17 13:52:03 +08:00

36 lines
1.0 KiB
TypeScript

import { warn } from '@/utils/log'
import { getAppEnvConfig } from '@/utils/env'
import type { GlobConfig } from '#/config'
export function useGlobSetting(): Readonly<GlobConfig> {
const {
VITE_GLOB_APP_TITLE,
VITE_GLOB_APP_TITLE_CN,
VITE_GLOB_API_URL,
VITE_GLOB_APP_SHORT_NAME,
VITE_GLOB_API_URL_PREFIX,
VITE_GLOB_UPLOAD_URL,
VITE_GLOB_PROD_MOCK,
VITE_GLOB_IMG_URL,
} = getAppEnvConfig()
if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
warn(
`VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`,
)
}
// Take global configuration
const glob: Readonly<GlobConfig> = {
title: VITE_GLOB_APP_TITLE,
titleCN: VITE_GLOB_APP_TITLE_CN,
apiUrl: VITE_GLOB_API_URL,
shortName: VITE_GLOB_APP_SHORT_NAME,
urlPrefix: VITE_GLOB_API_URL_PREFIX,
uploadUrl: VITE_GLOB_UPLOAD_URL,
prodMock: VITE_GLOB_PROD_MOCK,
imgUrl: VITE_GLOB_IMG_URL,
}
return glob as Readonly<GlobConfig>
}