From ba7e154d87174b58c83e9b9d9f180da85783bd7f Mon Sep 17 00:00:00 2001 From: 6666 <2855471171@qq.com> Date: Thu, 7 May 2026 17:49:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=A1=B5=E9=9D=A2=E5=92=8C?= =?UTF-8?q?=E6=88=91=E7=9A=84=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/HomePage.ets | 71 +++++++++++++++++++ entry/src/main/ets/pages/LoginPage.ets | 14 ++-- .../resources/base/profile/main_pages.json | 3 +- 3 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 entry/src/main/ets/pages/HomePage.ets diff --git a/entry/src/main/ets/pages/HomePage.ets b/entry/src/main/ets/pages/HomePage.ets new file mode 100644 index 0000000..2678752 --- /dev/null +++ b/entry/src/main/ets/pages/HomePage.ets @@ -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) + } +} diff --git a/entry/src/main/ets/pages/LoginPage.ets b/entry/src/main/ets/pages/LoginPage.ets index 694c117..067cfb8 100644 --- a/entry/src/main/ets/pages/LoginPage.ets +++ b/entry/src/main/ets/pages/LoginPage.ets @@ -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); } } diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index c478f43..e4ef11a 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,7 @@ { "src": [ "pages/LoginPage", - "pages/RegisterPage" + "pages/RegisterPage", + "pages/HomePage" ] } \ No newline at end of file