Răsfoiți Sursa

fix: add type annotation for progress parameter in file upload callbacks

0235711 19 ore în urmă
părinte
comite
969459c50b

+ 51 - 0
src/fmode-ng-augmentation.d.ts

@@ -0,0 +1,51 @@
+// Type augmentation for fmode-ng/core
+// This file provides type declarations for NovaStorage and NovaFile which are missing in the package
+
+declare module 'fmode-ng/core' {
+  import { FmodeParse, FmodeObject, FmodeQuery, FmodeUser } from 'fmode-ng/core';
+  import { WxworkAuth, WxworkCorp, WxworkSDK } from 'fmode-ng/core';
+  
+  /**
+   * NovaFile interface
+   * Represents a file uploaded to Nova storage
+   */
+  export interface NovaFile {
+    id: string;
+    key: string;
+    url: string;
+    name: string;
+    type: string;
+    size: number;
+    metadata?: any;
+    md5?: string;
+  }
+
+  /**
+   * NovaUploadOptions interface
+   * Options for uploading files
+   */
+  export interface NovaUploadOptions {
+    prefixKey?: string;
+    onProgress?: (progress: { total: { percent: number; loaded: number; size: number } }) => void;
+  }
+
+  /**
+   * NovaStorage class
+   * Handles file storage operations
+   */
+  export class NovaStorage {
+    /**
+     * Initialize NovaStorage with a company ID
+     * @param cid Company ID
+     */
+    static withCid(cid: string): Promise<NovaStorage>;
+    
+    /**
+     * Upload a file to storage
+     * @param file File to upload
+     * @param options Upload options
+     */
+    upload(file: File, options?: NovaUploadOptions): Promise<NovaFile>;
+  }
+}
+

+ 2 - 2
src/modules/project/services/project-file.service.ts

@@ -51,7 +51,7 @@ export class ProjectFileService {
       // 上传文件
       const uploadedFile: NovaFile = await storage.upload(file, {
         prefixKey,
-        onProgress: (progress) => {
+        onProgress: (progress: { total: { percent: number } }) => {
           if (onProgress) {
             onProgress(progress.total.percent);
           }
@@ -365,7 +365,7 @@ export class ProjectFileService {
 
       const uploadedFile = await storage.upload(file, {
         prefixKey,
-        onProgress: (progress) => {
+        onProgress: (progress: { total: { percent: number } }) => {
           if (onProgress) {
             onProgress(progress.total.percent);
           }