Преглед на файлове

新增.gitignore文件以忽略以.aider开头的文件,更新API逻辑以使用全局配置获取OSS相关信息,优化上传组件中的配置获取方式,同时更新依赖项的版本以确保兼容性。

zyh преди 8 месеца
родител
ревизия
d7086317d1
променени са 5 файла, в които са добавени 20 реда и са изтрити 6 реда
  1. 1 0
      .gitignore
  2. 2 1
      client/admin/api.ts
  3. 3 2
      client/admin/components_uploader.tsx
  4. 2 2
      client/admin/deno.lock
  5. 12 1
      client/admin/utils.ts

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.aider*

+ 2 - 1
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}`;

+ 3 - 2
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 = ({
       )}
     </Upload.Dragger>
   );
-};
+};

+ 2 - 2
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",

+ 12 - 1
client/admin/utils.ts

@@ -1,3 +1,5 @@
+import type { GlobalConfig } from '../share/types.ts';
+
 export function getEnumOptions<T extends string | number, M extends Record<T, string>>(enumObj: Record<string, T>, nameMap: M) {
   return Object.entries(enumObj)
     .filter(([_key, value]) => !isNaN(Number(value)) || typeof value === 'string')  // 保留数字和字符串类型的值
@@ -6,4 +8,13 @@ export function getEnumOptions<T extends string | number, M extends Record<T, st
       label: nameMap[value as T],
       value: value
     }));
-}
+}
+
+/**
+ * 获取全局配置项 (严格类型版本)
+ * @param key 配置键名
+ * @returns 配置值或undefined
+ */
+export function getGlobalConfig<T extends keyof GlobalConfig>(key: T): GlobalConfig[T] | undefined {
+  return (window as typeof window & { CONFIG?: GlobalConfig }).CONFIG?.[key];
+}