Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
58ecb8ad
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看板
提交
58ecb8ad
编写于
3月 21, 2024
作者:
xuty73419315
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改fileManager 示例 function改为箭头函数避免js 找不到this报错
上级
26300172
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
42 deletion
+42
-42
pages/API/get-file-system-manager/get-file-system-manager.uvue
.../API/get-file-system-manager/get-file-system-manager.uvue
+42
-42
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
58ecb8ad
...
...
@@ -80,7 +80,7 @@
fileManager.stat({
path: `${this.basePath}${this.statFile}`,
recursive: this.recursiveVal,
success:
function (res : StatSuccessResult)
{
success:
(res : StatSuccessResult) =>
{
if (this.logAble) {
this.log += 'statFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
...
...
@@ -88,14 +88,14 @@
this.statsRet = res.stats
console.log('this.statsRet', this.statsRet)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
console.log("statFileInfoTest complete", res)
this.done = true
if (res instanceof UniError) {
...
...
@@ -111,7 +111,7 @@
fileManager.getFileInfo({
filePath: `${this.basePath}${this.getFileInfoFile}`,
digestAlgorithm: this.getFileInfoAlgorithm,
success:
function (res : GetFileInfoSuccessResult)
{
success:
(res : GetFileInfoSuccessResult) =>
{
if (this.logAble) {
this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
...
...
@@ -119,14 +119,14 @@
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
...
...
@@ -142,20 +142,20 @@
fileManager.copyFile({
srcPath: `${this.basePath}${this.copyFromFile}`,
destPath: `${this.copyToBasePath}${this.copyToFile}`,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(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)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
...
...
@@ -171,20 +171,20 @@
fileManager.rename({
oldPath: `${this.basePath}${this.renameFromFile}`,
newPath: `${this.basePath}${this.renameToFile}`,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'renameFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
this.done = true
console.log("complete", res)
if (res instanceof UniError) {
...
...
@@ -198,21 +198,21 @@
const fileManager = uni.getFileSystemManager()
fileManager.readdir({
dirPath: `${this.basePath}${this.readDir}`,
success:
function (res : ReadDirSuccessResult)
{
success:
(res : ReadDirSuccessResult) =>
{
if (this.logAble) {
this.log += 'readDirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
this.fileListSuccess = res.files
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof ReadDirSuccessResult) {
...
...
@@ -232,20 +232,20 @@
filePath: `${this.basePath}${this.writeFile}`,
data: this.writeFileContent,
encoding: this.writeFileEncoding,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'writeFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
this.done = true
console.log("complete")
if (res instanceof UniError) {
...
...
@@ -261,21 +261,21 @@
fileManager.readFile({
filePath: `${this.basePath}${this.readFile}`,
encoding: this.readFileEncoding,
success:
function (res : ReadFileSuccessResult)
{
success:
(res : ReadFileSuccessResult) =>
{
if (this.logAble) {
this.log += 'readFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.readFileRet = res.data
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
...
...
@@ -290,20 +290,20 @@
fileManager.rmdir({
dirPath: `${this.basePath}${this.rmDirFile}`,
recursive: this.recursiveVal,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'rmdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
...
...
@@ -320,20 +320,20 @@
fileManager.mkdir({
dirPath: `${this.basePath}${this.mkdirFile}`,
recursive: this.recursiveVal,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'mkdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
if (res instanceof UniError) {
this.lastCompleteError = res
}
...
...
@@ -348,21 +348,21 @@
const fileManager = uni.getFileSystemManager()
fileManager.access({
path: `${this.basePath}${this.accessFile}`,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'accessFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.accessFileRet = res.errMsg
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
if (res instanceof UniError) {
this.lastCompleteError = res
}
...
...
@@ -377,20 +377,20 @@
fileManager.unlink({
filePath: `${this.basePath}${this.unlinkFile}`,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'unlinkTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(res : UniError) =>
{
if (this.logAble) {
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete:
function (res : any)
{
complete:
(res : any) =>
{
if (res instanceof UniError) {
this.lastCompleteError = res
}
...
...
@@ -403,26 +403,26 @@
const fileManager = uni.getFileSystemManager()
fileManager.readdir({
dirPath: `${this.basePath}${this.rmDirFile}`,
success:
function (res : ReadDirSuccessResult)
{
success:
(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)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'unlinkAllFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success unlink', res)
},
fail:
function (res : UniError)
{
fail:
(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)
{
complete
: (res : any) =>
{
if (res instanceof UniError) {
this.lastCompleteError = res
}
...
...
@@ -432,12 +432,12 @@
} as UnLinkOptions)
});
},
fail
: function (res : UniError)
{
fail
: (res : UniError) =>
{
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
console.log('fail to readdir', res)
this.lastFailError = res
},
complete
: function (res : any)
{
complete
: (res : any) =>
{
console.log("complete readdir", res)
this.done = true
if (res instanceof ReadDirSuccessResult) {
...
...
@@ -455,20 +455,20 @@
fileManager.copyFile({
srcPath: UTSAndroid.getResourcePath("static/list-mock/mock.json"),
destPath: `${this.copyToBasePath}/a/mock.json`,
success:
function (res : FileManagerSuccessResult)
{
success:
(res : FileManagerSuccessResult) =>
{
if (this.logAble) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail:
function (res : UniError)
{
fail:
(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)
{
complete:
(res : any) =>
{
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录