Browse Source

feat: 禁用学生端登录时给出提示信息

chenhao 2 years ago
parent
commit
3b23fcf62a
1 changed files with 29 additions and 8 deletions
  1. 29 8
      src/features/UserLogin/UserLogin.vue

+ 29 - 8
src/features/UserLogin/UserLogin.vue

@@ -17,7 +17,7 @@ import { getScreenShot, isElectron } from "@/utils/nativeMethods";
 import ua from "@/utils/ua";
 import { decryptLogin, preloadResource } from "@/utils/utils";
 import { CloseCircleOutline, LockClosed, Person } from "@vicons/ionicons5";
-import { FormItemInst, FormRules } from "naive-ui";
+import { FormItemInst, FormRules, useDialog } from "naive-ui";
 import { onMounted, onUnmounted, watch } from "vue";
 import { useRouter } from "vue-router";
 import GeeTest from "./GeeTest.vue";
@@ -32,6 +32,8 @@ import { useNewVersion } from "./useNewVersion";
 import { useRemoteAppChecker } from "./useRemoteAppChecker";
 import { useVCamChecker } from "./useVCamChecker";
 
+const dialog = useDialog();
+
 const { addTimeout, addInterval } = useTimers();
 
 resetStore();
@@ -92,8 +94,26 @@ useExamShellStats();
 
 let isGeeTestEnabled = $ref(false);
 onMounted(async () => {
-  const conf = await getElectronConfig();
-  store.QECSConfig = conf;
+  try {
+    const conf = await getElectronConfig();
+    store.QECSConfig = conf;
+  } catch (error) {
+    console.error(error);
+  }
+
+  if (store.QECSConfig && !store.QECSConfig.LOGIN_SUPPORT.includes("NATIVE")) {
+    dialog.warning({
+      title: "提醒",
+      content: "当前版本已禁用,请根据学校通知下载新版考生端程序进行考试!",
+      positiveText: "确定",
+      maskClosable: false,
+      closeOnEsc: false,
+      closable: false,
+      onPositiveClick: () => {
+        closeApp("notSupport");
+      },
+    });
+  }
 
   isGeeTestEnabled = await getGeeTestConfig(store.QECSConfig.ROOT_ORG_ID);
 });
@@ -111,7 +131,7 @@ const backgroundUrl = $computed(
 const productName = $computed(
   () => QECSConfig.OE_STUDENT_SYS_NAME || "远程教育网络考试"
 );
-const allowLoginType = $computed(() => QECSConfig.LOGIN_TYPE ?? []);
+const allowLoginType = $computed(() => QECSConfig?.LOGIN_TYPE ?? []);
 
 const { newVersionAvailable, checkNewVersion } = useNewVersion();
 const { disableLoginBtnBecauseAppVersionChecker } =
@@ -388,12 +408,13 @@ async function afterLogin(loginRes: any) {
 }
 //#endregion
 
-function closeApp() {
+function closeApp(type: "exit" | "notSupport" = "exit") {
+  const isNotSupport = type === "notSupport";
   logger({
     pgu: "AUTO",
     cnl: ["local", "server"],
-    key: "退出应用",
-    act: "点击关闭按钮",
+    key: isNotSupport ? "学生端登录禁用" : "退出应用",
+    act: isNotSupport ? "学生端登录禁用,点击确定按钮" : "点击关闭按钮",
   });
   window.close();
 }
@@ -418,7 +439,7 @@ onUnmounted(() => $message.destroyAll());
         />
         <!-- 加上它,在logo加载失败的时候有用 -->
       </div>
-      <a class="close" @click="closeApp">关闭</a>
+      <a class="close" @click="closeApp()">关闭</a>
     </header>
   </div>