diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b0ac3ed --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.aider* diff --git a/client/admin/api.ts b/client/admin/api.ts index 8c21d68..dd83fbf 100644 --- a/client/admin/api.ts +++ b/client/admin/api.ts @@ -1,4 +1,5 @@ import axios from 'axios'; +import { getGlobalConfig } from './utils.ts'; import type { MinioUploadPolicy, OSSUploadPolicy } from '@d8d-appcontainer/types'; import 'dayjs/locale/zh-cn'; import type { @@ -16,7 +17,7 @@ const API_BASE_URL = '/api'; // 获取OSS完整URL export const getOssUrl = (path: string): string => { // 获取全局配置中的OSS_HOST,如果不存在使用默认值 - const ossHost = (window.CONFIG?.OSS_BASE_URL) || ''; + const ossHost = getGlobalConfig('OSS_BASE_URL') || ''; // 确保path不以/开头 const ossPath = path.startsWith('/') ? path.substring(1) : path; return `${ossHost}/${ossPath}`; diff --git a/client/admin/components_uploader.tsx b/client/admin/components_uploader.tsx index 464a787..bf9785e 100644 --- a/client/admin/components_uploader.tsx +++ b/client/admin/components_uploader.tsx @@ -11,6 +11,7 @@ import { UploadOutlined, } from '@ant-design/icons'; import { uploadMinIOWithPolicy , uploadOSSWithPolicy} from '@d8d-appcontainer/api'; +import { getGlobalConfig } from './utils.ts'; import type { MinioUploadPolicy, OSSUploadPolicy } from '@d8d-appcontainer/types'; import 'dayjs/locale/zh-cn'; import { OssType } from '../share/types.ts'; @@ -93,7 +94,7 @@ export const Uploader = ({ }; // 执行上传 - const fileUrl = window.CONFIG?.OSS_TYPE === OssType.MINIO ? + const fileUrl = getGlobalConfig('OSS_TYPE') === OssType.MINIO ? await uploadMinIOWithPolicy( policy as MinioUploadPolicy, file, @@ -164,4 +165,4 @@ export const Uploader = ({ )} ); -}; \ No newline at end of file +}; diff --git a/client/admin/deno.lock b/client/admin/deno.lock index 55a0db8..ee8fb46 100644 --- a/client/admin/deno.lock +++ b/client/admin/deno.lock @@ -1,7 +1,7 @@ { "version": "4", "redirects": { - "http://esm.d8d.fun/@types/react@~19.0.12/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.12/index.d.ts", + "http://esm.d8d.fun/@types/react@~19.0.12/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.14/index.d.ts", "https://esm.d8d.fun/@antv/component@^2.1.2?target=denonext": "https://esm.d8d.fun/@antv/component@2.1.2?target=denonext", "https://esm.d8d.fun/@antv/coord@^0.4.7?target=denonext": "https://esm.d8d.fun/@antv/coord@0.4.7?target=denonext", "https://esm.d8d.fun/@antv/event-emitter@^0.1.3?target=denonext": "https://esm.d8d.fun/@antv/event-emitter@0.1.3?target=denonext", @@ -61,7 +61,7 @@ "https://esm.d8d.fun/@types/react-dom@~19.0.4/client.d.ts": "https://esm.d8d.fun/@types/react-dom@19.0.6/client.d.ts", "https://esm.d8d.fun/@types/react-dom@~19.0.4/index.d.ts": "https://esm.d8d.fun/@types/react-dom@19.0.6/index.d.ts", "https://esm.d8d.fun/@types/react@~19.0.10/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.14/index.d.ts", - "https://esm.d8d.fun/@types/react@~19.0.12/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.12/index.d.ts", + "https://esm.d8d.fun/@types/react@~19.0.12/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.14/index.d.ts", "https://esm.d8d.fun/@types/react@~19.0.12/jsx-runtime.d.ts": "https://esm.d8d.fun/@types/react@19.0.14/jsx-runtime.d.ts", "https://esm.d8d.fun/@types/react@~19.0.14/index.d.ts": "https://esm.d8d.fun/@types/react@19.0.14/index.d.ts", "https://esm.d8d.fun/@types/scheduler@~0.23.0/index.d.ts": "https://esm.d8d.fun/@types/scheduler@0.23.0/index.d.ts", diff --git a/client/admin/utils.ts b/client/admin/utils.ts index b3fbfdd..cf5aea4 100644 --- a/client/admin/utils.ts +++ b/client/admin/utils.ts @@ -1,3 +1,5 @@ +import type { GlobalConfig } from '../share/types.ts'; + export function getEnumOptions>(enumObj: Record, nameMap: M) { return Object.entries(enumObj) .filter(([_key, value]) => !isNaN(Number(value)) || typeof value === 'string') // 保留数字和字符串类型的值 @@ -6,4 +8,13 @@ export function getEnumOptions(key: T): GlobalConfig[T] | undefined { + return (window as typeof window & { CONFIG?: GlobalConfig }).CONFIG?.[key]; +}