Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
51c3a2a2f1
@ -121,7 +121,7 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
|||||||
options.loading && closeLoading(options) // 关闭loading
|
options.loading && closeLoading(options) // 关闭loading
|
||||||
|
|
||||||
if (response.config.responseType == 'json') {
|
if (response.config.responseType == 'json') {
|
||||||
if (response.data && response.data.code !== 200) {
|
if (response.data && response.data.code == 401) {
|
||||||
// if (response.data.code == 409) {
|
// if (response.data.code == 409) {
|
||||||
// if (!window.tokenRefreshing) {
|
// if (!window.tokenRefreshing) {
|
||||||
// window.tokenRefreshing = true
|
// window.tokenRefreshing = true
|
||||||
@ -161,21 +161,16 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
|||||||
// if (response.data.code == 302) {
|
// if (response.data.code == 302) {
|
||||||
// router.push({ path: response.data.data.routePath ?? '', name: response.data.data.routeName ?? '' })
|
// router.push({ path: response.data.data.routePath ?? '', name: response.data.data.routeName ?? '' })
|
||||||
// }
|
// }
|
||||||
if (response.data.code == 400) {
|
|
||||||
let routerPath = adminBaseRoute.path
|
// if (response.data.code == 401) {
|
||||||
userInfo.removeToken()
|
let routerPath = adminBaseRoute.path
|
||||||
routerPath += '/login'
|
userInfo.removeToken()
|
||||||
router.push({ path: routerPath })
|
routerPath += '/login'
|
||||||
}
|
router.push({ path: routerPath })
|
||||||
if (response.data.code == 401) {
|
// }
|
||||||
let routerPath = adminBaseRoute.path
|
|
||||||
userInfo.removeToken()
|
|
||||||
routerPath += '/login'
|
|
||||||
router.push({ path: routerPath })
|
|
||||||
}
|
|
||||||
// code不等于1, 页面then内的具体逻辑就不执行了
|
// code不等于1, 页面then内的具体逻辑就不执行了
|
||||||
return Promise.reject(response.data)
|
return Promise.reject(response.data)
|
||||||
} else if (options.showSuccessMessage && response.data && response.data.code == 1) {
|
} else if (options.showSuccessMessage && response.data && response.data.code == 200) {
|
||||||
ElNotification({
|
ElNotification({
|
||||||
message: response.data.msg ? response.data.msg : i18n.global.t('axios.Operation successful'),
|
message: response.data.msg ? response.data.msg : i18n.global.t('axios.Operation successful'),
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
@ -52,18 +52,12 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="state.showCaptcha" prop="captcha">
|
<el-form-item v-if="state.showCaptcha" prop="captcha">
|
||||||
<el-space>
|
<el-space>
|
||||||
<el-input
|
<el-input ref="captchaRef" v-model="form.code" type="text" :placeholder="t('login.Please input a captcha')">
|
||||||
ref="captchaRef"
|
|
||||||
v-model="form.code"
|
|
||||||
type="text"
|
|
||||||
:placeholder="t('login.Please input a captcha')"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Icon name="fa fa-unlock-alt" class="form-item-icon" size="16" color="var(--el-input-icon-color)" />
|
<Icon name="fa fa-unlock-alt" class="form-item-icon" size="16" color="var(--el-input-icon-color)" />
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<img class="captcha-img" @click.prevent="load()" :src="state.captcha" />
|
<img @click.prevent="load()" :src="state.captcha" />
|
||||||
</el-space>
|
</el-space>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-checkbox v-model="form.keep" :label="t('login.Hold session')" size="default"></el-checkbox> -->
|
<!-- <el-checkbox v-model="form.keep" :label="t('login.Hold session')" size="default"></el-checkbox> -->
|
||||||
@ -92,6 +86,7 @@ import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
|
|||||||
import { getCaptchaData } from '/@/api/common'
|
import { getCaptchaData } from '/@/api/common'
|
||||||
import * as pageBubble from '/@/utils/pageBubble'
|
import * as pageBubble from '/@/utils/pageBubble'
|
||||||
import type { FormInstance, InputInstance } from 'element-plus'
|
import type { FormInstance, InputInstance } from 'element-plus'
|
||||||
|
import { ElNotification } from 'element-plus'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { editDefaultLang } from '/@/lang/index'
|
import { editDefaultLang } from '/@/lang/index'
|
||||||
import { useConfig } from '/@/stores/config'
|
import { useConfig } from '/@/stores/config'
|
||||||
@ -133,7 +128,7 @@ const { t } = useI18n()
|
|||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
username: [buildValidatorData({ name: 'required', message: t('login.Please enter an account') }), buildValidatorData({ name: 'account' })],
|
username: [buildValidatorData({ name: 'required', message: t('login.Please enter an account') }), buildValidatorData({ name: 'account' })],
|
||||||
password: [buildValidatorData({ name: 'required', message: t('login.Please input a password') }), buildValidatorData({ name: 'password' })],
|
password: [buildValidatorData({ name: 'required', message: t('login.Please input a password') }), buildValidatorData({ name: 'password' })],
|
||||||
code: [buildValidatorData({ name: 'required', message: t('login.Please input a captcha') }), buildValidatorData({ name: 'required' })],
|
code: [buildValidatorData({ name: 'required', message: t('login.Please input a captcha') })],
|
||||||
})
|
})
|
||||||
|
|
||||||
const focusInput = () => {
|
const focusInput = () => {
|
||||||
@ -189,18 +184,26 @@ const onSubmit = () => {
|
|||||||
state.submitLoading = true
|
state.submitLoading = true
|
||||||
login(form)
|
login(form)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
adminInfo.dataFill({
|
if (res.code == 200) {
|
||||||
id: res.data.sysUser.id,
|
adminInfo.dataFill({
|
||||||
username: res.data.sysUser.account,
|
id: res.data.sysUser.id,
|
||||||
nickname: res.data.sysUser.userName,
|
username: res.data.sysUser.account,
|
||||||
avatar: '',
|
nickname: res.data.sysUser.userName,
|
||||||
last_login_time: '',
|
avatar: '',
|
||||||
token: res.data.token,
|
last_login_time: '',
|
||||||
refresh_token: '',
|
token: res.data.token,
|
||||||
// 是否是superAdmin,用于判定是否显示终端按钮等,不做任何权限判断
|
refresh_token: '',
|
||||||
super: false,
|
// 是否是superAdmin,用于判定是否显示终端按钮等,不做任何权限判断
|
||||||
})
|
super: false,
|
||||||
router.push({ path: adminBaseRoutePath })
|
})
|
||||||
|
router.push({ path: adminBaseRoutePath })
|
||||||
|
} else {
|
||||||
|
ElNotification({
|
||||||
|
message: res.msg,
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
load()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
state.submitLoading = false
|
state.submitLoading = false
|
||||||
|
Loading…
Reference in New Issue
Block a user