@ftlab/one-vue3 0.2.12 → 0.2.14

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/store/auth.js CHANGED
@@ -1,63 +1,63 @@
1
- import { defineStore } from 'pinia';
2
- import storage from '../utils/storage';
3
-
4
- const userInfo = storage.getAuth();
5
-
6
- // 同步路由的or翻译为路由name
7
- function translateOrToName(arr) {
8
- return arr.map((item) => {
9
- if (item.children && item.children.length) {
10
- item.children = translateOrToName(item.children);
11
- }
12
- return {
13
- ...item,
14
- or: item.name
15
- };
16
- });
17
- }
18
-
19
- export default defineStore('auth', {
20
- state: () => {
21
- return {
22
- userInfo: userInfo || {},
23
- username: userInfo.username || '',
24
- owner: userInfo.owner || '',
25
- roles: userInfo.roles || [],
26
- menus: [],
27
- resources: []
28
- };
29
- },
30
- actions: {
31
- setInfo(authInfo) {
32
- if (typeof authInfo === 'object') {
33
- this.userInfo = authInfo;
34
- this.username = authInfo.username;
35
- this.owner = authInfo.owner;
36
- this.roles = authInfo.roles;
37
- storage.setAuth(authInfo);
38
- storage.setToken(authInfo.token);
39
- }
40
- },
41
- setMenu(menus) {
42
- if (!menus.length) {
43
- // 在权限返回为空的时候给menus加一条空数据,防止下次路由进入再次空校验
44
- this.menus.push({});
45
- } else {
46
- this.menus = translateOrToName(menus);
47
- }
48
- },
49
- setResources(resources) {
50
- this.resources = translateOrToName(resources);
51
- },
52
- logout() {
53
- this.userInfo = {};
54
- this.username = '';
55
- this.owner = [];
56
- this.roles = [];
57
- this.menus = [];
58
- this.resources = [];
59
- storage.remove('auth');
60
- storage.remove('token');
61
- }
62
- }
63
- });
1
+ import { defineStore } from 'pinia';
2
+ import storage from '../utils/storage';
3
+
4
+ const userInfo = storage.getAuth();
5
+
6
+ // 同步路由的or翻译为路由name
7
+ function translateOrToName(arr) {
8
+ return arr.map((item) => {
9
+ if (item.children && item.children.length) {
10
+ item.children = translateOrToName(item.children);
11
+ }
12
+ return {
13
+ ...item,
14
+ or: item.name
15
+ };
16
+ });
17
+ }
18
+
19
+ export default defineStore('auth', {
20
+ state: () => {
21
+ return {
22
+ userInfo: userInfo || {},
23
+ username: userInfo.username || '',
24
+ owner: userInfo.owner || '',
25
+ roles: userInfo.roles || [],
26
+ menus: [],
27
+ resources: []
28
+ };
29
+ },
30
+ actions: {
31
+ setInfo(authInfo) {
32
+ if (typeof authInfo === 'object') {
33
+ this.userInfo = authInfo;
34
+ this.username = authInfo.username;
35
+ this.owner = authInfo.owner;
36
+ this.roles = authInfo.roles;
37
+ storage.setAuth(authInfo);
38
+ storage.setToken(authInfo.token);
39
+ }
40
+ },
41
+ setMenu(menus) {
42
+ if (!menus.length) {
43
+ // 在权限返回为空的时候给menus加一条空数据,防止下次路由进入再次空校验
44
+ this.menus.push({});
45
+ } else {
46
+ this.menus = translateOrToName(menus);
47
+ }
48
+ },
49
+ setResources(resources) {
50
+ this.resources = translateOrToName(resources);
51
+ },
52
+ logout() {
53
+ this.userInfo = {};
54
+ this.username = '';
55
+ this.owner = [];
56
+ this.roles = [];
57
+ this.menus = [];
58
+ this.resources = [];
59
+ storage.remove('auth');
60
+ storage.remove('token');
61
+ }
62
+ }
63
+ });
package/store/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createPinia } from 'pinia';
2
-
3
- const store = createPinia();
4
-
1
+ import { createPinia } from 'pinia';
2
+
3
+ const store = createPinia();
4
+
5
5
  export default store;
package/store/lang.js CHANGED
@@ -1,16 +1,16 @@
1
- import { defineStore } from 'pinia';
2
- import storage from '../utils/storage';
3
-
4
- export default defineStore('lang', {
5
- state: () => {
6
- return {
7
- language: storage.get('language') || 'cn'
8
- };
9
- },
10
- actions: {
11
- setLanguage(lang) {
12
- this.language = lang || 'cn';
13
- storage.set('language', lang);
14
- }
15
- }
16
- });
1
+ import { defineStore } from 'pinia';
2
+ import storage from '../utils/storage';
3
+
4
+ export default defineStore('lang', {
5
+ state: () => {
6
+ return {
7
+ language: storage.get('language') || 'cn'
8
+ };
9
+ },
10
+ actions: {
11
+ setLanguage(lang) {
12
+ this.language = lang || 'cn';
13
+ storage.set('language', lang);
14
+ }
15
+ }
16
+ });
package/utils/date.ts CHANGED
@@ -1,119 +1,119 @@
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, 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} [default=''] 默认返回值
43
- * @return {string}
44
- */
45
- const utc_cn: dateFormat = (date, defaultStr = '') => {
46
- if (!date || !isValidDate(date)) return defaultStr;
47
- return dayjs(date).utc().tz('Asia/Shanghai').format(TIME_FORMAT);
48
- };
49
-
50
- /**
51
- * @description utc时间转fr时间
52
- * @param {(string|Date)} date 日期
53
- * @param {string} [default=''] 默认返回值
54
- * @return {string}
55
- */
56
-
57
- const utc_fr: dateFormat = (date, defaultStr = '') => {
58
- if (!date || !isValidDate(date)) return defaultStr;
59
- return dayjs(date).utc().tz('Europe/Paris').format(TIME_FORMAT);
60
- };
61
-
62
- /**
63
- * @description 本地时间转utc日期
64
- * @param {(string|Date)} date 日期
65
- * @param {string} [default=''] 默认返回值
66
- * @return {Date}
67
- */
68
-
69
- const local_utc_date: dateTransform = (date, defaultStr = '') => {
70
- if (!date || !isValidDate(date)) return defaultStr;
71
- const localDate = new Date(dayjs(date).format(TIME_FORMAT)).getTime();
72
- const utcChargeTime = new Date(dayjs(date).utc().format(TIME_FORMAT)).getTime();
73
- const diff = (localDate - utcChargeTime) / (1000 * 3600);
74
- return diff > 0 ? dayjs(date).utc().add(diff, 'hours').toDate() : dayjs(date).utc().subtract(diff, 'hours').toDate();
75
- };
76
-
77
- /**
78
- * @description 本地时间保存为指定时区的日期
79
- * @param {(string|Date)} date 日期
80
- * @param {string} tz 时区
81
- * @return {Date}
82
- */
83
-
84
- const local_tz_date: tzTransform = (date, tz) => {
85
- if (!date || !isValidDate(date)) return '';
86
- const localOffsetInMinutes = dayjs(date).utcOffset();
87
- const tzOffsetInMinutes = dayjs(date).tz(tz).utcOffset();
88
- const offsetDifference = localOffsetInMinutes - tzOffsetInMinutes;
89
- return offsetDifference > 0
90
- ? dayjs(date).add(offsetDifference, 'minutes').toDate()
91
- : dayjs(date).subtract(offsetDifference, 'minutes').toDate();
92
- };
93
-
94
- /**
95
- * @description 本地时间保存为中国日期
96
- * @param {(string|Date)} date 日期
97
- * @param {string} [default=''] 默认返回值
98
- * @return {Date}
99
- */
100
-
101
- const local_cn_date: dateTransform = (date, defaultStr = '') => {
102
- if (!date || !isValidDate(date)) return defaultStr;
103
- return local_tz_date(date, 'Asia/Shanghai');
104
- };
105
-
106
- /**
107
- * @description 本地时间保存为法国日期
108
- * @param {(string|Date)} date 日期
109
- * @param {string} [default=''] 默认返回值
110
- * @return {Date}
111
- */
112
-
113
- const local_fr_date: dateTransform = (date, defaultStr = '') => {
114
- if (!date || !isValidDate(date)) return defaultStr;
115
- return local_tz_date(date, 'Europe/Paris');
116
- };
117
-
118
- export { utc_cn, utc_fr, local_utc_date, local_cn_date, local_fr_date, local_tz_date, isValidDate, dayjs };
119
- export type { dateFormat, dateTransform, tzTransform, dateValidate };
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, 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} [default=''] 默认返回值
43
+ * @return {string}
44
+ */
45
+ const utc_cn: dateFormat = (date, defaultStr = '') => {
46
+ if (!date || !isValidDate(date)) return defaultStr;
47
+ return dayjs(date).utc().tz('Asia/Shanghai').format(TIME_FORMAT);
48
+ };
49
+
50
+ /**
51
+ * @description utc时间转fr时间
52
+ * @param {(string|Date)} date 日期
53
+ * @param {string} [default=''] 默认返回值
54
+ * @return {string}
55
+ */
56
+
57
+ const utc_fr: dateFormat = (date, defaultStr = '') => {
58
+ if (!date || !isValidDate(date)) return defaultStr;
59
+ return dayjs(date).utc().tz('Europe/Paris').format(TIME_FORMAT);
60
+ };
61
+
62
+ /**
63
+ * @description 本地时间转utc日期
64
+ * @param {(string|Date)} date 日期
65
+ * @param {string} [default=''] 默认返回值
66
+ * @return {Date}
67
+ */
68
+
69
+ const local_utc_date: dateTransform = (date, defaultStr = '') => {
70
+ if (!date || !isValidDate(date)) return defaultStr;
71
+ const localDate = new Date(dayjs(date).format(TIME_FORMAT)).getTime();
72
+ const utcChargeTime = new Date(dayjs(date).utc().format(TIME_FORMAT)).getTime();
73
+ const diff = (localDate - utcChargeTime) / (1000 * 3600);
74
+ return diff > 0 ? dayjs(date).utc().add(diff, 'hours').toDate() : dayjs(date).utc().subtract(diff, 'hours').toDate();
75
+ };
76
+
77
+ /**
78
+ * @description 本地时间保存为指定时区的日期
79
+ * @param {(string|Date)} date 日期
80
+ * @param {string} tz 时区
81
+ * @return {Date}
82
+ */
83
+
84
+ const local_tz_date: tzTransform = (date, tz) => {
85
+ if (!date || !isValidDate(date)) return '';
86
+ const localOffsetInMinutes = dayjs(date).utcOffset();
87
+ const tzOffsetInMinutes = dayjs(date).tz(tz).utcOffset();
88
+ const offsetDifference = localOffsetInMinutes - tzOffsetInMinutes;
89
+ return offsetDifference > 0
90
+ ? dayjs(date).add(offsetDifference, 'minutes').toDate()
91
+ : dayjs(date).subtract(offsetDifference, 'minutes').toDate();
92
+ };
93
+
94
+ /**
95
+ * @description 本地时间保存为中国日期
96
+ * @param {(string|Date)} date 日期
97
+ * @param {string} [default=''] 默认返回值
98
+ * @return {Date}
99
+ */
100
+
101
+ const local_cn_date: dateTransform = (date, defaultStr = '') => {
102
+ if (!date || !isValidDate(date)) return defaultStr;
103
+ return local_tz_date(date, 'Asia/Shanghai');
104
+ };
105
+
106
+ /**
107
+ * @description 本地时间保存为法国日期
108
+ * @param {(string|Date)} date 日期
109
+ * @param {string} [default=''] 默认返回值
110
+ * @return {Date}
111
+ */
112
+
113
+ const local_fr_date: dateTransform = (date, defaultStr = '') => {
114
+ if (!date || !isValidDate(date)) return defaultStr;
115
+ return local_tz_date(date, 'Europe/Paris');
116
+ };
117
+
118
+ export { utc_cn, utc_fr, local_utc_date, local_cn_date, local_fr_date, local_tz_date, isValidDate, dayjs };
119
+ export type { dateFormat, dateTransform, tzTransform, dateValidate };
package/utils/storage.js CHANGED
@@ -1,27 +1,27 @@
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
- };
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
+ };
@@ -1 +0,0 @@
1
- "use strict";var T=Object.defineProperty,M=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var v=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var h=(n,o,t)=>o in n?T(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t,w=(n,o)=>{for(var t in o||(o={}))$.call(o,t)&&h(n,t,o[t]);if(v)for(var t of v(o))z.call(o,t)&&h(n,t,o[t]);return n},y=(n,o)=>M(n,U(o));var k=(n,o,t)=>new Promise((s,i)=>{var u=l=>{try{c(t.next(l))}catch(m){i(m)}},f=l=>{try{c(t.throw(l))}catch(m){i(m)}},c=l=>l.done?s(l.value):Promise.resolve(l.value).then(u,f);c((t=t.apply(n,o)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-e5e2a9ce.cjs"),e=require("vue");require("pinia");const P=r.buildProps({direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},contentPosition:{type:String,values:["left","center","right"],default:"center"},borderStyle:{type:r.definePropType(String),default:"solid"}}),I=e.defineComponent({name:"ElDivider"}),A=e.defineComponent(y(w({},I),{props:P,setup(n){const o=n,t=r.useNamespace("divider"),s=e.computed(()=>t.cssVar({"border-style":o.borderStyle}));return(i,u)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(t).b(),e.unref(t).m(i.direction)]),style:e.normalizeStyle(e.unref(s)),role:"separator"},[i.$slots.default&&i.direction!=="vertical"?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([e.unref(t).e("text"),e.unref(t).is(i.contentPosition)])},[e.renderSlot(i.$slots,"default")],2)):e.createCommentVNode("v-if",!0)],6))}}));var H=r._export_sfc(A,[["__file","/home/runner/work/element-plus/element-plus/packages/components/divider/src/divider.vue"]]);const q=r.withInstall(H);const L={class:"dialog__title"},j=["innerHTML"],F=e.defineComponent({__name:"CheckMessageDialog",emits:["preventHiddenDropdown"],setup(n,{expose:o,emit:t}){const s=e.ref(!1),i=e.inject("authBaseUrl"),u=e.inject("dialogI18n"),f=localStorage.getItem("token")||"",c=e.ref(!1),l=e.ref({}),m={Authorization:`Bearer ${f}`},D=e.computed(()=>`${i||r.configProxy.authBaseUrl||"https://gateway-staging.ftlapp.io"}/api/xpush/imm/userMessage/getUserMsgInfo`),C=d=>k(this,null,function*(){try{c.value=!0;const a=yield r.axios.get(D.value,{headers:m,params:{msgId:d}});a&&a.data&&(l.value=a.data)}catch(a){console.log(a)}finally{c.value=!1}}),_=e.computed(()=>l.value.immAttachments&&l.value.immAttachments.length!==0),B=d=>{d&&window.open(d,"_blank")};return o({open:d=>{C(d),s.value=!0}}),(d,a)=>{const x=q,g=r.ElButton,V=r.ElDropdownItem,S=r.ElDropdownMenu,E=r.ElDropdown,N=r.ElDialog,b=r.vLoading;return e.openBlock(),e.createBlock(N,{center:"",title:e.unref(u).dialogTitleText,modelValue:e.unref(s),"onUpdate:modelValue":a[1]||(a[1]=p=>e.isRef(s)?s.value=p:null),"append-to-body":"",model:!1,onClosed:a[2]||(a[2]=()=>{d.$emit("preventHiddenDropdown")})},{default:e.withCtx(()=>[e.createElementVNode("header",L,e.toDisplayString(e.unref(l).title),1),e.createVNode(x),e.withDirectives(e.createElementVNode("div",{innerHTML:e.unref(l).content},null,8,j),[[b,e.unref(c)]]),e.createElementVNode("footer",{class:e.normalizeClass(["mt15",[e.unref(_)?"f-s-c":"f-c-e"]])},[e.unref(_)?(e.openBlock(),e.createBlock(E,{key:0},{dropdown:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(l).immAttachments,p=>(e.openBlock(),e.createBlock(V,{key:p.fileDownloadUrl,onClick:()=>B(p.fileDownloadUrl)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.fileName),1)]),_:2},1032,["onClick"]))),128))]),_:1})]),default:e.withCtx(()=>[e.createVNode(g,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(u).downloadText),1)]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(g,{onClick:a[0]||(a[0]=p=>s.value=!1)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(u).cancelButtonText),1)]),_:1})],2)]),_:1},8,["title","modelValue"])}}});const O=r._export_sfc$1(F,[["__scopeId","data-v-b6d5935c"]]);exports.default=O;