feat: add axiosCancel

This commit is contained in:
Qiuxia Fan 2021-12-15 17:39:56 +08:00
parent 1b30216545
commit b0f6194f0c
3 changed files with 26 additions and 8 deletions

View File

@ -43,4 +43,16 @@ const router = createRouter({
routes,
});
(window as any).axiosCancel = [];
router.beforeEach((to, from, next) => {
const token = window.localStorage.getItem("skywalking-authority");
if ((window as any).axiosCancel.length !== 0) {
for (const func of (window as any).axiosCancel) {
setTimeout(func(), 0);
}
(window as any).axiosCancel = [];
}
next();
});
export default router;

8
src/shims-vue.d.ts vendored
View File

@ -19,3 +19,11 @@ declare module "*.vue" {
const Component: ReturnType<typeof defineComponent>;
export default Component;
}
declare global {
namespace JSX {}
interface Window {
Promise: any;
moment: any;
axiosCancel: any;
}
}

View File

@ -149,10 +149,10 @@ import {
ElInput,
ElButton,
} from "element-plus";
// import { useSelectorStore } from "@/store/modules/selectors";
import { useSelectorStore } from "@/store/modules/selectors";
import { EntityType, SelectOpt, Options } from "./data";
// const selectorStore = useSelectorStore();
const selectorStore = useSelectorStore();
const props = {
expandTrigger: "hover",
};
@ -173,24 +173,22 @@ const handleChange = (value: any) => {
const onCreate = () => {
console.log(state);
};
// selectorStore.fetchServices("general");
selectorStore.fetchServices("general");
</script>
<style lang="scss" scoped>
.new-dashboard {
width: 600px;
margin: 0 auto;
}
.item {
margin-top: 20px;
}
.selectors {
width: 600px;
}
.new-dashboard,
.selectors,
.el-cascader-menu {
width: 600px;
}
.create {
width: 160px;
width: 600px;
}
.btn {
margin-top: 40px;