<script lang="ts" setup>
import { loginApi } from "@/api/login";
import { store } from "@/store/store";

logger({ cnl: ["console"], pgu: "登录页面" });

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>
