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, 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; export default router;

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

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

View File

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