@ftlab/one-vue3 0.3.8-0 → 0.3.8-2
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/CHANGELOG.md +13 -1
- package/components.d.ts +1 -0
- package/function/{info.ts → info.js} +2 -2
- package/function/{permission.ts → permission.js} +2 -2
- package/package.json +1 -1
- package/store/app.js +24 -0
- package/store/auth.js +87 -0
- package/store/index.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
9
9
|
|
|
10
|
-
## [v0.3.8-
|
|
10
|
+
## [v0.3.8-2](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.8-1...v0.3.8-2)
|
|
11
|
+
|
|
12
|
+
### Commits
|
|
13
|
+
|
|
14
|
+
- fix: detail [`46b774a`](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/commit/46b774aba185902976975d94f6d80a2eb4854492)
|
|
15
|
+
|
|
16
|
+
## [v0.3.8-1](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.8-0...v0.3.8-1) - 2025-06-04
|
|
17
|
+
|
|
18
|
+
### Commits
|
|
19
|
+
|
|
20
|
+
- feat: npmignore change [`3862394`](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/commit/3862394016994f369c01f5573b6c6a8402098173)
|
|
21
|
+
|
|
22
|
+
## [v0.3.8-0](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.6...v0.3.8-0) - 2025-06-04
|
|
11
23
|
|
|
12
24
|
### Commits
|
|
13
25
|
|
package/components.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare module 'vue' {
|
|
|
11
11
|
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
|
|
12
12
|
ElButton: typeof import('element-plus/es')['ElButton']
|
|
13
13
|
ElCard: typeof import('element-plus/es')['ElCard']
|
|
14
|
+
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
|
|
14
15
|
ElDialog: typeof import('element-plus/es')['ElDialog']
|
|
15
16
|
ElDivider: typeof import('element-plus/es')['ElDivider']
|
|
16
17
|
ElDropdown: typeof import('element-plus/es')['ElDropdown']
|
|
@@ -2,10 +2,10 @@ import axios from 'axios';
|
|
|
2
2
|
|
|
3
3
|
const defaultBaseUrl = 'https://gateway-staging.ftlapp.io';
|
|
4
4
|
|
|
5
|
-
export async function getInfoResource(baseUrl
|
|
5
|
+
export async function getInfoResource(baseUrl, route, callBack) {
|
|
6
6
|
if (route.query.token) {
|
|
7
7
|
localStorage.setItem('token', route.query.token);
|
|
8
|
-
const res
|
|
8
|
+
const res = await axios.post(`${baseUrl ? baseUrl : defaultBaseUrl}/api/auth/loginWithToken`, null, {
|
|
9
9
|
headers: {
|
|
10
10
|
Authorization: route.query.token
|
|
11
11
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @param {*} resources auth返回的平铺资源列表
|
|
4
4
|
* @returns 返回需要筛选路由存在于平铺资源列表里的路由
|
|
5
5
|
*/
|
|
6
|
-
export function filterAsyncRoutes(asyncRoutes
|
|
7
|
-
const filterRoutes
|
|
6
|
+
export function filterAsyncRoutes(asyncRoutes, resources) {
|
|
7
|
+
const filterRoutes = [];
|
|
8
8
|
asyncRoutes.forEach((asy) => {
|
|
9
9
|
if (resources.find((res) => res.name === asy.name)) {
|
|
10
10
|
if (asy.children) {
|
package/package.json
CHANGED
package/store/app.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import storage from '../utils/storage';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
namespaced: true,
|
|
6
|
+
state: () => ({
|
|
7
|
+
language: storage.get('language') || 'cn'
|
|
8
|
+
}),
|
|
9
|
+
getters: {
|
|
10
|
+
language(state) {
|
|
11
|
+
return state.language;
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
mutations: {
|
|
15
|
+
SET_LANG(state, lang) {
|
|
16
|
+
state.language = lang;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
setLocalLang({ commit }, data) {
|
|
21
|
+
commit("SET_LANG", data);
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}
|
package/store/auth.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import storage from '../utils/storage';
|
|
2
|
+
|
|
3
|
+
const userInfo = storage.getAuth();
|
|
4
|
+
|
|
5
|
+
// 同步路由的or翻译为路由name
|
|
6
|
+
function translateOrToName(arr) {
|
|
7
|
+
return arr.map((item) => {
|
|
8
|
+
if (item.children && item.children.length) {
|
|
9
|
+
item.children = translateOrToName(item.children);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...item,
|
|
13
|
+
or: item.name
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
namespaced: true,
|
|
20
|
+
state: () => ({
|
|
21
|
+
userInfo: userInfo || {},
|
|
22
|
+
username: userInfo.username || "",
|
|
23
|
+
owner: userInfo.owner || "",
|
|
24
|
+
roles: userInfo.roles || [],
|
|
25
|
+
menus: [],
|
|
26
|
+
resources: [],
|
|
27
|
+
}),
|
|
28
|
+
getters: {
|
|
29
|
+
auth: (state) => state.userInfo,
|
|
30
|
+
},
|
|
31
|
+
mutations: {
|
|
32
|
+
SET_NAME(state, name) {
|
|
33
|
+
state.username = name;
|
|
34
|
+
},
|
|
35
|
+
SET_OWNER(state, owner) {
|
|
36
|
+
state.owner = owner;
|
|
37
|
+
},
|
|
38
|
+
SET_ROLES(state, roles) {
|
|
39
|
+
state.roles = roles;
|
|
40
|
+
},
|
|
41
|
+
SET_MENUS(state, menus) {
|
|
42
|
+
if (!menus.length) {
|
|
43
|
+
// 在权限返回为空的时候给menus加一条空数据,防止下次路由进入再次空校验
|
|
44
|
+
state.menus.push({});
|
|
45
|
+
} else {
|
|
46
|
+
state.menus = translateOrToName(menus);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
CLEAR_MENUS(state) {
|
|
50
|
+
state.menus = [];
|
|
51
|
+
},
|
|
52
|
+
SET_RESOURCES(state, resources) {
|
|
53
|
+
state.resources = translateOrToName(resources);
|
|
54
|
+
},
|
|
55
|
+
CLEAR_USERINFO(state) {
|
|
56
|
+
state.userInfo = {};
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
actions: {
|
|
60
|
+
setInfo({ commit }, authInfo) {
|
|
61
|
+
if (typeof authInfo === "object") {
|
|
62
|
+
commit("SET_NAME", authInfo.username);
|
|
63
|
+
commit("SET_OWNER", authInfo.owner);
|
|
64
|
+
commit("SET_ROLES", authInfo.roles);
|
|
65
|
+
storage.setAuth(authInfo);
|
|
66
|
+
storage.setToken(authInfo.token);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
setMenu({ commit }, menu) {
|
|
70
|
+
commit("SET_MENUS", menu);
|
|
71
|
+
},
|
|
72
|
+
setResources({ commit }, resources) {
|
|
73
|
+
commit("SET_RESOURCES", resources);
|
|
74
|
+
},
|
|
75
|
+
logout({ commit }) {
|
|
76
|
+
commit("SET_NAME", "");
|
|
77
|
+
commit("SET_OWNER", "");
|
|
78
|
+
commit("SET_ROLES", []);
|
|
79
|
+
commit("SET_RESOURCES", []);
|
|
80
|
+
commit("CLEAR_MENUS");
|
|
81
|
+
commit("CLEAR_USERINFO");
|
|
82
|
+
storage.remove("auth");
|
|
83
|
+
storage.remove("token");
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
}
|