@ftlab/one-vue3 0.3.8-6 → 0.4.0

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +36 -146
  2. package/README.md +143 -61
  3. package/assets/css/index.scss +25 -25
  4. package/assets/css/mixin.scss +142 -142
  5. package/assets/css/public.scss +175 -175
  6. package/assets/img/Germany.png +0 -0
  7. package/components.d.ts +6 -3
  8. package/dist/CheckMessageDialog-DygR717d.js +78 -0
  9. package/dist/FtlEntry.js +109 -0
  10. package/dist/FtlMessage.js +186 -0
  11. package/dist/FtlMultipleChoose-D8o09guU.js +312 -0
  12. package/dist/FtlMultipleChoose.js +1 -0
  13. package/dist/FtlNavbar-SsenWatk.js +191 -0
  14. package/dist/FtlNavbar.js +1 -0
  15. package/dist/FtlPasswordDialog-Dj_vS0mC.js +188 -0
  16. package/dist/FtlPasswordDialog.js +1 -0
  17. package/dist/FtlSidebar-D5AkRjgA.js +159 -0
  18. package/dist/FtlSidebar.js +1 -0
  19. package/dist/_plugin-vue_export-helper-Djzt4Yr7.js +7 -0
  20. package/dist/asyncToGenerator-CENKRPhX.js +26 -0
  21. package/dist/configProvider-CFU3sEdy.js +6 -0
  22. package/dist/ftlOne.js +16 -13
  23. package/dist/langSelect-DdbxrMFQ.js +106 -0
  24. package/dist/objectSpread2-Bpgh6RJW.js +57 -0
  25. package/dist/storage-DBeiC15W.js +25 -0
  26. package/dist/store.js +39 -98
  27. package/dist/style.css +2 -1
  28. package/dist/utils-BuLanift.js +10 -0
  29. package/dist/utils.js +558 -475
  30. package/eslint.config.js +34 -0
  31. package/ftlab-one-vue3-0.4.0.tgz +0 -0
  32. package/global.d.ts +63 -63
  33. package/i18n/cn.json +22 -22
  34. package/i18n/de.json +23 -0
  35. package/i18n/en.json +22 -22
  36. package/i18n/es.json +23 -0
  37. package/i18n/fr.json +22 -22
  38. package/package.json +119 -74
  39. package/vitest.config.ts +8 -0
  40. package/.eslintrc.cjs +0 -24
  41. package/.prettierrc.cjs +0 -18
  42. package/dist/CheckMessageDialog-0f85dbee.js +0 -167
  43. package/dist/index-2284be94.js +0 -15036
  44. package/dist/storage-9f2ae3ed.js +0 -30
  45. package/dist/utils-0eda3e43.js +0 -17
  46. package/dist/vuex.esm-bundler-2a047356.js +0 -770
  47. package/function/index.ts +0 -4
  48. package/function/info.js +0 -17
  49. package/function/permission.js +0 -17
  50. package/store/app.js +0 -24
  51. package/store/auth.js +0 -87
  52. package/store/index.ts +0 -10
  53. package/utils/date.ts +0 -127
  54. package/utils/index.ts +0 -3
  55. package/utils/storage.js +0 -27
  56. package/utils/utils.ts +0 -10
package/function/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import * as info from './info';
2
- import * as permission from './permission';
3
-
4
- export { info, permission };
package/function/info.js DELETED
@@ -1,17 +0,0 @@
1
- import axios from 'axios';
2
-
3
- const defaultBaseUrl = 'https://gateway-staging.ftlapp.io';
4
-
5
- export async function getInfoResource(baseUrl, route, callBack) {
6
- if (route.query.token) {
7
- localStorage.setItem('token', route.query.token);
8
- const res = await axios.post(`${baseUrl ? baseUrl : defaultBaseUrl}/api/auth/loginWithToken`, null, {
9
- headers: {
10
- Authorization: route.query.token
11
- }
12
- });
13
- if (callBack) {
14
- callBack(res.data);
15
- }
16
- }
17
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * @param {*} asyncRoutes 需要筛选的路由表
3
- * @param {*} resources auth返回的平铺资源列表
4
- * @returns 返回需要筛选路由存在于平铺资源列表里的路由
5
- */
6
- export function filterAsyncRoutes(asyncRoutes, resources) {
7
- const filterRoutes = [];
8
- asyncRoutes.forEach((asy) => {
9
- if (resources.find((res) => res.name === asy.name)) {
10
- if (asy.children) {
11
- asy.children = filterAsyncRoutes(asy.children, resources);
12
- }
13
- filterRoutes.push(asy);
14
- }
15
- });
16
- return filterRoutes;
17
- }
package/store/app.js DELETED
@@ -1,24 +0,0 @@
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 DELETED
@@ -1,87 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
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
- })
package/utils/date.ts DELETED
@@ -1,127 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import utc from 'dayjs/plugin/utc';
3
- import timezone from 'dayjs/plugin/timezone';
4
-
5
- dayjs.extend(timezone);
6
- dayjs.extend(utc);
7
-
8
- type dateFormat = (date: string | Date | null | undefined, format?: string, defaultStr?: string) => string;
9
- type dateTransform = (date: string | Date | null | undefined, defaultStr?: string) => Date | string;
10
- type tzTransform = (date: string | Date | null | undefined, tz: string) => Date | string;
11
- type dateValidate = (date: any) => boolean;
12
-
13
- const TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
14
-
15
- /**
16
- * @description 判断是否合法输入
17
- * @param {(string|Date)} value 日期
18
- * @returns {boolean}
19
- */
20
-
21
- const isValidDate: dateValidate = (value) => {
22
- const date = new Date(value);
23
- if (!isNaN(date.getTime())) {
24
- const year = date.getFullYear();
25
- const month = date.getMonth() + 1;
26
- const day = date.getDate();
27
- if (day === 29 && month === 2) {
28
- if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
29
- return true;
30
- } else {
31
- return false;
32
- }
33
- }
34
- return true;
35
- }
36
- return !isNaN(date.getTime());
37
- };
38
-
39
- /**
40
- * @description utc时间转cn时间
41
- * @param {(string|Date)} date 日期
42
- * @param {string} [format] 时间格式
43
- * @param {string} [default=''] 默认返回值
44
- * @return {string}
45
- */
46
- const utc_cn: dateFormat = (date, format, defaultStr = '') => {
47
- if (!date || !isValidDate(date)) return defaultStr;
48
- return dayjs(date)
49
- .utc()
50
- .tz('Asia/Shanghai')
51
- .format(format || TIME_FORMAT);
52
- };
53
-
54
- /**
55
- * @description utc时间转fr时间
56
- * @param {(string|Date)} date 日期
57
- * @param {string} [format] 时间格式
58
- * @param {string} [default=''] 默认返回值
59
- * @return {string}
60
- */
61
-
62
- const utc_fr: dateFormat = (date, format, defaultStr = '') => {
63
- if (!date || !isValidDate(date)) return defaultStr;
64
- return dayjs(date)
65
- .utc()
66
- .tz('Europe/Paris')
67
- .format(format || TIME_FORMAT);
68
- };
69
-
70
- /**
71
- * @description 本地时间转utc日期
72
- * @param {(string|Date)} date 日期
73
- * @param {string} [default=''] 默认返回值
74
- * @return {Date}
75
- */
76
-
77
- const local_utc_date: dateTransform = (date, defaultStr = '') => {
78
- if (!date || !isValidDate(date)) return defaultStr;
79
- const localDate = new Date(dayjs(date).format(TIME_FORMAT)).getTime();
80
- const utcChargeTime = new Date(dayjs(date).utc().format(TIME_FORMAT)).getTime();
81
- const diff = (localDate - utcChargeTime) / (1000 * 3600);
82
- return diff > 0 ? dayjs(date).utc().add(diff, 'hours').toDate() : dayjs(date).utc().subtract(diff, 'hours').toDate();
83
- };
84
-
85
- /**
86
- * @description 本地时间保存为指定时区的日期
87
- * @param {(string|Date)} date 日期
88
- * @param {string} tz 时区
89
- * @return {Date}
90
- */
91
-
92
- const local_tz_date: tzTransform = (date, tz) => {
93
- if (!date || !isValidDate(date)) return '';
94
- const localOffsetInMinutes = dayjs(date).utcOffset();
95
- const tzOffsetInMinutes = dayjs(date).tz(tz).utcOffset();
96
- const offsetDifference = localOffsetInMinutes - tzOffsetInMinutes;
97
- return offsetDifference > 0
98
- ? dayjs(date).add(offsetDifference, 'minutes').toDate()
99
- : dayjs(date).subtract(offsetDifference, 'minutes').toDate();
100
- };
101
-
102
- /**
103
- * @description 本地时间保存为中国日期
104
- * @param {(string|Date)} date 日期
105
- * @param {string} [default=''] 默认返回值
106
- * @return {Date}
107
- */
108
-
109
- const local_cn_date: dateTransform = (date, defaultStr = '') => {
110
- if (!date || !isValidDate(date)) return defaultStr;
111
- return local_tz_date(date, 'Asia/Shanghai');
112
- };
113
-
114
- /**
115
- * @description 本地时间保存为法国日期
116
- * @param {(string|Date)} date 日期
117
- * @param {string} [default=''] 默认返回值
118
- * @return {Date}
119
- */
120
-
121
- const local_fr_date: dateTransform = (date, defaultStr = '') => {
122
- if (!date || !isValidDate(date)) return defaultStr;
123
- return local_tz_date(date, 'Europe/Paris');
124
- };
125
-
126
- export { utc_cn, utc_fr, local_utc_date, local_cn_date, local_fr_date, local_tz_date, isValidDate, dayjs };
127
- export type { dateFormat, dateTransform, tzTransform, dateValidate };
package/utils/index.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './date';
2
- export { default as storage } from './storage';
3
- export * from './utils';
package/utils/storage.js DELETED
@@ -1,27 +0,0 @@
1
- export default {
2
- get(key) {
3
- return localStorage.getItem(key);
4
- },
5
- set(key, value) {
6
- localStorage.setItem(key, value);
7
- },
8
- remove(key) {
9
- localStorage.removeItem(key);
10
- },
11
- // 保存token到本地缓存
12
- setToken(token) {
13
- this.set('token', token);
14
- },
15
- // 保存用户信息到本地缓存
16
- setAuth(auth) {
17
- this.set('auth', JSON.stringify(auth));
18
- },
19
- // 读取token
20
- getToken() {
21
- return this.get('token');
22
- },
23
- // 读取用户信息
24
- getAuth() {
25
- return this.get('auth') ? JSON.parse(this.get('auth')) : {};
26
- },
27
- };
package/utils/utils.ts DELETED
@@ -1,10 +0,0 @@
1
- // 防抖
2
- export function debounce(fn, delay = 1000) {
3
- let timer: NodeJS.Timer;
4
- return function (...args) {
5
- clearTimeout(timer);
6
- timer = setTimeout(() => {
7
- fn.apply(this, args);
8
- }, delay);
9
- };
10
- }