Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
f3fa969b
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
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看板
提交
f3fa969b
编写于
12月 13, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get-file-system-manager 测试示例调通
上级
4b10b7bf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
133 addition
and
68 deletion
+133
-68
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+48
-36
pages/API/get-file-system-manager/get-file-system-manager.uvue
.../API/get-file-system-manager/get-file-system-manager.uvue
+85
-32
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
f3fa969b
...
@@ -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
isDone
()
await
page
.
setData
({
unlinkFile
:
'
a/2.txt
'
})
await
btnUnLinkFileButton
.
tap
()
await
btnUnLinkFileButton
.
tap
()
await
isDone
()
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
'
,
...
@@ -831,6 +846,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -831,6 +846,7 @@ describe('ExtApi-FileManagerTest', () => {
expect
(
statsRet
[
4
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a/m/3.txt
'
)
expect
(
statsRet
[
4
].
path
).
toEqual
(
'
/storage/emulated/0/Android/data/io.dcloud.uniappx/a/m/3.txt
'
)
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
5842
)
expect
(
statsRet
[
4
].
stats
.
size
).
toEqual
(
5842
)
// 清理文件,避免影响其他测试用例
// 清理文件,避免影响其他测试用例
await
page
.
setData
({
await
page
.
setData
({
unlinkFile
:
'
a/1.txt
'
,
unlinkFile
:
'
a/1.txt
'
,
...
@@ -865,10 +881,6 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -865,10 +881,6 @@ describe('ExtApi-FileManagerTest', () => {
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
fileListSuccess
=
await
getData
(
'
fileListSuccess
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
'
[]
'
)
expect
(
JSON
.
stringify
(
fileListSuccess
)).
toEqual
(
'
[]
'
)
});
});
});
});
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
f3fa969b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件{{accessFile}}是否存在</button>
<button type="primary" @tap="accessFileTest" class="btn-access-file">判断文件{{accessFile}}是否存在</button>
<button type="primary" @tap="getFileInfoTest" class="btn-get-file-info">获取文件信息{{getFileInfoFile}}</button>
<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="unlinkTest" class="btn-unlink-file">删除文件{{unlinkFile}}</button>
<button type="primary" @tap="copyStaticToFilesTest" class="btn-
remove-dir
">从static目录复制文件到a目录</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="unlinkAllFileTest" class="btn-clear-file">删除文件夹{{rmDirFile}}下的所有文件</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹{{rmDirFile}}</button>
<button type="primary" @tap="rmdirTest" class="btn-remove-dir">删除文件夹{{rmDirFile}}</button>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
...
@@ -29,11 +29,15 @@
...
@@ -29,11 +29,15 @@
data() {
data() {
return {
return {
log: "",
log: "",
/**
* 自动化测试需要关闭log
*/
logAble:true,
fileListSuccess: [] as string[],
fileListSuccess: [] as string[],
fileListComplete: [] as string[],
fileListComplete: [] as string[],
accessFileRet: '',
accessFileRet: '',
lastFailError: UniError("uni-file-manager", 1300000, "mock error"),
lastFailError:
new
UniError("uni-file-manager", 1300000, "mock error"),
lastCompleteError: UniError("uni-file-manager", 1300000, "mock error"),
lastCompleteError:
new
UniError("uni-file-manager", 1300000, "mock error"),
readDir: 'a',
readDir: 'a',
readFileRet: "",
readFileRet: "",
writeFileContent: "中文 en.\r\n\t换行",
writeFileContent: "中文 en.\r\n\t换行",
...
@@ -64,8 +68,6 @@
...
@@ -64,8 +68,6 @@
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,
globalAppResourcePath: uni.env.APP_RESOURCE_PATH,
globalUserDataPath: uni.env.USER_DATA_PATH
globalUserDataPath: uni.env.USER_DATA_PATH
}
}
},
},
...
@@ -81,13 +83,17 @@
...
@@ -81,13 +83,17 @@
path: `${this.basePath}${this.statFile}`,
path: `${this.basePath}${this.statFile}`,
recursive: this.recursiveVal,
recursive: this.recursiveVal,
success: function (res : StatSuccessResult) {
success: function (res : StatSuccessResult) {
this.log += 'statFileInfoTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'statFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest success', res)
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 : UniError) {
fail: function (res : UniError) {
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest fail', res)
console.log('statFileInfoTest fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -108,13 +114,17 @@
...
@@ -108,13 +114,17 @@
filePath: `${this.basePath}${this.getFileInfoFile}`,
filePath: `${this.basePath}${this.getFileInfoFile}`,
digestAlgorithm: this.getFileInfoAlgorithm,
digestAlgorithm: this.getFileInfoAlgorithm,
success: function (res : GetFileInfoSuccessResult) {
success: function (res : GetFileInfoSuccessResult) {
this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
this.getFileInfoSize = res.size
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
this.getFileInfoDigest = res.digest
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -137,11 +147,15 @@
...
@@ -137,11 +147,15 @@
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) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -163,11 +177,15 @@
...
@@ -163,11 +177,15 @@
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) {
this.log += 'renameFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'renameFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -186,12 +204,16 @@
...
@@ -186,12 +204,16 @@
fileManager.readdir({
fileManager.readdir({
dirPath: `${this.basePath}${this.readDir}`,
dirPath: `${this.basePath}${this.readDir}`,
success: function (res : ReadDirSuccessResult) {
success: function (res : ReadDirSuccessResult) {
this.log += 'readDirTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'readDirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
console.log("success", res)
this.fileListSuccess = res.files
this.fileListSuccess = res.files
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -217,11 +239,15 @@
...
@@ -217,11 +239,15 @@
data: this.writeFileContent,
data: this.writeFileContent,
encoding: this.writeFileEncoding,
encoding: this.writeFileEncoding,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'writeFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'writeFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
console.log('fail')
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -245,12 +271,16 @@
...
@@ -245,12 +271,16 @@
filePath: `${this.basePath}${this.readFile}`,
filePath: `${this.basePath}${this.readFile}`,
encoding: this.readFileEncoding,
encoding: this.readFileEncoding,
success: function (res : ReadFileSuccessResult) {
success: function (res : ReadFileSuccessResult) {
this.log += 'readFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'readFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
this.readFileRet = res.data
this.readFileRet = res.data
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -270,11 +300,15 @@
...
@@ -270,11 +300,15 @@
dirPath: `${this.basePath}${this.rmDirFile}`,
dirPath: `${this.basePath}${this.rmDirFile}`,
recursive: this.recursiveVal,
recursive: this.recursiveVal,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'rmdirTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'rmdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -297,11 +331,15 @@
...
@@ -297,11 +331,15 @@
dirPath: `${this.basePath}${this.mkdirFile}`,
dirPath: `${this.basePath}${this.mkdirFile}`,
recursive: this.recursiveVal,
recursive: this.recursiveVal,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'mkdirTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'mkdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -318,16 +356,19 @@
...
@@ -318,16 +356,19 @@
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) {
this.log += 'accessFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'accessFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
this.accessFileRet = res.errMsg
this.accessFileRet = res.errMsg
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -348,11 +389,15 @@
...
@@ -348,11 +389,15 @@
fileManager.unlink({
fileManager.unlink({
filePath: `${this.basePath}${this.unlinkFile}`,
filePath: `${this.basePath}${this.unlinkFile}`,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'unlinkTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'unlinkTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -376,11 +421,15 @@
...
@@ -376,11 +421,15 @@
fileManager.unlink({
fileManager.unlink({
filePath: `${this.basePath}${this.rmDirFile}/${element}`,
filePath: `${this.basePath}${this.rmDirFile}/${element}`,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'unlinkAllFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'unlinkAllFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success unlink', res)
console.log('success unlink', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail unlink', res)
console.log('fail unlink', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
@@ -419,11 +468,15 @@
...
@@ -419,11 +468,15 @@
srcPath: UTSAndroid.getResourcePath("static/list-mock/mock.json"),
srcPath: UTSAndroid.getResourcePath("static/list-mock/mock.json"),
destPath: `${this.copyToBasePath}/a/mock.json`,
destPath: `${this.copyToBasePath}/a/mock.json`,
success: function (res : FileManagerSuccessResult) {
success: function (res : FileManagerSuccessResult) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
console.log('success', res)
},
},
fail: function (res : UniError) {
fail: function (res : UniError) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
if(this.logAble){
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('fail', res)
this.lastFailError = res
this.lastFailError = res
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录