listpage-next 0.0.248 → 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.
- package/dist/api/client/client.js +18 -0
- package/dist/api/client/index.d.ts +1 -0
- package/dist/api/client/index.js +3 -0
- package/dist/ui/FileManager/FileManager.js +3 -2
- package/dist/ui/FileManager/components/AssetGrid.d.ts +1 -0
- package/dist/ui/FileManager/components/AssetGrid.js +14 -3
- package/dist/ui/FileManager/index.d.ts +1 -1
- package/dist/ui/FileManager/services/config.js +4 -4
- package/dist/ui/FileManager/services/storageService.js +5 -2
- package/dist/ui/FileManager/types.d.ts +3 -1
- package/dist/ui.css +0 -3
- package/package.json +1 -1
|
@@ -135,5 +135,23 @@ function setupClient(HttpClient) {
|
|
|
135
135
|
document.body.removeChild(link);
|
|
136
136
|
window.URL.revokeObjectURL(url);
|
|
137
137
|
};
|
|
138
|
+
HttpClient.prototype.upload = async function(url, data, config) {
|
|
139
|
+
const client = this.client;
|
|
140
|
+
const formData = new FormData();
|
|
141
|
+
if (data && 'object' == typeof data) Object.keys(data).forEach((key)=>{
|
|
142
|
+
const value = data[key];
|
|
143
|
+
if (Array.isArray(value)) value.forEach((item)=>{
|
|
144
|
+
formData.append(key, item);
|
|
145
|
+
});
|
|
146
|
+
else if (null != value) formData.append(key, value);
|
|
147
|
+
});
|
|
148
|
+
return client.post(url, formData, {
|
|
149
|
+
...config,
|
|
150
|
+
headers: {
|
|
151
|
+
'Content-Type': 'multipart/form-data',
|
|
152
|
+
...config?.headers
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
};
|
|
138
156
|
}
|
|
139
157
|
export { setupClient };
|
|
@@ -20,4 +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<T = any, D = any>(url: string, params?: D, config?: AxiosRequestConfig<D>): Promise<AxiosResponse<ApiResponse<T>>>;
|
|
23
24
|
}
|
package/dist/api/client/index.js
CHANGED
|
@@ -54,5 +54,8 @@ class HttpClient {
|
|
|
54
54
|
download(url, params, downloadOptions, config) {
|
|
55
55
|
throw new Error('Method should be implemented by setupClient');
|
|
56
56
|
}
|
|
57
|
+
upload(url, params, config) {
|
|
58
|
+
throw new Error('Method should be implemented by setupClient');
|
|
59
|
+
}
|
|
57
60
|
}
|
|
58
61
|
export { HttpClient };
|
|
@@ -183,7 +183,7 @@ function FileManager({ title, storage }) {
|
|
|
183
183
|
}));
|
|
184
184
|
};
|
|
185
185
|
return /*#__PURE__*/ jsxs("div", {
|
|
186
|
-
className: "flex h-
|
|
186
|
+
className: "flex h-full bg-slate-950 text-slate-200 font-sans",
|
|
187
187
|
children: [
|
|
188
188
|
/*#__PURE__*/ jsx(Sidebar, {
|
|
189
189
|
title: title,
|
|
@@ -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.
|
|
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 = '
|
|
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,
|
|
@@ -161,7 +162,7 @@ const deleteFolder = async (folderPath)=>{
|
|
|
161
162
|
const uploadObject = async (file, folderId)=>{
|
|
162
163
|
const prefix = folderId || '';
|
|
163
164
|
const cleanName = file.name.replace(/[^a-zA-Z0-9.-]/g, '_');
|
|
164
|
-
const key = `${prefix}${
|
|
165
|
+
const key = `${prefix}${cleanName}`;
|
|
165
166
|
try {
|
|
166
167
|
const cfg = getStorageConfig();
|
|
167
168
|
const s3 = getS3Client();
|
|
@@ -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'
|
|
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
|
}
|
package/dist/ui.css
CHANGED