From d7086317d197bf023ff4f283fcf73ba9b65f10c6 Mon Sep 17 00:00:00 2001 From: zyh Date: Thu, 10 Apr 2025 16:01:04 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E.gitignore=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BB=A5=E5=BF=BD=E7=95=A5=E4=BB=A5.aider=E5=BC=80=E5=A4=B4?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=EF=BC=8C=E6=9B=B4=E6=96=B0API?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BD=BF=E7=94=A8=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=8E=B7=E5=8F=96OSS=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BC=98=E5=8C=96=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=AD=E7=9A=84=E9=85=8D=E7=BD=AE=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=90=8C=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BE=9D=E8=B5=96=E9=A1=B9=E7=9A=84=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BB=A5=E7=A1=AE=E4=BF=9D=E5=85=BC=E5=AE=B9=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + client/admin/api.ts | 3 ++- client/admin/components_uploader.tsx | 5 +++-- client/admin/deno.lock | 4 ++-- client/admin/utils.ts | 13 ++++++++++++- 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 .gitignore 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]; +}