|
|
@@ -71,9 +71,12 @@ struct NewIndex {
|
|
|
context = getContext(this);
|
|
|
/** 音乐是否为零状态(预留) */
|
|
|
@Provide('isMusicZero') isMusicZero: boolean = false;
|
|
|
+ @State isShowTitleBar: boolean = true //是否显示分类导航条
|
|
|
/** 本地音乐列表,持久化存储 */
|
|
|
@StorageLink('musicLocalList') musicLocalList: Array<VideoItem> = []
|
|
|
@Provide isFavMusic: boolean = false
|
|
|
+ @StorageProp('windowWidth') windowWidth: number = 0;
|
|
|
+ @StorageProp('windowHeight') windowHeight: number = 0;
|
|
|
/** 标题栏配置模型 */
|
|
|
@State titleBarModel: TitleBar.Model = new TitleBar.Model()
|
|
|
.setTitleTextStyle(FontStyle.Normal)
|
|
|
@@ -175,6 +178,10 @@ struct NewIndex {
|
|
|
*/
|
|
|
|
|
|
async aboutToAppear() {
|
|
|
+ this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
|
|
|
+ if(this.isHiCar()){
|
|
|
+ this.isShowTitleBar = false
|
|
|
+ }
|
|
|
Utility.enableFullScreen()
|
|
|
this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
|
|
|
Utility.getAppName(getContext(this)).then((appName: string) => {
|
|
|
@@ -210,6 +217,13 @@ struct NewIndex {
|
|
|
this.refreshUserInfoState();
|
|
|
});
|
|
|
|
|
|
+ let eventSetting: emitter.InnerEvent = { eventId: 333 }
|
|
|
+ // 监听广播事件(通用设置配置更新)
|
|
|
+ emitter.on(eventSetting, (eventData: emitter.EventData) => {
|
|
|
+ this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -229,8 +243,6 @@ struct NewIndex {
|
|
|
this.getLeftView()
|
|
|
}
|
|
|
|
|
|
- // .backgroundColor(Color.Transparent)
|
|
|
-
|
|
|
Column() {
|
|
|
Stack() {
|
|
|
// 本地音乐内容区
|
|
|
@@ -264,7 +276,7 @@ struct NewIndex {
|
|
|
}
|
|
|
.showControlButton(false)
|
|
|
.minContentWidth(0)
|
|
|
- .sideBarWidth(this.isBigScreen() ? 300 : 270)
|
|
|
+ .sideBarWidth(260)
|
|
|
.autoHide(true)
|
|
|
.showSideBar($$this.isShowDrawer)
|
|
|
.onChange((value: boolean) => {
|
|
|
@@ -273,6 +285,29 @@ struct NewIndex {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //是不是hicar的屏幕分辨率
|
|
|
+ isHiCar() {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
//是不是正常的手机竖屏
|
|
|
isPhonePortrait() {
|
|
|
LogUtil.info('twocold this.currentHeightBreakpoint = '+this.currentHeightBreakpoint)
|
|
|
@@ -482,7 +517,7 @@ struct NewIndex {
|
|
|
@Builder
|
|
|
getDrawerView() {
|
|
|
List({ space: 0, scroller: this.scroller }) {
|
|
|
- ForEach(mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
|
|
|
+ ForEach(this.isHiCar()||!this.isShowTitleBar?mainViewModel.getDrawerData():mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
|
|
|
ListItem() {
|
|
|
Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
Row() {
|
|
|
@@ -525,6 +560,7 @@ struct NewIndex {
|
|
|
switch (item.id) {
|
|
|
case MainViewModel.MENU_MUSIC:
|
|
|
this.mType = 0
|
|
|
+ this.modeType = 0
|
|
|
if (!this.isBigScreen()) {
|
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
@@ -548,18 +584,21 @@ struct NewIndex {
|
|
|
// break
|
|
|
case MainViewModel.MENU_MIEDIA_KU:
|
|
|
this.modeType = 1
|
|
|
+ this.mType = 0
|
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
break
|
|
|
case MainViewModel.MENU_MIEDIA_ARTIST:
|
|
|
this.modeType = 2
|
|
|
+ this.mType = 0
|
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
break
|
|
|
case MainViewModel.MENU_MIEDIA_ALBUM:
|
|
|
this.modeType = 3
|
|
|
+ this.mType = 0
|
|
|
this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
@@ -877,4 +916,10 @@ function themeColorWithAlpha(themeColor: string, alpha: number, isDarkMode: bool
|
|
|
const g = parseInt(color.substring(2, 4), 16);
|
|
|
const b = parseInt(color.substring(4, 6), 16);
|
|
|
return `rgba(${r},${g},${b},${alpha})`;
|
|
|
+}
|
|
|
+
|
|
|
+// 定义接口
|
|
|
+interface HiCarAspectRatio {
|
|
|
+ ratio: number;
|
|
|
+ name: string;
|
|
|
}
|