@ftlab/one-vue3 0.3.8-0 → 0.3.8-1

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 CHANGED
@@ -7,7 +7,13 @@ 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-0](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.6...v0.3.8-0)
10
+ ## [v0.3.8-1](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.8-0...v0.3.8-1)
11
+
12
+ ### Commits
13
+
14
+ - feat: npmignore change [`3862394`](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/commit/3862394016994f369c01f5573b6c6a8402098173)
15
+
16
+ ## [v0.3.8-0](https://gitlab.ftlapp.cn/ftl/ftlab/one-vue3/compare/v0.3.6...v0.3.8-0) - 2025-06-04
11
17
 
12
18
  ### Commits
13
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftlab/one-vue3",
3
- "version": "0.3.8-0",
3
+ "version": "0.3.8-1",
4
4
  "description": "One for Apps based on Element UI",
5
5
  "main": "dist/ftlOne.js",
6
6
  "exports": {
package/store/app.ts 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.ts 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
+ }
package/store/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { createStore } from 'vuex'
2
+ import app from './app'
3
+ import auth from './auth'
4
+
5
+ export default createStore({
6
+ modules: {
7
+ app,
8
+ auth
9
+ }
10
+ })