提交 dcc58244 编写于 作者: Q qiang

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

上级 63246f76
import { import {
warpPlusMethod, warpPlusMethod,
warpPlusErrorCallback, warpPlusErrorCallback,
getFileName getExtName
} from '../util' } from '../util'
import { import {
...@@ -25,8 +25,7 @@ export function saveFile ({ ...@@ -25,8 +25,7 @@ export function saveFile ({
tempFilePath tempFilePath
} = {}, callbackId) { } = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile') const errorCallback = warpPlusErrorCallback(callbackId, 'saveFile')
let fileName = getFileName(tempFilePath) const fileName = `${Date.now()}${index++}${getExtName(tempFilePath)}`
fileName = `${Date.now()}${index++}_${fileName}`
plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry plus.io.resolveLocalFileSystemURL(tempFilePath, entry => { // 读取临时文件 FileEntry
getSavedFileDir(dir => { getSavedFileDir(dir => {
......
...@@ -206,3 +206,8 @@ export function getFileName (path) { ...@@ -206,3 +206,8 @@ export function getFileName (path) {
const array = path.split('/') const array = path.split('/')
return array[array.length - 1] 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.
先完成此消息的编辑!
想要评论请 注册