初始版本提交
This commit is contained in:
34
src/hooks/setting/index.ts
Normal file
34
src/hooks/setting/index.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import type { GlobConfig } from '/#/config';
|
||||
|
||||
import { warn } from '/@/utils/log';
|
||||
import { getAppEnvConfig } from '/@/utils/env';
|
||||
|
||||
export const useGlobSetting = (): Readonly<GlobConfig> => {
|
||||
const {
|
||||
VITE_GLOB_APP_TITLE,
|
||||
VITE_GLOB_API_URL,
|
||||
VITE_GLOB_APP_SHORT_NAME,
|
||||
VITE_GLOB_API_URL_PREFIX,
|
||||
VITE_GLOB_UPLOAD_URL,
|
||||
VITE_GLOB_OUT_LINK_URL,
|
||||
VITE_GLOB_PRINT_BASE_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,
|
||||
apiUrl: VITE_GLOB_API_URL,
|
||||
shortName: VITE_GLOB_APP_SHORT_NAME,
|
||||
urlPrefix: VITE_GLOB_API_URL_PREFIX,
|
||||
uploadUrl: VITE_GLOB_UPLOAD_URL,
|
||||
outLink: VITE_GLOB_OUT_LINK_URL,
|
||||
printBaseUrl: VITE_GLOB_PRINT_BASE_URL,
|
||||
};
|
||||
return glob as Readonly<GlobConfig>;
|
||||
};
|
||||
Reference in New Issue
Block a user