12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
- <template>
- <div class="home">
- <header class="header">
- <div class="school-logo">
- <img
- v-show="logoPath"
- class="logo-size"
- :src="logoPath"
- alt="school logo"
- style="
- background: linear-gradient(to bottom, #38f6f5 0%, #8efdf4 100%);
- "
- @load="(e) => (e.target.style = '')"
- />
- </div>
- <a
- class="close"
- style="border-bottom-left-radius: 6px;"
- @click="closeApp"
- >
- 关闭
- </a>
- </header>
- <div class="center">
- <div class="content">
- <div style="display: flex;">
- <a
- v-if="allowLoginType.includes('STUDENT_CODE')"
- key="STUDENT_CODE"
- :class="[
- 'qm-big-text',
- 'login-type',
- loginType === 'STUDENT_CODE' && 'active-type',
- allowLoginType.length === 1 && 'single-login-type',
- ]"
- style="border-top-left-radius: 6px;"
- @click="loginType = 'STUDENT_CODE'"
- >
- {{ QECSConfig.STUDENT_CODE_LOGIN_ALIAS }}
- </a>
- <a
- v-if="allowLoginType.includes('IDENTITY_NUMBER')"
- key="IDENTITY_NUMBER"
- :class="[
- 'qm-big-text',
- 'login-type',
- loginType !== 'STUDENT_CODE' && 'active-type',
- allowLoginType.length === 1 && 'single-login-type',
- ]"
- style="border-top-right-radius: 6px;"
- @click="loginType = 'STUDENT_IDENTITY_NUMBER'"
- >
- {{ QECSConfig.IDENTITY_NUMBER_LOGIN_ALIAS }}
- </a>
- <a
- v-if="allowLoginType.length === 0"
- key="loading"
- :class="['qm-big-text', 'login-type']"
- >
- loading...
- </a>
- </div>
- <div class="qm-title-text" style="margin: 40px 0 20px 0;">
- {{ productName }}
- </div>
- <div style="margin: 0 40px 40px 40px;">
- <i-form ref="loginForm" :model="loginForm" :rules="loginFormRule">
- <i-form-item
- prop="accountValue"
- style="margin-bottom: 30px; height: 42px;"
- >
- <i-input
- v-model="loginForm.accountValue"
- type="text"
- size="large"
- @on-blur="loginForm.accountValue && (initVerifyCode = true)"
- >
- <i-icon slot="prepend" type="ios-person"></i-icon>
- </i-input>
- </i-form-item>
- <i-form-item
- prop="password"
- style="margin-bottom: 30px; height: 42px;"
- >
- <i-input
- v-model="loginForm.password"
- type="password"
- size="large"
- @on-enter="loginForuser"
- @on-blur="loginForm.accountValue && (initVerifyCode = true)"
- >
- <i-icon slot="prepend" type="ios-lock"></i-icon>
- </i-input>
- </i-form-item>
- <i-form-item
- prop="verifyCode"
- style="margin-bottom: 30px; height: 42px;"
- >
- <VerifyCode
- :account-value="loginForm.accountValue"
- :init="initVerifyCode"
- @calcVerify="calcVerify"
- />
- </i-form-item>
- <i-form-item style="position: relative;">
- <div
- v-if="errorInfo !== ''"
- style="position: absolute; top: -37px; width: 100%;"
- >
- <i-alert type="error" show-icon>{{ errorInfo }}</i-alert>
- </div>
- <i-button
- size="large"
- class="qm-primary-button"
- style="margin-top: 10px;"
- long
- :disabled="disableLoginBtn"
- :loading="loginBtnLoading"
- @click="loginForuser"
- >
- {{ newVersionAvailable ? "点击更新版本" : "登录" }}
- </i-button>
- </i-form-item>
- </i-form>
- </div>
- </div>
- </div>
- <footer class="footer">
- <div style="position: absolute; right: 20px; bottom: 20px;">
- 版本: {{ VUE_APP_GIT_REPO_VERSION }}
- </div>
- <DevTools />
- </footer>
- </div>
- </template>
- <script>
- import moment from "moment";
- import { mapMutations } from "vuex";
- import { FACE_API_MODEL_PATH } from "@/constants/constants";
- import DevTools from "./DevTools.vue";
- import nativeExe, { fileExists } from "@/utils/nativeExe";
- import {
- EPCC_DOMAIN,
- VUE_APP_CONFIG_FILE_SEVER_URL,
- } from "@/constants/constants";
- import UA, { chromeUA } from "@/utils/ua.js";
- import {
- createLog,
- createUserDetailLog,
- createEncryptLog,
- } from "@/utils/logger";
- import VerifyCode from "./VerifyCode.vue";
- // 检测devtools. 仅在chrome 72+ 有效。
- let element = new Image();
- Object.defineProperty(element, "id", {
- get: function () {
- // console.log("trigger devtools log");
- window._hmt.push([
- "_trackEvent",
- "控制台打开",
- window.location.href,
- "|||" +
- localStorage.getItem("domain") +
- "|||" +
- localStorage.getItem("key"),
- ]);
- return null;
- },
- });
- /**
- * 在任何组件需要强制退出,做以下步骤
- * 1. this.$Message.info()
- * 2. this.$router.push("/login"+domain);
- * 因为在/login里会删除localStorage的token,而在router.beforeEach会检查是否有token,达到退出的目的。
- */
- export default {
- name: "Login",
- components: {
- DevTools,
- VerifyCode,
- },
- data() {
- return {
- domainInUrl:
- this.$route.params.domain ||
- window.location.hostname.split(".")[0] + ".ecs.qmth.com.cn",
- QECSConfig: {},
- loginType: "STUDENT_CODE",
- errorInfo: "",
- loginForm: {
- accountValue: "",
- password: "",
- verifyCode: "",
- tid: "",
- // result: "",
- },
- loginFormRule: {
- accountValue: [
- {
- required: true,
- message: "请填写登录账号",
- trigger: "blur",
- },
- ],
- password: [
- {
- required: true,
- message: "请填写密码",
- trigger: "blur",
- },
- ],
- verifyCode: [
- {
- required: true,
- message: "请填写计算结果",
- trigger: "blur",
- type: "number",
- },
- {
- type: "number",
- asyncValidator: (rule, value) => {
- return new Promise((resolve, reject) => {
- if (value < -999 || value > 999) {
- reject("验证码长度不对"); // reject with error message
- } else {
- resolve();
- }
- });
- },
- message: "验证码长度不对",
- trigger: "blur",
- },
- ],
- },
- loginBtnLoading: false,
- isElectron: true,
- disableLoginBtnBecauseRemoteApp: true,
- disableLoginBtnBecauseVCam: true,
- disableLoginBtnBecauseAppVersionChecker: false,
- disableLoginBtnBecauseRefreshServiceWorker: false,
- disableLoginBtnBecauseNotAllowedNative: true,
- newVersionAvailable: false,
- VUE_APP_GIT_REPO_VERSION: process.env.VUE_APP_GIT_REPO_VERSION,
- initVerifyCode: false,
- };
- },
- computed: {
- logoPath() {
- // "!/progressive/true/format/webp"
- return this.QECSConfig.LOGO_FILE_URL ? this.QECSConfig.LOGO_FILE_URL : "";
- },
- productName() {
- return this.QECSConfig.OE_STUDENT_SYS_NAME || "远程教育网络考试";
- },
- allowLoginType() {
- return (
- (this.QECSConfig.LOGIN_TYPE && this.QECSConfig.LOGIN_TYPE.split(",")) ||
- []
- );
- },
- schoolDomain() {
- const domain = this.domainInUrl;
- if (!domain || !domain.includes("qmth.com.cn")) {
- this.$Message.error({
- content: "机构地址出错,请关闭程序后再登录。",
- duration: 15,
- closable: true,
- });
- }
- return domain;
- },
- isEPCC() {
- return this.schoolDomain === EPCC_DOMAIN;
- },
- usernameInputPlaceholder() {
- if (this.loginType === "STUDENT_CODE") {
- return "请输入学号";
- } else {
- return "请输入身份证号";
- }
- },
- passwordInputPlaceholder() {
- if (this.loginType === "STUDENT_CODE") {
- return "初始密码为身份证号后6位";
- } else {
- return "初始密码为身份证号后6位";
- }
- },
- disableLoginBtn() {
- // console.log(
- // this.isElectron,
- // this.disableLoginBtnBecauseRemoteApp,
- // this.disableLoginBtnBecauseVCam,
- // this.disableLoginBtnBecauseAppVersionChecker
- // );
- return (
- (this.isElectron &&
- (this.disableLoginBtnBecauseRemoteApp ||
- this.disableLoginBtnBecauseVCam)) ||
- this.disableLoginBtnBecauseAppVersionChecker ||
- this.disableLoginBtnBecauseRefreshServiceWorker ||
- this.disableLoginBtnBecauseNotAllowedNative
- );
- },
- },
- async mounted() {
- // this.testServiceWorker();
- this.examShellStats();
- // await this.checkNewVersion();
- if (localStorage.getItem("__swReload")) {
- localStorage.removeItem("__swReload");
- this.$Message.info({
- content: "正在更新版本...",
- });
- this.disableLoginBtnBecauseRefreshServiceWorker = true;
- await new Promise((resolve) => {
- setTimeout(() => {
- resolve();
- }, 2000);
- });
- location.reload(true);
- }
- // manual precache for models
- fetch(
- FACE_API_MODEL_PATH + "tiny_face_detector_model-weights_manifest.json"
- );
- fetch(FACE_API_MODEL_PATH + "face_landmark_68_model-weights_manifest.json");
- fetch(FACE_API_MODEL_PATH + "face_expression_model-weights_manifest.json");
- // alread precached
- // fetch("/models/tiny_face_detector_model-shard1");
- // fetch("/models/face_landmark_68_model-shard1");
- // this.checkNewVersionInterval = setInterval(() => {
- // if (window.__newSWAvailable) {
- // this.newVersionAvailable = true;
- // }
- // }, 1000);
- this.checkNewVersionListener = document.addEventListener(
- "__newSWAvailable",
- () => {
- this.newVersionAvailable = true;
- },
- { once: true }
- );
- if (this.isEPCC) {
- const redirectUrl = new URLSearchParams(location.search).get(
- "redirectUrl"
- );
- if (redirectUrl) {
- sessionStorage.setItem("redirectUrl", redirectUrl);
- }
- this.login();
- }
- // 上传本机加密日志
- this.uploadLogInterval = setInterval(() => createEncryptLog(), 5 * 1000);
- },
- async created() {
- createLog({
- currentPage: "登录页面",
- action: "page created",
- UA: navigator.userAgent,
- });
- // 测试log顺序
- // createLog({
- // currentPage: "登录页面2",
- // action: "page created",
- // UA: navigator.userAgent,
- // });
- if (navigator.connection) {
- console.log("UA: ", navigator.userAgent);
- console.log(
- "_trackEvent",
- "登录页面",
- `当前网速: ${Number(navigator.connection.downlink).toPrecision(
- 1
- )}Mib; 网络延迟: ${Number(navigator.connection.rtt).toPrecision(1)}ms`
- );
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- `当前网速: ${Number(navigator.connection.downlink).toPrecision(
- 1
- )}Mib; 网络延迟: ${Number(navigator.connection.rtt).toPrecision(1)}ms`,
- ]);
- }
- if (this.isEPCC) {
- this.$Spin.show({
- render: () => {
- return <div style="font-size: 44px">正在登录...</div>;
- },
- });
- }
- this.isElectron = typeof nodeRequire != "undefined";
- if (
- navigator.userAgent.indexOf("WOW64") != -1 ||
- navigator.userAgent.indexOf("Win64") != -1
- ) {
- window._hmt.push(["_trackEvent", "登录页面", "64Bit OS"]);
- } else {
- window._hmt.push(["_trackEvent", "登录页面", "非64Bit OS"]);
- }
- this.$Message.config({
- duration: 15,
- size: "large",
- closable: true, // 没有影响到所有的组件。。。 https://github.com/iview/iview/issues/2962
- });
- window.sessionStorage.removeItem("token");
- window.sessionStorage.clear();
- window.localStorage.removeItem("key");
- if (localStorage.getItem("user-for-reload")) {
- const lsUser = JSON.parse(localStorage.getItem("user-for-reload"));
- this.loginForm.accountValue =
- process.env.NODE_ENV === "production"
- ? ""
- : lsUser.studentCode ||
- (lsUser.studentCodeList && lsUser.studentCodeList[0]);
- this.loginForm.password =
- process.env.NODE_ENV === "production" ? "" : "180613";
- }
- if (
- [
- "xjtu.ecs.qmth.com.cn",
- "ccnu.ecs.qmth.com.cn",
- "snnu.ecs.qmth.com.cn",
- "swjtu.ecs.qmth.com.cn",
- ].includes(this.$route.params.domain)
- ) {
- if (
- typeof nodeRequire == "undefined" ||
- !window.nodeRequire("fs").existsSync("multiCamera.exe")
- ) {
- this.disableLoginBtnBecauseAppVersionChecker = true;
- this.$Message.error({
- content: "请与学校申请最新的客户端,进行考试!",
- duration: 2 * 24 * 60 * 60,
- });
- }
- }
- if (["cup.ecs.qmth.com.cn"].includes(this.$route.params.domain)) {
- // console.log(UA.getBrowser(), chromeUA);
- if (
- UA.getBrowser().name !== "electron-exam-shell" ||
- (UA.getBrowser().major !== "2" && UA.getBrowser().major !== "1") ||
- chromeUA.major < "58"
- ) {
- this.disableLoginBtnBecauseAppVersionChecker = true;
- this.$Message.error({
- content: "请与学校申请最新的客户端,进行考试!",
- duration: 2 * 24 * 60 * 60,
- });
- }
- }
- // if (
- // ["cugr.ecs.qmth.com.cn", "sdu.ecs.qmth.com.cn"].includes(
- // this.$route.params.domain
- // )
- // ) {
- // // console.log(UA.getBrowser(), chromeUA);
- // if (
- // UA.getBrowser().name !== "electron-exam-shell" ||
- // UA.getBrowser().major !== "2" ||
- // chromeUA.major < "76"
- // ) {
- // this.disableLoginBtnBecauseAppVersionChecker = true;
- // this.$Message.error({
- // content: "请与学校申请最新的客户端,进行考试!",
- // duration: 2 * 24 * 60 * 60,
- // });
- // }
- // }
- await this.checkElectronConfig();
- await this.checkVCam();
- await this.checkAllowedClient();
- if (
- this.allowLoginType.length === 1 &&
- this.allowLoginType[0] === "IDENTITY_NUMBER"
- ) {
- this.loginType = "STUDENT_IDENTITY_NUMBER";
- }
- },
- beforeDestroy() {
- clearTimeout(this.loginTimeout);
- clearInterval(this.uploadLogInterval);
- // clearInterval(this.checkNewVersionInterval);
- document.removeEventListener(
- "__newSWAvailable",
- this.checkNewVersionListener
- );
- },
- methods: {
- ...mapMutations(["updateUser", "updateTimeDifference", "updateQECSConfig"]),
- testServiceWorker() {
- if ("serviceWorker" in navigator) {
- // Register service worker
- navigator.serviceWorker
- .register("/service-worker-test.js")
- .then(function (reg) {
- console.log("Registration OK!. Scope is " + reg.scope);
- })
- .catch(function (err) {
- console.error("Registration FAILED! " + err);
- });
- }
- },
- async loginForuser() {
- // 供user点击的 login 方法。主要是保护 login 方法,不因为user重复点击,多个请求不按预期时间进行。
- createLog({ currentPage: "登录页面", action: "点击登录按钮" });
- if (this.loginBtnLoading) {
- return;
- }
- this.loginBtnLoading = true;
- const before = Date.now();
- try {
- await this.login();
- } finally {
- const end = Date.now();
- this.loginTimeout = setTimeout(() => {
- this.loginBtnLoading = false;
- }, 10 * 1000 - (end - before));
- }
- },
- async login() {
- // 测试 createLog 在网络堵塞的情况下,是否会堵塞页面
- // alert("haha");
- createLog({
- currentPage: "登录页面--login clicked",
- action: "page created",
- UA: navigator.userAgent,
- });
- // alert("haha end");
- this.errorInfo = "";
- // epcc立即登录
- if (!this.isEPCC && this.disableLoginBtn) {
- return;
- }
- try {
- const hasNewVersion = await this.checkNewVersion();
- if (hasNewVersion) return;
- } catch (error) {
- console.log("检测新版本出错");
- }
- let loginResponse;
- if (!this.isEPCC) {
- // https://www.cnblogs.com/weiqinl/p/6708993.html
- const valid = await this.$refs.loginForm.validate();
- if (!valid) {
- return;
- }
- let repPara = this.loginForm;
- // 以下网络请求失败,直接报网络异常错误
- loginResponse = await this.$http.post(
- "/api/ecs_core/verifyCode/login",
- {
- ...repPara,
- accountType: this.loginType,
- domain: this.schoolDomain,
- rootOrgId: this.QECSConfig.ROOT_ORG_ID,
- alwaysOK: true,
- }
- );
- } else {
- loginResponse = await this.epccLogin();
- if (!loginResponse) {
- return;
- } else {
- loginResponse.data = { content: loginResponse.data, code: "200" }; // 和老接口的always ok保持一致
- }
- }
- let data = loginResponse.data;
- // if (
- // Math.abs() >
- // 5 * 60 * 1000
- // ) {
- // window._hmt.push(["_trackEvent", "登录页面", "本机时间误差过大"]);
- // this.$Message.error({
- // content: "与服务器时间差异超过5分钟,请校准本机时间之后再重试!",
- // duration: 30
- // });
- // throw new Error("与服务器时间差异超过5分钟,请校准本机时间之后再重试!");
- // }
- this.updateTimeDifference(
- moment(loginResponse.headers.date).diff(moment())
- );
- this.initVerifyCode = false;
- this.$nextTick(() => (this.initVerifyCode = true));
- if (data.code == "200") {
- data = data.content;
- this.errorInfo = "";
- //缓存用户信息
- window.sessionStorage.setItem("token", data.token);
- window.localStorage.setItem("key", data.key);
- window.localStorage.setItem("domain", this.schoolDomain);
- try {
- const student = (
- await this.$http.get(
- "/api/ecs_core/student/getStudentInfoBySession"
- )
- ).data;
- const specialty = (
- await this.$http.get(
- "/api/ecs_exam_work/exam_student/specialtyNameList/"
- )
- ).data;
- const user = {
- ...data,
- ...student,
- specialty: specialty.join(),
- schoolDomain: this.schoolDomain,
- };
- this.updateUser(user);
- window.localStorage.setItem("user-for-reload", JSON.stringify(user));
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "登录",
- this.$route.query.LogoutReason,
- ]);
- const alreadyInExam = await this.checkExamInProgress();
- window._hmt.push(["_trackEvent", "登录页面", "登录成功"]);
- createUserDetailLog({ action: "登录成功" });
- if (alreadyInExam) {
- this.logger({ action: "断点续考", detail: "登录页面" });
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "断点续考",
- "重新登录",
- ]);
- return;
- }
- this.$router.push("/online-exam");
- let userIds = JSON.parse(localStorage.getItem("userIds"));
- userIds = [...new Set(userIds).add(user.id)];
- localStorage.setItem("userIds", JSON.stringify(userIds));
- // 学习中心机器
- // (JSON.parse(localStorage.getItem("userIds")) || []).length > 5;
- this.$Spin.hide();
- } catch (error) {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "登录失败",
- "getStudentInfoBySession失败",
- ]);
- this.logger({ action: "登录失败" });
- this.$Message.error({
- content: "获取学生信息失败,请重试!",
- duration: 15,
- closable: true,
- });
- if (this.isEPCC) {
- this.$Spin.hide();
- this.logout();
- }
- }
- } else {
- window._hmt.push(["_trackEvent", "登录页面", "登录失败", data.desc]);
- createLog({ currentPage: "登录页面", action: "登录失败" });
- this.errorInfo = data.desc;
- }
- },
- async checkNewVersion() {
- let myHeaders = new Headers();
- myHeaders.append("Content-Type", "application/javascript");
- myHeaders.append("Cache-Control", "no-cache");
- const response = await fetch(
- document.scripts[document.scripts.length - 1].src + "?x" + Date.now(),
- {
- method: process.env.NODE_ENV === "development" ? "GET" : "HEAD",
- headers: myHeaders,
- }
- );
- // 给后台更多时间去处理 resource/uuid.js 的请求
- await new Promise((resolve) => setTimeout(() => resolve(), 1500));
- if (!response.ok || this.newVersionAvailable) {
- if (
- response.ok &&
- this.newVersionAvailable &&
- localStorage.getItem("__swReload")
- ) {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "service worker刷新失败",
- ]);
- this.$Message.destroy();
- this.$Message.info({
- content: "请重新打开程序。",
- duration: 2 * 24 * 60 * 60,
- });
- return true;
- }
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "新版本发布后,客户端自动刷新",
- ]);
- this.$Message.info({
- content: "正在获取新版本...",
- });
- localStorage.setItem("__swReload", "anything");
- this.disableLoginBtnBecauseRefreshServiceWorker = true;
- await new Promise((resolve) => {
- setTimeout(() => {
- resolve();
- }, 1000);
- });
- location.reload(true);
- return true;
- }
- },
- async checkElectronConfig() {
- try {
- const fileSever = VUE_APP_CONFIG_FILE_SEVER_URL;
- const res = await fetch(
- fileSever +
- "/org_properties/byOrgDomain/" +
- this.domainInUrl +
- "/studentClientConfig.json" +
- "?" +
- Date.now() +
- Math.random()
- );
- if (res.ok) {
- const json = await res.json();
- this.QECSConfig = json;
- this.updateQECSConfig(json);
- } else {
- this.$Message.error({
- content: "获取远程配置文件出错,请重新打开程序!",
- duration: 15,
- closable: true,
- });
- return;
- }
- } catch (e) {
- this.$Message.error({
- content: "获取远程配置文件出错,请重新打开程序!",
- duration: 15,
- closable: true,
- });
- return;
- }
- await this.checkRemoteApp();
- },
- async checkRemoteApp() {
- if (typeof nodeRequire == "undefined") {
- return;
- }
- async function checkRemoteAppTxt() {
- let applicationNames;
- try {
- const fs = window.nodeRequire("fs");
- try {
- applicationNames = fs.readFileSync(
- "remoteApplication.txt",
- "utf-8"
- );
- } catch (error) {
- console.log(error);
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "读取remoteApplication.txt出错--0",
- ]);
- await new Promise((resolve2) => setTimeout(() => resolve2(), 3000));
- applicationNames = fs.readFileSync(
- "remoteApplication.txt",
- "utf-8"
- );
- }
- } catch (error) {
- console.log(error);
- createLog({
- currentPage: "登录页面",
- errorType: "e-01",
- error: error.message,
- detail: applicationNames,
- });
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "读取remoteApplication.txt出错",
- ]);
- this.$Message.error({
- content: "系统检测出错(e-01),请退出程序后重试!",
- duration: 2 * 24 * 60 * 60,
- });
- return;
- }
- if (applicationNames && applicationNames.trim()) {
- let names = applicationNames
- .replace("qq", "QQ")
- .replace("teamviewer", "TeamViewer")
- .replace("lookmypc", "LookMyPC")
- .replace("xt", "协通")
- .replace("winaw32", "Symantec PCAnywhere")
- .replace("pcaquickconnect", "Symantec PCAnywhere")
- .replace("sessioncontroller", "Symantec PCAnywhere")
- .replace(/sunloginclient/gi, "向日葵")
- .replace(/sunloginremote/gi, "向日葵")
- .replace("wemeetapp", "腾讯会议")
- .replace("wechat", "微信");
- names = [...new Set(names.split(",").map((v) => v.trim()))].join(
- ","
- );
- this.disableLoginBtnBecauseRemoteApp = true;
- this.$Message.info({
- content: "在考试期间,请关掉" + names + "软件,诚信考试。",
- duration: 2 * 24 * 60 * 60,
- });
- } else {
- this.disableLoginBtnBecauseRemoteApp = false;
- }
- }
- //如果配置中配置了 DISABLE_REMOTE_ASSISTANCE
- if (
- this.QECSConfig.PREVENT_CHEATING_CONFIG.includes(
- "DISABLE_REMOTE_ASSISTANCE"
- )
- ) {
- let exe = "Project1.exe";
- if (fileExists("Project2.exe")) {
- const remoteAppName =
- "qq;teamviewer;lookmypc;xt;winaw32;pcaquickconnect;sessioncontroller;sunloginclient;sunloginremote;wemeetapp;wechat";
- exe = `Project2.exe "${remoteAppName}" `;
- }
- await nativeExe(exe, checkRemoteAppTxt.bind(this));
- } else {
- this.disableLoginBtnBecauseRemoteApp = false;
- }
- },
- async checkVCam() {
- if (typeof nodeRequire == "undefined") {
- return;
- }
- const vcamList = [
- "17GuaGua Cam",
- "91KBOX",
- // "ASUS Virtual Camera",
- "e2eSoft iVCam",
- "e2eSoft VCam",
- "FaceRig Virtual Camera",
- // "Lenovo Virtual Camera",
- "MagicCamera Capture",
- "MeiSe",
- "Virtual Cam",
- "YY伴侣",
- "WebcamMax Capture",
- "Wecam",
- "Vcam ",
- "softcam",
- "Vandate Virtual Camera",
- "video2webcam",
- "VCDCut Pro",
- "9158虚拟视频",
- "9158Capture",
- "Insta360 Virtual Camera",
- "无他直播伴侣PC客户端",
- "无他相机电脑版",
- "mobiola webcamera",
- "艾米秀宝(ImiShowBox)",
- "video2Webcam",
- "飞翔虚拟视频",
- "魔力秀",
- "YY开播",
- "无他伴侣",
- "视频连麦",
- "酷狗直播伴侣",
- ];
- async function checkVCamTxt() {
- let applicationNames;
- try {
- const fs = window.nodeRequire("fs");
- try {
- applicationNames = fs.readFileSync("CameraInfo.txt", "utf-8");
- } catch (error) {
- console.log(error);
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "CameraInfo.txt出错--0",
- ]);
- await new Promise((resolve2) => setTimeout(() => resolve2(), 3000));
- applicationNames = fs.readFileSync("CameraInfo.txt", "utf-8");
- }
- } catch (error) {
- console.log(error);
- createLog({
- currentPage: "登录页面",
- errorType: "e-02",
- error: error.message,
- detail: applicationNames,
- });
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "读取CameraInfo.txt出错",
- ]);
- this.$Message.error({
- content: "系统检测出错(e-02),请退出程序后重试!",
- duration: 2 * 24 * 60 * 60,
- });
- return;
- }
- this.disableLoginBtnBecauseVCam = false;
- if (applicationNames && applicationNames.trim()) {
- for (const vc of vcamList) {
- if (applicationNames.toUpperCase().includes(vc.toUpperCase())) {
- this.disableLoginBtnBecauseVCam = true;
- this.$Message.info({
- content:
- "在考试期间,请关掉" + "虚拟摄像头" + "软件,诚信考试。",
- duration: 2 * 24 * 60 * 60,
- });
- console.log(applicationNames);
- }
- }
- }
- }
- //如果配置中配置了 DISABLE_VIRTUAL_CAMERA
- if (
- this.QECSConfig.PREVENT_CHEATING_CONFIG.includes(
- "DISABLE_VIRTUAL_CAMERA"
- )
- ) {
- await nativeExe("multiCamera.exe", checkVCamTxt.bind(this));
- } else {
- this.disableLoginBtnBecauseVCam = false;
- }
- },
- async checkAllowedClient() {
- if (process.env.VUE_APP_SKIP_CHECK_NATIVE === "true") {
- console.log(
- "环境检查: process.env.VUE_APP_SKIP_CHECK_NATIVE === " +
- process.env.VUE_APP_SKIP_CHECK_NATIVE,
- " 允许浏览器访问"
- );
- this.disableLoginBtnBecauseNotAllowedNative = false;
- return;
- }
- // if (!this.FE_FEATURE_ALLOW_CHECK) {
- // this.disableLoginBtnBecauseNotAllowedNative = false;
- // return;
- // }
- /**
- * 本应用仅处理学生端的请求。不做跳转,不管浏览器类型。
- * 允许NATIVE/允许BROWSER,在以下场景中能访问:学生端/移动端浏览器
- */
- // if (
- // this.QECSConfig.LOGIN_SUPPORT.includes("BROWSER") &&
- // this.QECSConfig.LOGIN_SUPPORT.includes("NATIVE")
- // ) {
- // // FIXME: 暂时允许选择浏览器的可以在浏览器中访问
- // this.disableLoginBtnBecauseNotAllowedNative = false;
- // return;
- // } else
- if (this.QECSConfig.LOGIN_SUPPORT.includes("NATIVE")) {
- // 检测是否是学生端。 检测是否有node。检测是否能node调用。
- const hasShell = UA.getBrowser().name === "electron-exam-shell";
- const hasNode = typeof nodeRequire !== "undefined";
- let hasFs = false;
- let hasReadFileSync = false;
- if (hasShell && hasNode) {
- const fs = window.nodeRequire("fs");
- if (fs && typeof fs.readFileSync === "function") {
- hasFs = true;
- hasReadFileSync = true;
- this.disableLoginBtnBecauseNotAllowedNative = false;
- }
- }
- if (this.disableLoginBtnBecauseNotAllowedNative) {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "不允许访问-" +
- JSON.stringify({
- hasShell,
- hasNode,
- hasFs,
- hasReadFileSync,
- }),
- ]);
- this.$Message.error({
- content: "请与学校申请最新的客户端,进行考试!",
- duration: 2 * 24 * 60 * 60,
- });
- }
- // } else if (this.QECSConfig.LOGIN_SUPPORT.includes("BROWSER")) {
- // const hasShell = UA.getBrowser().name === "electron-exam-shell";
- // if (hasShell) {
- // if (this.disableLoginBtnBecauseNotAllowedNative) {
- // window._hmt.push([
- // "_trackEvent",
- // "登录页面",
- // "不允许访问-不允许在考生端中访问只设定移动端浏览器访问的设置",
- // ]);
- // this.$Message.error({
- // content: "本考试不支持在考生端中进行!",
- // duration: 2 * 24 * 60 * 60,
- // });
- // }
- // }
- // // TODO: redirect to wap site
- // // if(chromeUA.major < "66") { } // 到移动端去判断
- // return;
- } else {
- this.$Message.error({
- content: "本考试不支持在考生端中进行!",
- duration: 2 * 24 * 60 * 60,
- });
- }
- },
- closeApp() {
- console.log("关闭应用");
- window.close();
- },
- examShellStats() {
- const shellVersion = window.navigator.userAgent
- .split(" ")
- .find((v) => v.startsWith("electron-exam-shell/"));
- const chromeVersion = window.navigator.userAgent
- .split(" ")
- .find((v) => v.startsWith("Chrome/"));
- if (shellVersion) {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "学生端版本",
- shellVersion + "/" + chromeVersion,
- ]);
- } else {
- if (chromeVersion) {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "学生端版本/chrome",
- chromeVersion,
- ]);
- } else {
- window._hmt.push([
- "_trackEvent",
- "登录页面",
- "学生端版本/其他浏览器",
- window.navigator.userAgent,
- ]);
- }
- }
- },
- async epccLogin() {
- const {
- accountType,
- accountValue,
- rootOrgId,
- appId,
- timestamp,
- token,
- redirectUrl,
- } = this.$route.query;
- if (
- accountType &&
- accountValue &&
- rootOrgId &&
- appId &&
- timestamp &&
- token &&
- redirectUrl
- ) {
- try {
- const response = await this.$http.post(
- "/api/ecs_core/auth/thirdPartyStudentAccess" + location.search
- );
- return response;
- } catch (error) {
- window._hmt.push(["_trackEvent", "第三方登录页面", "接口出错", ""]);
- this.$Spin.hide();
- this.logout();
- }
- } else {
- this.$Spin.hide();
- this.logout();
- }
- },
- calcVerify({ uuid, verifyCode }) {
- // console.log(uuid, verifyCode);
- this.loginForm.tid = uuid;
- this.loginForm.verifyCode = verifyCode;
- },
- },
- };
- </script>
- <style scoped>
- .home {
- display: flex;
- flex-direction: column;
- height: 100vh;
- }
- .school-logo {
- justify-self: flex-start;
- margin-left: 100px;
- }
- .logo-size {
- height: 100px;
- width: 400px;
- object-fit: cover;
- }
- .header {
- min-height: 120px;
- display: grid;
- align-items: center;
- justify-items: center;
- }
- .center {
- background-image: url("https://cdn.qmth.com.cn/ui/ecs-client-bg.jpg!/progressive/true");
- background-position: center;
- background-repeat: no-repeat;
- background-size: cover;
- width: 100vw;
- min-height: 600px;
- }
- .content {
- margin-top: 100px;
- margin-left: 65%;
- width: 300px;
- border-radius: 6px;
- background-color: white;
- display: grid;
- grid-template-areas: "";
- }
- .login-type {
- flex: 1;
- line-height: 40px;
- background-color: #eeeeee;
- }
- .active-type {
- background-color: #ffffff;
- }
- .single-login-type {
- border-top-left-radius: 6px;
- border-top-right-radius: 6px;
- }
- .close {
- position: absolute;
- top: 0;
- right: 0;
- background-color: #eeeeee;
- color: #999999;
- width: 80px;
- height: 40px;
- line-height: 40px;
- }
- .close:hover {
- color: #444444;
- }
- .footer {
- position: relative;
- }
- </style>
- <style>
- .ivu-message-notice-content-text {
- font-size: 32px;
- }
- .ivu-message-notice-content-text i.ivu-icon {
- font-size: 32px;
- }
- </style>
|