This is an automated email from the ASF dual-hosted git repository.

qiuxiafan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-booster-ui.git

commit b0f6194f0c9e3562d7471f9dee4e350ccacb947c
Author: Qiuxia Fan <[email protected]>
AuthorDate: Wed Dec 15 17:39:56 2021 +0800

    feat: add axiosCancel
---
 src/router/index.ts         | 12 ++++++++++++
 src/shims-vue.d.ts          |  8 ++++++++
 src/views/dashboard/New.vue | 14 ++++++--------
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/router/index.ts b/src/router/index.ts
index 71c22d0..95a2080 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -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;
diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts
index 81a9eb4..a65cf34 100644
--- a/src/shims-vue.d.ts
+++ b/src/shims-vue.d.ts
@@ -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;
+  }
+}
diff --git a/src/views/dashboard/New.vue b/src/views/dashboard/New.vue
index 45d55f4..f104bb2 100644
--- a/src/views/dashboard/New.vue
+++ b/src/views/dashboard/New.vue
@@ -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;

Reply via email to