|
@@ -1,7 +1,7 @@
|
|
|
import { common } from '@kit.AbilityKit';
|
|
import { common } from '@kit.AbilityKit';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
-import { ArrayUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
|
|
|
|
+import { AppUtil, ArrayUtil, FileUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
import MediaTable from '../common/util/MediaTable';
|
|
import MediaTable from '../common/util/MediaTable';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
@@ -15,6 +15,7 @@ export struct DeleteComptent {
|
|
|
@State isDeleteYuan: boolean = true
|
|
@State isDeleteYuan: boolean = true
|
|
|
@State isDeletePicture: boolean = true
|
|
@State isDeletePicture: boolean = true
|
|
|
@State isDeleteLrc: boolean = true
|
|
@State isDeleteLrc: boolean = true
|
|
|
|
|
+ @State packName: string = ''
|
|
|
onDeleteResult = (_result: boolean) => {
|
|
onDeleteResult = (_result: boolean) => {
|
|
|
}
|
|
}
|
|
|
onCancel = () => {
|
|
onCancel = () => {
|
|
@@ -25,6 +26,7 @@ export struct DeleteComptent {
|
|
|
|
|
|
|
|
|
|
|
|
|
async aboutToAppear() {
|
|
async aboutToAppear() {
|
|
|
|
|
+ this.packName = AppUtil.getBundleName()
|
|
|
this.isDeleteYuan = PreferencesUtil.getBooleanSync('isDeleteYuan', true);
|
|
this.isDeleteYuan = PreferencesUtil.getBooleanSync('isDeleteYuan', true);
|
|
|
this.isDeletePicture = PreferencesUtil.getBooleanSync('isDeletePicture', true);
|
|
this.isDeletePicture = PreferencesUtil.getBooleanSync('isDeletePicture', true);
|
|
|
this.isDeleteLrc = PreferencesUtil.getBooleanSync('isDeleteLrc', true)
|
|
this.isDeleteLrc = PreferencesUtil.getBooleanSync('isDeleteLrc', true)
|
|
@@ -165,11 +167,14 @@ export struct DeleteComptent {
|
|
|
const task = new taskpool.Task(
|
|
const task = new taskpool.Task(
|
|
|
deleteMultipleFiles,
|
|
deleteMultipleFiles,
|
|
|
JSON.stringify(this.selectedFiles),
|
|
JSON.stringify(this.selectedFiles),
|
|
|
- this.isDeleteYuan,this.isDeletePicture,this.isDeleteLrc,this.context
|
|
|
|
|
|
|
+ this.isDeleteYuan,this.isDeletePicture,this.isDeleteLrc,this.context,this.packName
|
|
|
);
|
|
);
|
|
|
taskpool.execute(task, taskpool.Priority.HIGH).then((result) => {
|
|
taskpool.execute(task, taskpool.Priority.HIGH).then((result) => {
|
|
|
if(result){
|
|
if(result){
|
|
|
- this.onDeleteResult(true)
|
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ this.onDeleteResult(true)
|
|
|
|
|
+ },500)
|
|
|
|
|
+
|
|
|
}else {
|
|
}else {
|
|
|
this.onDeleteResult(false)
|
|
this.onDeleteResult(false)
|
|
|
}
|
|
}
|
|
@@ -189,7 +194,8 @@ async function deleteMultipleFiles(
|
|
|
isDeleteYuan:boolean,
|
|
isDeleteYuan:boolean,
|
|
|
isDeletePicture:boolean,
|
|
isDeletePicture:boolean,
|
|
|
isDeleteLrc:boolean,
|
|
isDeleteLrc:boolean,
|
|
|
- context:Context
|
|
|
|
|
|
|
+ context:Context,
|
|
|
|
|
+ packName:string
|
|
|
) {
|
|
) {
|
|
|
|
|
|
|
|
const selectedFiles: VideoItem[] = JSON.parse(selectedFilesStr)
|
|
const selectedFiles: VideoItem[] = JSON.parse(selectedFilesStr)
|
|
@@ -223,8 +229,9 @@ async function deleteMultipleFiles(
|
|
|
|
|
|
|
|
table.deleteData(item, async () => {
|
|
table.deleteData(item, async () => {
|
|
|
if(isDeleteYuan){
|
|
if(isDeleteYuan){
|
|
|
- await PermissionUtil.activatePermission(item.filePath)
|
|
|
|
|
- await FileUtil.unlink(item.filePath)
|
|
|
|
|
|
|
+ if(item.filePath.toLowerCase().includes(packName)){
|
|
|
|
|
+ await FileUtil.unlink(item.filePath)
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
console.info(`onecold 封面文件=: ${item.pixelMapPath}`);
|
|
console.info(`onecold 封面文件=: ${item.pixelMapPath}`);
|
|
@@ -239,7 +246,7 @@ async function deleteMultipleFiles(
|
|
|
console.info(`onecold 歌词文件=: ${lyricPath}`);
|
|
console.info(`onecold 歌词文件=: ${lyricPath}`);
|
|
|
if(isDeleteLrc) {
|
|
if(isDeleteLrc) {
|
|
|
|
|
|
|
|
- if (lyricPath && FileUtil.accessSync(lyricPath)) {
|
|
|
|
|
|
|
+ if (lyricPath&&item.filePath.toLowerCase().includes(packName) && FileUtil.accessSync(lyricPath)) {
|
|
|
await FileUtil.unlink(lyricPath);
|
|
await FileUtil.unlink(lyricPath);
|
|
|
console.info( `onecold 歌词文件已删除: ${lyricPath}`);
|
|
console.info( `onecold 歌词文件已删除: ${lyricPath}`);
|
|
|
}
|
|
}
|