|
@@ -13,6 +13,7 @@ import { DOMAIN, VITE_GIT_REPO_VERSION } from "@/constants/constants";
|
|
|
import { onMounted, onUnmounted, watch } from "vue";
|
|
|
import { Person, LockClosed, CloseCircleOutline } from "@vicons/ionicons5";
|
|
|
import { FormRules, FormItemInst } from "naive-ui";
|
|
|
+import GeeTest from "./GeeTest.vue";
|
|
|
|
|
|
logger({
|
|
|
cnl: ["console", "local", "server"],
|
|
@@ -110,23 +111,67 @@ const fromRules: FormRules = {
|
|
|
let errorInfo = $ref("");
|
|
|
watch([formValue], () => (errorInfo = ""));
|
|
|
|
|
|
+type Captcha = {
|
|
|
+ appendTo(sel: string): void;
|
|
|
+ onReady(cb: () => void): void;
|
|
|
+ onError(cb: (error: any) => void): void;
|
|
|
+ destroy(): void;
|
|
|
+ getValidate(): any;
|
|
|
+};
|
|
|
+let captchaObj: Captcha = $ref();
|
|
|
+let resetGeeTime = $ref(0);
|
|
|
+resetGeeTime = Date.now();
|
|
|
+// 超过60秒,刷新极验;优化刷新次数,当用户真正想输入时
|
|
|
+watch(
|
|
|
+ () => [formValue.accountType, formValue.accountValue, formValue.password],
|
|
|
+ () => {
|
|
|
+ if (isGeeTestEnabled && Date.now() - resetGeeTime > 60 * 1000) {
|
|
|
+ captchaObj?.destroy();
|
|
|
+ resetGeeTime = Date.now();
|
|
|
+ }
|
|
|
+ }
|
|
|
+);
|
|
|
+
|
|
|
const router = useRouter();
|
|
|
|
|
|
async function loginForuser() {
|
|
|
if (await formRef.validate().catch(() => true)) return;
|
|
|
|
|
|
+ if (isGeeTestEnabled) {
|
|
|
+ if (!captchaObj?.getValidate()) {
|
|
|
+ $message.error("请完成验证");
|
|
|
+ loginBtnLoading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
logger({
|
|
|
pgn: "登录页面",
|
|
|
+ cnl: ["local", "server"],
|
|
|
act: "login clicked",
|
|
|
ext: { UA: navigator.userAgent },
|
|
|
});
|
|
|
errorInfo = "";
|
|
|
+
|
|
|
+ let geeParams = {};
|
|
|
+ if (isGeeTestEnabled) {
|
|
|
+ // const geeForm = document.querySelector(".geetest_form").children;
|
|
|
+ const geeRes = captchaObj.getValidate();
|
|
|
+ geeParams = {
|
|
|
+ user_id: localStorage.getItem("uuidForEcs"),
|
|
|
+ client_type: "Web",
|
|
|
+ challenge: geeRes.geetest_challenge, // geeForm[0].value,
|
|
|
+ validate: geeRes.geetest_validate, // geeForm[1].value,
|
|
|
+ seccode: geeRes.geetest_seccode, // geeForm[2].value,
|
|
|
+ };
|
|
|
+ }
|
|
|
const res = await loginApi(
|
|
|
formValue.accountType,
|
|
|
formValue.accountValue,
|
|
|
formValue.password,
|
|
|
domain,
|
|
|
- store.QECSConfig.ROOT_ORG_ID
|
|
|
+ store.QECSConfig.ROOT_ORG_ID,
|
|
|
+ geeParams
|
|
|
);
|
|
|
|
|
|
if (res.data.code === "200") {
|
|
@@ -135,6 +180,8 @@ async function loginForuser() {
|
|
|
store.user = res.data.content;
|
|
|
} else {
|
|
|
errorInfo = res.data.desc;
|
|
|
+ captchaObj.destroy();
|
|
|
+ resetGeeTime = Date.now();
|
|
|
logger({
|
|
|
pgu: "AUTO",
|
|
|
act: "点击登录-res-error",
|
|
@@ -144,21 +191,33 @@ async function loginForuser() {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const [{ data: student }, { data: specialty }] = await Promise.all([
|
|
|
- getStudentInfoBySessionApi(),
|
|
|
- getStudentSpecialtyNameListApi(),
|
|
|
- ]);
|
|
|
- const user = {
|
|
|
- ...res.data.content,
|
|
|
- ...student,
|
|
|
- specialty: specialty.join(),
|
|
|
- schoolDomain: domain,
|
|
|
- };
|
|
|
-
|
|
|
- store.user = user;
|
|
|
- createUserDetailLog();
|
|
|
-
|
|
|
- void router.push({ name: "ChangePassword" });
|
|
|
+ try {
|
|
|
+ const [{ data: student }, { data: specialty }] = await Promise.all([
|
|
|
+ getStudentInfoBySessionApi(),
|
|
|
+ getStudentSpecialtyNameListApi(),
|
|
|
+ ]);
|
|
|
+ const user = {
|
|
|
+ ...res.data.content,
|
|
|
+ ...student,
|
|
|
+ specialty: specialty.join(),
|
|
|
+ schoolDomain: domain,
|
|
|
+ };
|
|
|
+
|
|
|
+ store.user = user;
|
|
|
+ createUserDetailLog();
|
|
|
+
|
|
|
+ void router.push({ name: "ChangePassword" });
|
|
|
+ } catch (error) {
|
|
|
+ logger({
|
|
|
+ cnl: ["local", "server"],
|
|
|
+ act: "登录失败",
|
|
|
+ dtl: "getStudentInfoBySession失败",
|
|
|
+ });
|
|
|
+ $message.error("获取学生信息失败,请重试!", {
|
|
|
+ duration: 15,
|
|
|
+ closable: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function closeApp() {
|
|
@@ -247,7 +306,10 @@ function closeApp() {
|
|
|
class="form-item-style"
|
|
|
style="height: 40px; margin-top: 0px"
|
|
|
>
|
|
|
- <!-- <GeeTest :reset="resetGeeTime" @onLoad="handleGtResult" /> -->
|
|
|
+ <GeeTest
|
|
|
+ :reset="resetGeeTime"
|
|
|
+ @onLoad="(v) => (captchaObj = v)"
|
|
|
+ />
|
|
|
</n-form-item>
|
|
|
|
|
|
<div
|