|
|
@@ -1,4 +1,4 @@
|
|
|
-import { AppUtil, DeviceUtil,DisplayUtil, PreferencesUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
+import { AppUtil, DeviceUtil, DisplayUtil, PreferencesUtil, ToastUtil } from '@pura/harmony-utils';
|
|
|
import TitleBar from '../view/TitleBar';
|
|
|
import { router } from '@kit.ArkUI';
|
|
|
import mainViewModel, { MainViewModel } from '../viewmodel/MainViewModel';
|
|
|
@@ -45,39 +45,35 @@ const TAG = 'NewIndex'; // 日志标签
|
|
|
@Preview
|
|
|
@Entry
|
|
|
@Component
|
|
|
-struct NewIndex{
|
|
|
+struct NewIndex {
|
|
|
/** 列表滚动器,用于抽屉菜单列表滚动 */
|
|
|
private scroller: Scroller = new Scroller();
|
|
|
-
|
|
|
/** 应用包名 */
|
|
|
- @State bundleName:string = ''
|
|
|
- @State appName:string = ''
|
|
|
+ @State bundleName: string = ''
|
|
|
+ @State appName: string = ''
|
|
|
/** 是否显示侧边抽屉菜单 */
|
|
|
- @Provide isShowDrawer:boolean = false;
|
|
|
+ @Provide isShowDrawer: boolean = false;
|
|
|
/** 抽屉菜单 X 轴偏移量,用于手势滑动动画 */
|
|
|
@Provide offsetX: number = 0;
|
|
|
-
|
|
|
/** 本地视频列表,页面参数传入 */
|
|
|
- @Provide videoLocalList: Array<VideoItem> = []
|
|
|
+ @Provide videoLocalList: Array<VideoItem> = []
|
|
|
/** Y 轴偏移量(预留) */
|
|
|
@State offsetY: number = 0;
|
|
|
/** 主内容类型(0:本地音乐,1:网络内容) */
|
|
|
- @Provide mType:number = 0
|
|
|
+ @Provide mType: number = 0
|
|
|
/** 模式类型(如歌手、专辑等) */
|
|
|
- @Provide modeType:number = 0
|
|
|
+ @Provide modeType: number = 0
|
|
|
/** 是否为零状态(预留) */
|
|
|
- @Provide('isZero') isZero:boolean = false;
|
|
|
+ @Provide('isZero') isZero: boolean = false;
|
|
|
/** 是否显示赞助入口 */
|
|
|
- @State isShowSponsorship:boolean = false
|
|
|
+ @State isShowSponsorship: boolean = false
|
|
|
/** 页面上下文 */
|
|
|
context = getContext(this);
|
|
|
-
|
|
|
/** 音乐是否为零状态(预留) */
|
|
|
- @Provide('isMusicZero') isMusicZero:boolean = false;
|
|
|
+ @Provide('isMusicZero') isMusicZero: boolean = false;
|
|
|
/** 本地音乐列表,持久化存储 */
|
|
|
- @StorageLink('musicLocalList') musicLocalList: Array<VideoItem> = []
|
|
|
-
|
|
|
- @Provide isFavMusic:boolean = false
|
|
|
+ @StorageLink('musicLocalList') musicLocalList: Array<VideoItem> = []
|
|
|
+ @Provide isFavMusic: boolean = false
|
|
|
/** 标题栏配置模型 */
|
|
|
@State titleBarModel: TitleBar.Model = new TitleBar.Model()
|
|
|
.setTitleTextStyle(FontStyle.Normal)
|
|
|
@@ -86,8 +82,7 @@ struct NewIndex{
|
|
|
.setLeftIconWidth(28)
|
|
|
.setLeftIconHeight(28)
|
|
|
.setTitleBarMinHeight(64)
|
|
|
- .setTitleName('首页')
|
|
|
- // .setRightIcon($r('app.media.add'))
|
|
|
+ .setTitleName('首页')// .setRightIcon($r('app.media.add'))
|
|
|
.setTitleFontSize(19)
|
|
|
.setTitleFontColor(Color.White)
|
|
|
.setTitleBarBackground($r('app.color.title_bar_bg'))
|
|
|
@@ -106,19 +101,17 @@ struct NewIndex{
|
|
|
// })
|
|
|
|
|
|
/** 应用版本号 */
|
|
|
- @State versionName:string =''
|
|
|
-
|
|
|
+ @State versionName: string = ''
|
|
|
/** 音频根目录路径 */
|
|
|
- @Provide rootPath:string = ''
|
|
|
+ @Provide rootPath: string = ''
|
|
|
/** 当前路径 */
|
|
|
- @Provide currentPath:string = ''
|
|
|
+ @Provide currentPath: string = ''
|
|
|
/** 是否为历史记录页面 */
|
|
|
- @Provide isHistory:boolean = false
|
|
|
+ @Provide isHistory: boolean = false
|
|
|
/** 是否可以返回上一级 */
|
|
|
- @Provide isCanBack:boolean= false
|
|
|
+ @Provide isCanBack: boolean = false
|
|
|
@StorageProp('currentColorMode') currentMode: number = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
@StorageProp('themeColor') themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
|
|
|
-
|
|
|
/**
|
|
|
* 一多界面适配断点系统
|
|
|
*/
|
|
|
@@ -126,7 +119,7 @@ struct NewIndex{
|
|
|
/** 当前断点类型(如大屏/小屏) */
|
|
|
@StorageProp('currentBreakpoint') currentBreakpoint: string = BreakpointTypeEnum.MD;
|
|
|
/** 记录上一次点击返回键的时间戳,用于双击退出 */
|
|
|
- private backTime:number=0;
|
|
|
+ private backTime: number = 0;
|
|
|
|
|
|
/**
|
|
|
* 返回键处理逻辑:
|
|
|
@@ -134,23 +127,24 @@ struct NewIndex{
|
|
|
* - 如果是根目录,双击返回键退出应用,否则提示
|
|
|
*/
|
|
|
onBackPress(): boolean | void {
|
|
|
- if(this.currentPath !== this.rootPath||this.isHistory||this.isFavMusic||(this.modeType!==0&&this.isCanBack)){
|
|
|
+ if (this.currentPath !== this.rootPath || this.isHistory || this.isFavMusic ||
|
|
|
+ (this.modeType !== 0 && this.isCanBack)) {
|
|
|
const eventData: emitter.EventData = {};
|
|
|
emitter.emit({ eventId: 888 }, eventData); // 发送音频广播通知更新doSwipBack
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
let nowtime = Date.now();
|
|
|
- if(nowtime - this.backTime < 1000){
|
|
|
+ if (nowtime - this.backTime < 1000) {
|
|
|
const mContext = getContext(this) as common.UIAbilityContext
|
|
|
mContext.terminateSelf(); // 关闭应用
|
|
|
AvSessionController.getInstance(true).unregisterSessionListener()
|
|
|
- }else {
|
|
|
- if(this.isShowDrawer){
|
|
|
+ } else {
|
|
|
+ if (this.isShowDrawer) {
|
|
|
// 如果抽屉菜单打开,先关闭抽屉
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
- }else{
|
|
|
- this.backTime=nowtime;
|
|
|
+ } else {
|
|
|
+ this.backTime = nowtime;
|
|
|
ToastUtil.showToast("再按一次将退出当前应用")
|
|
|
}
|
|
|
}
|
|
|
@@ -158,6 +152,19 @@ struct NewIndex{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 刷新@State用户信息变量,确保UI同步
|
|
|
+ */
|
|
|
+ refreshUserInfoState() {
|
|
|
+ this.isLogin = PreferencesUtil.getBooleanSync('isLogin', false);
|
|
|
+ this.userId = PreferencesUtil.getNumberSync('userId', 0);
|
|
|
+ this.userName = PreferencesUtil.getStringSync('userName', '未登录用户');
|
|
|
+ this.userAvatarUrl = PreferencesUtil.getStringSync('userAvatarUrl', '');
|
|
|
+ this.subscriptionName = PreferencesUtil.getStringSync('subscriptionName', '');
|
|
|
+ this.subscriptionEndDate = PreferencesUtil.getStringSync('subscriptionEndDate', '');
|
|
|
+ this.hasActiveSubscription = PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 页面显示生命周期钩子
|
|
|
* - 注册断点系统
|
|
|
@@ -170,7 +177,7 @@ struct NewIndex{
|
|
|
async aboutToAppear() {
|
|
|
Utility.enableFullScreen()
|
|
|
this.topRectHeight = px2vp(AppUtil.getStatusBarHeight());
|
|
|
- Utility.getAppName(getContext(this)).then((appName:string)=>{
|
|
|
+ Utility.getAppName(getContext(this)).then((appName: string) => {
|
|
|
this.appName = appName
|
|
|
})
|
|
|
this.isDarkMode = this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
@@ -179,31 +186,30 @@ struct NewIndex{
|
|
|
this.videoLocalList = params.videoList as VideoItem[];
|
|
|
// Utility.setStatusBarLight()
|
|
|
ScreenUtil.setScreenSize();
|
|
|
- this.bundleName = AppUtil.getBundleName()
|
|
|
- this.versionName = AppUtil.getVersionName();
|
|
|
+ this.bundleName = AppUtil.getBundleName()
|
|
|
+ this.versionName = AppUtil.getVersionName();
|
|
|
// await ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024)
|
|
|
this.isShowSponsorship = Utility.isOpenTime()
|
|
|
let themeColor = PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
|
- hilog.info(0x0000, 'Heanup', '当前 NewIndex themeColor:'+themeColor);
|
|
|
+ hilog.info(0x0000, 'Heanup', '当前 NewIndex themeColor:' + themeColor);
|
|
|
AppStorage.setOrCreate('themeColor', themeColor);
|
|
|
- this.themeColor=themeColor
|
|
|
+ this.themeColor = themeColor
|
|
|
|
|
|
// ====== 本地会员同步提醒逻辑 ======
|
|
|
- let isLogin = PreferencesUtil.getBooleanSync('isLogin', false);
|
|
|
- this.userId = PreferencesUtil.getNumberSync('userId', 0);
|
|
|
- this.userName = PreferencesUtil.getStringSync('userName', '未登录用户');
|
|
|
- this.userAvatarUrl = PreferencesUtil.getStringSync('userAvatarUrl', '');
|
|
|
- this.subscriptionName = PreferencesUtil.getStringSync('subscriptionName', '');
|
|
|
- this.subscriptionEndDate = PreferencesUtil.getStringSync('subscriptionEndDate', '');
|
|
|
- this.hasActiveSubscription = PreferencesUtil.getBooleanSync('hasActiveSubscription', false);
|
|
|
+ // this.refreshUserInfoState();
|
|
|
// if (this.isLogin) {
|
|
|
// void this.fetchUserInfo();
|
|
|
// }
|
|
|
- console.log('Heanup isLogin:'+isLogin)
|
|
|
- console.log('Heanup Utility.isNobleForOld():'+Utility.isNobleForOld())
|
|
|
-
|
|
|
+ console.log('Heanup isLogin:' + this.isLogin)
|
|
|
+ console.log('Heanup Utility.isNobleForOld():' + Utility.isNobleForOld())
|
|
|
|
|
|
await UserUtil.fetchUserInfo();
|
|
|
+ this.refreshUserInfoState();
|
|
|
+ let changeUserState: emitter.InnerEvent = { eventId: 1001 }
|
|
|
+ emitter.on(changeUserState, () => {
|
|
|
+ this.refreshUserInfoState();
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -214,63 +220,65 @@ struct NewIndex{
|
|
|
console.info('NewIndex aboutToDisappear');
|
|
|
this.breakpointSystem.unregister();
|
|
|
emitter.off(888);
|
|
|
+ emitter.off(1001);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
build() {
|
|
|
SideBarContainer(SideBarContainerType.AUTO) {
|
|
|
Column() {
|
|
|
this.getLeftView()
|
|
|
}
|
|
|
+
|
|
|
// .backgroundColor(Color.Transparent)
|
|
|
|
|
|
Column() {
|
|
|
- Stack(){
|
|
|
- // 本地音乐内容区
|
|
|
+ Stack() {
|
|
|
+ // 本地音乐内容区
|
|
|
LocalMusic()
|
|
|
- .visibility(this.mType===0?Visibility.Visible:Visibility.None)
|
|
|
+ .visibility(this.mType === 0 ? Visibility.Visible : Visibility.None)
|
|
|
// 网络内容区
|
|
|
UserCenter()
|
|
|
- .visibility(this.mType===1?Visibility.Visible:Visibility.None)
|
|
|
+ .visibility(this.mType === 1 ? Visibility.Visible : Visibility.None)
|
|
|
ScanFilePage()
|
|
|
- .visibility(this.mType===2?Visibility.Visible:Visibility.None)
|
|
|
+ .visibility(this.mType === 2 ? Visibility.Visible : Visibility.None)
|
|
|
SettingPage()
|
|
|
- .visibility(this.mType===3?Visibility.Visible:Visibility.None)
|
|
|
+ .visibility(this.mType === 3 ? Visibility.Visible : Visibility.None)
|
|
|
AboutPage()
|
|
|
- .visibility(this.mType===4?Visibility.Visible:Visibility.None)
|
|
|
+ .visibility(this.mType === 4 ? Visibility.Visible : Visibility.None)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
.showControlButton(false)
|
|
|
.minContentWidth(0)
|
|
|
- .sideBarWidth(this.isBigScreen()?300:270)
|
|
|
+ .sideBarWidth(this.isBigScreen() ? 300 : 270)
|
|
|
.autoHide(true)
|
|
|
.showSideBar($$this.isShowDrawer)
|
|
|
.onChange((value: boolean) => {
|
|
|
- this.isShowDrawer= value
|
|
|
+ this.isShowDrawer = value
|
|
|
})
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- isBigScreen(){
|
|
|
- if(this.currentWidthBreakpoint == WidthBreakpoint.WIDTH_LG){
|
|
|
+ /**
|
|
|
+ * 判断是否横屏
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ isBigScreen() {
|
|
|
+ if (this.currentWidthBreakpoint == WidthBreakpoint.WIDTH_LG) {
|
|
|
return true
|
|
|
}
|
|
|
if (DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
|
|
|
&& this.currentWidthBreakpoint === WidthBreakpoint.WIDTH_SM
|
|
|
- &&this.currentHeightBreakpoint == HeightBreakpoint.HEIGHT_LG) {
|
|
|
+ && this.currentHeightBreakpoint == HeightBreakpoint.HEIGHT_LG) {
|
|
|
return false
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return true
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Builder
|
|
|
- getLeftView(){
|
|
|
+ getLeftView() {
|
|
|
Column() {
|
|
|
Column() {
|
|
|
// 抽屉顶部背景图
|
|
|
@@ -290,7 +298,7 @@ struct NewIndex{
|
|
|
}
|
|
|
.width('100%')
|
|
|
.height('100%')
|
|
|
- .onClick((event:ClickEvent)=>{
|
|
|
+ .onClick((event: ClickEvent) => {
|
|
|
// 阻止事件冒泡
|
|
|
})
|
|
|
}
|
|
|
@@ -298,14 +306,14 @@ struct NewIndex{
|
|
|
.height('100%')
|
|
|
.borderRadius({
|
|
|
topLeft: 0,
|
|
|
- topRight : 20,
|
|
|
+ topRight: 20,
|
|
|
bottomLeft: 0,
|
|
|
bottomRight: 20
|
|
|
})
|
|
|
// .backgroundColor($r('app.color.silvery'))
|
|
|
.backgroundColor($r('app.color.index_background'))
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
|
- .onClick((event:ClickEvent)=>{
|
|
|
+ .onClick((event: ClickEvent) => {
|
|
|
// 点击抽屉外部关闭抽屉
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
@@ -316,19 +324,19 @@ struct NewIndex{
|
|
|
.transition({ type: TransitionType.Delete, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
|
|
|
.gesture(
|
|
|
PanGesture()
|
|
|
- .onActionUpdate((event:GestureEvent)=>{
|
|
|
+ .onActionUpdate((event: GestureEvent) => {
|
|
|
// 手势滑动更新抽屉偏移
|
|
|
- if(event.offsetX<0){
|
|
|
+ if (event.offsetX < 0) {
|
|
|
this.offsetX = event.offsetX;
|
|
|
}
|
|
|
})
|
|
|
.onActionEnd(() => {
|
|
|
// 手势结束判断是否关闭抽屉
|
|
|
- if(this.offsetX<-DisplayUtil.getWidth()/15){
|
|
|
+ if (this.offsetX < -DisplayUtil.getWidth() / 15) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = true
|
|
|
this.offsetX = 0
|
|
|
@@ -348,6 +356,7 @@ struct NewIndex{
|
|
|
@State hasActiveSubscription: boolean = false;
|
|
|
@State subscriptionName: string = '';
|
|
|
@State subscriptionEndDate: string = '';
|
|
|
+
|
|
|
// 用户信息卡片
|
|
|
@Builder
|
|
|
buildUserInfoCard() {
|
|
|
@@ -394,7 +403,7 @@ struct NewIndex{
|
|
|
.textAlign(TextAlign.Start)
|
|
|
this.TimeTextBuilder()
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.TimeTextBuilder()
|
|
|
}
|
|
|
}
|
|
|
@@ -404,13 +413,13 @@ struct NewIndex{
|
|
|
|
|
|
}
|
|
|
.onClick(() => {
|
|
|
- if (!this.isLogin) {
|
|
|
- this.mType=1
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ // if (!this.isLogin) {
|
|
|
+ this.mType = 1
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
- }
|
|
|
+ // }
|
|
|
}
|
|
|
})
|
|
|
.width('100%')
|
|
|
@@ -419,7 +428,7 @@ struct NewIndex{
|
|
|
.backgroundColor($r('app.color.user_center_card_background'))
|
|
|
.borderRadius(24)
|
|
|
.width('86%')
|
|
|
- .margin({ left: 10, right: 10, top: this.topRectHeight+10 })
|
|
|
+ .margin({ left: 10, right: 10, top: this.topRectHeight + 10 })
|
|
|
.shadow({
|
|
|
radius: 8,
|
|
|
color: 0x11000000,
|
|
|
@@ -429,33 +438,33 @@ struct NewIndex{
|
|
|
}
|
|
|
|
|
|
@Builder
|
|
|
- TimeTextBuilder(){
|
|
|
+ TimeTextBuilder() {
|
|
|
Text(Utility.getTimePeriod())
|
|
|
.fontSize(13)
|
|
|
- .margin({top: 5 })
|
|
|
+ .margin({ top: 5 })
|
|
|
.fontColor($r('app.color.text_color'))
|
|
|
.align(Alignment.Start)
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 动态生成抽屉菜单内容
|
|
|
* 根据 isShowSponsorship 展示不同菜单项
|
|
|
*/
|
|
|
@Builder
|
|
|
- getDrawerView(){
|
|
|
- List({space: 0, scroller: this.scroller}){
|
|
|
- ForEach(mainViewModel.getDrawerData2(),(item: ItemData,index:number)=>{
|
|
|
- ListItem(){
|
|
|
+ getDrawerView() {
|
|
|
+ List({ space: 0, scroller: this.scroller }) {
|
|
|
+ ForEach(mainViewModel.getDrawerData2(), (item: ItemData, index: number) => {
|
|
|
+ ListItem() {
|
|
|
Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
Row() {
|
|
|
// 菜单图标
|
|
|
if (typeof item.img === 'object' && item.img !== null && (item.img as sysResource).type === 'symbol') {
|
|
|
- SymbolGlyph((item.img as sysResource).value as Resource)
|
|
|
- // .size({ width: 22, height: 22 })
|
|
|
+ SymbolGlyph((item.img as sysResource).value as Resource)// .size({ width: 22, height: 22 })
|
|
|
.fontSize(22)
|
|
|
.fontColor([this.themeColor])
|
|
|
.alignSelf(ItemAlign.Center)
|
|
|
.margin({ left: 25 })
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Image(item.img as Resource)
|
|
|
.height(22)
|
|
|
.alignSelf(ItemAlign.Center)
|
|
|
@@ -467,7 +476,7 @@ struct NewIndex{
|
|
|
Text(item.title)
|
|
|
.margin({ left: 10, right: 20 })
|
|
|
.fontSize(15)
|
|
|
- .fontColor(this.mType ==index?this.themeColor:$r('app.color.index_tab_font_color'))
|
|
|
+ .fontColor(this.mType == index ? this.themeColor : $r('app.color.index_tab_font_color'))
|
|
|
.fontWeight(480)
|
|
|
Blank()
|
|
|
// 右侧箭头
|
|
|
@@ -486,27 +495,27 @@ struct NewIndex{
|
|
|
switch (item.id) {
|
|
|
case MainViewModel.MENU_MUSIC:
|
|
|
this.mType = 0
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
}
|
|
|
break
|
|
|
case MainViewModel.MENU_FILE_SCAN:
|
|
|
- this.mType=2
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ this.mType = 2
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
}
|
|
|
break
|
|
|
- // case MainViewModel.MENU_HOME:
|
|
|
- // this.mType = 0
|
|
|
- // this.modeType = 0
|
|
|
- // animateTo({ duration: 555 }, () => {
|
|
|
- // this.isShowDrawer = false
|
|
|
- // })
|
|
|
- // break
|
|
|
+ // case MainViewModel.MENU_HOME:
|
|
|
+ // this.mType = 0
|
|
|
+ // this.modeType = 0
|
|
|
+ // animateTo({ duration: 555 }, () => {
|
|
|
+ // this.isShowDrawer = false
|
|
|
+ // })
|
|
|
+ // break
|
|
|
case MainViewModel.MENU_MIEDIA_KU:
|
|
|
this.modeType = 1
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
@@ -526,8 +535,8 @@ struct NewIndex{
|
|
|
})
|
|
|
break
|
|
|
case MainViewModel.MENU_SETTING:
|
|
|
- this.mType=3
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ this.mType = 3
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
@@ -542,8 +551,8 @@ struct NewIndex{
|
|
|
}, router.RouterMode.Single);
|
|
|
break
|
|
|
case MainViewModel.MENU_USER:
|
|
|
- this.mType=1
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ this.mType = 1
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
@@ -575,7 +584,7 @@ struct NewIndex{
|
|
|
});
|
|
|
break
|
|
|
case MainViewModel.MENU_HAOPING:
|
|
|
- Utility.gotoMarket(getContext(this) as common.UIAbilityContext,this.bundleName)
|
|
|
+ Utility.gotoMarket(getContext(this) as common.UIAbilityContext, this.bundleName)
|
|
|
break
|
|
|
case MainViewModel.MENU_TEST_SPEED:
|
|
|
router.pushUrl({
|
|
|
@@ -588,8 +597,8 @@ struct NewIndex{
|
|
|
});
|
|
|
break
|
|
|
case MainViewModel.MENU_ABOUT:
|
|
|
- this.mType=4
|
|
|
- if(!this.isBigScreen()){
|
|
|
+ this.mType = 4
|
|
|
+ if (!this.isBigScreen()) {
|
|
|
animateTo({ duration: 555 }, () => {
|
|
|
this.isShowDrawer = false
|
|
|
})
|
|
|
@@ -599,12 +608,17 @@ struct NewIndex{
|
|
|
// }, router.RouterMode.Single);
|
|
|
break
|
|
|
case MainViewModel.MENU_UPDATE:
|
|
|
- AlertDialog.show({title:'版本更新',message:'当前版本为最新版本:'+this.versionName,
|
|
|
- autoCancel:true, alignment:DialogAlignment.Center,
|
|
|
- offset:{dx:0,dy:-20},//在Y轴方向上的编译量
|
|
|
- confirm:{
|
|
|
- value:'确定',fontColor:Color.White,backgroundColor:$r('app.color.title_bar_bg'),
|
|
|
- action:()=>{
|
|
|
+ AlertDialog.show({
|
|
|
+ title: '版本更新',
|
|
|
+ message: '当前版本为最新版本:' + this.versionName,
|
|
|
+ autoCancel: true,
|
|
|
+ alignment: DialogAlignment.Center,
|
|
|
+ offset: { dx: 0, dy: -20 }, //在Y轴方向上的编译量
|
|
|
+ confirm: {
|
|
|
+ value: '确定',
|
|
|
+ fontColor: Color.White,
|
|
|
+ backgroundColor: $r('app.color.title_bar_bg'),
|
|
|
+ action: () => {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -622,8 +636,9 @@ struct NewIndex{
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- .clickEffect({level:ClickEffectLevel.HEAVY})
|
|
|
- .transition(TransitionEffect.move(TransitionEdge.BOTTOM).animation({ duration: 600, curve: Curve.Ease, delay: 60*index }))
|
|
|
+ .clickEffect({ level: ClickEffectLevel.HEAVY })
|
|
|
+ .transition(TransitionEffect.move(TransitionEdge.BOTTOM)
|
|
|
+ .animation({ duration: 600, curve: Curve.Ease, delay: 60 * index }))
|
|
|
.width('90%')
|
|
|
.height(55)
|
|
|
|
|
|
@@ -631,17 +646,22 @@ struct NewIndex{
|
|
|
}
|
|
|
.width('86%')
|
|
|
.borderRadius(20)
|
|
|
- .margin({bottom:20,left:10,right:10,top:10})
|
|
|
+ .margin({
|
|
|
+ bottom: 20,
|
|
|
+ left: 10,
|
|
|
+ right: 10,
|
|
|
+ top: 10
|
|
|
+ })
|
|
|
.alignListItem(ListItemAlign.Center)
|
|
|
.layoutWeight(1)
|
|
|
.backgroundColor($r('app.color.silvery'))
|
|
|
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
|
|
|
}
|
|
|
|
|
|
- gotoShare(){
|
|
|
+ gotoShare() {
|
|
|
let shareData: systemShare.SharedData = new systemShare.SharedData({
|
|
|
utd: uniformTypeDescriptor.UniformDataType.TEXT,
|
|
|
- content: 'https://appgallery.huawei.com/app/detail?id='+this.bundleName,
|
|
|
+ content: 'https://appgallery.huawei.com/app/detail?id=' + this.bundleName,
|
|
|
title: this.appName, // 不传title字段时,显示content
|
|
|
description: '精心雕琢的无损音乐播放器',
|
|
|
// thumbnail: new Uint8Array() // 推荐传入适合的缩略图 不传则显示默认text图标
|
|
|
@@ -770,7 +790,6 @@ struct NewIndex{
|
|
|
// }
|
|
|
|
|
|
|
|
|
-
|
|
|
@StorageProp('currentHeightBreakpoint') currentHeightBreakpoint: HeightBreakpoint | undefined =
|
|
|
HeightBreakpoint.HEIGHT_LG;
|
|
|
@StorageProp('currentWidthBreakpoint') currentWidthBreakpoint: WidthBreakpoint | undefined = WidthBreakpoint.WIDTH_SM;
|
|
|
@@ -781,6 +800,7 @@ struct NewIndex{
|
|
|
return this.currentWidthBreakpoint === WidthBreakpoint.WIDTH_SM
|
|
|
&& this.currentHeightBreakpoint === HeightBreakpoint.HEIGHT_MD
|
|
|
}
|
|
|
+
|
|
|
//是否是Pura X外屏,或者小屏幕或者手机横屏
|
|
|
isCoverOpacity() {
|
|
|
if (this.isPuraWP()) {
|
|
|
@@ -804,7 +824,7 @@ struct NewIndex{
|
|
|
isPhoneLan() {
|
|
|
if (DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
|
|
|
&& this.currentBreakpoint !== BreakpointTypeEnum.SM) {
|
|
|
- if (DisplayUtil.getFoldStatus() === 0 ) {
|
|
|
+ if (DisplayUtil.getFoldStatus() === 0) {
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
@@ -812,45 +832,8 @@ struct NewIndex{
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 展示Banner广告
|
|
|
- */
|
|
|
- // showBannerAd() {
|
|
|
- // if (!this.bannerAd) {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // this.isShowAd = true
|
|
|
- // this.status = "已展示"
|
|
|
- // }
|
|
|
- /**
|
|
|
- * ================== 穿山甲广告相关结束 ==================
|
|
|
- */
|
|
|
-
|
|
|
- // geIDD() {
|
|
|
- // // 获取应用签名等信息示例代码
|
|
|
- // let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
|
|
|
- // bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO;
|
|
|
- // try {
|
|
|
- // bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => {
|
|
|
- // hilog.info(0x0000, 'testTag11', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data));
|
|
|
- // }).catch((err: BusinessError) => {
|
|
|
- // hilog.error(0x0000, 'testTag11', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message);
|
|
|
- // });
|
|
|
- // } catch (err) {
|
|
|
- // let message = (err as BusinessError).message;
|
|
|
- // hilog.error(0x0000, 'testTag33', 'getBundleInfoForSelf failed: %{public}s', message);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- /*** 本地会员同步弹窗内容Builder */
|
|
|
- @Builder
|
|
|
- syncNobleDialogContentBuilder(): void {
|
|
|
- Text('检测到您是本地会员,为保障权益请登录账号,会员权益将自动同步到您的账号。')
|
|
|
- .fontSize(16)
|
|
|
- .fontColor('#222')
|
|
|
- .width('100%')
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- .padding(16)
|
|
|
+ isLoginChange() {
|
|
|
+ this.refreshUserInfoState();
|
|
|
}
|
|
|
}
|
|
|
|