Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
4ee1b1db
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6006
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4ee1b1db
编写于
12月 13, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
手动合并 get-file-system-manager dev分支内容到本地
上级
9d6dffe7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
615 addition
and
375 deletion
+615
-375
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+214
-125
pages/API/get-file-system-manager/get-file-system-manager.uvue
.../API/get-file-system-manager/get-file-system-manager.uvue
+401
-250
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
4ee1b1db
...
@@ -30,29 +30,23 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -30,29 +30,23 @@ describe('ExtApi-FileManagerTest', () => {
let
globalUserDataPath
=
await
getData
(
'
globalUserDataPath
'
)
let
globalUserDataPath
=
await
getData
(
'
globalUserDataPath
'
)
await
page
.
setData
({
await
page
.
setData
({
logAble
:
false
,
recursiveVal
:
true
,
recursiveVal
:
true
,
copyToBasePath
:
globalUserDataPath
,
copyToBasePath
:
globalUserDataPath
,
basePath
:
globalUserDataPath
,
basePath
:
globalUserDataPath
,
rmDirFile
:
'
a
'
,
rmDirFile
:
'
a
'
,
unlinkFile
:
'
a/1.txt
'
readDir
:
'
a
'
,
writeFile
:
'
a/1.txt
'
,
readFile
:
'
a/1.txt
'
,
unlinkFile
:
'
a/1.txt
'
,
writeFileContent
:
'
锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦
'
})
})
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const
btnUnLinkFileButton
=
await
page
.
$
(
'
.btn-
unlink
-file
'
)
const
btnUnLinkFileButton
=
await
page
.
$
(
'
.btn-
clear
-file
'
)
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/2.txt
'
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/3.txt
'
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
// 清除文件夹
// 清除文件夹
const
btnRmDirButton
=
await
page
.
$
(
'
.btn-remove-dir
'
)
const
btnRmDirButton
=
await
page
.
$
(
'
.btn-remove-dir
'
)
...
@@ -200,17 +194,18 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -200,17 +194,18 @@ describe('ExtApi-FileManagerTest', () => {
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
,
\"
1.txt
\"
,
\"
3.txt
\"
]
"
)
});
});
it
(
'
TEMP_PATH test
'
,
async
()
=>
{
it
(
'
TEMP_PATH test
'
,
async
()
=>
{
// 测试 TEMP_PATH
// 测试 TEMP_PATH
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
await
page
.
setData
({
await
page
.
setData
({
logAble
:
false
,
recursiveVal
:
true
,
recursiveVal
:
true
,
basePath
:
globalTempPath
,
basePath
:
globalTempPath
,
copyToBasePath
:
globalTempPath
,
copyToBasePath
:
globalTempPath
,
rmDirFile
:
'
a
'
,
rmDirFile
:
'
a
'
,
mkdirFile
:
'
a
'
,
unlinkFile
:
'
a/我们经历了一场兵慌马乱的战争.1@2#3$4%5^6&7*8(9)0+-qwertyuiopasdfghjklzxcvbnm;,/中文路径/张三/name/中文文件.mock
'
unlinkFile
:
'
a/我们经历了一场兵慌马乱的战争.1@2#3$4%5^6&7*8(9)0+-qwertyuiopasdfghjklzxcvbnm;,/中文路径/张三/name/中文文件.mock
'
})
})
...
@@ -220,12 +215,6 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -220,12 +215,6 @@ describe('ExtApi-FileManagerTest', () => {
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/提前创建的目录/4.txt
'
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
// 清除文件夹
// 清除文件夹
const
btnRmDirButton
=
await
page
.
$
(
'
.btn-remove-dir
'
)
const
btnRmDirButton
=
await
page
.
$
(
'
.btn-remove-dir
'
)
...
@@ -244,9 +233,9 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -244,9 +233,9 @@ describe('ExtApi-FileManagerTest', () => {
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
let
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
let
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
b
\"
]
"
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[]
"
)
let
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
let
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
b
\"
]
"
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[]
"
)
// 测试 创建多层级文件目录
// 测试 创建多层级文件目录
await
page
.
setData
({
await
page
.
setData
({
...
@@ -286,10 +275,8 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -286,10 +275,8 @@ describe('ExtApi-FileManagerTest', () => {
* 从资源文件中读取图片为base64,测试写入较大文件场景
* 从资源文件中读取图片为base64,测试写入较大文件场景
* 'static/list-mock/safe.png' 注意,依赖这个资源文件,不能删除
* 'static/list-mock/safe.png' 注意,依赖这个资源文件,不能删除
*/
*/
let
globalAppResourcePath
=
await
getData
(
'
globalAppResourcePath
'
)
await
page
.
setData
({
await
page
.
setData
({
basePath
:
""
,
basePath
:
globalAppResourcePath
,
readFile
:
'
static/list-mock/safe.png
'
,
readFile
:
'
static/list-mock/safe.png
'
,
readFileEncoding
:
'
base64
'
readFileEncoding
:
'
base64
'
})
})
...
@@ -434,7 +421,8 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -434,7 +421,8 @@ describe('ExtApi-FileManagerTest', () => {
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
4.txt
\"
]
"
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
4.txt
\"
]
"
)
await
page
.
setData
({
await
page
.
setData
({
unlinkFile
:
'
a/提前创建的目录/4.txt
'
unlinkFile
:
'
a/提前创建的目录/4.txt
'
,
rmDirFile
:
'
a/提前创建的目录
'
})
})
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
isDone
()
...
@@ -447,12 +435,10 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -447,12 +435,10 @@ describe('ExtApi-FileManagerTest', () => {
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[]
"
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[]
"
)
});
});
it
(
'
CROSS DIR test
'
,
async
()
=>
{
it
(
'
CROSS DIR test
'
,
async
()
=>
{
/**
/**
* 跨越用户目录和代码资源目录
* 跨越用户目录和代码资源目录
...
@@ -460,6 +446,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -460,6 +446,7 @@ describe('ExtApi-FileManagerTest', () => {
let
globalRootPath
=
await
getData
(
'
globalRootPath
'
)
let
globalRootPath
=
await
getData
(
'
globalRootPath
'
)
await
page
.
setData
({
await
page
.
setData
({
recursiveVal
:
true
,
recursiveVal
:
true
,
logAble
:
false
,
basePath
:
globalRootPath
,
basePath
:
globalRootPath
,
readDir
:
'
a
'
,
readDir
:
'
a
'
,
rmDirFile
:
'
a
'
,
rmDirFile
:
'
a
'
,
...
@@ -470,8 +457,8 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -470,8 +457,8 @@ describe('ExtApi-FileManagerTest', () => {
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
const
btn
UnLinkFileButton
=
await
page
.
$
(
'
.btn-unlink
-file
'
)
const
btn
ClearFileButton
=
await
page
.
$
(
'
.btn-clear
-file
'
)
await
btn
UnLink
FileButton
.
tap
()
await
btn
Clear
FileButton
.
tap
()
await
isDone
()
await
isDone
()
...
@@ -505,9 +492,8 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -505,9 +492,8 @@ describe('ExtApi-FileManagerTest', () => {
// 准备从资源目录拷贝png
// 准备从资源目录拷贝png
let
globalAppResourcePath
=
await
getData
(
'
globalAppResourcePath
'
)
await
page
.
setData
({
await
page
.
setData
({
basePath
:
globalAppResourcePath
,
basePath
:
""
,
unlinkFile
:
'
static/list-mock/safe.png
'
,
unlinkFile
:
'
static/list-mock/safe.png
'
,
accessFile
:
'
static/list-mock/safe.png
'
,
accessFile
:
'
static/list-mock/safe.png
'
,
})
})
...
@@ -519,6 +505,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -519,6 +505,7 @@ describe('ExtApi-FileManagerTest', () => {
expect
(
accessFileRet
).
toEqual
(
'
access:ok
'
)
expect
(
accessFileRet
).
toEqual
(
'
access:ok
'
)
// 尝试删除资源,期望失败
// 尝试删除资源,期望失败
const
btnUnLinkFileButton
=
await
page
.
$
(
'
.btn-unlink-file
'
)
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
isDone
()
...
@@ -542,6 +529,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -542,6 +529,7 @@ describe('ExtApi-FileManagerTest', () => {
basePath
:
globalRootPath
,
basePath
:
globalRootPath
,
unlinkFile
:
'
a/从代码目录拷贝的资源.png
'
,
unlinkFile
:
'
a/从代码目录拷贝的资源.png
'
,
accessFile
:
'
a/从代码目录拷贝的资源.png
'
,
accessFile
:
'
a/从代码目录拷贝的资源.png
'
,
rmDirFile
:
'
a
'
,
})
})
await
btnAccessFileButton
.
tap
()
await
btnAccessFileButton
.
tap
()
await
isDone
()
await
isDone
()
...
@@ -549,6 +537,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -549,6 +537,7 @@ describe('ExtApi-FileManagerTest', () => {
accessFileRet
=
await
getData
(
"
accessFileRet
"
)
accessFileRet
=
await
getData
(
"
accessFileRet
"
)
expect
(
accessFileRet
).
toEqual
(
'
access:ok
'
)
expect
(
accessFileRet
).
toEqual
(
'
access:ok
'
)
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
isDone
()
...
@@ -558,6 +547,31 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -558,6 +547,31 @@ describe('ExtApi-FileManagerTest', () => {
accessFileRet
=
await
getData
(
"
accessFileRet
"
)
accessFileRet
=
await
getData
(
"
accessFileRet
"
)
expect
(
accessFileRet
).
toEqual
(
''
)
expect
(
accessFileRet
).
toEqual
(
''
)
// 从页面的按钮触发一次文件复制
const
btnCopyStaticFileButton
=
await
page
.
$
(
'
.btn-copyStatic-file
'
)
await
btnCopyStaticFileButton
.
tap
()
await
isDone
()
await
btnReadDirButton
.
tap
()
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[
\"
mock.json
\"
]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[
\"
mock.json
\"
]
"
)
// 从页面的按钮触发一次文件清空
await
btnClearFileButton
.
tap
()
await
isDone
()
await
btnReadDirButton
.
tap
()
await
isDone
()
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
"
[]
"
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
"
[]
"
)
});
});
...
@@ -568,6 +582,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -568,6 +582,7 @@ describe('ExtApi-FileManagerTest', () => {
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
await
page
.
setData
({
await
page
.
setData
({
recursiveVal
:
true
,
recursiveVal
:
true
,
logAble
:
false
,
basePath
:
globalTempPath
,
basePath
:
globalTempPath
,
readDir
:
'
d
'
,
readDir
:
'
d
'
,
rmDirFile
:
'
d
'
,
rmDirFile
:
'
d
'
,
...
@@ -700,98 +715,172 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -700,98 +715,172 @@ describe('ExtApi-FileManagerTest', () => {
});
});
// it('stat and asset test', async () => {
it
(
'
stat and asset test
'
,
async
()
=>
{
// // 测试 USER_DATA_PATH
// 测试 USER_DATA_PATH //globalTempPath
// let globalInnerRootPath = await getData('globalInnerRootPath')
let
globalRootPath
=
await
getData
(
'
globalRootPath
'
)
// await page.setData({
await
page
.
setData
({
// recursiveVal: true,
recursiveVal
:
true
,
// copyToBasePath:globalInnerRootPath,
copyToBasePath
:
globalRootPath
,
// basePath: globalInnerRootPath,
basePath
:
globalRootPath
,
// rmDirFile:'a',
rmDirFile
:
'
a
'
,
// mkdirFile:'a',
mkdirFile
:
'
a
'
,
// unlinkFile:'a/1.txt',
unlinkFile
:
'
a/1.txt
'
,
// })
})
// // 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
// 先清除文件,需要清除全部可能存在的历史测试文件,避免运行失败
// const btnUnLinkFileButton = await page.$('.btn-unlink-file')
const
btnUnLinkFileButton
=
await
page
.
$
(
'
.btn-unlink-file
'
)
// await btnUnLinkFileButton.tap()
await
btnUnLinkFileButton
.
tap
()
// await isDone()
await
isDone
()
// await page.setData({
await
page
.
setData
({
// unlinkFile:'a/2.txt',
unlinkFile
:
'
a/2.txt
'
,
// })
})
// await btnUnLinkFileButton.tap()
await
btnUnLinkFileButton
.
tap
()
// await isDone()
await
isDone
()
// await page.setData({
await
page
.
setData
({
// unlinkFile:'a/m/3.txt',
unlinkFile
:
'
a/m/3.txt
'
,
// })
})
// await btnUnLinkFileButton.tap()
await
btnUnLinkFileButton
.
tap
()
// await isDone()
await
isDone
()
// // // 清除文件夹
// // 清除文件夹
// const btnRmDirButton = await page.$('.btn-remove-dir')
const
btnRmDirButton
=
await
page
.
$
(
'
.btn-remove-dir
'
)
// await btnRmDirButton.tap()
await
btnRmDirButton
.
tap
()
// await isDone()
await
isDone
()
// // // 重新创建测试目录
// // 重新创建测试目录
// const btnMkdDirButton = await page.$('.btn-mkdir')
const
btnMkdDirButton
=
await
page
.
$
(
'
.btn-mkdir
'
)
// await btnMkdDirButton.tap()
await
btnMkdDirButton
.
tap
()
// await isDone()
await
isDone
()
// const btnReadDirButton = await page.$('.btn-read-dir')
const
btnReadDirButton
=
await
page
.
$
(
'
.btn-read-dir
'
)
// await btnReadDirButton.tap()
await
btnReadDirButton
.
tap
()
// await isDone()
await
isDone
()
// // 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
// let fileListComplete = await getData('fileListComplete')
let
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
// expect(JSON.stringify(fileListComplete)).toEqual('[]')
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
'
[]
'
)
// let fileListSuccess = await getData('fileListSuccess')
let
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
// expect(JSON.stringify(fileListSuccess)).toEqual('[]')
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
'
[]
'
)
// // 写入一个文件
// 写入一个文件
// await page.setData({
await
page
.
setData
({
// writeFileContent: "锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦",
writeFileContent
:
"
锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦
"
,
// writeFileEncoding:"utf-8",
writeFileEncoding
:
"
utf-8
"
,
// writeFile:'a/1.txt',
writeFile
:
'
a/1.txt
'
,
// recursiveVal:false,
recursiveVal
:
false
,
// statFile:'a/1.txt',
statFile
:
'
a/1.txt
'
,
// })
})
let
lastFailError
=
await
getData
(
'
lastFailError
'
)
console
.
log
(
lastFailError
)
// let lastFailError = await getData('lastFailError')
// console.log(lastFailError)
const
btnWriteFileButton
=
await
page
.
$
(
'
.btn-write-file
'
)
await
btnWriteFileButton
.
tap
()
// // const btnWriteFileButton = await page.$('.btn-write-file')
await
isDone
()
// // await btnWriteFileButton.tap()
// // await isDone()
const
btnStatFileButton
=
await
page
.
$
(
'
.btn-stat-file
'
)
await
btnStatFileButton
.
tap
()
// // const btnStatFileButton = await page.$('.btn-stat-file')
await
isDone
()
// // await btnStatFileButton.tap()
// // await isDone()
// 读取单个文件信息
let
statsRet
=
await
getData
(
'
statsRet
'
)
// // // 读取单个文件信息
expect
(
statsRet
.
length
).
toEqual
(
1
)
// // let statsRet = await getData('statsRet')
expect
(
statsRet
[
0
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a/1.txt
'
)
// // console.log(statsRet)
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
69
)
// // expect(statsRet.path).toEqual('')
/**
// // await page.setData({
* 创建子目录和子目录文件,测试recursive参数
// // recursiveVal:true,
*/
// // statFile:'a/1.txt',
await
page
.
setData
({
// // })
writeFileContent
:
"
1234567890
"
,
writeFileEncoding
:
"
ascii
"
,
// // await btnStatFileButton.tap()
writeFile
:
'
a/2.txt
'
,
// // await isDone()
basePath
:
globalRootPath
,
recursiveVal
:
false
,
// // // 读取单个文件信息
statFile
:
'
a
'
,
// // statsRet = await getData('statsRet')
mkdirFile
:
'
a/m
'
,
// // console.log(statsRet)
})
// // expect(statsRet.path).toEqual('')
await
btnWriteFileButton
.
tap
()
await
isDone
()
// });
// 创建子目录
await
btnMkdDirButton
.
tap
()
await
isDone
()
// 复制一份文件到 /a/m/3.txt
await
page
.
setData
({
// asset 只能正式版测试,这里只能模拟返回路径
basePath
:
''
,
copyFromFile
:
'
file:///android_asset/uni-uts/uni-prompt/toast_error.png
'
,
copyToFile
:
'
a/m/3.txt
'
,
})
const
btnCopyFileButton
=
await
page
.
$
(
'
.btn-copy-file
'
)
await
btnCopyFileButton
.
tap
()
await
isDone
()
await
page
.
setData
({
basePath
:
globalRootPath
,
recursiveVal
:
true
,
statFile
:
'
a
'
,
})
await
btnStatFileButton
.
tap
()
await
isDone
()
// 读取全部文件信息
statsRet
=
await
getData
(
'
statsRet
'
)
console
.
log
(
statsRet
)
expect
(
statsRet
.
length
).
toEqual
(
5
)
expect
(
statsRet
[
0
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a
'
)
expect
(
statsRet
[
0
].
stats
.
size
).
toEqual
(
0
)
expect
(
statsRet
[
2
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a/2.txt
'
)
expect
(
statsRet
[
2
].
stats
.
size
).
toEqual
(
10
)
expect
(
statsRet
[
4
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a/m/3.txt
'
)
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
5842
)
// 清理文件,避免影响其他测试用例
await
page
.
setData
({
unlinkFile
:
'
a/1.txt
'
,
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/2.txt
'
,
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/m/3.txt
'
,
rmDirFile
:
'
a
'
,
readDir
:
'
a
'
,
recursiveVal
:
true
,
})
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
await
btnRmDirButton
.
tap
()
await
isDone
()
await
btnReadDirButton
.
tap
()
await
isDone
()
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
fileListComplete
=
await
getData
(
'
fileListComplete
'
)
expect
(
JSON
.
stringify
(
fileListComplete
)).
toEqual
(
'
[]
'
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
'
[]
'
)
});
});
});
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
4ee1b1db
<template>
<template>
<scroll-view>
<!-- #ifdef APP -->
<view>
<scroll-view style="flex: 1">
<button type="primary" @tap="readDirTest" class="btn-read-dir">读取文件夹</button>
<!-- #endif -->
<button type="primary" @tap="readFileTest" class="btn-read-file">读取文件</button>
<text>显示简易操作日志,详细日志需真机运行查看</text><button size="mini" @click="log=''">清空日志</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹</button>
<text style="margin: 2px; padding: 2px; border: 1px solid #000000;" :value="log" />
<button type="primary" @tap="unlinkTest" class="btn-unlink-file">删除文件</button>
<button type="primary" @tap="statFileInfoTest" class="btn-stat-file">递归获取目录files的Stats对象{{statFile}}</button>
<button type="primary" @tap="mkdirTest" class="btn-mkdir">创建文件夹</button>
<button type="primary" @tap="mkdirTest" class="btn-mkdir">创建文件夹{{mkdirFile}}</button>
<button type="primary" @tap="writeFileTest" class="btn-write-file">写入文件</button>
<button type="primary" @tap="writeFileTest" class="btn-write-file">覆盖写入文件{{writeFile}}</button>
<button type="primary" @tap="renameFileTest" class="btn-rename-file">重命名文件</button>
<button type="primary" @tap="readDirTest" class="btn-read-dir">读取文件夹{{readDir}}</button>
<button type="primary" @tap="copyFileTest" class="btn-copy-file">复制文件</button>
<button type="primary" @tap="readFileTest" class="btn-read-file">读取文件{{readFile}}</button>
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件是否存在</button>
<button type="primary" @tap="copyFileTest" class="btn-copy-file">复制文件{{copyFromFile}}到{{copyToFile}}</button>
<button type="primary" @tap="getFileInfoTest" class="btn-get-file-info">获取文件信息</button>
<button type="primary" @tap="renameFileTest"
<button type="primary" @tap="statFileInfoTest" class="btn-stat-file">获取文件Stats </button>
class="btn-rename-file">重命名文件{{renameFromFile}}到{{renameToFile}}</button>
</view>
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件{{accessFile}}是否存在</button>
</scroll-view>
<button type="primary" @tap="getFileInfoTest" class="btn-get-file-info">获取文件信息{{getFileInfoFile}}</button>
<button type="primary" @tap="unlinkTest" class="btn-unlink-file">删除文件{{unlinkFile}}</button>
<button type="primary" @tap="copyStaticToFilesTest" class="btn-copyStatic-file">从static目录复制文件到a目录</button>
<button type="primary" @tap="unlinkAllFileTest" class="btn-clear-file">删除文件夹{{rmDirFile}}下的所有文件</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹{{rmDirFile}}</button>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
</template>
<script>
<script>
export default {
export default {
data() {
return {
data() {
log: "",
return {
/**
fileListSuccess:[] as string[],
* 自动化测试需要关闭log
fileListComplete:[] as string[],
*/
accessFileRet:'',
logAble:true,
lastFailError:UniError("uni-file-manager",1300000,"mock error"),
fileListSuccess: [] as string[],
lastCompleteError:UniError("uni-file-manager",1300000,"mock error"),
fileListComplete: [] as string[],
readDir:'a',
accessFileRet: '',
readFileRet:"",
lastFailError: new UniError("uni-file-manager", 1300000, "mock error"),
writeFileContent:"锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦",
lastCompleteError: new UniError("uni-file-manager", 1300000, "mock error"),
getFileInfoAlgorithm:"md5",
readDir: 'a',
getFileInfoSize:-1,
readFileRet: "",
getFileInfoDigest:"",
writeFileContent: "中文 en.\r\n\t换行",
unlinkFile:'a/1.txt',
getFileInfoAlgorithm: "md5",
accessFile:'a/1.txt',
getFileInfoSize: -1,
writeFile:'a/1.txt',
getFileInfoDigest: "",
copyFromFile:'a/1.txt',
unlinkFile: 'a/1.txt',
copyToFile:'a/2.txt',
accessFile: 'a/1.txt',
renameFromFile:'a/2.txt',
writeFile: 'a/1.txt',
renameToFile:'a/3.txt',
copyFromFile: 'a/1.txt',
getFileInfoFile:'a/1.txt',
copyToFile: 'a/2.txt',
statFile:'a/1.txt',
renameFromFile: 'a/2.txt',
rmDirFile:'a',
renameToFile: 'a/3.txt',
mkdirFile:'a',
getFileInfoFile: 'a/1.txt',
readFile:'a/1.txt',
statFile: '',
recursiveVal:true,
rmDirFile: 'a',
mkdirFile: 'a',
readFile: 'a/1.txt',
recursiveVal: true,
done: false,
done: false,
writeFileEncoding:"utf-8",
writeFileEncoding:
"utf-8",
readFileEncoding:"utf-8",
readFileEncoding:
"utf-8",
statsRet:[] as Array<FileStats>,
statsRet:
[] as Array<FileStats>,
/**
/**
* 待测试的全局环境变量
* 待测试的全局环境变量
*/
*/
basePath: uni.env.USER_DATA_PATH,
basePath: uni.env.USER_DATA_PATH,
copyToBasePath: uni.env.USER_DATA_PATH,
copyToBasePath: uni.env.USER_DATA_PATH,
globalTempPath:uni.env.CACHE_PATH,
globalTempPath: uni.env.CACHE_PATH,
globalRootPath:uni.env.SANDBOX_PATH,
globalRootPath: uni.env.SANDBOX_PATH,
globalInnerRootPath:uni.env.ANDROID_INTERNAL_SANDBOX_PATH,
globalUserDataPath: uni.env.USER_DATA_PATH
globalAppResourcePath:uni.env.APP_RESOURCE_PATH,
}
globalUserDataPath:uni.env.USER_DATA_PATH
},
}
},
onLoad() {
onLoad() {
},
},
methods: {
methods: {
statFileInfoTest:
function(e:any)
{
statFileInfoTest:
function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.stat({
fileManager.stat({
path:`${this.basePath}${this.statFile}`,
path: `${this.basePath}${this.statFile}`,
recursive:this.recursiveVal,
recursive: this.recursiveVal,
success:function(res:StatSuccessResult){
success: function (res : StatSuccessResult) {
console.log('success',res)
if(this.logAble){
this.log += 'statFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest success', res)
this.statsRet = res.stats
this.statsRet = res.stats
console.log('this.statsRet',this.statsRet)
console.log('this.statsRet', this.statsRet)
},
},
fail:function(res:any){
fail: function (res : UniError) {
console.log('fail',res)
if(this.logAble){
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("
complete",
res)
console.log("
statFileInfoTest complete",
res)
this.done = true
this.done = true
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as StatOptions)
} as StatOptions)
},
},
getFileInfoTest:function(e:any){
getFileInfoTest: function (e : any) {
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.getFileInfo({
fileManager.getFileInfo({
filePath:`${this.basePath}${this.getFileInfoFile}`,
filePath: `${this.basePath}${this.getFileInfoFile}`,
digestAlgorithm:this.getFileInfoAlgorithm,
digestAlgorithm: this.getFileInfoAlgorithm,
success:function(res:GetFileInfoSuccessResult){
success: function (res : GetFileInfoSuccessResult) {
console.log('success',res)
if(this.logAble){
this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.getFileInfoSize = res.size
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
this.getFileInfoDigest = res.digest
},
},
fail:function(res:any){
fail: function (res : UniError) {
console.log('fail',res)
if(this.logAble){
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("complete",res)
console.log("complete",
res)
this.done = true
this.done = true
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as GetFileInfoOptions)
} as GetFileInfoOptions)
},
},
copyFileTest:function(e:any)
{
copyFileTest: function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.copyFile({
fileManager.copyFile({
srcPath:`${this.basePath}${this.copyFromFile}`,
srcPath: `${this.basePath}${this.copyFromFile}`,
destPath:`${this.copyToBasePath}${this.copyToFile}`,
destPath: `${this.copyToBasePath}${this.copyToFile}`,
success:function(res:FileManagerSuccessResult){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res:any){
}
console.log('fail',res)
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("complete",
res)
console.log("complete",
res)
this.done = true
this.done = true
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as CopyFileOptions)
} as CopyFileOptions)
},
},
renameFileTest:function(e:any)
{
renameFileTest: function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.rename({
fileManager.rename({
oldPath:`${this.basePath}${this.renameFromFile}`,
oldPath: `${this.basePath}${this.renameFromFile}`,
newPath:`${this.basePath}${this.renameToFile}`,
newPath: `${this.basePath}${this.renameToFile}`,
success:function(res:FileManagerSuccessResult){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'renameFileTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res:any){
}
console.log('fail',res)
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
this.done = true
this.done = true
console.log("complete",
res)
console.log("complete",
res)
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as RenameOptions)
} as RenameOptions)
},
},
readDirTest:function(e:any){
readDirTest: function (e : any) {
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.readdir({
fileManager.readdir({
dirPath:`${this.basePath}${this.readDir}`,
dirPath: `${this.basePath}${this.readDir}`,
success:function(res:ReadDirSuccessResult){
success: function (res : ReadDirSuccessResult) {
console.log("success",res)
if(this.logAble){
this.log += 'readDirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
this.fileListSuccess = res.files
this.fileListSuccess = res.files
},
},
fail:function(res:any){
fail: function (res : UniError) {
console.log('fail',res)
if(this.logAble){
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("complete",res)
console.log("complete",
res)
this.done = true
this.done = true
if
(res instanceof ReadDirSuccessResult)
{
if
(res instanceof ReadDirSuccessResult)
{
this.fileListComplete = res.files
this.fileListComplete = res.files
}
}
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as ReadDirOptions)
} as ReadDirOptions)
},
},
writeFileTest:function(e:any)
{
writeFileTest: function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.writeFile({
fileManager.writeFile({
filePath:`${this.basePath}${this.writeFile}`,
filePath: `${this.basePath}${this.writeFile}`,
data:this.writeFileContent,
data: this.writeFileContent,
encoding:this.writeFileEncoding,
encoding: this.writeFileEncoding,
success:function(res){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'writeFileTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res){
}
console.log('fail')
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res)
{
complete: function (res : any)
{
this.done = true
this.done = true
console.log("complete")
console.log("complete")
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as WriteFileOptions)
} as WriteFileOptions)
},
},
readFileTest:function(e:any)
{
readFileTest: function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.readFile({
fileManager.readFile({
filePath:`${this.basePath}${this.readFile}`,
filePath: `${this.basePath}${this.readFile}`,
encoding:this.readFileEncoding,
encoding: this.readFileEncoding,
success:function(res:ReadFileSuccessResult){
success: function (res : ReadFileSuccessResult) {
console.log('success',res)
if(this.logAble){
this.log += 'readFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.readFileRet = res.data
this.readFileRet = res.data
},
},
fail:function(res:any){
fail: function (res : UniError) {
console.log('fail',res)
if(this.logAble){
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("complete",
res)
console.log("complete",
res)
this.done = true
this.done = true
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as ReadFileOptions)
} as ReadFileOptions)
},
},
rmdirTest:function(e:any){
rmdirTest: function (e : any) {
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.rmdir({
fileManager.rmdir({
dirPath:`${this.basePath}${this.rmDirFile}`,
dirPath: `${this.basePath}${this.rmDirFile}`,
recursive:this.recursiveVal,
recursive: this.recursiveVal,
success:function(res:FileManagerSuccessResult){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'rmdirTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res:any){
}
console.log('fail',res)
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
console.log("complete",
res)
console.log("complete",
res)
this.done = true
this.done = true
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
}
}
} as RmDirOptions)
} as RmDirOptions)
},
},
mkdirTest:function(e:any)
{
mkdirTest: function (e : any)
{
// 准备测试数据
// 准备测试数据
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.mkdir({
fileManager.mkdir({
dirPath:`${this.basePath}${this.mkdirFile}`,
dirPath: `${this.basePath}${this.mkdirFile}`,
recursive:this.recursiveVal,
recursive: this.recursiveVal,
success:function(res:FileManagerSuccessResult){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'mkdirTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res:any){
}
console.log('fail',res)
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
this.done = true
this.done = true
console.log("complete",
res)
console.log("complete",
res)
}
}
} as MkDirOptions)
} as MkDirOptions)
},
},
accessFileTest:
function(e:any)
{
accessFileTest:
function (e : any)
{
this.accessFileRet = ''
this.accessFileRet = ''
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.access({
fileManager.access({
path: `${this.basePath}${this.accessFile}`,
path:`${this.basePath}${this.accessFile}`,
success: function (res : FileManagerSuccessResult) {
success:function(res:FileManagerSuccessResult){
if(this.logAble){
console.log('success',res)
this.log += 'accessFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.accessFileRet = res.errMsg
this.accessFileRet = res.errMsg
},
},
fail:function(res:UniError){
fail: function (res : UniError) {
console.log('fail',res)
if(this.logAble){
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
console.log("complete",
res)
console.log("complete",
res)
this.done = true
this.done = true
}
}
} as AccessOptions)
} as AccessOptions)
},
},
unlinkTest:function(e:any)
{
unlinkTest: function (e : any)
{
let fileManager = uni.getFileSystemManager()
let fileManager = uni.getFileSystemManager()
fileManager.unlink({
fileManager.unlink({
filePath:`${this.basePath}${this.unlinkFile}`,
filePath: `${this.basePath}${this.unlinkFile}`,
success:function(res:FileManagerSuccessResult){
success: function (res : FileManagerSuccessResult) {
console.log('success',res)
if(this.logAble){
},
this.log += 'unlinkTest success:' + JSON.stringify(res) + '\n\n'
fail:function(res:UniError){
}
console.log('fail',res)
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
complete:function(res:any)
{
complete: function (res : any)
{
if
(res instanceof UniError)
{
if
(res instanceof UniError)
{
this.lastCompleteError = res
this.lastCompleteError = res
}
}
console.log("complete",
res)
console.log("complete",
res)
this.done = true
this.done = true
}
}
} as UnLinkOptions)
} as UnLinkOptions)
},
},
unlinkAllFileTest: function (e : any) {
}
let fileManager = uni.getFileSystemManager()
}
fileManager.readdir({
dirPath: `${this.basePath}${this.rmDirFile}`,
success: function (res : ReadDirSuccessResult) {
console.log("success to readdir", res)
res.files.forEach(element => {
console.log(element)
fileManager.unlink({
filePath: `${this.basePath}${this.rmDirFile}/${element}`,
success: function (res : FileManagerSuccessResult) {
if(this.logAble){
this.log += 'unlinkAllFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success unlink', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail unlink', res)
this.lastFailError = res
},
complete: function (res : any) {
if (res instanceof UniError) {
this.lastCompleteError = res
}
console.log("complete unlink", res)
this.done = true
}
} as UnLinkOptions)
});
},
fail: function (res : UniError) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
console.log('fail to readdir', res)
this.lastFailError = res
},
complete: function (res : any) {
console.log("complete readdir", res)
this.done = true
if (res instanceof ReadDirSuccessResult) {
this.fileListComplete = res.files
}
if (res instanceof UniError) {
this.lastCompleteError = res
}
}
} as ReadDirOptions)
},
copyStaticToFilesTest: function (e : any) {
let fileManager = uni.getFileSystemManager()
fileManager.copyFile({
srcPath: UTSAndroid.getResourcePath("static/list-mock/mock.json"),
destPath: `${this.copyToBasePath}/a/mock.json`,
success: function (res : FileManagerSuccessResult) {
if(this.logAble){
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: function (res : UniError) {
if(this.logAble){
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
this.lastCompleteError = res
}
}
} as CopyFileOptions)
},
}
}
</script>
</script>
<style>
<style>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录