mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-23 00:20:07 +00:00
应用访问框架及API能力增强SAMPLE
Signed-off-by: wangxiaoyun <wangxiaoyun@kaihong.com>
This commit is contained in:
parent
0da5f614e1
commit
3bfe58197d
@ -17,5 +17,6 @@ import Logger from './src/main/ets/utils/Logger'
|
||||
import FileManager from './src/main/ets/filemanager/FileManager'
|
||||
import ThumbnailImage from './src/main/ets/filemanager/components/ThumbnailImage'
|
||||
import FileSystem from './src/main/ets/filemanager/fileio/FileIoManager'
|
||||
import NewFileSystem from './src/main/ets/filemanager/fileio/NewFileIoManager'
|
||||
|
||||
export { Logger, FileManager, ThumbnailImage, FileSystem }
|
||||
export { Logger, FileManager, ThumbnailImage, FileSystem , NewFileSystem }
|
||||
|
@ -96,6 +96,7 @@ class FileSystem {
|
||||
// 如果是文件夹,就读取文件夹中文件的数量
|
||||
if (dirent.isDirectory()) {
|
||||
subdirectoryNum = this.getSubdirectoryNum(filePath + `${dirent.name}`);
|
||||
time = this.getFileTime(filePath + `${dirent.name}`);
|
||||
} else {
|
||||
// 如果不是文件夹,就读取文件大小和时间
|
||||
fileSize = this.getFileSize(filePath + `${dirent.name}`);
|
||||
@ -131,7 +132,7 @@ class FileSystem {
|
||||
// 获取文件修改时间
|
||||
getFileTime(filePath: string): Date {
|
||||
try {
|
||||
let fileTime = fileio.statSync(filePath).ctime;
|
||||
let fileTime = fileio.statSync(filePath).mtime;
|
||||
return new Date(fileTime * 1000);
|
||||
} catch (err) {
|
||||
Logger.error(`getFileTime failed, code is ${err.code}, message is ${err.message}`);
|
||||
@ -222,4 +223,4 @@ class FileSystem {
|
||||
}
|
||||
}
|
||||
|
||||
export default new FileSystem()
|
||||
export default new FileSystem()
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import storageStatistics from '@ohos.file.storageStatistics'
|
||||
import fs from '@ohos.file.fs'
|
||||
import { Options } from '@ohos.file.fs';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import Logger from '../../utils/Logger'
|
||||
import { FileType, SubDirectoryType } from '../../mock/local/FileData'
|
||||
import prompt from '@ohos.promptAction'
|
||||
|
||||
class NewFileSystem {
|
||||
// 创建多级目录
|
||||
createDirectory(filePath: string): void {
|
||||
try {
|
||||
console.log("To create recursive path");
|
||||
fs.mkdirSync(filePath,true);
|
||||
} catch (err) {
|
||||
Logger.error(`create directory failed, code is ${err.code}, message is ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 修改文件时间
|
||||
setFileTime(filePath: string, time: number): void {
|
||||
try {
|
||||
fs.utimes(filePath,time);
|
||||
} catch (err) {
|
||||
Logger.error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
|
||||
throw new Error(`setFileTime failed, code is ${err.code}, message is ${err.message}`);
|
||||
}
|
||||
}
|
||||
// 读取文件内容
|
||||
async ReadFile(filePath: string):Promise<string> {
|
||||
try{
|
||||
let content : string='';
|
||||
let options: Options = {
|
||||
encoding: 'utf-8'
|
||||
};
|
||||
await fs.readLines(filePath, options).then((readerIterator: fs.ReaderIterator) => {
|
||||
for (let it = readerIterator.next(); !it.done; it = readerIterator.next()) {
|
||||
content += it.value;
|
||||
}
|
||||
}
|
||||
).catch((err: BusinessError) => {
|
||||
console.info("readLines failed with error message: " + err.message + ", error code: " + err.code);
|
||||
});
|
||||
return content;
|
||||
} catch (err) {
|
||||
Logger.error(`OpenFile failed, code is ${err.code}, message is ${err.message}`);
|
||||
throw new Error(`OpenFile failed, code is ${err.code}, message is ${err.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new NewFileSystem()
|
@ -24,20 +24,22 @@ export class FileStructure {
|
||||
// 数据类型 1:文件夹、2:文件
|
||||
public type: number = 0;
|
||||
// 文件大小
|
||||
public size?: string
|
||||
public size?: string;
|
||||
// 处理日期格式
|
||||
private dateFormat(time: Date): string {
|
||||
let date = time
|
||||
let year = date.getFullYear()
|
||||
let month: string | number = date.getMonth() + 1
|
||||
month = month >= 10 ? month : ('0' + month)
|
||||
let day: string | number = date.getDate()
|
||||
day = day >= 10 ? day : ('0' + day)
|
||||
let hours: string | number = date.getHours()
|
||||
hours = hours >= 10 ? hours : ('0' + hours)
|
||||
let minutes: string | number = date.getMinutes()
|
||||
minutes = minutes >= 10 ? minutes : ('0' + minutes)
|
||||
return `${year}/${month}/${day} ${hours}:${minutes}`
|
||||
let date = time;
|
||||
let year = date.getFullYear();
|
||||
let month: string | number = date.getMonth() + 1;
|
||||
month = month >= 10 ? month : ('0' + month);
|
||||
let day: string | number = date.getDate();
|
||||
day = day >= 10 ? day : ('0' + day);
|
||||
let hours: string | number = date.getHours();
|
||||
hours = hours >= 10 ? hours : ('0' + hours);
|
||||
let minutes: string | number = date.getMinutes();
|
||||
minutes = minutes >= 10 ? minutes : ('0' + minutes);
|
||||
let seconds: string | number = date.getSeconds();
|
||||
seconds = seconds >= 10 ? seconds : ('0' + seconds);
|
||||
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
constructor(name: string, type: number, time: Date, childrenNum?: number, size?: string) {
|
||||
@ -77,4 +79,4 @@ export interface SubDirectoryType {
|
||||
time: Date;
|
||||
childrenNum?: number;
|
||||
fileSize?: string;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,11 @@
|
||||
|
||||
4. 点击右上角多选按钮,选择需要复制和移动的文件(可多选,并且不可移动到本身的子目录下),选中后点击左下角“复制和移动”按钮,在页面中点击目标目录会进入该目录,在目标目录下点击“移动到这”按钮,完成文件复制和移动。
|
||||
|
||||
5. 点击右上角多选按钮,选择需要删除的文件,选中后点击右下角“删除”按钮,在弹窗中点击“删除”,即可删除文件。
|
||||
5. 点击右上角多选按钮,选择需要删除的文件,选中后点击右下角“更多”按钮,弹出的菜单钟选择“删除”,在弹窗中点击“删除”,即可删除文件。
|
||||
|
||||
6. 点击右上角多选按钮,选择一项需要修改时间的文件,选中后点击右下角“更多”按钮,弹出的菜单钟选择“修改文件(夹)时间”,在弹窗的文本框中输入要修改的时间,点击“确定”,即可修改文件(夹)时间。
|
||||
|
||||
7. 点击单个文件,可进入文件内容查看页面。
|
||||
6. 在主页点击“监听文件”,进入文件监听页面。
|
||||
1. 点击**添加监听**按钮,选择**IN_CREATE**监听,然后点击**确定**按钮,成功添加IN_CREATE监听。
|
||||
2. 点击**添加**按钮,成功添加一个文件,触发事件后日志显示为相应日志:event:256,fileName为新增文件的路径。
|
||||
@ -157,4 +161,4 @@ Library/src/main/ets/
|
||||
git config core.sparsecheckout true
|
||||
echo code/BasicFeature/FileManager/FileManager/ > .git/info/sparse-checkout
|
||||
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
|
||||
git pull origin master
|
||||
git pull origin master
|
||||
|
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// 用户改变文件(夹)时间的弹窗
|
||||
@CustomDialog
|
||||
export struct ChangeTimeDialog {
|
||||
controller?: CustomDialogController
|
||||
textController: TextInputController = new TextInputController()
|
||||
confirm: () => void = () => {}
|
||||
time: string = ''
|
||||
|
||||
aboutToAppear() {
|
||||
if (this.time) {
|
||||
AppStorage.SetOrCreate('time', this.time);
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.label_change_time'))
|
||||
.fontSize(20)
|
||||
}
|
||||
.width('100%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
|
||||
TextInput({
|
||||
placeholder: $r('app.string.label_input'),
|
||||
text: this.time ? this.time : '',
|
||||
controller: this.textController
|
||||
})
|
||||
.id('input')
|
||||
.placeholderColor(Color.Grey)
|
||||
.placeholderFont({ size: 14, weight: 400 })
|
||||
.caretColor(Color.Blue)
|
||||
.width('100%')
|
||||
.height(40)
|
||||
.margin({ top: 20, bottom: 20 })
|
||||
.fontSize(14)
|
||||
.fontColor(Color.Black)
|
||||
.enableKeyboardOnFocus(false)
|
||||
.onChange((value: string) => {
|
||||
AppStorage.SetOrCreate('time', value)
|
||||
})
|
||||
|
||||
Row() {
|
||||
Text($r('app.string.label_confirm'))
|
||||
.id('promise')
|
||||
.fontColor($r('app.color.text_color'))
|
||||
.fontSize(20)
|
||||
.letterSpacing(2)
|
||||
.opacity(.8)
|
||||
}
|
||||
.padding({ top: 10, bottom: 10 })
|
||||
.margin({ bottom: 20 })
|
||||
// 界面需求,这里给出50%
|
||||
.width('50%')
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.borderWidth(2)
|
||||
.borderColor($r('app.color.text_color'))
|
||||
.borderRadius(40)
|
||||
.onClick(() => {
|
||||
this.confirm()
|
||||
})
|
||||
|
||||
Text($r('app.string.label_cancel'))
|
||||
.id('cancel')
|
||||
.fontSize(20)
|
||||
.onClick(() => {
|
||||
this.controller?.close()
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.padding(40)
|
||||
.borderRadius(20)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
@ -15,15 +15,38 @@
|
||||
|
||||
import router from '@ohos.router'
|
||||
import prompt from '@ohos.promptAction'
|
||||
import { FileSystem } from '@ohos/feature-file-manager'
|
||||
import { FileSystem, NewFileSystem } from '@ohos/feature-file-manager'
|
||||
import { FileStructure, FileType } from '@ohos/feature-file-manager/src/main/ets/mock/local/FileData'
|
||||
// 添加文件的弹窗
|
||||
import { InputNameDialog } from './InputNameDialog'
|
||||
// 删除文件的弹窗
|
||||
import { DeleteDialog } from './DeleteDialog'
|
||||
//修改文件(夹)时间的弹窗
|
||||
import { ChangeTimeDialog } from './ChangeTimeDialog'
|
||||
// 基础沙箱路径---固定路径
|
||||
const BASE_PATH = '/data/storage/el2/base/haps/'
|
||||
|
||||
// 处理日期格式
|
||||
function str2TimeStamp(time: string): number {
|
||||
let dateString = time.slice(0, 10);
|
||||
let timeString = time.slice(11,19);
|
||||
|
||||
let dateParts = dateString.split('/');
|
||||
let year = parseInt(dateParts[0],10);
|
||||
let month = parseInt(dateParts[1],10);
|
||||
let day = parseInt(dateParts[2],10);
|
||||
|
||||
let timeParts = timeString.split(':');
|
||||
let hour = parseInt(timeParts[0],10);
|
||||
let minites = parseInt(timeParts[1],10);
|
||||
let seconds = parseInt(timeParts[2],10);
|
||||
|
||||
let date = new Date(year,month-1,day,hour,minites,seconds,0);
|
||||
let tt = date.getTime();
|
||||
|
||||
return tt;
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
export struct MyPhone {
|
||||
@ -37,6 +60,7 @@ export struct MyPhone {
|
||||
@State @Watch('clearTempData') isSelect: boolean = false
|
||||
// 被选中的数组---样式判断
|
||||
@State selectedFiles: Array<string> = []
|
||||
@State selectedFilesTime: string = ''
|
||||
// 读取的文件结构
|
||||
@State fileData: Array<FileStructure> = []
|
||||
// 命名弹窗的类型---默认是文件夹
|
||||
@ -84,6 +108,7 @@ export struct MyPhone {
|
||||
clearTempData() {
|
||||
if (this.isSelect) {
|
||||
this.selectedFiles = []
|
||||
this.selectedFilesTime = ''
|
||||
this.needDeleteFiles.clear()
|
||||
this.needMoveFiles = []
|
||||
}
|
||||
@ -99,7 +124,7 @@ export struct MyPhone {
|
||||
return prompt.showToast({ message: $r('app.string.tip_input_name') });
|
||||
}
|
||||
if (this.fileDialogType === 1) {
|
||||
FileSystem.createDirectory(this.directoryPath + name);
|
||||
NewFileSystem.createDirectory(this.directoryPath + name);
|
||||
} else {
|
||||
// 创建文件
|
||||
FileSystem.createFile(this.directoryPath + name);
|
||||
@ -142,6 +167,23 @@ export struct MyPhone {
|
||||
}
|
||||
})
|
||||
})
|
||||
//修改文件(夹)时间的弹窗
|
||||
changeTimeDialog: CustomDialogController = new CustomDialogController({
|
||||
builder: ChangeTimeDialog({
|
||||
time: this.selectedFilesTime,
|
||||
confirm: () => {
|
||||
const time: string | undefined = AppStorage.Get('time');
|
||||
if (!time) {
|
||||
return prompt.showToast({ message: $r('app.string.tip_input_name') });
|
||||
}
|
||||
let timeStamp = str2TimeStamp(time);
|
||||
NewFileSystem.setFileTime(this.directoryPath + this.selectedFiles[0],timeStamp);
|
||||
this.isSelect = false;
|
||||
this.updateFileData();
|
||||
this.changeTimeDialog.close();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
@ -233,7 +275,7 @@ export struct MyPhone {
|
||||
if (this.fileData.length > 0) {
|
||||
// 目录列表
|
||||
List({ space: 16 }) {
|
||||
ForEach(this.fileData, (file: FileStructure) => {
|
||||
ForEach(this.fileData, (file: FileStructure, index: number) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
if (this.isSelect) {
|
||||
@ -302,6 +344,7 @@ export struct MyPhone {
|
||||
this.needMoveFiles.splice(index, 1)
|
||||
} else {
|
||||
this.selectedFiles.push(file.name)
|
||||
this.selectedFilesTime = file.time
|
||||
// 处理需要删除的数据格式
|
||||
this.needDeleteFiles.set(this.directoryPath + file.name, file.type)
|
||||
// 需要移动的文件的格式
|
||||
@ -334,10 +377,27 @@ export struct MyPhone {
|
||||
directoryPath: `${this.directoryPath}${file.name}/`
|
||||
}
|
||||
})
|
||||
} else{
|
||||
//如果是文件就打开文件
|
||||
let filePath = this.directoryPath + file.name;
|
||||
console.log(filePath);
|
||||
NewFileSystem.ReadFile(filePath).then(content => {
|
||||
router.pushUrl({
|
||||
url: 'filemanager/pages/MyPhone/OpenFile',
|
||||
params: {
|
||||
fileName: file.name,
|
||||
fileSize: file.size,
|
||||
fileContent: content,
|
||||
}
|
||||
}, router.RouterMode.Standard);
|
||||
}).catch(error => {
|
||||
console.error(error.message);
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.id("ListItem"+index)
|
||||
.width('100%')
|
||||
})
|
||||
}
|
||||
@ -442,23 +502,36 @@ export struct MyPhone {
|
||||
})
|
||||
|
||||
Column({ space: 8 }) {
|
||||
Image($r('app.media.delete'))
|
||||
.width(30)
|
||||
.height(30)
|
||||
|
||||
Text($r('app.string.label_delete'))
|
||||
.id('delete')
|
||||
Text($r('app.string.label_more'))
|
||||
.id('more')
|
||||
.fontSize(16)
|
||||
}
|
||||
.onClick(() => {
|
||||
if (this.selectedFiles.length > 0) {
|
||||
this.deleteDialog.open()
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: $r('app.string.tip_choose_one')
|
||||
})
|
||||
}
|
||||
})
|
||||
.bindMenu([
|
||||
{
|
||||
value: $r('app.string.label_change_time'),
|
||||
action: () => {
|
||||
if (this.selectedFiles.length == 1) {
|
||||
this.changeTimeDialog.open()
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: $r('app.string.tip_choose_can_onlyone')
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
value: $r('app.string.label_delete'),
|
||||
action: () => {
|
||||
if (this.selectedFiles.length > 0) {
|
||||
this.deleteDialog.open()
|
||||
} else {
|
||||
prompt.showToast({
|
||||
message: $r('app.string.tip_choose_one')
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
])
|
||||
}
|
||||
.width('100%')
|
||||
.borderRadius(18)
|
||||
@ -537,4 +610,4 @@ export struct MyPhone {
|
||||
.height('100%')
|
||||
.padding({ left: 12, right: 12 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import router from '@ohos.router';
|
||||
import prompt from '@ohos.prompt'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct OpenFile {
|
||||
@State myFileName: string = router.getParams()['fileName'];
|
||||
@State myFileContent: string = router.getParams()['fileContent'];
|
||||
@State text: string = router.getParams()['text'];
|
||||
@State showFileName: string = this.myFileName;
|
||||
@State showFileContent: string = this.myFileContent;
|
||||
scroller: Scroller = new Scroller();
|
||||
controllerArea: TextAreaController = new TextAreaController();
|
||||
controllerInput: TextInputController = new TextInputController();
|
||||
|
||||
build() {
|
||||
Scroll(this.scroller) {
|
||||
Row() {
|
||||
Column() {
|
||||
Row() {
|
||||
Row() {
|
||||
Image($r('app.media.ic_back'))
|
||||
.width(24)
|
||||
.height(24)
|
||||
.align(Alignment.Start)
|
||||
.id('back')
|
||||
.onClick(() => {
|
||||
router.back();
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
}
|
||||
.height(26)
|
||||
.margin({ top: 19, left: 26, right: 24 })
|
||||
.align(Alignment.Center)
|
||||
|
||||
Column() {
|
||||
Row() {
|
||||
TextInput({ text: this.showFileName, controller: this.controllerInput })
|
||||
.fontSize(30)
|
||||
.fontColor('#182431')
|
||||
.textAlign(TextAlign.Start)
|
||||
.id('fileName')
|
||||
.borderRadius(0)
|
||||
.fontWeight(500)
|
||||
.margin({ left: 8, right: 8 })
|
||||
.backgroundColor('#f1f3f5')
|
||||
.maxLength(30)
|
||||
}
|
||||
.width('100%')
|
||||
.align(Alignment.Start)
|
||||
.margin({ top: 8 })
|
||||
}
|
||||
.margin({ top: 11 })
|
||||
.height(81)
|
||||
|
||||
Row() {
|
||||
TextArea({ text: this.showFileContent, controller: this.controllerArea })
|
||||
.fontSize(16)
|
||||
.fontColor('#182431')
|
||||
.height(560)
|
||||
.id('fileContent')
|
||||
.borderRadius(0)
|
||||
.fontWeight(400)
|
||||
.align(Alignment.TopStart)
|
||||
.backgroundColor('#f1f3f5')
|
||||
.opacity(0.6)
|
||||
.margin({ left: 8, right: 8 })
|
||||
}
|
||||
.margin({ top: 11 })
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor('#f1f3f5')
|
||||
}
|
||||
}
|
||||
}
|
@ -112,10 +112,22 @@
|
||||
"name": "tip_choose_one",
|
||||
"value": "tip_choose_one"
|
||||
},
|
||||
{
|
||||
"name": "tip_choose_can_onlyone",
|
||||
"value": "tip_choose_can_onlyone"
|
||||
},
|
||||
{
|
||||
"name": "label_rename",
|
||||
"value": "label_rename"
|
||||
},
|
||||
{
|
||||
"name": "label_change_time",
|
||||
"value": "label_change_time"
|
||||
},
|
||||
{
|
||||
"name": "label_file_end",
|
||||
"value": "label_file_end"
|
||||
},
|
||||
{
|
||||
"name": "label_share",
|
||||
"value": "label_share"
|
||||
@ -160,6 +172,10 @@
|
||||
"name": "label_delete_success",
|
||||
"value": "label_delete_success"
|
||||
},
|
||||
{
|
||||
"name": "label_more",
|
||||
"value": "label_more"
|
||||
},
|
||||
{
|
||||
"name": "label_input",
|
||||
"value": "label_input"
|
||||
@ -221,4 +237,4 @@
|
||||
"value": "File Content4"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
"filemanager/pages/video/VideoFileList",
|
||||
"filemanager/pages/document/DocumentFileList",
|
||||
"filemanager/pages/audio/AudioFileList",
|
||||
"filemanager/pages/MyPhone/MyPhone"
|
||||
"filemanager/pages/MyPhone/MyPhone",
|
||||
"filemanager/pages/MyPhone/OpenFile"
|
||||
]
|
||||
}
|
||||
|
@ -112,10 +112,22 @@
|
||||
"name": "tip_choose_one",
|
||||
"value": "tip_choose_one"
|
||||
},
|
||||
{
|
||||
"name": "tip_choose_can_onlyone",
|
||||
"value": "tip_choose_can_onlyone"
|
||||
},
|
||||
{
|
||||
"name": "label_rename",
|
||||
"value": "label_rename"
|
||||
},
|
||||
{
|
||||
"name": "label_change_time",
|
||||
"value": "label_change_time"
|
||||
},
|
||||
{
|
||||
"name": "label_file_end",
|
||||
"value": "label_file_end"
|
||||
},
|
||||
{
|
||||
"name": "label_share",
|
||||
"value": "label_share"
|
||||
@ -160,6 +172,10 @@
|
||||
"name": "label_delete_success",
|
||||
"value": "label_delete_success"
|
||||
},
|
||||
{
|
||||
"name": "label_more",
|
||||
"value": "label_more"
|
||||
},
|
||||
{
|
||||
"name": "label_input",
|
||||
"value": "label_input"
|
||||
@ -221,4 +237,4 @@
|
||||
"value": "File Content4"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -112,10 +112,22 @@
|
||||
"name": "tip_choose_one",
|
||||
"value": "请至少选中一项"
|
||||
},
|
||||
{
|
||||
"name": "tip_choose_can_onlyone",
|
||||
"value": "请选择且只能选择一项进行时间修改"
|
||||
},
|
||||
{
|
||||
"name": "label_rename",
|
||||
"value": "重命名"
|
||||
},
|
||||
{
|
||||
"name": "label_change_time",
|
||||
"value": "修改文件(夹)时间"
|
||||
},
|
||||
{
|
||||
"name": "label_file_end",
|
||||
"value": "文件到底了"
|
||||
},
|
||||
{
|
||||
"name": "label_share",
|
||||
"value": "分享"
|
||||
@ -160,6 +172,10 @@
|
||||
"name": "label_delete_success",
|
||||
"value": "删除成功"
|
||||
},
|
||||
{
|
||||
"name": "label_more",
|
||||
"value": "更多"
|
||||
},
|
||||
{
|
||||
"name": "label_input",
|
||||
"value": "请输入文件名称"
|
||||
@ -221,4 +237,4 @@
|
||||
"value": " 4.准备葡萄干、核桃仁、纸杯、将面糊倒入纸杯,再加入葡萄干、核桃仁,把纸杯蛋糕放进烤箱,定时40分钟,取出即可食用。"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1076,120 +1076,186 @@ export default function abilityTest() {
|
||||
/**
|
||||
* 点击主页中我的手机
|
||||
*/
|
||||
it(BUNDLE + 'MobileFunction_001', 0, async function () {
|
||||
Logger.info(TAG, BUNDLE + 'MobileFunction_001 begin')
|
||||
let driver = await Driver.create()
|
||||
await driver.delayMs(500)
|
||||
it('MobileFunction_001', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_001 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(500);
|
||||
// 主页能够显示List中内容,点击手机
|
||||
await driver.assertComponentExist(ON.type('List'))
|
||||
await driver.assertComponentExist(ON.type('ListItem').id('ListItem5'))
|
||||
let btnStart = await driver.findComponent(ON.type('ListItem').id('ListItem5'))
|
||||
await btnStart.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.type('List'));
|
||||
await driver.assertComponentExist(ON.type('ListItem').id('ListItem5'));
|
||||
let btnStart = await driver.findComponent(ON.type('ListItem').id('ListItem5'));
|
||||
await btnStart.click();
|
||||
await driver.delayMs(500);
|
||||
// 跳转我的手机界面
|
||||
await driver.assertComponentExist(ON.type('Text').id('makeFile'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('makeDirectory'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('sort'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('clean'))
|
||||
// 测试新建文件功能
|
||||
let btnFile = await driver.findComponent(ON.type('Text').id('makeFile'))
|
||||
await btnFile.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('cancel'))
|
||||
let btnCancel = await driver.findComponent(ON.id('cancel'))
|
||||
await btnCancel.click()
|
||||
await driver.delayMs(500)
|
||||
await btnFile.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('input'))
|
||||
let input = await driver.findComponent(ON.id('input'))
|
||||
await input.inputText('testFile')
|
||||
await driver.assertComponentExist(ON.id('promise'))
|
||||
let btnPromise = await driver.findComponent(ON.id('promise'))
|
||||
await btnPromise.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.text('testFile'))
|
||||
let testFile = await driver.findComponent(ON.text('testFile'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('makeFile'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('makeDirectory'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('sort'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('clean'));
|
||||
// 测试新建文件及打开功能
|
||||
let btnFile = await driver.findComponent(ON.type('Text').id('makeFile'));
|
||||
await btnFile.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.assertComponentExist(ON.id('cancel'));
|
||||
let btnCancel = await driver.findComponent(ON.id('cancel'));
|
||||
await btnCancel.click();
|
||||
await driver.delayMs(500);
|
||||
await btnFile.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('input'));
|
||||
let input = await driver.findComponent(ON.id('input'));
|
||||
await input.inputText('testFile');
|
||||
await driver.assertComponentExist(ON.id('promise'));
|
||||
let btnPromise = await driver.findComponent(ON.id('promise'));
|
||||
await btnPromise.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.text('testFile'));
|
||||
let testFile = await driver.findComponent(ON.text('testFile'));
|
||||
await testFile.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('fileName'));
|
||||
let back = await driver.findComponent(ON.id('back'));
|
||||
await back.click();
|
||||
await driver.delayMs(200);
|
||||
Logger.info(TAG, BUNDLE + 'MobileFunction_001 end');
|
||||
});
|
||||
it('MobileFunction_002', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_002 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(200);
|
||||
// 测试新建文件夹功能
|
||||
let btnDirectory = await driver.findComponent(ON.type('Text').id('makeDirectory'))
|
||||
await btnDirectory.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('cancel'))
|
||||
let directoryCancel = await driver.findComponent(ON.id('cancel'))
|
||||
await directoryCancel.click()
|
||||
await driver.delayMs(500)
|
||||
await btnDirectory.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('input'))
|
||||
let inputDirectory = await driver.findComponent(ON.id('input'))
|
||||
await inputDirectory.inputText('testDirectory')
|
||||
await driver.assertComponentExist(ON.id('promise'))
|
||||
let directoryPromise = await driver.findComponent(ON.id('promise'))
|
||||
await directoryPromise.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.text('testDirectory'))
|
||||
let testDirectory = await driver.findComponent(ON.text('testDirectory'))
|
||||
// 点击select图片
|
||||
await driver.assertComponentExist(ON.id('select'))
|
||||
let selectImage = await driver.findComponent(ON.id('select'))
|
||||
await selectImage.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.type('Text').id('copy'))
|
||||
let btnCopy = await driver.findComponent(ON.type('Text').id('copy'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('rename'))
|
||||
let btnRename = await driver.findComponent(ON.type('Text').id('rename'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('share'))
|
||||
await driver.assertComponentExist(ON.type('Text').id('delete'))
|
||||
let btnDelete = await driver.findComponent(ON.type('Text').id('delete'))
|
||||
// 测试复制
|
||||
await testFile.click()
|
||||
await btnCopy.click()
|
||||
await testDirectory.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('move'))
|
||||
let btnMove = await driver.findComponent(ON.id('move'))
|
||||
await btnMove.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.text('testFile'))
|
||||
let copyFile = await driver.findComponent(ON.text('testFile'))
|
||||
// 测试删除
|
||||
await driver.assertComponentExist(ON.id('secondarySelect'))
|
||||
let btnSecondarySelect = await driver.findComponent(ON.id('secondarySelect'))
|
||||
await btnSecondarySelect.click()
|
||||
await driver.delayMs(500)
|
||||
await copyFile.click()
|
||||
await driver.assertComponentExist(ON.type('Text').id('delete'))
|
||||
let newDelete = await driver.findComponent(ON.type('Text').id('delete'))
|
||||
await newDelete.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('checkDelete'))
|
||||
let btnCheckDelete = await driver.findComponent(ON.id('checkDelete'))
|
||||
await btnCheckDelete.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.id('blank'))
|
||||
// 测试重命名
|
||||
await driver.assertComponentExist(ON.id('left'))
|
||||
let btnLeft = await driver.findComponent(ON.id('left'))
|
||||
await btnLeft.click()
|
||||
await driver.delayMs(500)
|
||||
let btnSelect = await driver.findComponent(ON.id('select'))
|
||||
await btnSelect.click()
|
||||
await testFile.click()
|
||||
let btnRenameNew = await driver.findComponent(ON.type('Text').id('rename'))
|
||||
await btnRenameNew.click()
|
||||
await driver.delayMs(500)
|
||||
let inputDirectoryNew = await driver.findComponent(ON.id('input'))
|
||||
await inputDirectoryNew.inputText('testFileNew')
|
||||
let btnPromiseNew = await driver.findComponent(ON.id('promise'))
|
||||
await btnPromiseNew.click()
|
||||
await driver.delayMs(500)
|
||||
await driver.assertComponentExist(ON.text('testFileNew'))
|
||||
let btnDirectory = await driver.findComponent(ON.type('Text').id('makeDirectory'));
|
||||
await btnDirectory.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('cancel'));
|
||||
let directoryCancel = await driver.findComponent(ON.id('cancel'));
|
||||
await directoryCancel.click();
|
||||
await driver.delayMs(200);
|
||||
await btnDirectory.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('input'));
|
||||
let inputDirectory = await driver.findComponent(ON.id('input'));
|
||||
await inputDirectory.inputText('testDirectory/testSubDirectory');
|
||||
await driver.assertComponentExist(ON.id('promise'));
|
||||
let directoryPromise = await driver.findComponent(ON.id('promise'));
|
||||
await directoryPromise.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.text('testDirectory'));
|
||||
let testDirectory = await driver.findComponent(ON.text('testDirectory'));
|
||||
await testDirectory.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.text('testSubDirectory'));
|
||||
// 返回
|
||||
await driver.pressBack()
|
||||
await driver.delayMs(500)
|
||||
Logger.info(TAG, BUNDLE + 'MobileFunction_001 end')
|
||||
})
|
||||
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(500);
|
||||
Logger.info(TAG, BUNDLE + 'MobileFunction_002 end');
|
||||
});
|
||||
it('MobileFunction_003', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_003 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(200);
|
||||
// 点击select图片
|
||||
await driver.assertComponentExist(ON.id('select'));
|
||||
let selectImage = await driver.findComponent(ON.id('select'));
|
||||
await selectImage.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.assertComponentExist(ON.type('Text').id('copy'));
|
||||
let btnCopy = await driver.findComponent(ON.type('Text').id('copy'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('rename'));
|
||||
let btnRename = await driver.findComponent(ON.type('Text').id('rename'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('share'));
|
||||
await driver.assertComponentExist(ON.type('Text').id('more'));
|
||||
let btnDelete = await driver.findComponent(ON.type('Text').id('delete'));
|
||||
// 测试复制
|
||||
let testFile = await driver.findComponent(ON.text('testFile'));
|
||||
let testDirectory = await driver.findComponent(ON.text('testDirectory'));
|
||||
await testFile.click();
|
||||
await btnCopy.click();
|
||||
await testDirectory.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('move'));
|
||||
let btnMove = await driver.findComponent(ON.id('move'));
|
||||
await btnMove.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.text('testFile'));
|
||||
let copyFile = await driver.findComponent(ON.text('testFile'));
|
||||
// 返回
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(500);
|
||||
Logger.info(TAG, 'MobileFunction_003 end');
|
||||
});
|
||||
it('MobileFunction_004', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_004 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(200);
|
||||
// 测试重命名
|
||||
await driver.assertComponentExist(ON.id('select'));
|
||||
let btnSelect = await driver.findComponent(ON.id('select'));
|
||||
let testFile = await driver.findComponent(ON.text('testFile'));
|
||||
await btnSelect.click();
|
||||
await testFile.click();
|
||||
let btnRenameNew = await driver.findComponent(ON.type('Text').id('rename'));
|
||||
await btnRenameNew.click();
|
||||
await driver.delayMs(500);
|
||||
let inputDirectoryNew = await driver.findComponent(ON.id('input'));
|
||||
await inputDirectoryNew.inputText('testFileNew');
|
||||
let btnPromiseNew = await driver.findComponent(ON.id('promise'));
|
||||
await btnPromiseNew.click();
|
||||
await driver.delayMs(500);
|
||||
await driver.assertComponentExist(ON.text('testFileNew'));
|
||||
Logger.info(TAG, BUNDLE + 'MobileFunction_004 end');
|
||||
});
|
||||
it('MobileFunction_005', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_005 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(200);
|
||||
// 点击select图片
|
||||
await driver.assertComponentExist(ON.id('select'));
|
||||
let selectImage = await driver.findComponent(ON.id('select'));
|
||||
await selectImage.click();
|
||||
await driver.delayMs(200);
|
||||
//测试更多--修改时间
|
||||
let testFile = await driver.findComponent(ON.text('testFileNew'));
|
||||
await testFile.click();
|
||||
await driver.assertComponentExist(ON.type('Text').id('more'));
|
||||
let newMore = await driver.findComponent(ON.type('Text').id('more'));
|
||||
await newMore.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.click(500, 983);
|
||||
await driver.assertComponentExist(ON.id('promise'));
|
||||
let inputTimeNew = await driver.findComponent(ON.id('input'));
|
||||
await inputTimeNew.inputText('2023/10/10 10:10:10');
|
||||
let changeTime = await driver.findComponent(ON.type('Text').id('promise'));
|
||||
await changeTime.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.text('2023/10/10 10:10:10'));
|
||||
Logger.info(TAG, 'MobileFunction_005 end');
|
||||
});
|
||||
it('MobileFunction_006', 0, async function () {
|
||||
Logger.info(TAG, 'MobileFunction_006 begin');
|
||||
let driver = Driver.create();
|
||||
await driver.delayMs(200);
|
||||
//测试更多--删除
|
||||
await driver.assertComponentExist(ON.id('select'));
|
||||
let selectImage = await driver.findComponent(ON.id('select'));
|
||||
await selectImage.click();
|
||||
await driver.delayMs(200);
|
||||
let testFile = await driver.findComponent(ON.text('testFileNew'));
|
||||
await testFile.click();
|
||||
await driver.assertComponentExist(ON.type('Text').id('more'));
|
||||
let newMore = await driver.findComponent(ON.type('Text').id('more'));
|
||||
await newMore.click();
|
||||
await driver.delayMs(200);
|
||||
await driver.click(452, 1074);
|
||||
await driver.delayMs(200);
|
||||
await driver.assertComponentExist(ON.id('checkDelete'));
|
||||
let btnCheckDelete = await driver.findComponent(ON.id('checkDelete'));
|
||||
await btnCheckDelete.click();
|
||||
await driver.delayMs(200);
|
||||
// 返回
|
||||
await driver.pressBack();
|
||||
await driver.delayMs(200);
|
||||
Logger.info(TAG, 'MobileFunction_006 end');
|
||||
});
|
||||
/** 场景:检验FileManager获取权限功能
|
||||
* 输入:调用requestPermission
|
||||
* 预期输出:点击允许后能够成功调用createFileAsset,getFileAssets
|
||||
@ -1329,4 +1395,4 @@ export default function abilityTest() {
|
||||
Logger.info(TAG, BUNDLE + 'CreateTxtFileAssetFunction_001 end')
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,9 @@
|
||||
|我的手机模块功能| 位于我的手机页| |显示新建文件夹,新建文件,排序,清理|是|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击select图片| 显示复制,重命名,分享,删除| 是 |Pass|
|
||||
|我的手机模块功能| 位于我的手机页 |点击新建文件,输入testFile,点击确认| 成功创建testFile| 是 |Pass|
|
||||
|我的手机模块功能| 位于我的手机页 |点击新建文件夹,输入testDirectory,点击确认| 成功创建testDirectory| 是 |Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 依次点击testFile,复制,testDirectory,移动按钮| 在testDirectory成功创建testFile| 是 |Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择testFile,重命名,输入新文件名,确认| 成功重命名| 是 |Pass|
|
||||
|我的手机模块功能| 位于testDirectory| 选择复制的testFile,点击删除| 成功删除后,显示空图片| 是 |Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击上一步新建的文件| 跳转至文件内容显示页面|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击新建文件夹,输入testDirectory/testSubDirectory,点击确认| 成功创建多级目录|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 依次点击testFile,复制,testDirectory,移动按钮| 在testDirectory成功创建testFile|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择testFile,重命名,输入新文件名,确认| 成功重命名|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择要修改时间的的testFileNew,点击更多,选择修改文件(夹)时间,弹框中输入修改时间,点击确定| 成功修改文件时间|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择要删除的testFileNew,点击更多,选择删除| 成功删除后,显示空图片|否|Pass|
|
||||
|
@ -21,9 +21,11 @@
|
||||
|添加功能| 位于文档详情页| 点击添加图标| 不超过屏幕显示范围时显示新增文档|是|Pass|
|
||||
|删除功能| 位于图片,视频,音频详情页| 长按文件,点击删除| 文件被删除|是|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| |显示新建文件夹,新建文件,排序,清理|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击select图片| 显示复制,重命名,分享,删除|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页 |点击新建文件,输入testFile,点击确认| 成功创建testFile|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页 |点击新建文件夹,输入testDirectory,点击确认| 成功创建testDirectory|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击select图片| 显示复制,重命名,分享,更多|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击新建文件,输入testFile,点击确认| 成功创建testFile|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击上一步新建的文件| 跳转至文件内容显示页面|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页| 点击新建文件夹,输入testDirectory/testSubDirectory,点击确认| 成功创建多级目录|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 依次点击testFile,复制,testDirectory,移动按钮| 在testDirectory成功创建testFile|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择testFile,重命名,输入新文件名,确认| 成功重命名|否|Pass|
|
||||
|我的手机模块功能| 位于testDirectory| 选择复制的testFile,点击删除| 成功删除后,显示空图片|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择要修改时间的的testFileNew,点击更多,选择“修改文件(夹)”时间,弹框中输入修改时间,点击确定| 成功修改文件时间|否|Pass|
|
||||
|我的手机模块功能| 位于我的手机页,点击select图片| 选择要删除的testFileNew,点击更多,选择删除| 成功删除后,显示空图片|否|Pass|
|
||||
|
Loading…
Reference in New Issue
Block a user