ref : 重构令牌管理逻辑,,统一状态码识别
This commit is contained in:
@@ -97,7 +97,7 @@ let tableColumns: ColumnsType = reactive([
|
||||
title: t('views.logManage.mml.logTime'),
|
||||
dataIndex: 'logTime',
|
||||
align: 'left',
|
||||
width: 150,
|
||||
width: 200,
|
||||
customRender(opt) {
|
||||
if (!opt.value) return '';
|
||||
return parseDateToStr(opt.value);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { message } from 'ant-design-vue/es';
|
||||
import { reactive, onMounted, computed, toRaw } from 'vue';
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
import { getCaptchaImage } from '@/api/login';
|
||||
import { getCaptchaImage } from '@/api/auth';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import useLayoutStore from '@/store/modules/layout';
|
||||
@@ -75,21 +75,28 @@ function fnFinish() {
|
||||
function fnGetCaptcha() {
|
||||
if (state.captchaClick) return;
|
||||
state.captchaClick = true;
|
||||
getCaptchaImage().then(res => {
|
||||
state.captchaClick = false;
|
||||
if (res.code != RESULT_CODE_SUCCESS) {
|
||||
message.warning(`${res.msg}`, 3);
|
||||
return;
|
||||
}
|
||||
state.captcha.enabled = Boolean(res.captchaEnabled);
|
||||
if (state.captcha.enabled) {
|
||||
state.captcha.codeImg = res.img;
|
||||
state.from.uuid = res.uuid;
|
||||
if (res.text) {
|
||||
state.from.code = res.text;
|
||||
getCaptchaImage()
|
||||
.then(res => {
|
||||
if (res.code !== RESULT_CODE_SUCCESS) {
|
||||
message.warning({
|
||||
content: `${res.msg}`,
|
||||
duration: 3,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
const { enabled, img, uuid } = res.data;
|
||||
state.captcha.enabled = Boolean(enabled);
|
||||
if (state.captcha.enabled) {
|
||||
state.captcha.codeImg = img;
|
||||
state.from.uuid = uuid;
|
||||
}
|
||||
if (res.data?.text) {
|
||||
state.from.code = res.data.text;
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
state.captchaClick = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 判断是否有背景地址
|
||||
|
||||
@@ -910,6 +910,7 @@ onMounted(() => {
|
||||
|
||||
<!-- 状态历史框 -->
|
||||
<HistoryModal
|
||||
v-if="neTypeAndId.length > 1"
|
||||
v-model:open="modalState.openByHistory"
|
||||
:title="t('views.neData.baseStation.history')"
|
||||
:ne-type="neTypeAndId[0]"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { GlobalFooter } from 'antdv-pro-layout';
|
||||
import { Modal, message } from 'ant-design-vue/es';
|
||||
import { computed, onMounted, reactive, toRaw } from 'vue';
|
||||
import { register } from '@/api/login';
|
||||
import { register } from '@/api/auth';
|
||||
import { regExpPasswd, regExpUserName } from '@/utils/regular-utils';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { stepState, fnToStepName } from '../hooks/useStep';
|
||||
import { Modal } from 'ant-design-vue/es';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { removeToken } from '@/plugins/auth-token';
|
||||
import { delAccessToken, delRefreshToken } from '@/plugins/auth-token';
|
||||
import { useRouter } from 'vue-router';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
@@ -56,7 +56,8 @@ function fnGuideDone() {
|
||||
bootloaderDone()
|
||||
.then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
removeToken();
|
||||
delAccessToken();
|
||||
delRefreshToken();
|
||||
useAppStore().bootloader = false;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
import { onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { TOKEN_RESPONSE_FIELD } from '@/constants/token-constants';
|
||||
import { getToken, setToken } from '@/plugins/auth-token';
|
||||
import { getAccessToken, setAccessToken } from '@/plugins/auth-token';
|
||||
import { bootloaderStart } from '@/api/system/quick-start/bootloader';
|
||||
import { fnToStepName } from '../hooks/useStep';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
@@ -19,11 +18,10 @@ function fnChangeLocale(e: any) {
|
||||
|
||||
/**引导开始 */
|
||||
function fnGuideStart() {
|
||||
if (getToken()) return;
|
||||
if (getAccessToken()) return;
|
||||
bootloaderStart().then(res => {
|
||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||
const token = res.data[TOKEN_RESPONSE_FIELD];
|
||||
setToken(token);
|
||||
setAccessToken(res.data.accessToken, res.data.refreshExpiresIn);
|
||||
} else {
|
||||
router.push({ name: 'Login' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user