mrxy-yk 1.4.2 → 1.5.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.
@@ -1,4 +1,5 @@
1
1
  import { EmptyOption } from '../components/empty/type';
2
+ import { Pages } from '../entity';
2
3
  export * from '../element-plus/components/attrs';
3
4
  export * from '../components/attrs';
4
5
  export declare const AMapConfig: {
@@ -30,3 +31,16 @@ export declare const EChartsThemeConfig: {
30
31
  dark: Record<string, any>;
31
32
  default: Record<string, any>;
32
33
  };
34
+ /**
35
+ * 分页配置
36
+ */
37
+ export declare const PagesConfig: {
38
+ params: (pages: Pages) => any;
39
+ };
40
+ /**
41
+ * 加密配置
42
+ */
43
+ export declare const EncryptConfig: {
44
+ encryptMethod: (str: string) => string;
45
+ decryptMethod: (str: string) => string;
46
+ };
@@ -14,6 +14,15 @@ const EChartsThemeConfig = {
14
14
  dark: null,
15
15
  default: null
16
16
  };
17
+ const PagesConfig = {
18
+ params: (pages) => {
19
+ return { pageNum: pages.pageNum, pageSize: pages.pageSize };
20
+ }
21
+ };
22
+ const EncryptConfig = {
23
+ encryptMethod: (str) => str,
24
+ decryptMethod: (str) => str
25
+ };
17
26
  export {
18
27
  AMapConfig,
19
28
  EChartsThemeConfig,
@@ -23,5 +32,7 @@ export {
23
32
  ElUploadImagesGlobal,
24
33
  EmptyGlobal,
25
34
  EmptyStatusExtendConfig,
26
- ExportLinkGlobal
35
+ EncryptConfig,
36
+ ExportLinkGlobal,
37
+ PagesConfig
27
38
  };
@@ -0,0 +1,26 @@
1
+ import { TableColumnCtx } from 'element-plus';
2
+ import { VNode, DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
3
+ type __VLS_Props = {
4
+ emptyStr?: string;
5
+ formatter?: ((row: any, column: TableColumnCtx, cellValue: any, index: number) => VNode) | string;
6
+ };
7
+ declare function __VLS_template(): {
8
+ attrs: Partial<{}>;
9
+ slots: {
10
+ 'filter-icon'?(_: any): any;
11
+ expand?(_: any): any;
12
+ header?(_: any): any;
13
+ default?(_: any): any;
14
+ };
15
+ refs: {};
16
+ rootEl: any;
17
+ };
18
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
19
+ declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
20
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
21
+ export default _default;
22
+ type __VLS_WithTemplateSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -2,8 +2,5 @@ export declare class Pages {
2
2
  pageNum: number;
3
3
  pageSize: number;
4
4
  total: number;
5
- get params(): {
6
- pageNum: number;
7
- pageSize: number;
8
- };
5
+ get params(): any;
9
6
  }
@@ -1,9 +1,10 @@
1
+ import { PagesConfig } from "../config/index.js";
1
2
  class Pages {
2
3
  pageNum = 1;
3
4
  pageSize = 10;
4
5
  total = 0;
5
6
  get params() {
6
- return { pageNum: this.pageNum, pageSize: this.pageSize };
7
+ return PagesConfig.params(this);
7
8
  }
8
9
  }
9
10
  export {
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import { MatchUnit } from "./utils/match-unit/index.js";
10
10
  import { TransitionFade } from "./utils/transition-fade/index.js";
11
11
  import { echarts } from "./utils/echarts/index.js";
12
12
  import { AMapLoader, newAMapInfoWindow, newAMapMap, newAMapMarkerCluster, useAMapLoader } from "./utils/amap/index.js";
13
+ import { StorageUtil } from "./utils/storage/index.js";
13
14
  import { Pages } from "./entity/Pages.js";
14
15
  import { BigFloat } from "./entity/BigFloat.js";
15
16
  import { RejectError } from "./entity/RejectError.js";
@@ -77,6 +78,7 @@ export {
77
78
  PromiseUtil,
78
79
  RejectError,
79
80
  SetupLifeCycle,
81
+ StorageUtil,
80
82
  TableUtil,
81
83
  TransitionFade,
82
84
  YsVideo,
@@ -4,3 +4,4 @@ export * from './transition-fade';
4
4
  export * from './fn-periodically';
5
5
  export * from './echarts';
6
6
  export * from './amap';
7
+ export * from './storage';
@@ -0,0 +1,69 @@
1
+ declare class LocalStorage {
2
+ dataset: Map<string, string>;
3
+ getItem(key: string): string;
4
+ setItem(key: string, value: string): void;
5
+ clear(): void;
6
+ removeItem(key: string): void;
7
+ }
8
+ declare class SessionStorage extends LocalStorage {
9
+ }
10
+ export declare class StorageUtil {
11
+ static localStorage: Storage | LocalStorage;
12
+ static sessionStorage: Storage | SessionStorage;
13
+ static init(): void;
14
+ static local: {
15
+ /**
16
+ * 获取localStorage的值 - 解密
17
+ * @param key
18
+ */
19
+ get(key: string): any;
20
+ /**
21
+ * 设置localStorage的值 - 加密
22
+ * @param key
23
+ * @param value
24
+ */
25
+ set(key: string, value: any): void;
26
+ remove: (key: string) => void;
27
+ clear: () => void;
28
+ };
29
+ static session: {
30
+ /**
31
+ * 获取sessionStorage的值 - 解密
32
+ * @param key
33
+ */
34
+ get(key: string): any;
35
+ /**
36
+ * 设置sessionStorage的值 - 加密
37
+ * @param key
38
+ * @param value
39
+ */
40
+ set(key: string, value: any): void;
41
+ remove: (key: string) => void;
42
+ clear: () => void;
43
+ };
44
+ static cookie: {
45
+ /**
46
+ * 获取cookie
47
+ * @param key
48
+ */
49
+ get(key: string): string;
50
+ /**
51
+ * 设置cookie
52
+ * @param key
53
+ * @param value
54
+ * @param expires 日期字符串|日期对象|天数
55
+ * @param path
56
+ */
57
+ set(key: string, value: string, expires?: string | Date | number, path?: string): void;
58
+ /**
59
+ * 获取所有cookie
60
+ */
61
+ getAll(): Record<string, string>;
62
+ /**
63
+ * 删除cookie
64
+ * @param key
65
+ */
66
+ remove(key: string): void;
67
+ };
68
+ }
69
+ export {};
@@ -0,0 +1,140 @@
1
+ import { EncryptConfig } from "../../config/index.js";
2
+ class LocalStorage {
3
+ dataset = /* @__PURE__ */ new Map();
4
+ getItem(key) {
5
+ return this.dataset.get(key);
6
+ }
7
+ setItem(key, value) {
8
+ this.dataset.set(key, value);
9
+ }
10
+ clear() {
11
+ this.dataset.clear();
12
+ }
13
+ removeItem(key) {
14
+ this.dataset.delete(key);
15
+ }
16
+ }
17
+ class SessionStorage extends LocalStorage {
18
+ }
19
+ class StorageUtil {
20
+ static localStorage = null;
21
+ static sessionStorage = null;
22
+ static init() {
23
+ try {
24
+ this.localStorage = window.localStorage;
25
+ } catch {
26
+ this.localStorage = new LocalStorage();
27
+ }
28
+ try {
29
+ this.sessionStorage = window.sessionStorage;
30
+ } catch {
31
+ this.sessionStorage = new SessionStorage();
32
+ }
33
+ }
34
+ static local = {
35
+ /**
36
+ * 获取localStorage的值 - 解密
37
+ * @param key
38
+ */
39
+ get(key) {
40
+ const str = StorageUtil.localStorage.getItem(key);
41
+ if (str) {
42
+ return JSON.parse(EncryptConfig.decryptMethod(str));
43
+ }
44
+ },
45
+ /**
46
+ * 设置localStorage的值 - 加密
47
+ * @param key
48
+ * @param value
49
+ */
50
+ set(key, value) {
51
+ StorageUtil.localStorage.setItem(key, EncryptConfig.encryptMethod(JSON.stringify(value)));
52
+ },
53
+ remove: (key) => {
54
+ StorageUtil.localStorage.removeItem(key);
55
+ },
56
+ clear: () => {
57
+ StorageUtil.localStorage.clear();
58
+ }
59
+ };
60
+ static session = {
61
+ /**
62
+ * 获取sessionStorage的值 - 解密
63
+ * @param key
64
+ */
65
+ get(key) {
66
+ const str = StorageUtil.sessionStorage.getItem(key);
67
+ if (str) {
68
+ return JSON.parse(EncryptConfig.decryptMethod(str));
69
+ }
70
+ },
71
+ /**
72
+ * 设置sessionStorage的值 - 加密
73
+ * @param key
74
+ * @param value
75
+ */
76
+ set(key, value) {
77
+ StorageUtil.sessionStorage.setItem(key, EncryptConfig.encryptMethod(JSON.stringify(value)));
78
+ },
79
+ remove: (key) => {
80
+ StorageUtil.sessionStorage.removeItem(key);
81
+ },
82
+ clear: () => {
83
+ StorageUtil.sessionStorage.clear();
84
+ }
85
+ };
86
+ static cookie = {
87
+ /**
88
+ * 获取cookie
89
+ * @param key
90
+ */
91
+ get(key) {
92
+ const str = this.getAll()[key];
93
+ return str ? EncryptConfig.decryptMethod(str) : void 0;
94
+ },
95
+ /**
96
+ * 设置cookie
97
+ * @param key
98
+ * @param value
99
+ * @param expires 日期字符串|日期对象|天数
100
+ * @param path
101
+ */
102
+ set(key, value, expires, path = "/") {
103
+ let cookieStr = `${key}=${EncryptConfig.encryptMethod(value)};path=${path}`;
104
+ if (expires) {
105
+ let date = /* @__PURE__ */ new Date();
106
+ if (typeof expires === "number") {
107
+ date.setTime(date.getTime() + expires * 864e5);
108
+ } else {
109
+ date = new Date(expires);
110
+ }
111
+ cookieStr += ";expires=" + date.toUTCString();
112
+ }
113
+ document.cookie = cookieStr;
114
+ },
115
+ /**
116
+ * 获取所有cookie
117
+ */
118
+ getAll() {
119
+ const cookieStr = document.cookie;
120
+ const cookieArr = cookieStr.split(";");
121
+ const cookieObj = {};
122
+ cookieArr.forEach((item) => {
123
+ const m = item.split("=");
124
+ cookieObj[m[0].trim()] = m[1];
125
+ });
126
+ return cookieObj;
127
+ },
128
+ /**
129
+ * 删除cookie
130
+ * @param key
131
+ */
132
+ remove(key) {
133
+ this.set(key, "", -1);
134
+ }
135
+ };
136
+ }
137
+ StorageUtil.init();
138
+ export {
139
+ StorageUtil
140
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrxy-yk",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "A collection of Vue 3 components and utilities",