李佳青 4 months ago
parent
commit
ea531f5003

File diff suppressed because it is too large
+ 286 - 254
package-lock.json


+ 1 - 0
package.json

@@ -46,6 +46,7 @@
     "@angular/compiler-cli": "^17.0.2",
     "@angular/language-service": "^17.0.2",
     "@capacitor/cli": "6.0.0",
+    "@compodoc/compodoc": "^1.1.25",
     "@ionic/angular-toolkit": "^11.0.1",
     "@types/jasmine": "~5.1.0",
     "@typescript-eslint/eslint-plugin": "^6.0.0",

+ 6 - 0
src/app/tab1/tab1.page.html

@@ -16,6 +16,12 @@
   <!--虚拟身份-->
   <ion-card>
     <ion-item lines="full">
+      <ion-avatar slot="start" *ngIf="!currentUser?.id">
+        <img alt="头像" src="https://ionicframework.com/docs/img/demos/avatar.svg" />
+      </ion-avatar>
+      <ion-label *ngIf="!currentUser?.id">
+        <ion-note>虚拟身份名</ion-note>
+      </ion-label>
       <ng-container *ngFor="let person of dePerson">
         <ion-avatar slot="start">
           <img alt="头像" [src]="person?.get('avatar')" />

+ 4 - 0
src/app/tab1/tab1.page.ts

@@ -21,6 +21,10 @@ export class Tab1Page {
   ];
 
   async ngOnInit() {
+    this.currentUser = await Parse.User.current()
+    setInterval(async () => {
+      this.currentUser = await Parse.User.current()
+    }, 1000)
     this.dePerson = await this.getPersonDate()
   }
   //虚拟角

+ 1 - 1
src/app/tab3/tab3.page.html

@@ -24,7 +24,7 @@
         </ng-template>
       </ion-popover>
     </ion-buttons>
-    <ion-buttons slot="end" routerLink="/user/edit/info">
+    <ion-buttons slot="end" routerLink="/user/edit/info" *ngIf="user?.id">
       <ion-button>
         <ion-icon slot="start" name="create-outline"></ion-icon>
       </ion-button>

+ 6 - 1
src/modules/user/edit-info/edit-info.page.html

@@ -1,6 +1,6 @@
 <ion-header [translucent]="true">
   <ion-toolbar>
-    <ion-title>{{currentUser?.get('username')}} - {{currentUser?.id}}资料编辑</ion-title>
+    <ion-title>资料编辑</ion-title>
     <ion-buttons slot="start">
       <ion-button routerLink="/tabs/tab3" fill="clear" color="dark">
         <ion-icon name="chevron-back-outline" size="large"></ion-icon>
@@ -13,6 +13,11 @@
 <ion-content color="light">
   <ion-card>
     <ion-list>
+      <ion-item lines="none">
+        <ion-note>
+          {{currentUser?.get('username')}} - {{currentUser?.id}}
+        </ion-note>
+      </ion-item>
       <ion-item>
         <ion-input [(ngModel)]="userInfo.name" label="昵称:"></ion-input>
       </ion-item>

+ 0 - 1
src/modules/user/login/login.page.html

@@ -14,7 +14,6 @@
     <ion-card>
       <ion-card-header>
         <ion-card-title>登录/注册</ion-card-title>
-        <ion-card-subtitle>该页面需登陆可继续使用</ion-card-subtitle>
       </ion-card-header>
 
       <ion-card-content>

+ 39 - 39
src/modules/user/login/login.page.ts

@@ -9,70 +9,70 @@ import * as Parse from "parse"
 })
 export class LoginPage implements OnInit {
 
-  username:string = ""
-  password:string = ""
+  username: string = ""
+  password: string = ""
   constructor(
     // 新增:Router服务,用于路由跳转
-    private navCtrl:NavController,
-    private alertController:AlertController
+    private navCtrl: NavController,
+    private alertController: AlertController
   ) { }
 
   ngOnInit() {
   }
 
-  async login(){
+  async login() {
     let user
     try {
-      user = await Parse.User.logIn(this.username,this.password)
-    } catch (error:any) {
-      let message:string = ""
+      user = await Parse.User.logIn(this.username, this.password)
+    } catch (error: any) {
+      let message: string = ""
       // 新增提示词详情,根据Parse.User.login方法返回的不同英文提示词,增加对应的中文内容转换
-      if(error?.message.indexOf("is required")>-1){
+      if (error?.message.indexOf("is required") > -1) {
         message = "必须输入账号或邮箱"
       }
-      if(error?.message.indexOf("Invalid username")>-1){
+      if (error?.message.indexOf("Invalid username") > -1) {
         message = "账号或密码错误,请检查"
       }
       this.presentAlert({
-        header:"登录失败",
-        subHeader:"状态码:"+error.code,
-        message:message || error.message
+        header: "登录失败",
+        subHeader: "状态码:" + error.code,
+        message: message || error.message
       })
     }
     console.log(user)
-    if(user?.id){
+    if (user?.id) {
       this.navCtrl.back()
     }
   }
-  async register(){
+  async register() {
     let user = new Parse.User()
-    user.set("username",this.username)
-    user.set("password",this.password)
+    user.set("username", this.username)
+    user.set("password", this.password)
     try {
-        let result = await user.signUp();
-        console.log(result)
-        if(result?.id){
-          this.navCtrl.back()
-        }
-        // Hooray! Let them use the app now.
-    } catch (error:any) {
-        // 新增提示词详情,根据Parse.User.signUp方法返回的不同英文提示词,增加对应的中文内容转换
-        let message:string = ""
-        if(error?.message.indexOf("already exists")>-1){
-          message = "该账号已存在请修改后重试"
-        }
-        if(error?.message.indexOf("empty")>-1){
-          message = "账号不能为空请输入后重试"
-        }
-        this.presentAlert({
-          header:"注册失败",
-          subHeader:"状态码:"+error.code,
-          message:message || error.message
-        })
+      let result = await user.signUp();
+      console.log(result)
+      if (result?.id) {
+        this.navCtrl.back()
+      }
+      // Hooray! Let them use the app now.
+    } catch (error: any) {
+      // 新增提示词详情,根据Parse.User.signUp方法返回的不同英文提示词,增加对应的中文内容转换
+      let message: string = ""
+      if (error?.message.indexOf("already exists") > -1) {
+        message = "该账号已存在请修改后重试"
+      }
+      if (error?.message.indexOf("empty") > -1) {
+        message = "账号不能为空请输入后重试"
+      }
+      this.presentAlert({
+        header: "注册失败",
+        subHeader: "状态码:" + error.code,
+        message: message || error.message
+      })
     }
   }
 
-  async presentAlert(options:{header:string,subHeader:string,message:string}) {
+  async presentAlert(options: { header: string, subHeader: string, message: string }) {
     const alert = await this.alertController.create({
       header: options?.header,
       subHeader: options?.subHeader,
@@ -87,7 +87,7 @@ export class LoginPage implements OnInit {
    * 返回上级页面函数
    * @desc
    */
-  back(){
+  back() {
     this.navCtrl.back()
   }
 }

+ 5 - 0
tsconfig.doc.json

@@ -0,0 +1,5 @@
+{
+    "include": [
+        "src/**/*.ts"
+    ]
+}

Some files were not shown because too many files changed in this diff