Compare commits

...

2 Commits

Author SHA1 Message Date
瓶中沙 239939373a 12345 2024-01-24 09:12:25 +08:00
瓶中沙 82f524b3b6 123 2024-01-24 09:00:48 +08:00
4 changed files with 17 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -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();
// stringheaderheaderkey"cdcm"
const cdcm = tokenInfo.slice(0, tokenInfo.length).toString()
return { cdcm };
} else {
localRemove("token");
}
}
@ -33,7 +34,7 @@ function getNeedToken() {
axios.interceptors.response.use(
(res) => {
// token
const ret = response.decode(new Uint8Array(res.data));
const ret = response.decode(new Uint8Array(res));
if(ret.code ===40100 || ret.code ===40101) {
localRemove("token");
ElMessage.closeAll();

View File

@ -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,7 +88,7 @@ export default {
},
});
onMounted(() => {
onMounted(async () => {
getSys();
});
const getSys = async () => {

View File

@ -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) {