xs-common-plugins 1.2.0 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +298 -290
- package/common.js +110 -110
- package/index.js +1 -1
- package/package.json +16 -16
- package/src/common/common.js +548 -548
- package/src/components/CheckBox_Cmp/index.vue +62 -62
- package/src/components/FormItem/index.vue +92 -92
- package/src/components/ReportCmp/index.vue +76 -76
- package/src/components/Search/index.scss +219 -219
- package/src/components/Search/index.vue +410 -406
- package/src/components/Search/product_option/index.scss +1 -1
- package/src/components/Search/product_option/index.vue +1 -8
- package/src/components/Search/product_option/methods.js +16 -4
- package/src/components/Search_filter/index.scss +104 -104
- package/src/components/TableItem/TableItem.vue +55 -55
- package/src/components/TextOVer/index.vue +55 -55
- package/src/components/UploadImg/index.vue +177 -177
- package/src/components/im/index.vue +155 -155
- package/src/components/im/pages/chatList/index.vue +45 -45
- package/src/components/im/pages/chatRoom/index.vue +159 -159
- package/src/components/xsSelect/index.vue +125 -125
- package/src/mixin/keepAlive.js +52 -0
- package/src/plugins/im/components/chat/index.scss +163 -163
- package/src/plugins/im/components/chat/index.vue +144 -144
- package/src/plugins/im/components/chat/methods.js +149 -149
- package/src/plugins/im/components/msg-image/index.vue +40 -40
- package/src/plugins/im/components/send-msg/index.scss +164 -164
- package/src/plugins/im/components/send-msg/index.vue +107 -107
- package/src/plugins/im/components/send-msg/methods.js +125 -125
- package/src/plugins/im/components/template-message/index.vue +76 -76
- package/src/plugins/im/components/without.vue +19 -19
- package/src/plugins/im/index.js +31 -31
- package/src/plugins/im/utils/services.js +625 -625
- package/src/plugins/index.js +60 -60
- package/src/plugins/row-col-cmp/index.js +20 -20
- package/src/router/permission.js +126 -126
- package/src/store/modules/dic.js +74 -74
- package/src/store/modules/oss.js +40 -40
- package/src/styles/index.scss +91 -91
- package/src/styles/table.scss +90 -90
- package/src/utils/api.js +54 -54
- package/src/utils/auth.js +38 -38
- package/src/utils/concat_batch_btns.js +88 -88
- package/src/utils/enum.js +150 -150
- package/src/utils/filter.js +5 -5
- package/src/utils/filterRules.js +55 -55
- package/src/utils/getMenu.js +82 -82
- package/src/utils/global_directive.js +10 -0
- package/src/utils/ossService.js +55 -55
- package/src/utils/prototype.js +46 -46
- package/src/utils/search.js +33 -33
- package/src/utils/signalR.js +24 -24
- package/src/views/callback/index.vue +35 -35
- package/src/views/home/index.vue +25 -25
- package/src/views/layout/components/AppMain.vue +21 -5
- package/src/views/layout/components/Navbar.vue +20 -13
- package/src/views/layout/components/TagsView/index.vue +130 -91
- package/src/views/slienceAuth/index.vue +42 -42
|
@@ -122,7 +122,7 @@ import ImCom from "@/components/im";
|
|
|
122
122
|
import { getLocalStorage, setLocalStorage } from "@/utils/localStorage";
|
|
123
123
|
import { setToken } from "@/utils/auth"; // get token from cookie
|
|
124
124
|
import { initMenu } from '@/utils/getMenu'
|
|
125
|
-
|
|
125
|
+
import Vue from 'vue'
|
|
126
126
|
export default {
|
|
127
127
|
components: {
|
|
128
128
|
Breadcrumb,
|
|
@@ -156,6 +156,9 @@ export default {
|
|
|
156
156
|
computed: {
|
|
157
157
|
...mapGetters(["sidebar", "avatar"]),
|
|
158
158
|
},
|
|
159
|
+
beforeCreate () {
|
|
160
|
+
Vue.prototype.$bus = this
|
|
161
|
+
},
|
|
159
162
|
created() {
|
|
160
163
|
const userName = getToken("LoginUserName");
|
|
161
164
|
if (userName === "admin") {
|
|
@@ -165,19 +168,23 @@ export default {
|
|
|
165
168
|
},
|
|
166
169
|
methods: {
|
|
167
170
|
changeTenant (id) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
this.$
|
|
171
|
-
|
|
172
|
-
newuser.TId = id
|
|
173
|
-
setLocalStorage('userProfile', newuser)
|
|
174
|
-
this.userProfile = getLocalStorage('userProfile')
|
|
175
|
-
let user = res.data
|
|
176
|
-
setToken(user.accessToken);
|
|
177
|
-
localStorage.setItem("token", user.accessToken);
|
|
178
|
-
initMenu()
|
|
179
|
-
|
|
171
|
+
if(id === this.userProfile.TId) return
|
|
172
|
+
this.$nextTick(() => {
|
|
173
|
+
this.$router.replace({
|
|
174
|
+
path: '/redirect' + '/home'
|
|
180
175
|
})
|
|
176
|
+
})
|
|
177
|
+
this.$ask.ucmng.api.sysmng.Tenant.SwitchTenant({clientId: getConfig('CLIENT_ID'), newTId: id}).then(res => {
|
|
178
|
+
let newuser = this.userProfile
|
|
179
|
+
newuser.TId = id
|
|
180
|
+
setLocalStorage('userProfile', newuser)
|
|
181
|
+
this.userProfile = getLocalStorage('userProfile')
|
|
182
|
+
let user = res.data
|
|
183
|
+
setToken(user.accessToken);
|
|
184
|
+
localStorage.setItem("token", user.accessToken);
|
|
185
|
+
this.$bus.$emit('changeTenant', id) // 全局通知
|
|
186
|
+
initMenu()
|
|
187
|
+
})
|
|
181
188
|
},
|
|
182
189
|
getTenantList () {
|
|
183
190
|
this.$ask.ucmng.api.sysmng.Tenant.GetTenants().then(res => {
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="tags-view-container" class="tags-view-container">
|
|
3
|
-
<scroll-pane
|
|
3
|
+
<scroll-pane
|
|
4
|
+
ref="scrollPane"
|
|
5
|
+
class="tags-view-wrapper"
|
|
6
|
+
@scroll="handleScroll"
|
|
7
|
+
>
|
|
4
8
|
<router-link
|
|
5
9
|
v-for="tag in visitedViews"
|
|
6
10
|
ref="tag"
|
|
7
11
|
:key="tag.path"
|
|
8
|
-
:class="isActive(tag)?'active':''"
|
|
12
|
+
:class="isActive(tag) ? 'active' : ''"
|
|
9
13
|
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
|
10
14
|
tag="span"
|
|
11
15
|
class="tags-view-item"
|
|
12
|
-
@click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
|
|
13
|
-
@contextmenu.prevent.native="openMenu(tag
|
|
16
|
+
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
|
|
17
|
+
@contextmenu.prevent.native="openMenu(tag, $event)"
|
|
14
18
|
>
|
|
15
19
|
{{ tag.title }}
|
|
16
|
-
<span
|
|
20
|
+
<span
|
|
21
|
+
v-if="!isAffix(tag)"
|
|
22
|
+
class="el-icon-close"
|
|
23
|
+
@click.prevent.stop="closeSelectedTag(tag)"
|
|
24
|
+
/>
|
|
17
25
|
</router-link>
|
|
18
26
|
</scroll-pane>
|
|
19
|
-
<ul
|
|
27
|
+
<ul
|
|
28
|
+
v-show="visible"
|
|
29
|
+
:style="{ left: left + 'px', top: top + 'px' }"
|
|
30
|
+
class="contextmenu"
|
|
31
|
+
>
|
|
20
32
|
<li @click="refreshSelectedTag(selectedTag)">刷新</li>
|
|
21
|
-
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)"
|
|
33
|
+
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
|
|
34
|
+
关闭
|
|
35
|
+
</li>
|
|
22
36
|
<li @click="closeOthersTags">关闭其他</li>
|
|
23
37
|
<li @click="closeAllTags(selectedTag)">关闭全部</li>
|
|
24
38
|
</ul>
|
|
@@ -26,9 +40,23 @@
|
|
|
26
40
|
</template>
|
|
27
41
|
|
|
28
42
|
<script>
|
|
29
|
-
import ScrollPane from
|
|
30
|
-
import path from
|
|
31
|
-
import router from
|
|
43
|
+
import ScrollPane from "./ScrollPane";
|
|
44
|
+
import path from "path";
|
|
45
|
+
import router from "../../../../router/index";
|
|
46
|
+
|
|
47
|
+
function _forEachRoute(arr, path) {
|
|
48
|
+
if (arr && arr.length > 0) {
|
|
49
|
+
arr.find((item) => {
|
|
50
|
+
if (item.url === path) {
|
|
51
|
+
item["meta"]["upload"] = true;
|
|
52
|
+
return item;
|
|
53
|
+
} else {
|
|
54
|
+
_forEachRoute(item.children, path);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
32
60
|
export default {
|
|
33
61
|
components: { ScrollPane },
|
|
34
62
|
data() {
|
|
@@ -37,163 +65,174 @@ export default {
|
|
|
37
65
|
top: 0,
|
|
38
66
|
left: 0,
|
|
39
67
|
selectedTag: {},
|
|
40
|
-
affixTags: []
|
|
41
|
-
}
|
|
68
|
+
affixTags: [],
|
|
69
|
+
};
|
|
42
70
|
},
|
|
43
71
|
computed: {
|
|
44
72
|
visitedViews() {
|
|
45
|
-
return this.$store.state.tagsView.visitedViews
|
|
73
|
+
return this.$store.state.tagsView.visitedViews;
|
|
46
74
|
},
|
|
47
75
|
routes() {
|
|
48
|
-
return router.options.routes
|
|
49
|
-
}
|
|
76
|
+
return router.options.routes;
|
|
77
|
+
},
|
|
50
78
|
},
|
|
51
79
|
watch: {
|
|
52
80
|
$route() {
|
|
53
|
-
this.addTags()
|
|
54
|
-
this.moveToCurrentTag()
|
|
81
|
+
this.addTags();
|
|
82
|
+
this.moveToCurrentTag();
|
|
55
83
|
},
|
|
56
84
|
visible(value) {
|
|
57
85
|
if (value) {
|
|
58
|
-
document.body.addEventListener(
|
|
86
|
+
document.body.addEventListener("click", this.closeMenu);
|
|
59
87
|
} else {
|
|
60
|
-
document.body.removeEventListener(
|
|
88
|
+
document.body.removeEventListener("click", this.closeMenu);
|
|
61
89
|
}
|
|
62
|
-
}
|
|
90
|
+
},
|
|
63
91
|
},
|
|
64
92
|
mounted() {
|
|
65
|
-
this.initTags()
|
|
66
|
-
this.addTags()
|
|
93
|
+
this.initTags();
|
|
94
|
+
this.addTags();
|
|
67
95
|
},
|
|
68
96
|
methods: {
|
|
69
97
|
isActive(route) {
|
|
70
|
-
return route.path === this.$route.path
|
|
98
|
+
return route.path === this.$route.path;
|
|
71
99
|
},
|
|
72
100
|
isAffix(tag) {
|
|
73
|
-
return tag.meta && tag.meta.affix
|
|
101
|
+
return tag.meta && tag.meta.affix;
|
|
74
102
|
},
|
|
75
|
-
filterAffixTags(routes, basePath =
|
|
76
|
-
let tags = []
|
|
77
|
-
routes.forEach(route => {
|
|
103
|
+
filterAffixTags(routes, basePath = "/") {
|
|
104
|
+
let tags = [];
|
|
105
|
+
routes.forEach((route) => {
|
|
78
106
|
if (route.meta && route.meta.affix) {
|
|
79
|
-
const tagPath = path.resolve(basePath, route.path)
|
|
107
|
+
const tagPath = path.resolve(basePath, route.path);
|
|
80
108
|
tags.push({
|
|
81
109
|
fullPath: tagPath,
|
|
82
110
|
path: tagPath,
|
|
83
111
|
name: route.name,
|
|
84
|
-
meta: { ...route.meta }
|
|
85
|
-
})
|
|
112
|
+
meta: { ...route.meta },
|
|
113
|
+
});
|
|
86
114
|
}
|
|
87
115
|
if (route.children) {
|
|
88
|
-
const tempTags = this.filterAffixTags(route.children, route.path)
|
|
116
|
+
const tempTags = this.filterAffixTags(route.children, route.path);
|
|
89
117
|
if (tempTags.length >= 1) {
|
|
90
|
-
tags = [...tags, ...tempTags]
|
|
118
|
+
tags = [...tags, ...tempTags];
|
|
91
119
|
}
|
|
92
120
|
}
|
|
93
|
-
})
|
|
94
|
-
return tags
|
|
121
|
+
});
|
|
122
|
+
return tags;
|
|
95
123
|
},
|
|
96
124
|
initTags() {
|
|
97
|
-
const affixTags = this.affixTags = this.filterAffixTags(this.routes)
|
|
125
|
+
const affixTags = (this.affixTags = this.filterAffixTags(this.routes));
|
|
98
126
|
for (const tag of affixTags) {
|
|
99
127
|
if (tag.name) {
|
|
100
|
-
this.$store.dispatch(
|
|
128
|
+
this.$store.dispatch("tagsView/addVisitedView", tag);
|
|
101
129
|
}
|
|
102
130
|
}
|
|
103
131
|
},
|
|
104
132
|
addTags() {
|
|
105
|
-
const { meta } = this.$route
|
|
133
|
+
const { meta } = this.$route;
|
|
106
134
|
if (meta && meta.title) {
|
|
107
|
-
this.$store.dispatch(
|
|
135
|
+
this.$store.dispatch("tagsView/addView", this.$route);
|
|
108
136
|
}
|
|
109
|
-
return false
|
|
137
|
+
return false;
|
|
110
138
|
},
|
|
111
139
|
moveToCurrentTag() {
|
|
112
|
-
const tags = this.$refs.tag
|
|
140
|
+
const tags = this.$refs.tag;
|
|
113
141
|
this.$nextTick(() => {
|
|
114
142
|
for (const tag of tags) {
|
|
115
143
|
if (tag.to.path === this.$route.path) {
|
|
116
|
-
this.$refs.scrollPane.moveToTarget(tag)
|
|
144
|
+
this.$refs.scrollPane.moveToTarget(tag);
|
|
117
145
|
// when query is different then update
|
|
118
146
|
if (tag.to.fullPath !== this.$route.fullPath) {
|
|
119
|
-
this.$store.dispatch(
|
|
147
|
+
this.$store.dispatch("tagsView/updateVisitedView", this.$route);
|
|
120
148
|
}
|
|
121
|
-
break
|
|
149
|
+
break;
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
|
-
})
|
|
152
|
+
});
|
|
125
153
|
},
|
|
126
154
|
refreshSelectedTag(view) {
|
|
127
|
-
this.$store.dispatch(
|
|
128
|
-
const { fullPath } = view
|
|
155
|
+
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
|
|
156
|
+
const { fullPath } = view;
|
|
129
157
|
this.$nextTick(() => {
|
|
130
158
|
this.$router.replace({
|
|
131
|
-
path:
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
})
|
|
159
|
+
path: "/redirect" + fullPath,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
135
163
|
},
|
|
164
|
+
|
|
136
165
|
closeSelectedTag(view) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
166
|
+
console.log('closeTag',view);
|
|
167
|
+
const arr = this.$router.options.routes;
|
|
168
|
+
_forEachRoute(arr, view.path);
|
|
169
|
+
|
|
170
|
+
this.$store
|
|
171
|
+
.dispatch("tagsView/delView", view)
|
|
172
|
+
.then(({ visitedViews }) => {
|
|
173
|
+
if (this.isActive(view)) {
|
|
174
|
+
// 通知标签页组件清除缓存/更新视图
|
|
175
|
+
window.nnav = true;
|
|
176
|
+
this.toLastView(visitedViews, view);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
142
179
|
},
|
|
143
180
|
closeOthersTags() {
|
|
144
|
-
this.$router.push(this.selectedTag)
|
|
145
|
-
this.$store
|
|
146
|
-
this.
|
|
147
|
-
|
|
181
|
+
this.$router.push(this.selectedTag);
|
|
182
|
+
this.$store
|
|
183
|
+
.dispatch("tagsView/delOthersViews", this.selectedTag)
|
|
184
|
+
.then(() => {
|
|
185
|
+
this.moveToCurrentTag();
|
|
186
|
+
});
|
|
148
187
|
},
|
|
149
188
|
closeAllTags(view) {
|
|
150
|
-
this.$store.dispatch(
|
|
151
|
-
if (this.affixTags.some(tag => tag.path === view.path)) {
|
|
152
|
-
return
|
|
189
|
+
this.$store.dispatch("tagsView/delAllViews").then(({ visitedViews }) => {
|
|
190
|
+
if (this.affixTags.some((tag) => tag.path === view.path)) {
|
|
191
|
+
return;
|
|
153
192
|
}
|
|
154
|
-
this.toLastView(visitedViews, view)
|
|
155
|
-
})
|
|
193
|
+
this.toLastView(visitedViews, view);
|
|
194
|
+
});
|
|
156
195
|
},
|
|
157
196
|
toLastView(visitedViews, view) {
|
|
158
|
-
const latestView = visitedViews.slice(-1)[0]
|
|
197
|
+
const latestView = visitedViews.slice(-1)[0];
|
|
159
198
|
if (latestView) {
|
|
160
|
-
this.$router.push(latestView.fullPath)
|
|
199
|
+
this.$router.push(latestView.fullPath);
|
|
161
200
|
} else {
|
|
162
201
|
// now the default is to redirect to the home page if there is no tags-view,
|
|
163
202
|
// you can adjust it according to your needs.
|
|
164
|
-
if (view.name ===
|
|
203
|
+
if (view.name === "Dashboard") {
|
|
165
204
|
// to reload home page
|
|
166
|
-
this.$router.replace({ path:
|
|
205
|
+
this.$router.replace({ path: "/redirect" + view.fullPath });
|
|
167
206
|
} else {
|
|
168
|
-
this.$router.push(
|
|
207
|
+
this.$router.push("/");
|
|
169
208
|
}
|
|
170
209
|
}
|
|
171
210
|
},
|
|
172
211
|
openMenu(tag, e) {
|
|
173
|
-
const menuMinWidth = 105
|
|
174
|
-
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
|
|
175
|
-
const offsetWidth = this.$el.offsetWidth // container width
|
|
176
|
-
const maxLeft = offsetWidth - menuMinWidth // left boundary
|
|
177
|
-
const left = e.clientX - offsetLeft + 15 // 15: margin right
|
|
212
|
+
const menuMinWidth = 105;
|
|
213
|
+
const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
|
|
214
|
+
const offsetWidth = this.$el.offsetWidth; // container width
|
|
215
|
+
const maxLeft = offsetWidth - menuMinWidth; // left boundary
|
|
216
|
+
const left = e.clientX - offsetLeft + 15; // 15: margin right
|
|
178
217
|
|
|
179
218
|
if (left > maxLeft) {
|
|
180
|
-
this.left = maxLeft
|
|
219
|
+
this.left = maxLeft;
|
|
181
220
|
} else {
|
|
182
|
-
this.left = left
|
|
221
|
+
this.left = left;
|
|
183
222
|
}
|
|
184
223
|
|
|
185
|
-
this.top = e.clientY
|
|
186
|
-
this.visible = true
|
|
187
|
-
this.selectedTag = tag
|
|
224
|
+
this.top = e.clientY;
|
|
225
|
+
this.visible = true;
|
|
226
|
+
this.selectedTag = tag;
|
|
188
227
|
},
|
|
189
228
|
closeMenu() {
|
|
190
|
-
this.visible = false
|
|
229
|
+
this.visible = false;
|
|
191
230
|
},
|
|
192
231
|
handleScroll() {
|
|
193
|
-
this.closeMenu()
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
232
|
+
this.closeMenu();
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
197
236
|
</script>
|
|
198
237
|
|
|
199
238
|
<style lang="scss" scoped>
|
|
@@ -202,7 +241,7 @@ export default {
|
|
|
202
241
|
width: 100%;
|
|
203
242
|
background: #fff;
|
|
204
243
|
border-bottom: 1px solid #d8dce5;
|
|
205
|
-
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .12), 0 0 3px 0 rgba(0, 0, 0, .04);
|
|
244
|
+
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
|
|
206
245
|
.tags-view-wrapper {
|
|
207
246
|
.tags-view-item {
|
|
208
247
|
display: inline-block;
|
|
@@ -224,11 +263,11 @@ export default {
|
|
|
224
263
|
margin-right: 15px;
|
|
225
264
|
}
|
|
226
265
|
&.active {
|
|
227
|
-
background-color: #
|
|
266
|
+
background-color: #409eff;
|
|
228
267
|
color: #fff;
|
|
229
|
-
border-color: #
|
|
268
|
+
border-color: #409eff;
|
|
230
269
|
&::before {
|
|
231
|
-
content:
|
|
270
|
+
content: "";
|
|
232
271
|
background: #fff;
|
|
233
272
|
display: inline-block;
|
|
234
273
|
width: 8px;
|
|
@@ -251,7 +290,7 @@ export default {
|
|
|
251
290
|
font-size: 12px;
|
|
252
291
|
font-weight: 400;
|
|
253
292
|
color: #333;
|
|
254
|
-
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, .3);
|
|
293
|
+
box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
|
|
255
294
|
li {
|
|
256
295
|
margin: 0;
|
|
257
296
|
padding: 7px 16px;
|
|
@@ -274,10 +313,10 @@ export default {
|
|
|
274
313
|
vertical-align: 2px;
|
|
275
314
|
border-radius: 50%;
|
|
276
315
|
text-align: center;
|
|
277
|
-
transition: all .3s cubic-bezier(.645, .045, .355, 1);
|
|
316
|
+
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
|
278
317
|
transform-origin: 100% 50%;
|
|
279
318
|
&:before {
|
|
280
|
-
transform: scale(.6);
|
|
319
|
+
transform: scale(0.6);
|
|
281
320
|
display: inline-block;
|
|
282
321
|
vertical-align: -3px;
|
|
283
322
|
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="slienceAuth">
|
|
3
|
-
<!-- 静默授权, 获取平台token -->
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
<script>
|
|
7
|
-
import http from 'xs-request/lib/requestApi'
|
|
8
|
-
import { getConfig } from "@/utils/global-config";
|
|
9
|
-
import { setLocalStorage } from "@/utils/localStorage";
|
|
10
|
-
export default {
|
|
11
|
-
beforeRouteEnter (to, from, next) {
|
|
12
|
-
next(vm => {
|
|
13
|
-
vm.apartyGetToken(to, next, vm)
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
methods: {
|
|
17
|
-
async apartyGetToken(to, next, vm) {
|
|
18
|
-
if(window.parent !== window.self && window.name === "qualityTestParty") { // 识别被哪个 iframe 引用
|
|
19
|
-
if (!localStorage.getItem("token")) {
|
|
20
|
-
await http.get(
|
|
21
|
-
getConfig("ID4_AUTH") +
|
|
22
|
-
"AccountIframe/Token?accountName=" +
|
|
23
|
-
to.query.accountName
|
|
24
|
-
).then(async (res) => {
|
|
25
|
-
if (res.code == 0) {
|
|
26
|
-
localStorage.setItem('token', res.data)
|
|
27
|
-
await http.get(getConfig("ID4_AUTH") + 'connect/userinfo').then((res) => {
|
|
28
|
-
setLocalStorage("userProfile", res.data);
|
|
29
|
-
next('/')
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
localStorage.removeItem("token");
|
|
35
|
-
vm.apartyGetToken(to, next, vm)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
<style lang="sass" scoped></style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="slienceAuth">
|
|
3
|
+
<!-- 静默授权, 获取平台token -->
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
import http from 'xs-request/lib/requestApi'
|
|
8
|
+
import { getConfig } from "@/utils/global-config";
|
|
9
|
+
import { setLocalStorage } from "@/utils/localStorage";
|
|
10
|
+
export default {
|
|
11
|
+
beforeRouteEnter (to, from, next) {
|
|
12
|
+
next(vm => {
|
|
13
|
+
vm.apartyGetToken(to, next, vm)
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
methods: {
|
|
17
|
+
async apartyGetToken(to, next, vm) {
|
|
18
|
+
if(window.parent !== window.self && window.name === "qualityTestParty") { // 识别被哪个 iframe 引用
|
|
19
|
+
if (!localStorage.getItem("token")) {
|
|
20
|
+
await http.get(
|
|
21
|
+
getConfig("ID4_AUTH") +
|
|
22
|
+
"AccountIframe/Token?accountName=" +
|
|
23
|
+
to.query.accountName
|
|
24
|
+
).then(async (res) => {
|
|
25
|
+
if (res.code == 0) {
|
|
26
|
+
localStorage.setItem('token', res.data)
|
|
27
|
+
await http.get(getConfig("ID4_AUTH") + 'connect/userinfo').then((res) => {
|
|
28
|
+
setLocalStorage("userProfile", res.data);
|
|
29
|
+
next('/')
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
localStorage.removeItem("token");
|
|
35
|
+
vm.apartyGetToken(to, next, vm)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
<style lang="sass" scoped></style>
|