提交 dcc58244 编写于 作者: Q qiang

fix: 回退 uni.saveFile 文件命名规则,避免存在特殊符号导致的部分问题

上级 63246f76
import {
warpPlusMethod,
warpPlusErrorCallback,
getFileName
getExtName
} from '../util'
import {
......@@ -25,8 +25,7 @@ export function saveFile ({
tempFilePath
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile')
let fileName = getFileName(tempFilePath)
fileName = `${Date.now()}${index++}_${fileName}`
const fileName = `${Date.now()}${index++}${getExtName(tempFilePath)}`
plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry
getSavedFileDir(dir => {
......
......@@ -206,3 +206,8 @@ export function getFileName (path) {
const array = path.split('/')
return array[array.length - 1]
}
export function getExtName (path) {
const array = path.split('.')
return array.length > 1 ? '.' + array[array.length - 1] : ''
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册