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() {
|
function getNeedToken() {
|
||||||
console.log(333, localGet("token"));
|
|
||||||
const ret_token = localGet("token");
|
const ret_token = localGet("token");
|
||||||
if (ret_token) {
|
if (ret_token && ret_token.timestamp) {
|
||||||
ret_token.timestamp = new Date().getTime();
|
ret_token.timestamp = new Date().getTime();
|
||||||
const tokenInfo = token.encode(ret_token).finish();
|
const tokenInfo = token.encode(ret_token).finish();
|
||||||
// 直接转换为string丢到header里,header的key为"cdcm"
|
// 直接转换为string丢到header里,header的key为"cdcm"
|
||||||
const cdcm = tokenInfo.slice(0, tokenInfo.length).toString()
|
const cdcm = tokenInfo.slice(0, tokenInfo.length).toString()
|
||||||
return { cdcm };
|
return { cdcm };
|
||||||
|
} else {
|
||||||
|
localRemove("token");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +34,7 @@ function getNeedToken() {
|
||||||
axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
(res) => {
|
(res) => {
|
||||||
// token过期
|
// token过期
|
||||||
const ret = response.decode(new Uint8Array(res.data));
|
const ret = response.decode(new Uint8Array(res));
|
||||||
if(ret.code ===40100 || ret.code ===40101) {
|
if(ret.code ===40100 || ret.code ===40101) {
|
||||||
localRemove("token");
|
localRemove("token");
|
||||||
ElMessage.closeAll();
|
ElMessage.closeAll();
|
||||||
|
|
|
@ -73,7 +73,8 @@ import { onMounted, reactive, ref, toRefs, nextTick } from "vue";
|
||||||
import infoApi from "@/api/infoApi.js";
|
import infoApi from "@/api/infoApi.js";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import * as echarts from "echarts";
|
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 {
|
export default {
|
||||||
name: "home",
|
name: "home",
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -87,7 +88,7 @@ export default {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
getSys();
|
getSys();
|
||||||
});
|
});
|
||||||
const getSys = async () => {
|
const getSys = async () => {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="middle-bottom"></div>
|
<div class="middle-bottom"></div>
|
||||||
<div class="right-bottom">
|
<div class="right-bottom">
|
||||||
<div class="title">数据控制器</div>
|
<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 label-position="top" :rules="rules" :model="ruleForm" ref="loginForm" class="login-form" size="large">
|
||||||
<el-form-item prop="username">
|
<el-form-item prop="username">
|
||||||
<el-input type="text" v-model.trim="ruleForm.username" autocomplete="off" placeholder="请输入账号">
|
<el-input type="text" v-model.trim="ruleForm.username" autocomplete="off" placeholder="请输入账号">
|
||||||
|
@ -37,13 +37,15 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { reactive, ref, toRefs } from "vue";
|
import { reactive, ref, toRefs, onMounted } from "vue";
|
||||||
import { localSet, localGet } from "@/utils";
|
import { localSet, localGet } from "@/utils";
|
||||||
import myApi from "@/api/myApi.js";
|
import myApi from "@/api/myApi.js";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { user, token, response } from '../proto/data/pd'
|
import { user, token, response } from '../proto/data/pd'
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import md5 from 'js-md5'
|
import md5 from 'js-md5'
|
||||||
|
import { localRemove, pathMap } from "@/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Login",
|
name: "Login",
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -63,6 +65,10 @@ export default {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
onMounted(() => {
|
||||||
|
localRemove("token");
|
||||||
|
|
||||||
|
});
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
loginForm.value.validate(async (valid) => {
|
loginForm.value.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
Loading…
Reference in New Issue