!5 修复登出账号、修改密码等操作会清除uuid的bug 感谢大佬ray 提出的pr

Merge pull request !5 from master
master
学习很差啦 2021-12-30 03:06:29 +00:00 committed by Gitee
commit 1fa264b0bf
2 changed files with 7 additions and 9 deletions

View File

@ -5,7 +5,6 @@
</template>
<script>
import {v4 as uuidv4} from 'uuid';
import {getCategoryTree} from '@/api/goods.js'
export default {
updated() {
@ -17,13 +16,7 @@ export default {
})
}
},
mounted() {
let uuid = this.getStore('uuid');
if (!uuid) {
uuid = uuidv4();
this.setStore('uuid', uuid);
}
},
};
</script>

View File

@ -4,6 +4,7 @@ import { router } from "../router/index";
import { Message } from "view-design";
import Cookies from "js-cookie";
import { handleRefreshToken } from "../api/index";
import {v4 as uuidv4} from 'uuid';
// 统一请求路径前缀
export const commonUrl =
@ -29,7 +30,11 @@ service.interceptors.request.use(
...config.params
};
}
const uuid = getStore("uuid");
let uuid = getStore("uuid");
if (!uuid) {
uuid = uuidv4();
setStore('uuid', uuid);
}
config.headers["uuid"] = uuid;
return config;
},