web
9 小时以前 49fa0d82a40345342966e810b44429aec0480ef3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// @ts-nocheck
// #ifdef APP-NVUE  || APP-VUE
export const getLocalFilePath = (path : string) => {
    if (typeof plus == 'undefined') return path
    if (/^(_www|_doc|_documents|_downloads|file:\/\/|\/storage\/emulated\/0\/)/.test(path)) return path
    if (/^\//.test(path)) {
        const localFilePath = plus.io.convertAbsoluteFileSystem(path)
        if (localFilePath !== path) {
            return localFilePath
        } else {
            path = path.slice(1)
        }
    }
    return '_www/' + path
}
// #endif
 
 
// #ifdef UNI-APP-X && APP
export { getResourcePath as getLocalFilePath } from '@/uni_modules/lime-file-utils'
// export const getLocalFilePath = (path : string) : string => {
//     let uri = path
//     if (uri.startsWith("http") || uri.startsWith("<svg") || uri.startsWith("data:image/svg+xml")) {
//         return uri
//     }
//     if (uri.startsWith("file://")) {
//         uri = uri.substring("file://".length)
//     } else if (uri.startsWith("unifile://")) {
//         uri = UTSAndroid.convert2AbsFullPath(uri)
//     } else {
//         uri = UTSAndroid.convert2AbsFullPath(uri)
//         if (uri.startsWith("/android_asset/")) {
//             uri = uri.replace("/android_asset/", "")
//         }
//     }
//     if (new File(uri).exists()) {
//         return uri
//     } else {
//         return null
//     }
//     // return UTSAndroid.convert2AbsFullPath(path)
// }
// #endif
// #ifdef APP-IOS
// export const getLocalFilePath = (path : string) : string => {
//     try {
//         let uri = path
//         if (uri.startsWith("http") || uri.startsWith("<svg") || uri.startsWith("data:image/svg+xml")) {
//             return uri
//         }
//         if (uri.startsWith("file://")) {
//             return uri.substring("file://".length)
//         } else if (path.startsWith("/var/")) {
//             return path
//         }
//         return UTSiOS.getResourcePath(path)
//     } catch (e) {
//         return null
//     }
//     // return UTSiOS.getResourcePath(path)
// }
// #endif