소스 검색

页面优化

LiuSiQi 4 달 전
부모
커밋
ad8240d9fc

+ 109 - 2
package-lock.json

@@ -23,6 +23,7 @@
         "@capacitor/status-bar": "6.0.0",
         "@ionic/angular": "^8.0.0",
         "ionicons": "^7.0.0",
+        "parse": "^5.2.0",
         "rxjs": "~7.8.0",
         "tslib": "^2.3.0",
         "zone.js": "~0.14.2"
@@ -40,6 +41,7 @@
         "@capacitor/cli": "6.0.0",
         "@ionic/angular-toolkit": "^11.0.1",
         "@types/jasmine": "~5.1.0",
+        "@types/parse": "^3.0.9",
         "@typescript-eslint/eslint-plugin": "^6.0.0",
         "@typescript-eslint/parser": "^6.0.0",
         "eslint": "^8.57.0",
@@ -2407,6 +2409,18 @@
         "node": ">=6.9.0"
       }
     },
+    "node_modules/@babel/runtime-corejs3": {
+      "version": "7.24.6",
+      "resolved": "https://registry.npmmirror.com/@babel/runtime-corejs3/-/runtime-corejs3-7.24.6.tgz",
+      "integrity": "sha512-tbC3o8uHK9xMgMsvUm9qGqxVpbv6yborMBLbDteHIc7JDNHsTV0vDMQ5j1O1NXvO+BDELtL9KgoWYaUVIVGt8w==",
+      "dependencies": {
+        "core-js-pure": "^3.30.2",
+        "regenerator-runtime": "^0.14.0"
+      },
+      "engines": {
+        "node": ">=6.9.0"
+      }
+    },
     "node_modules/@babel/template": {
       "version": "7.24.6",
       "resolved": "https://registry.npmmirror.com/@babel/template/-/template-7.24.6.tgz",
@@ -4876,6 +4890,15 @@
         "@types/node": "*"
       }
     },
+    "node_modules/@types/parse": {
+      "version": "3.0.9",
+      "resolved": "https://registry.npmmirror.com/@types/parse/-/parse-3.0.9.tgz",
+      "integrity": "sha512-DGTHygc7krgmNAK8h42giwmAofCd9uv2++RD+zw6OmWI7AEnlTYZwEuWsx22SA2CSMQrZW8P2INHLpQbnQFUng==",
+      "dev": true,
+      "dependencies": {
+        "@types/node": "*"
+      }
+    },
     "node_modules/@types/qs": {
       "version": "6.9.15",
       "resolved": "https://registry.npmmirror.com/@types/qs/-/qs-6.9.15.tgz",
@@ -7046,6 +7069,16 @@
         "url": "https://opencollective.com/core-js"
       }
     },
+    "node_modules/core-js-pure": {
+      "version": "3.37.1",
+      "resolved": "https://registry.npmmirror.com/core-js-pure/-/core-js-pure-3.37.1.tgz",
+      "integrity": "sha512-J/r5JTHSmzTxbiYYrzXg9w1VpqrYt+gexenBE9pugeyhwPZTAEJddyiReJWsLO6uNQ8xJZFbod6XC7KKwatCiA==",
+      "hasInstallScript": true,
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/core-js"
+      }
+    },
     "node_modules/core-util-is": {
       "version": "1.0.3",
       "resolved": "https://registry.npmmirror.com/core-util-is/-/core-util-is-1.0.3.tgz",
@@ -7208,6 +7241,12 @@
         "node": ">= 8"
       }
     },
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
+      "optional": true
+    },
     "node_modules/css-loader": {
       "version": "6.10.0",
       "resolved": "https://registry.npmmirror.com/css-loader/-/css-loader-6.10.0.tgz",
@@ -9796,6 +9835,11 @@
         "postcss": "^8.1.0"
       }
     },
+    "node_modules/idb-keyval": {
+      "version": "6.2.1",
+      "resolved": "https://registry.npmmirror.com/idb-keyval/-/idb-keyval-6.2.1.tgz",
+      "integrity": "sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg=="
+    },
     "node_modules/ieee754": {
       "version": "1.2.1",
       "resolved": "https://registry.npmmirror.com/ieee754/-/ieee754-1.2.1.tgz",
@@ -12962,6 +13006,25 @@
         "node": ">=6"
       }
     },
+    "node_modules/parse": {
+      "version": "5.2.0",
+      "resolved": "https://registry.npmmirror.com/parse/-/parse-5.2.0.tgz",
+      "integrity": "sha512-FoD3kcLAQCw/2J1984sl3GUBzbHE2tA9mUcyw/EBWZ46WVZTzV+kjnA5tttXyzN4uodt21wSluzjbGnyLqreKw==",
+      "dependencies": {
+        "@babel/runtime-corejs3": "7.24.6",
+        "idb-keyval": "6.2.1",
+        "react-native-crypto-js": "1.0.0",
+        "uuid": "10.0.0",
+        "ws": "8.17.1",
+        "xmlhttprequest": "1.8.0"
+      },
+      "engines": {
+        "node": ">=18 <21"
+      },
+      "optionalDependencies": {
+        "crypto-js": "4.2.0"
+      }
+    },
     "node_modules/parse-json": {
       "version": "5.2.0",
       "resolved": "https://registry.npmmirror.com/parse-json/-/parse-json-5.2.0.tgz",
@@ -13001,6 +13064,38 @@
         "node": ">= 0.10"
       }
     },
+    "node_modules/parse/node_modules/uuid": {
+      "version": "10.0.0",
+      "resolved": "https://registry.npmmirror.com/uuid/-/uuid-10.0.0.tgz",
+      "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
+      "funding": [
+        "https://github.com/sponsors/broofa",
+        "https://github.com/sponsors/ctavan"
+      ],
+      "bin": {
+        "uuid": "dist/bin/uuid"
+      }
+    },
+    "node_modules/parse/node_modules/ws": {
+      "version": "8.17.1",
+      "resolved": "https://registry.npmmirror.com/ws/-/ws-8.17.1.tgz",
+      "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
+      "engines": {
+        "node": ">=10.0.0"
+      },
+      "peerDependencies": {
+        "bufferutil": "^4.0.1",
+        "utf-8-validate": ">=5.0.2"
+      },
+      "peerDependenciesMeta": {
+        "bufferutil": {
+          "optional": true
+        },
+        "utf-8-validate": {
+          "optional": true
+        }
+      }
+    },
     "node_modules/parse5": {
       "version": "7.1.2",
       "resolved": "https://registry.npmmirror.com/parse5/-/parse5-7.1.2.tgz",
@@ -13636,6 +13731,11 @@
       "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==",
       "dev": true
     },
+    "node_modules/react-native-crypto-js": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/react-native-crypto-js/-/react-native-crypto-js-1.0.0.tgz",
+      "integrity": "sha512-FNbLuG/HAdapQoybeZSoes1PWdOj0w242gb+e1R0hicf3Gyj/Mf8M9NaED2AnXVOX01b2FXomwUiw1xP1K+8sA=="
+    },
     "node_modules/read-package-json": {
       "version": "7.0.1",
       "resolved": "https://registry.npmmirror.com/read-package-json/-/read-package-json-7.0.1.tgz",
@@ -13766,8 +13866,7 @@
     "node_modules/regenerator-runtime": {
       "version": "0.14.1",
       "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
-      "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==",
-      "dev": true
+      "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
     },
     "node_modules/regenerator-transform": {
       "version": "0.15.2",
@@ -16881,6 +16980,14 @@
         "node": ">=8.0"
       }
     },
+    "node_modules/xmlhttprequest": {
+      "version": "1.8.0",
+      "resolved": "https://registry.npmmirror.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
+      "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==",
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
     "node_modules/y18n": {
       "version": "5.0.8",
       "resolved": "https://registry.npmmirror.com/y18n/-/y18n-5.0.8.tgz",

+ 2 - 0
package.json

@@ -28,6 +28,7 @@
     "@capacitor/status-bar": "6.0.0",
     "@ionic/angular": "^8.0.0",
     "ionicons": "^7.0.0",
+    "parse": "^5.2.0",
     "rxjs": "~7.8.0",
     "tslib": "^2.3.0",
     "zone.js": "~0.14.2"
@@ -45,6 +46,7 @@
     "@capacitor/cli": "6.0.0",
     "@ionic/angular-toolkit": "^11.0.1",
     "@types/jasmine": "~5.1.0",
+    "@types/parse": "^3.0.9",
     "@typescript-eslint/eslint-plugin": "^6.0.0",
     "@typescript-eslint/parser": "^6.0.0",
     "eslint": "^8.57.0",

+ 22 - 21
src/app/app-routing.module.ts

@@ -1,15 +1,16 @@
-import { NgModule } from '@angular/core';
-import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
-
-const routes: Routes = [
-  {
-    path: '',
-    loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
-  },
-  {
-    path: 'new-page',
-    loadChildren: () => import('./new-page/new-page.module').then( m => m.NewPagePageModule)
-  },
  {
+import { NgModule } from '@angular/core';
+import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
+
+const routes: Routes = [
+  {
+    path: '',
+    loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
+  },
+  {
+    path: 'new-page',
+    loadChildren: () => import('./new-page/new-page.module').then( m => m.NewPagePageModule)
+  },
+  {
     path: 'login',
     loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
   },
@@ -17,12 +18,12 @@ const routes: Routes = [
     path: 'register',
     loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
   }
-
-];
-@NgModule({
-  imports: [
-    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
-  ],
-  exports: [RouterModule]
-})
-export class AppRoutingModule {}
+  
+];
+@NgModule({
+  imports: [
+    RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
+  ],
+  exports: [RouterModule]
+})
+export class AppRoutingModule {}

+ 5 - 204
src/app/login/login.page.html

@@ -20,12 +20,12 @@
                     <h2>Login</h2>
                     <div class="inputbox">
                         <ion-icon name="person-outline"></ion-icon>
-                        <input type="text" id="login-user" required>
+                        <input type="text" id="login-user" required [ngModelOptions]="{standalone: true}" [(ngModel)]="username">
                         <label for="">Username</label>
                     </div>
                     <div class="inputbox">
                         <ion-icon name="lock-closed-outline"></ion-icon>
-                        <input type="password" id="login-pass" required>
+                        <input type="password" id="login-pass" required [ngModelOptions]="{standalone: true}" [(ngModel)]="password">
                         <label for="">Password</label>
                     </div>
                     <div class="forget">
@@ -34,7 +34,7 @@
                             <a href="#" onclick="goBox('forget')">Forget Password</a>
                         </label>
                     </div>
-                    <button class="loginBtn" onclick="doLogin()">Log In</button>
+                    <button class="loginBtn" (click)="doLogin()">Log In</button>
                     
                     <div (click)="goRegister()" style="color: white">
                       <p>Don't have a account</p>
@@ -45,206 +45,7 @@
             </div>
  
         </div>
-        <!-- <div class="register-box">
-            <div class="register-form">
-                <form action="" id="register-form">
-                    <h2>Register</h2>
-                    <div class="inputbox">
-                        <ion-icon name="person-outline"></ion-icon>
-                        <input type="text" id="register-user" required>
-                        <label for="">Username</label>
-                    </div>
-                    <div class="inputbox">
-                        <ion-icon name="mail-outline"></ion-icon>
-                        <input type="email" id="register-email" required>
-                        <label for="">Email</label>
-                    </div>
-                    <div class="inputbox" style="width: 200px;">
-                        <ion-icon name="shield-checkmark-outline"></ion-icon>
-                        <input type="text" id="register-code" required>
-                        <label for="">Enter Captcha</label>
-                        <button onclick="sendCode()">Send Code</button>
-                    </div>
-                    <div class="inputbox">
-                        <ion-icon name="lock-closed-outline"></ion-icon>
-                        <input type="password" id="register-pass" required>
-                        <label for="">Password</label>
-                    </div>
- 
-                    <button class="registerBtn" onclick="doRegister()">Register</button>
-                    <div class="link">
-                        <p>Have a account
-                            <a href="#" onclick="goBox('login')">login</a>
-                        </p>
-                    </div>
-                </form>
-            </div>
-        </div>
-
-        <div class="forget-box">
-            <div class="forget-form">
-                <form action="" id="forget-form">
-                    <h2>Find Password</h2>
-                    <div class="inputbox">
-                        <ion-icon name="mail-outline"></ion-icon>
-                        <input type="email" id="forget-email" required>
-                        <label for="">Email</label>
-                    </div>
-                    <div class="inputbox" style="width: 200px;">
-                        <ion-icon name="shield-checkmark-outline"></ion-icon>
-                        <input type="text" id="forget-code" required>
-                        <label for="">Enter Captcha</label>
-                        <button onclick="sendCode()">Send Code</button>
-                    </div>
-                    <div class="inputbox">
-                        <ion-icon name="lock-closed-outline"></ion-icon>
-                        <input type="password" id="forget-pass" required>
-                        <label for="">New Password</label>
-                    </div>
-                    <button class="registerBtn" onclick="doUpdate()">Update</button>
-                    <div class="link">
-                        <p>Have a account
-                            <a href="#" onclick="goBox('login')">login</a>
-                        </p>
-                    </div>
-                </form>
-            </div>
-        </div> -->
+      
     </section>
- 
-    <!-- <script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
-    <script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
-    <script>
- 
-        document.addEventListener('DOMContentLoaded', function () {
-            // 检查本地存储中的“Remember Me”状态,更新复选框
-            let rememberMeCheckbox = document.getElementById('remember-me');
- 
-            if (localStorage.getItem('rememberMe') === 'true') {
-                rememberMeCheckbox.checked = true;
- 
-                let user = JSON.parse(localStorage.getItem('user'))
- 
-                document.getElementById('login-user').value=user.username
-                document.getElementById('login-pass').value=user.password
-            }
-        });
- 
-        // 登录事件
-        function doLogin() {
-            const username = document.getElementById('login-user').value
-            const password = document.getElementById('login-pass').value
-            console.log('登录表单:',
-                {
-                    username: username,
-                    password: password
-                });
-            if (username === 'sa' && password === '123') {
-                
-                alert('Login Success!!!')
- 
-                const rememberMeCheckBox = document.getElementById('remember-me')
-                if (rememberMeCheckBox.checked) {
-                    localStorage.setItem('rememberMe', 'true')
- 
-                    const userObj = { username: username, password: password };
-                    const userStr = JSON.stringify(userObj);
-                    localStorage.setItem('user', userStr);
-                } else {
-                    localStorage.removeItem('rememberMe')
-                    localStorage.removeItem('user')
-                }
- 
- 
-            } else {
-                alert('Login Fail!!!')
-            }
-        }
- 
-        // 注册事件
-        function doRegister() {
-            const username = document.getElementById('register-user').value
-            const email = document.getElementById('register-email').value
-            const code = document.getElementById('register-code').value
-            const password = document.getElementById('register-pass').value
- 
- 
-            console.log('注册表单:',
-                {
-                    username: username,
-                    email: email,
-                    code: code,
-                    password: password
-                });
- 
-            if (username && email && code && password) {
-                alert('Register Success!!!');
- 
- 
-                // 清空表单内容
-                document.getElementById('register-user').value = '';
-                document.getElementById('register-email').value = '';
-                document.getElementById('register-code').value = '';
-                document.getElementById('register-pass').value = '';
- 
-                // 切换到登录表单
-                goBox();
-            } else {
-                alert('Register Fail!!!');
-            }
-        }
- 
-        // 找回密码事件
-       function doUpdate() {
-            const email = document.getElementById('forget-email').value
-            const code = document.getElementById('forget-code').value
-            const password = document.getElementById('forget-pass').value
- 
- 
-            console.log('更新密码表单',
-                {
-                    email: email,
-                    code: code,
-                    password: password
-                });
- 
-            if (email && code && password) {
-                alert('UUpdate Success!!!');
- 
- 
-                // 清空表单内容
-                document.getElementById('forget-email').value = '';
-                document.getElementById('forget-code').value = '';
-                document.getElementById('forget-pass').value = '';
- 
-                // 切换到登录表单
-                goBox();
-            } else {
-                alert('Update Fail!!!');
-            }
-        }
- 
-        // 切换登录注册表单
-        function goBox(type) {
-            let loginForm = document.querySelector('.login-box');
-            let registerForm = document.querySelector('.register-box');
-            let forgetPasswordForm = document.querySelector('.forget-box');
- 
-            // 首先隐藏所有表单
-            loginForm.classList.remove('active');
-            registerForm.classList.remove('active');
-            forgetPasswordForm.classList.remove('active');
- 
-            // 根据目标显示对应的表单
-            if (type === 'register') {
-                registerForm.classList.add('active');
-            } else if (type === 'forget') {
-                forgetPasswordForm.classList.add('active');
-            } else {
-                loginForm.classList.add('active');
-            }
-        }
- 
-    </script> -->
-</body>
+    
  

+ 18 - 0
src/app/login/login.page.ts

@@ -1,15 +1,33 @@
 import { Component, OnInit } from '@angular/core';
 import { Router } from '@angular/router';
 
+import * as Parse from "parse"
+(Parse as any).serverURL = "https://web2023.fmode.cn/parse"
+Parse.initialize("dev")
+
 @Component({
   selector: 'app-login',
   templateUrl: './login.page.html',
   styleUrls: ['./login.page.scss'],
 })
 export class LoginPage implements OnInit {
+  username:string | undefined
+  password:string | undefined
 
   constructor(private router: Router) {}
 
+
+  async doLogin(){
+    try {
+      let user = await Parse.User.logIn(String(this.username), String(this.password))
+      this.router.navigate(['/tabs']);
+      console.log('登录成功');
+      
+    } catch (error) {
+      console.log(error);
+    }
+    
+  }
   goRegister(){
     this.router.navigate(['/register']);
   }

+ 2 - 2
src/app/register/register.module.ts

@@ -1,6 +1,6 @@
 import { NgModule } from '@angular/core';
 import { CommonModule } from '@angular/common';
-import { FormsModule } from '@angular/forms';
+import { FormsModule, ReactiveFormsModule } from '@angular/forms';
 
 import { IonicModule } from '@ionic/angular';
 
@@ -11,7 +11,7 @@ import { RegisterPage } from './register.page';
 @NgModule({
   imports: [
     CommonModule,
-    FormsModule,
+    FormsModule,ReactiveFormsModule,
     IonicModule,
     RegisterPageRoutingModule
   ],

+ 9 - 9
src/app/register/register.page.html

@@ -13,31 +13,31 @@
               <h2>Register</h2>
               <div class="inputbox">
                   <ion-icon name="person-outline"></ion-icon>
-                  <input type="text" id="register-user" required>
+                  <input type="text" id="register-user" required  [ngModelOptions]="{standalone: true}" [(ngModel)]="username">
                   <label for="">Username</label>
               </div>
               <div class="inputbox">
                   <ion-icon name="mail-outline"></ion-icon>
-                  <input type="email" id="register-email" required>
+                  <input type="email" id="register-email" required  [ngModelOptions]="{standalone: true}" [(ngModel)]="email">
                   <label for="">Email</label>
               </div>
-              <div class="inputbox" style="width: 200px;">
+              <!-- <div class="inputbox" style="width: 200px;">
                   <ion-icon name="shield-checkmark-outline"></ion-icon>
                   <input type="text" id="register-code" required>
                   <label for="">Enter Captcha</label>
                   <button onclick="sendCode()">Send Code</button>
-              </div>
+              </div> -->
               <div class="inputbox">
                   <ion-icon name="lock-closed-outline"></ion-icon>
-                  <input type="password" id="register-pass" required>
+                  <input type="password" id="register-pass" required  [ngModelOptions]="{standalone: true}" [(ngModel)]="password">
                   <label for="">Password</label>
               </div>
 
-              <button class="registerBtn" onclick="doRegister()">Register</button>
+              <button class="registerBtn" (click)="saveRegister()">Register</button>
               <div class="link">
-                  <p>Have a account
-                      <a href="#" onclick="goBox('login')">login</a>
-                  </p>
+                  <div>Have a account
+                      <p (click)="gologin()">login</p>
+                  </div>
               </div>
           </form>
       </div>

+ 36 - 1
src/app/register/register.page.ts

@@ -1,4 +1,6 @@
 import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+import * as Parse from "parse"
 
 @Component({
   selector: 'app-register',
@@ -7,9 +9,42 @@ import { Component, OnInit } from '@angular/core';
 })
 export class RegisterPage implements OnInit {
 
-  constructor() { }
+  username:string | undefined
+  email:string | undefined
+  password:string | undefined
+
+  constructor(private router: Router) { }
 
   ngOnInit() {
   }
 
+  currentUser:any
+  async saveRegister(){
+    // this.currentUser = Parse.User.current()
+    if(!this.username){
+      return alert("用户名未填写")
+    } else if(!this.password){
+      return alert("密码未填写")
+    }
+    let user = Parse.Object.extend("_User")
+    user = new user()
+    user.set('mobile',this.username)
+    user.set('username',this.username)
+    user.set('email',this.email)
+    user.set('password',this.password)
+    try {
+      await user.save()
+      alert("保存成功")
+      this.router.navigate(['/login']);
+      console.log("保存成功");
+    } catch (error){
+      alert("保存失败")
+      console.log("保存失败");
+    }
+  }
+
+  gologin(){
+    this.router.navigate(['/login']);
+  }
+
 }