@cloudbase/weda-ui 3.4.7 → 3.4.8
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.
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import useSWR from 'swr';
|
|
2
2
|
import { getTempFileURL } from '../tcb';
|
|
3
|
-
|
|
4
|
-
export function useTempUrl(cloudId) {
|
|
5
|
-
const isCloudId = isCloudFileID(cloudId);
|
|
3
|
+
export function useTempUrl(fileId) {
|
|
6
4
|
const prefix = 'tcb:cloud-id:temp-url';
|
|
7
|
-
|
|
8
|
-
const key = isCloudId
|
|
9
|
-
? `${prefix}:${transFileCloudidToName(cloudId)}`
|
|
10
|
-
: cloudId;
|
|
5
|
+
const key = `${prefix}:${fileId}`;
|
|
11
6
|
return useSWR(key, async () => {
|
|
12
|
-
if (!
|
|
13
|
-
return
|
|
7
|
+
if (!(fileId === null || fileId === void 0 ? void 0 : fileId.startsWith('cloud://'))) {
|
|
8
|
+
return fileId;
|
|
14
9
|
}
|
|
15
|
-
const tempUrl = await getTempFileURL(
|
|
10
|
+
const tempUrl = await getTempFileURL(fileId);
|
|
16
11
|
return tempUrl;
|
|
17
12
|
},
|
|
18
13
|
// 8秒dedupe
|