Compare commits
2 Commits
2b38ec4a7a
...
239939373a
Author | SHA1 | Date |
---|---|---|
瓶中沙 | 239939373a | |
瓶中沙 | 82f524b3b6 |
Binary file not shown.
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 9.8 KiB |
|
@ -17,14 +17,15 @@ axios.defaults.headers = getNeedToken();
|
|||
|
||||
|
||||
function getNeedToken() {
|
||||
console.log(333, localGet("token"));
|
||||
const ret_token = localGet("token");
|
||||
if (ret_token) {
|
||||
if (ret_token && ret_token.timestamp) {
|
||||
ret_token.timestamp = new Date().getTime();
|
||||
const tokenInfo = token.encode(ret_token).finish();
|
||||
// 直接转换为string丢到header里,header的key为"cdcm"
|
||||
const cdcm = tokenInfo.slice(0, tokenInfo.length).toString()
|
||||
return { cdcm };
|
||||
} else {
|
||||
localRemove("token");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,8 +33,8 @@ function getNeedToken() {
|
|||
// 请求拦截器,内部根据返回值,重新组装,统一管理。
|
||||
axios.interceptors.response.use(
|
||||
(res) => {
|
||||
// token过期
|
||||
const ret = response.decode(new Uint8Array(res.data));
|
||||
// token过期
|
||||
const ret = response.decode(new Uint8Array(res));
|
||||
if(ret.code ===40100 || ret.code ===40101) {
|
||||
localRemove("token");
|
||||
ElMessage.closeAll();
|
||||
|
|
|
@ -73,7 +73,8 @@ import { onMounted, reactive, ref, toRefs, nextTick } from "vue";
|
|||
import infoApi from "@/api/infoApi.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import * as echarts from "echarts";
|
||||
import { user, token, response, info } from '../proto/data/pd'
|
||||
import { user, token, response, info } from '../proto/data/pd';
|
||||
import myApi from "@/api/myApi.js";
|
||||
export default {
|
||||
name: "home",
|
||||
setup() {
|
||||
|
@ -87,8 +88,8 @@ export default {
|
|||
},
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getSys();
|
||||
onMounted(async () => {
|
||||
getSys();
|
||||
});
|
||||
const getSys = async () => {
|
||||
const res = await infoApi.getSys();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="middle-bottom"></div>
|
||||
<div class="right-bottom">
|
||||
<div class="title">数据控制器</div>
|
||||
<div class="s-title">登录LOGIN</div>
|
||||
<!-- <div class="s-title">登录LOGIN</div> -->
|
||||
<el-form label-position="top" :rules="rules" :model="ruleForm" ref="loginForm" class="login-form" size="large">
|
||||
<el-form-item prop="username">
|
||||
<el-input type="text" v-model.trim="ruleForm.username" autocomplete="off" placeholder="请输入账号">
|
||||
|
@ -37,13 +37,15 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { reactive, ref, toRefs } from "vue";
|
||||
import { reactive, ref, toRefs, onMounted } from "vue";
|
||||
import { localSet, localGet } from "@/utils";
|
||||
import myApi from "@/api/myApi.js";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { user, token, response } from '../proto/data/pd'
|
||||
import axios from "axios";
|
||||
import md5 from 'js-md5'
|
||||
import { localRemove, pathMap } from "@/utils";
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
setup() {
|
||||
|
@ -63,6 +65,10 @@ export default {
|
|||
],
|
||||
},
|
||||
});
|
||||
onMounted(() => {
|
||||
localRemove("token");
|
||||
|
||||
});
|
||||
const submitForm = async () => {
|
||||
loginForm.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
|
|
Loading…
Reference in New Issue