修复登出账号、修改密码等操作会清除uuidbug

master
zhanglei829 2021-12-30 10:13:34 +08:00
parent 4ff8eb6494
commit d2a0940858
2 changed files with 7 additions and 9 deletions

View File

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

View File

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