mali-applet-ui 1.1.95 → 1.1.96
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/package.json +1 -1
- package/utils/applet.js +14 -0
- package/utils/file.js +3 -2
package/package.json
CHANGED
package/utils/applet.js
CHANGED
|
@@ -102,3 +102,17 @@ export function getAppDpr () {
|
|
|
102
102
|
ratio = info.pixelRatio || 2
|
|
103
103
|
return ratio
|
|
104
104
|
}
|
|
105
|
+
|
|
106
|
+
export function getUserDataPath () {
|
|
107
|
+
let udPath = ''
|
|
108
|
+
|
|
109
|
+
// #ifdef MP-WEIXIN
|
|
110
|
+
udPath = wx.env.USER_DATA_PATH
|
|
111
|
+
// #endif
|
|
112
|
+
|
|
113
|
+
// #ifdef MP-DINGTALK
|
|
114
|
+
udPath = dd.env.USER_DATA_PATH
|
|
115
|
+
// #endif
|
|
116
|
+
|
|
117
|
+
return udPath
|
|
118
|
+
}
|
package/utils/file.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils'
|
|
2
|
+
import { getUserDataPath } from './applet'
|
|
2
3
|
|
|
3
4
|
export function getFileSuffix (filename) {
|
|
4
5
|
const pos = filename.lastIndexOf('.')
|
|
@@ -41,7 +42,7 @@ export function openFileByUrl (fileUrl, fileName, options) {
|
|
|
41
42
|
const fileType = opts.type || getFileSuffix(name || getFileName(url)).toLowerCase()
|
|
42
43
|
uni.downloadFile({
|
|
43
44
|
url,
|
|
44
|
-
filePath: name ? `${
|
|
45
|
+
filePath: name ? `${getUserDataPath()}/${name.indexOf('.') === -1 ? `${name}.${fileType}` : name}` : '',
|
|
45
46
|
success: (downRes) => {
|
|
46
47
|
if (getFilePreviewTypes().includes(fileType)) {
|
|
47
48
|
uni.openDocument({
|
|
@@ -98,7 +99,7 @@ export function saveFileByUrl (fileUrl, fileName, options) {
|
|
|
98
99
|
const fileType = opts.type || getFileSuffix(name || getFileName(url)).toLowerCase()
|
|
99
100
|
uni.downloadFile({
|
|
100
101
|
url,
|
|
101
|
-
filePath: name ? `${
|
|
102
|
+
filePath: name ? `${getUserDataPath()}/${name.indexOf('.') === -1 ? `${name}.${fileType}` : name}` : '',
|
|
102
103
|
success: (downRes) => {
|
|
103
104
|
uni.saveFile({
|
|
104
105
|
tempFilePath: downRes.filePath || downRes.tempFilePath,
|