|
|
@@ -1,6 +1,6 @@
|
|
|
import { AppUtil, DeviceUtil, DisplayUtil, LogUtil, PreferencesUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
import TitleBar from '../view/TitleBar';
|
|
|
-import { curves, LengthMetrics, router, SegmentButton, SegmentButtonOptions } from '@kit.ArkUI';
|
|
|
+import { curves, LengthMetrics, router, SegmentButton, SegmentButtonOptions, SymbolGlyphModifier } from '@kit.ArkUI';
|
|
|
import mainViewModel, { MainViewModel } from '../viewmodel/MainViewModel';
|
|
|
import ItemData from '../viewmodel/ItemData';
|
|
|
import type { sysResource } from '../viewmodel/ItemData';
|
|
|
@@ -43,6 +43,7 @@ import { ChartsCount } from './ChartsCount';
|
|
|
import { image } from '@kit.ImageKit';
|
|
|
import { Playlist } from '../viewmodel/Playlist';
|
|
|
import PlaylistTable from '../common/util/PlaylistTable';
|
|
|
+import { convertPlaylistSongsToVideoItems } from './PlaylistDetailPage';
|
|
|
|
|
|
// import { FFmpeg, FFProgressMessageParser } from '@sj/ffmpeg';
|
|
|
|
|
|
@@ -56,6 +57,11 @@ const TAG = 'NewIndex'; // 日志标签
|
|
|
@Entry
|
|
|
@Component
|
|
|
struct NewIndex {
|
|
|
+ /** 页面上下文 */
|
|
|
+ context = this.getUIContext().getHostContext() as common.UIAbilityContext
|
|
|
+ @Provide currentSongList: Array<VideoItem> = []//当前歌单
|
|
|
+ @Provide currentSongListName:string = '' //当前歌单名称
|
|
|
+ @Provide currentSongListID:string='' //当前歌单ID
|
|
|
@State isDarkMode: boolean = false
|
|
|
/** 列表滚动器,用于抽屉菜单列表滚动 */
|
|
|
private scroller: Scroller = new Scroller();
|
|
|
@@ -78,8 +84,6 @@ struct NewIndex {
|
|
|
@Provide('isZero') isZero: boolean = false;
|
|
|
/** 是否显示赞助入口 */
|
|
|
@State isShowSponsorship: boolean = false
|
|
|
- /** 页面上下文 */
|
|
|
- context = this.getUIContext().getHostContext() as common.UIAbilityContext
|
|
|
/** 音乐是否为零状态(预留) */
|
|
|
@Provide('isMusicZero') isMusicZero: boolean = false;
|
|
|
@State isShowTitleBar: boolean = true //是否显示分类导航条
|
|
|
@@ -405,23 +409,6 @@ struct NewIndex {
|
|
|
isHiCar() {
|
|
|
|
|
|
return this.isHiCarStatus&&this.curDisplayIsHiCar;
|
|
|
- // const hiCarAspectRatios: HiCarAspectRatio[] = [
|
|
|
- // { ratio: 800 / 480, name: "800x480" },
|
|
|
- // { ratio: 762 / 752, name: "762x752" },
|
|
|
- // { ratio: 968 / 1280, name: "968x1280" },
|
|
|
- // { ratio: 1200 / 1200, name: "1200x1200" },
|
|
|
- // { ratio: 1280 / 720, name: "1280x720" },
|
|
|
- // { ratio: 1920 / 1080, name: "1920x1080" }
|
|
|
- // ];
|
|
|
- // const currentRatio: number = this.windowWidth / this.windowHeight;
|
|
|
- // const RATIO_TOLERANCE: number = 0.1; // 宽高比容差
|
|
|
- //
|
|
|
- // for (const hiCarRatio of hiCarAspectRatios) {
|
|
|
- // if (Math.abs(currentRatio - hiCarRatio.ratio) <= RATIO_TOLERANCE) {
|
|
|
- // LogUtil.info(`HiCar detected: ${hiCarRatio.name}, actual: ${this.windowWidth}x${this.windowHeight}`);
|
|
|
- // return true;
|
|
|
- // }
|
|
|
- // }
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
@@ -1094,16 +1081,91 @@ struct NewIndex {
|
|
|
}
|
|
|
.backgroundColor(Color.Transparent)
|
|
|
.clickEffect({ level: ClickEffectLevel.MIDDLE, scale: 0.6 })
|
|
|
- .onClick(() => {
|
|
|
- this.openPlaylist(playlist)
|
|
|
+ .onClick(async () => {
|
|
|
+ if (!this.playlistTable) {
|
|
|
+ ToastUtil.showToast('歌单功能初始化中,请稍后再试')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 加载歌单歌曲
|
|
|
+ const playlistSongs = await this.playlistTable.queryPlaylistSongs(playlist.id)
|
|
|
+ this.currentSongList = await convertPlaylistSongsToVideoItems(this.context,playlistSongs)
|
|
|
+ this.currentSongListName= playlist.name
|
|
|
+ this.currentSongListID = playlist.id
|
|
|
+ this.modeType = 4//切换到歌单模式
|
|
|
+ this.doShowDrawer()
|
|
|
})
|
|
|
- .gesture(LongPressGesture().onAction(() => {
|
|
|
- this.showPlaylistMenu(playlist)
|
|
|
- }))
|
|
|
+ .bindContextMenu(this.MenuBuilder(playlist), ResponseType.LongPress,
|
|
|
+ {
|
|
|
+ preview: MenuPreviewMode.IMAGE,
|
|
|
+ previewAnimationOptions: { scale: [0.8, 1.0] },
|
|
|
+ })
|
|
|
+ .bindContextMenu(this.MenuBuilder(playlist), ResponseType.RightClick,
|
|
|
+ {
|
|
|
+ preview: MenuPreviewMode.IMAGE,
|
|
|
+ previewAnimationOptions: { scale: [0.8, 1.0] },
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ @Builder
|
|
|
+ MenuBuilder(playlist: Playlist) {
|
|
|
+ Menu(){
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.square_and_pencil')),
|
|
|
+ content: '编辑歌单'
|
|
|
+ })
|
|
|
+ .onClick(async() => {
|
|
|
+ this.openPlaylist(playlist)
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.trash')),
|
|
|
+ content: '删除歌单'
|
|
|
+ })
|
|
|
+ .onClick(async() => {
|
|
|
+ this.deletePlaylist(playlist)
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除歌单
|
|
|
+ */
|
|
|
+ async deletePlaylist(playlist: Playlist) {
|
|
|
+ if (playlist&&this.playlistTable) {
|
|
|
+ // 显示确认对话框
|
|
|
+ AlertDialog.show({
|
|
|
+ title: '删除歌单',
|
|
|
+ message: `确定要删除歌单"${playlist.name}"吗?此操作不可撤销。`,
|
|
|
+ primaryButton: {
|
|
|
+ value: '取消',
|
|
|
+ action: () => {}
|
|
|
+ },
|
|
|
+ secondaryButton: {
|
|
|
+ value: '删除',
|
|
|
+ fontColor: Color.Red,
|
|
|
+ action: async () => {
|
|
|
+ if (this.playlistTable) {
|
|
|
+ const success = await this.playlistTable.deletePlaylist(playlist.id)
|
|
|
+ if (success) {
|
|
|
+ ToastUtil.showToast('歌单删除成功')
|
|
|
+ // 发送刷新事件
|
|
|
+ emitter.emit({ eventId: EventConstants.EVENT_PLAYLIST_REFRESH }, {})
|
|
|
+ } else {
|
|
|
+ ToastUtil.showToast('歌单删除失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 显示创建歌单对话框
|
|
|
*/
|
|
|
@@ -1157,13 +1219,6 @@ struct NewIndex {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 显示歌单菜单
|
|
|
- */
|
|
|
- showPlaylistMenu(playlist: Playlist) {
|
|
|
- // TODO: 显示歌单操作菜单(重命名、删除等)
|
|
|
- console.info('显示歌单菜单:', playlist.name)
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 初始化歌单数据库
|