소스 검색

init login

Michael Wang 3 년 전
부모
커밋
9865969cb2
5개의 변경된 파일64개의 추가작업 그리고 3개의 파일을 삭제
  1. 22 0
      src/api/login.ts
  2. 39 1
      src/features/UserLogin/UserLogin.vue
  3. 1 1
      src/router/index.ts
  4. 1 0
      src/store/store.ts
  5. 1 1
      vite.config.ts

+ 22 - 0
src/api/login.ts

@@ -0,0 +1,22 @@
+import { httpApp } from "@/plugins/axiosApp";
+
+/** 用户登录 */
+export async function loginApi(
+  accountType: string,
+  accountValue: string,
+  password: string,
+  domain: string,
+  rootOrgId: number
+) {
+  return httpApp.post<any, { data: { content: any } }>(
+    "/api/ecs_core/verifyCode/gt/login",
+    {
+      accountType,
+      accountValue,
+      password,
+      domain,
+      rootOrgId,
+      alwaysOK: true,
+    }
+  );
+}

+ 39 - 1
src/features/UserLogin/UserLogin.vue

@@ -1,7 +1,45 @@
-<script lang="ts" setup></script>
+<script lang="ts" setup>
+import { loginApi } from "@/api/login";
+import { store } from "@/store/store";
+
+const accountType = $ref("STUDENT_CODE");
+const accountValue = $ref("");
+const password = $ref("");
+// console.log(import.meta.env);
+const domain = import.meta.env.DEV
+  ? (import.meta.env.VITE_DEVELOPMENT_DOMAIN as string)
+  : "";
+const rootOrgId = 0;
+
+async function handleLoginClick() {
+  const res = await loginApi(
+    accountType,
+    accountValue,
+    password,
+    domain,
+    rootOrgId
+  );
+  console.log(res);
+
+  store.user = res.data.content;
+}
+</script>
 
 <template>
   <div>login</div>
+  <div>
+    <n-form>
+      <n-form-item label="学号">
+        <n-input v-model:value="accountValue" clearable />
+      </n-form-item>
+      <n-form-item label="密码">
+        <n-input v-model:value="password" clearable />
+      </n-form-item>
+      <n-form-item>
+        <n-button @click="handleLoginClick"> 登录 </n-button>
+      </n-form-item>
+    </n-form>
+  </div>
 </template>
 
 <style scoped></style>

+ 1 - 1
src/router/index.ts

@@ -28,7 +28,7 @@ const routes: RouteRecordRaw[] = [
 // keep it simple for now.
 const router = createRouter({
   // 4. Provide the history implementation to use. We are using the hash history for simplicity here.
-  history: createWebHistory("web"),
+  history: createWebHistory("oe-web"),
   routes, // short for `routes: routes`
 });
 

+ 1 - 0
src/store/store.ts

@@ -4,6 +4,7 @@ import { Store } from "@/types/student-client";
 export const useStore = defineStore("ecs", {
   state: () => {
     return {
+      user: {},
       globalMaskCount: 0,
     } as Store;
   },

+ 1 - 1
vite.config.ts

@@ -3,7 +3,7 @@ import vue from "@vitejs/plugin-vue";
 import ViteComponents from "unplugin-vue-components/vite";
 import { NaiveUiResolver } from "unplugin-vue-components/resolvers";
 
-const SERVER_URL = "https://192.168.10.39";
+const SERVER_URL = "http://192.168.10.39:8000";
 const path = require("path");
 
 // https://vitejs.dev/config/