|
|
@@ -14,6 +14,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'
|
|
|
import { emitter } from '@kit.BasicServicesKit'
|
|
|
import { BreakpointTypeEnum } from '../common/util/BreakpointSystem'
|
|
|
import { resourceManager } from '@kit.LocalizationKit'
|
|
|
+import { DialogHelper } from '@pura/harmony-dialog'
|
|
|
|
|
|
|
|
|
@Preview
|
|
|
@@ -25,6 +26,7 @@ export struct ScanFilePage{
|
|
|
|
|
|
@State strText:string = ''
|
|
|
@State isStart:boolean = false
|
|
|
+ @State isStartCover:boolean = false
|
|
|
@State appName:string = ''
|
|
|
//lottie动画构建渲染上下文
|
|
|
private mainRenderingSettings: RenderingContextSettings = new RenderingContextSettings(true)
|
|
|
@@ -73,6 +75,7 @@ export struct ScanFilePage{
|
|
|
|
|
|
ToastUtil.showToast('扫描文件入库成功!')
|
|
|
this.isStart = false
|
|
|
+ this.isStartCover = false
|
|
|
this.strText = ''
|
|
|
//结束动画
|
|
|
lottie.pause()
|
|
|
@@ -107,6 +110,7 @@ export struct ScanFilePage{
|
|
|
|
|
|
this.initLottie(this.path,true)
|
|
|
this.isStart = true
|
|
|
+ this.isStartCover = true
|
|
|
this.strText = Utility.resourceToString(getContext(this),$r('app.string.scaning'))
|
|
|
lottie.play()
|
|
|
}
|
|
|
@@ -225,7 +229,7 @@ export struct ScanFilePage{
|
|
|
|
|
|
.width('60%')
|
|
|
.height(55)
|
|
|
- .margin({ top: 30, bottom: 20 })
|
|
|
+ .margin({ top: 20, bottom: 10 })
|
|
|
.linearGradient({
|
|
|
direction: GradientDirection.Right,
|
|
|
colors: [['#ff37a0fc', 0.0], ['#67e667', 0.5], ['#f5856e', 1.0]]
|
|
|
@@ -237,6 +241,26 @@ export struct ScanFilePage{
|
|
|
})
|
|
|
.alignSelf(ItemAlign.Center)
|
|
|
|
|
|
+ Button(this.isStartCover?'正在扫描':$r('app.string.onekey_cover'), { type: ButtonType.Capsule, stateEffect: false })
|
|
|
+
|
|
|
+ .width('60%')
|
|
|
+ .height(55)
|
|
|
+ .margin({ top: 10, bottom: 20 })
|
|
|
+ .linearGradient({
|
|
|
+ direction: GradientDirection.Right,
|
|
|
+ colors: [['#ff37a0fc', 0.0], ['#67e667', 0.5], ['#f5856e', 1.0]]
|
|
|
+ })
|
|
|
+ .enabled(this.isStartCover ?false:true)
|
|
|
+ .onClick(() => {
|
|
|
+ if(PreferencesUtil.getStringSync('COVER_API','')===''){
|
|
|
+ this.showTipsDialog()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.doOptimize()
|
|
|
+
|
|
|
+ })
|
|
|
+ .alignSelf(ItemAlign.Center)
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -251,65 +275,65 @@ export struct ScanFilePage{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+ showTipsDialog() {
|
|
|
+ DialogHelper.showCustomContentDialog({
|
|
|
+ dialogId: 'tips',
|
|
|
+ title: "友情提示",
|
|
|
+ autoCancel: false, //点击遮障层时,不关闭弹窗
|
|
|
+ backCancel: true, //点击返回键,不关闭弹窗
|
|
|
+ contentBuilder: () => {
|
|
|
+ this.customTipsBuilder("请到设置界面配置封面服务器地址!")
|
|
|
+ },
|
|
|
+ buttons: [],
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
+ @Builder
|
|
|
+ customTipsBuilder(content: string) {
|
|
|
+ Column() {
|
|
|
+ Text(content)
|
|
|
+ .fontColor(Color.Gray)
|
|
|
+ .fontSize(16)
|
|
|
+ .alignSelf(ItemAlign.Start)
|
|
|
+ .margin({ bottom: 15 })
|
|
|
+ .fontSize(16)
|
|
|
+
|
|
|
+ Row() {
|
|
|
+ Button('教程')
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .backgroundColor($r('app.color.title_bar_bg'))//.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
|
|
|
+ .height(50)
|
|
|
+ .layoutWeight(1)
|
|
|
+ .stateEffect(true)
|
|
|
+ .margin({ right: 6 })
|
|
|
+ .onClick(() => {
|
|
|
+ ToastUtil.showToast('欢迎进群学习教程,复制Q群号成功!')
|
|
|
+ Utility.copyText('685109858')
|
|
|
+ DialogHelper.closeDialog('tips'); //关闭弹框
|
|
|
+ })
|
|
|
+ Button('跳转')
|
|
|
+ .fontColor(Color.White)//.linearGradient( { direction: GradientDirection.Right, colors:[['#ff37a0fc',0.0],['#67e667',0.5],['#f5856e',1.0]]})
|
|
|
+ .layoutWeight(1)
|
|
|
+ .height(50)
|
|
|
+ .backgroundColor($r('app.color.title_bar_bg'))
|
|
|
+ .stateEffect(true)
|
|
|
+ .margin({ left: 6 })
|
|
|
+ .onClick(() => {
|
|
|
+ DialogHelper.closeDialog('tips'); //关闭弹框
|
|
|
+ router.pushUrl({
|
|
|
+ url: 'pages/SettingPage'
|
|
|
+ }, router.RouterMode.Single);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ .width("100%")
|
|
|
+ .padding(10)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
|
|
|
-// async function scanDirectoryTask(context: Context, curPath: string, lockPath: string) {
|
|
|
-// const table: MediaTable = new MediaTable(context);
|
|
|
-//
|
|
|
-//
|
|
|
-// try {
|
|
|
-// // 使用 Promise 包装数据库操作
|
|
|
-// await new Promise<void>((resolve, reject) => {
|
|
|
-// table.getRdbStore(context, async (err:Error) => {
|
|
|
-// if (err) {
|
|
|
-// reject(err);
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// const files = FileUtil.listFileSync(curPath);
|
|
|
-// const pendingTasks: Promise<void>[] = [];
|
|
|
-//
|
|
|
-// for (const file of files) {
|
|
|
-// const fPath = `${curPath}/${file}`;
|
|
|
-// if (fPath === lockPath) continue;
|
|
|
-//
|
|
|
-// if (FileUtil.isDirectory(fPath)) {
|
|
|
-// // 用立即执行函数处理异步递归
|
|
|
-// pendingTasks.push((async () => {
|
|
|
-// await scanDirectoryTask(context, fPath, lockPath);
|
|
|
-// })());
|
|
|
-// } else {
|
|
|
-// if(!fPath.endsWith('.lrc')&&Utility.isMeidaByExtension(fPath)&&!fPath.endsWith('.srt')){
|
|
|
-// // 用 Promise 包装媒体处理逻辑
|
|
|
-// pendingTasks.push((async () => {
|
|
|
-// let mediaItem:VideoItem = await Utility.uriGetMusicAssetsFromFile(context, fPath, CommonConstants.TYPE_LOCAL, true);
|
|
|
-// ;
|
|
|
-// await new Promise<void>((resolve: (value: void) => void) => {
|
|
|
-// table.insert(mediaItem, (id: number) => {
|
|
|
-// resolve(); // 明确调用 resolve 且无返回值
|
|
|
-// });
|
|
|
-// });
|
|
|
-// })());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 关键点:等待所有异步操作完成
|
|
|
-// await Promise.all(pendingTasks);
|
|
|
-// resolve();
|
|
|
-// });
|
|
|
-// });
|
|
|
-//
|
|
|
-// // Logger.info('onecold scanDirectory 全部扫描完成后执行 = ')
|
|
|
-//
|
|
|
-// } catch (err) {
|
|
|
-// Logger.error(`Scan failed: ${err.code} - ${err.message}`);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
|
|
|
@Concurrent
|
|
|
async function scanDirectoryTask(context: Context, dirPath: string, lockPath: string,cover_api:string) {
|