UserLogin.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script lang="ts" setup>
  2. import { loginApi } from "@/api/login";
  3. import { store } from "@/store/store";
  4. logger({ cnl: ["console"], pgu: "登录页面" });
  5. const accountType = $ref("STUDENT_CODE");
  6. const accountValue = $ref("");
  7. const password = $ref("");
  8. // console.log(import.meta.env);
  9. const domain = import.meta.env.DEV
  10. ? (import.meta.env.VITE_DEVELOPMENT_DOMAIN as string)
  11. : "";
  12. const rootOrgId = 0;
  13. async function handleLoginClick() {
  14. const res = await loginApi(
  15. accountType,
  16. accountValue,
  17. password,
  18. domain,
  19. rootOrgId
  20. );
  21. console.log(res);
  22. store.user = res.data.content;
  23. }
  24. </script>
  25. <template>
  26. <div>login</div>
  27. <div>
  28. <n-form>
  29. <n-form-item label="学号">
  30. <n-input v-model:value="accountValue" clearable />
  31. </n-form-item>
  32. <n-form-item label="密码">
  33. <n-input v-model:value="password" clearable />
  34. </n-form-item>
  35. <n-form-item>
  36. <n-button @click="handleLoginClick"> 登录 </n-button>
  37. </n-form-item>
  38. </n-form>
  39. </div>
  40. </template>
  41. <style scoped></style>