1
0

index.ts 1.8 KB

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