listpage-next 0.0.249 → 0.0.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,5 +20,5 @@ export declare class HttpClient implements IHttpClient {
20
20
  filename?: string;
21
21
  type?: string;
22
22
  }, config?: AxiosRequestConfig<D>): Promise<void>;
23
- upload<D = any, T = any>(url: string, params?: D, config?: AxiosRequestConfig<D>): Promise<T>;
23
+ upload<T = any, D = any>(url: string, params?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<ApiResponse<T>>>;
24
24
  }
@@ -236,7 +236,8 @@ function FileManager({ title, storage }) {
236
236
  viewMode: viewMode,
237
237
  onSelect: setSelectedItem,
238
238
  onNavigate: handleNavigate,
239
- onDelete: handleDeleteRequest
239
+ onDelete: handleDeleteRequest,
240
+ onDownload: storage.downloadFile
240
241
  })
241
242
  })
242
243
  }),
@@ -6,6 +6,7 @@ export interface AssetGridProps {
6
6
  onSelect: (item: FileSystemItem) => void;
7
7
  onNavigate: (folderId: string) => void;
8
8
  onDelete?: (id: string, type: 'folder' | 'asset', name: string) => void;
9
+ onDownload?: (url: string, name: string) => void;
9
10
  selectedIds?: Set<string>;
10
11
  }
11
12
  export declare const AssetGrid: React.FC<AssetGridProps>;
@@ -1,8 +1,8 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import react from "react";
3
3
  import dayjs from "dayjs";
4
- import { Box, Check, ExternalLink, FileText, Folder, Image, Link, Music, Trash2, Video } from "lucide-react";
5
- const AssetGrid = ({ items, viewMode, onSelect, onNavigate, onDelete, selectedIds })=>{
4
+ import { Box, Check, Download, ExternalLink, FileText, Folder, Image, Link, Music, Trash2, Video } from "lucide-react";
5
+ const AssetGrid = ({ items, viewMode, onSelect, onNavigate, onDelete, onDownload, selectedIds })=>{
6
6
  const [copiedId, setCopiedId] = react.useState(null);
7
7
  const handleCopyLink = async (url, id)=>{
8
8
  if (!url) return;
@@ -98,7 +98,7 @@ const AssetGrid = ({ items, viewMode, onSelect, onNavigate, onDelete, selectedId
98
98
  }) : 'image' === item.type && item.url ? /*#__PURE__*/ jsx("div", {
99
99
  className: `${'list' === viewMode ? 'w-10 h-10' : 'w-full h-full'} rounded-lg overflow-hidden bg-slate-950 relative border border-slate-800 flex items-center justify-center`,
100
100
  children: /*#__PURE__*/ jsx("img", {
101
- src: item.url,
101
+ src: item.preview,
102
102
  alt: item.name,
103
103
  className: "w-full h-full object-cover"
104
104
  })
@@ -163,6 +163,17 @@ const AssetGrid = ({ items, viewMode, onSelect, onNavigate, onDelete, selectedId
163
163
  children: /*#__PURE__*/ jsx(ExternalLink, {
164
164
  className: "w-3 h-3"
165
165
  })
166
+ }),
167
+ onDownload && /*#__PURE__*/ jsx("button", {
168
+ onClick: (e)=>{
169
+ e.stopPropagation();
170
+ onDownload(item.url, item.name);
171
+ },
172
+ className: "p-1.5 bg-slate-700 rounded-lg hover:bg-slate-600 text-white",
173
+ title: "下载",
174
+ children: /*#__PURE__*/ jsx(Download, {
175
+ className: "w-3 h-3"
176
+ })
166
177
  })
167
178
  ]
168
179
  }),
@@ -1,3 +1,3 @@
1
1
  export { FileManager, type FileManagerProps } from './FileManager';
2
2
  export { AssetSelectorModal, type AssetSelectorModalProps, } from './components/AssetSelectorModal';
3
- export type { StorageAdapter } from './types';
3
+ export type { StorageAdapter, Folder, Asset } from './types';
@@ -1,10 +1,10 @@
1
1
  let storageConfig = null;
2
2
  const getStorageConfig = ()=>{
3
3
  if (storageConfig) return storageConfig;
4
- const endpoint = 'https://xxx.xxx.xxx.xxx';
5
- const accessKeyId = '';
6
- const secretAccessKey = '';
7
- const bucketName = '';
4
+ const endpoint = 'xxx';
5
+ const accessKeyId = 'xxx';
6
+ const secretAccessKey = 'xxx';
7
+ const bucketName = 'xxxxx';
8
8
  const region = 'us-east-1';
9
9
  if (!endpoint || !accessKeyId || !secretAccessKey || !bucketName) throw new Error('Storage configuration is missing');
10
10
  return {
@@ -87,6 +87,7 @@ const listAssets = async ()=>{
87
87
  id: key,
88
88
  name: name,
89
89
  url: url,
90
+ preview: '',
90
91
  type: type,
91
92
  width: 0,
92
93
  height: 0,
@@ -239,11 +240,13 @@ const formatBytes = (bytes, decimals = 2)=>{
239
240
  const i = Math.floor(Math.log(bytes) / Math.log(k));
240
241
  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
241
242
  };
243
+ const downloadFile = async (url, fileName)=>{};
242
244
  const adapter = {
243
245
  createFolder,
244
246
  deleteFolder,
245
247
  uploadObject,
246
248
  deleteObject,
247
- listAssets
249
+ listAssets,
250
+ downloadFile
248
251
  };
249
252
  export { adapter, createFolder, deleteFolder, deleteObject, listAssets, uploadObject };
@@ -10,6 +10,7 @@ export interface Asset {
10
10
  id: string;
11
11
  name: string;
12
12
  url: string;
13
+ preview?: string;
13
14
  type: AssetType;
14
15
  parentId: string | null;
15
16
  width?: number;
@@ -22,7 +23,7 @@ export type FileSystemItem = Folder | Asset;
22
23
  export type ViewMode = 'grid' | 'list';
23
24
  export interface FilterState {
24
25
  search: string;
25
- source: 'all' | 'upload' | 'ai-generated';
26
+ source: 'all' | 'upload';
26
27
  }
27
28
  export interface StorageAdapter {
28
29
  listAssets: () => Promise<{
@@ -33,4 +34,5 @@ export interface StorageAdapter {
33
34
  deleteFolder: (folderPath: string) => Promise<void>;
34
35
  deleteObject: (assetId: string) => Promise<void>;
35
36
  uploadObject: (file: File, folderId: string | null) => Promise<Partial<Asset>>;
37
+ downloadFile: (url: string, fileName: string) => Promise<void>;
36
38
  }