首页页面和我的页面的框架

This commit is contained in:
2026-05-07 17:49:16 +08:00
parent a7cd4d908c
commit ba7e154d87
3 changed files with 81 additions and 7 deletions

View File

@@ -0,0 +1,71 @@
@Entry
@Component
struct HomePage {
@State currentIndex: number = 0;
build() {
Tabs({ barPosition: BarPosition.End, index: this.currentIndex }) {
TabContent() {
this.HomeContent()
}
.tabBar(this.TabBarItem(0, '首页', '○'))
TabContent() {
this.MineContent()
}
.tabBar(this.TabBarItem(1, '我的', '○'))
}
.barMode(BarMode.Fixed)
.onChange((index: number) => {
this.currentIndex = index;
})
.width('100%')
.height('100%')
.backgroundColor('#F5F6F7')
}
@Builder
TabBarItem(index: number, title: string, icon: string) {
Column() {
Text(icon)
.fontSize(22)
Text(title)
.fontSize(12)
.fontColor(this.currentIndex === index ? '#4E6EF2' : '#999999')
.fontWeight(this.currentIndex === index ? FontWeight.Medium : FontWeight.Normal)
.margin({ top: 2 })
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
@Builder
HomeContent() {
Column() {
Text('首页')
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
@Builder
MineContent() {
Column() {
Text('我的')
.fontSize(20)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
}

View File

@@ -1,4 +1,4 @@
import { router } from '@kit.ArkUI';
import { promptAction, router } from '@kit.ArkUI';
@Entry
@Component
@@ -132,11 +132,13 @@ struct LoginPage {
this.isLoading = true;
// 模拟登录请求
setTimeout(() => {
this.isLoading = false;
// TODO: 登录成功,跳转刷题主页
// router.replaceUrl({ url: 'pages/HomePage' });
}, 1500);
if (this.username === 'admin' && this.password === 'admin123') {
router.replaceUrl({ url: 'pages/HomePage' });
} else {
this.isLoading = false;
promptAction.showToast({ message: '账号或密码错误', duration: 2000 });
}
}, 500);
}
}

View File

@@ -1,6 +1,7 @@
{
"src": [
"pages/LoginPage",
"pages/RegisterPage"
"pages/RegisterPage",
"pages/HomePage"
]
}