zyf-model-engine 0.0.1 → 0.0.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.
Files changed (153) hide show
  1. package/build/getEnv.d.ts +13 -0
  2. package/build/plugins.d.ts +7 -0
  3. package/build/proxy.d.ts +11 -0
  4. package/index.html +2 -100
  5. package/manifest.webmanifest +1 -0
  6. package/package.json +3 -94
  7. package/registerSW.js +1 -0
  8. package/src/api/config/servicePort.d.ts +2 -0
  9. package/src/api/enums/httpEnum.d.ts +29 -0
  10. package/src/api/helper/axiosCancel.d.ts +21 -0
  11. package/src/api/helper/axiosFileCancel.d.ts +27 -0
  12. package/src/api/helper/checkStatus.d.ts +6 -0
  13. package/src/api/index.d.ts +26 -0
  14. package/src/api/interface/index.d.ts +18 -0
  15. package/src/components/CTree/interface/index.d.ts +6 -0
  16. package/src/components/Grid/interface/index.d.ts +5 -0
  17. package/src/components/ProTable/interface/index.d.ts +66 -0
  18. package/src/config/index.d.ts +5 -0
  19. package/src/config/nprogress.d.ts +3 -0
  20. package/src/config/piniaPersist.d.ts +10 -0
  21. package/src/config/serviceLoading.d.ts +5 -0
  22. package/src/enums/httpEnum.d.ts +19 -0
  23. package/src/hooks/interface/index.d.ts +30 -0
  24. package/src/hooks/useOnline.d.ts +6 -0
  25. package/src/hooks/useTable.d.ts +47 -0
  26. package/src/main.d.ts +1 -0
  27. package/src/stores/commonStore.d.ts +2 -0
  28. package/src/stores/index.d.ts +2 -0
  29. package/src/stores/interface/index.d.ts +1 -0
  30. package/src/utils/color.d.ts +28 -0
  31. package/src/utils/commonUtils.d.ts +63 -0
  32. package/src/utils/errorHandler.d.ts +5 -0
  33. package/src/utils/is.d.ts +82 -0
  34. package/src/utils/layoutUtils.d.ts +44 -0
  35. package/src/utils/localUtils.d.ts +24 -0
  36. package/src/utils/serviceDict.d.ts +7 -0
  37. package/style.css +1 -0
  38. package/sw.js +1 -0
  39. package/vite.config.d.ts +2 -0
  40. package/workbox-3e911b1d.js +1 -0
  41. package/zyf-model-engine.mjs +45118 -0
  42. package/zyf-model-engine.umd.js +81 -0
  43. package/.editorconfig +0 -15
  44. package/.env +0 -13
  45. package/.env.development +0 -20
  46. package/.env.production +0 -25
  47. package/.env.test +0 -25
  48. package/.eslintignore +0 -15
  49. package/.eslintrc-auto-import.json +0 -65
  50. package/.eslintrc.cjs +0 -66
  51. package/.husky/commit-msg +0 -4
  52. package/.husky/pre-commit +0 -5
  53. package/.prettierignore +0 -9
  54. package/.prettierrc.cjs +0 -41
  55. package/.stylelintignore +0 -4
  56. package/.stylelintrc.cjs +0 -40
  57. package/.vscode/extensions.json +0 -14
  58. package/.vscode/settings.json +0 -92
  59. package/CHANGELOG.md +0 -246
  60. package/LICENSE +0 -21
  61. package/README.md +0 -205
  62. package/auto-imports.d.ts +0 -132
  63. package/build/getEnv.ts +0 -46
  64. package/build/plugins.ts +0 -138
  65. package/build/proxy.ts +0 -28
  66. package/commitlint.config.cjs +0 -84
  67. package/components.d.ts +0 -28
  68. package/lint-staged.config.cjs +0 -8
  69. package/postcss.config.cjs +0 -5
  70. package/src/App.vue +0 -16
  71. package/src/api/config/servicePort.ts +0 -3
  72. package/src/api/enums/httpEnum.ts +0 -35
  73. package/src/api/helper/axiosCancel.ts +0 -50
  74. package/src/api/helper/axiosFileCancel.ts +0 -62
  75. package/src/api/helper/checkStatus.ts +0 -97
  76. package/src/api/index.ts +0 -142
  77. package/src/api/interface/index.ts +0 -27
  78. package/src/assets/global-icons/icon-demo.svg +0 -1
  79. package/src/assets/iconfont/iconfont.scss +0 -44
  80. package/src/assets/iconfont/iconfont.ttf +0 -0
  81. package/src/assets/images/empty-img.png +0 -0
  82. package/src/assets/option-icons/add.svg +0 -1
  83. package/src/assets/option-icons/check.svg +0 -1
  84. package/src/assets/option-icons/config.svg +0 -1
  85. package/src/assets/option-icons/del.svg +0 -1
  86. package/src/assets/option-icons/detail.svg +0 -1
  87. package/src/assets/option-icons/edit.svg +0 -2
  88. package/src/assets/option-icons/export.svg +0 -1
  89. package/src/assets/option-icons/folder.svg +0 -1
  90. package/src/assets/option-icons/full-screen.svg +0 -1
  91. package/src/assets/option-icons/more.svg +0 -1
  92. package/src/assets/option-icons/return.svg +0 -1
  93. package/src/assets/option-icons/search.svg +0 -1
  94. package/src/components/CSvgIcon/index.scss +0 -23
  95. package/src/components/CSvgIcon/index.vue +0 -74
  96. package/src/components/CTree/index.scss +0 -48
  97. package/src/components/CTree/index.vue +0 -176
  98. package/src/components/CTree/interface/index.ts +0 -6
  99. package/src/components/Dialog/index.scss +0 -74
  100. package/src/components/Dialog/index.vue +0 -87
  101. package/src/components/Empty/index.scss +0 -16
  102. package/src/components/Empty/index.vue +0 -43
  103. package/src/components/Grid/components/GridItem.vue +0 -68
  104. package/src/components/Grid/index.vue +0 -167
  105. package/src/components/Grid/interface/index.ts +0 -6
  106. package/src/components/Loading/index.scss +0 -67
  107. package/src/components/Loading/index.vue +0 -13
  108. package/src/components/Overflow/index.vue +0 -76
  109. package/src/components/ProTable/components/ColSetting.vue +0 -45
  110. package/src/components/ProTable/components/Pagination.vue +0 -29
  111. package/src/components/ProTable/components/SearchForm/components/SearchFormItem.vue +0 -93
  112. package/src/components/ProTable/components/SearchForm/index.scss +0 -12
  113. package/src/components/ProTable/components/SearchForm/index.vue +0 -91
  114. package/src/components/ProTable/components/TableColumn.vue +0 -56
  115. package/src/components/ProTable/index.scss +0 -14
  116. package/src/components/ProTable/index.vue +0 -274
  117. package/src/components/ProTable/interface/index.ts +0 -86
  118. package/src/components/ScrollBox/index.vue +0 -44
  119. package/src/components/SvgIcon/index.vue +0 -20
  120. package/src/components/Tabs/index.vue +0 -142
  121. package/src/config/index.ts +0 -12
  122. package/src/config/nprogress.ts +0 -12
  123. package/src/config/piniaPersist.ts +0 -19
  124. package/src/config/serviceLoading.ts +0 -45
  125. package/src/enums/httpEnum.ts +0 -24
  126. package/src/hooks/interface/index.ts +0 -32
  127. package/src/hooks/useOnline.ts +0 -27
  128. package/src/hooks/useTable.ts +0 -167
  129. package/src/main.ts +0 -35
  130. package/src/plugins/button/button.vue +0 -56
  131. package/src/plugins/index.js +0 -26
  132. package/src/plugins/index.vue +0 -24
  133. package/src/plugins/msg/msg.vue +0 -56
  134. package/src/stores/commonStore.ts +0 -9
  135. package/src/stores/index.ts +0 -8
  136. package/src/stores/interface/index.ts +0 -1
  137. package/src/styles/common.scss +0 -87
  138. package/src/styles/element.scss +0 -233
  139. package/src/styles/reset.scss +0 -20
  140. package/src/styles/var.scss +0 -2
  141. package/src/typings/global.d.ts +0 -37
  142. package/src/typings/window.d.ts +0 -8
  143. package/src/utils/color.ts +0 -59
  144. package/src/utils/commonUtils.ts +0 -175
  145. package/src/utils/errorHandler.ts +0 -28
  146. package/src/utils/is.ts +0 -147
  147. package/src/utils/layoutUtils.ts +0 -83
  148. package/src/utils/localUtils.ts +0 -42
  149. package/src/utils/serviceDict.ts +0 -9
  150. package/src/vite-env.d.ts +0 -6
  151. package/tsconfig.json +0 -50
  152. package/vite.config.ts +0 -76
  153. /package/{public/logo.png → logo.png} +0 -0
@@ -1,56 +0,0 @@
1
- <template>
2
- <div class="msg" ref="msg" :class="{ active: msgStatus }">
3
- <div class="msg-warpper">
4
- {{ text }}
5
- </div>
6
- </div>
7
- </template>
8
- <script setup>
9
- import { ref } from "vue";
10
- //控制组件的显示
11
- let msgStatus = ref(false);
12
- let text = ref("");
13
-
14
- const msgPlugin = function (msg, time = 2000) {
15
- text.value = msg;
16
- msgStatus.value = true;
17
- setTimeout(() => {
18
- msgStatus.value = false;
19
- }, time);
20
- };
21
- defineExpose({
22
- //向外暴露方法
23
- msgPlugin
24
- });
25
- </script>
26
-
27
- <script>
28
- export default {
29
- name: "VueMsg"
30
- };
31
- </script>
32
-
33
- <style scoped>
34
- .msg {
35
- position: absolute;
36
- top: 50%;
37
- left: 50%;
38
- z-index: -1;
39
- width: 0;
40
- height: 22px;
41
- min-height: 0;
42
- color: #ffffff;
43
- text-align: center;
44
- background-color: rgb(0 0 0 / 50%);
45
- border-radius: 5px;
46
- opacity: 0;
47
- transition: all 0.5s;
48
- transform: translate(-50%, -50%);
49
- }
50
- .msg.active {
51
- z-index: 11;
52
- width: 150px;
53
- min-height: 25px;
54
- opacity: 1;
55
- }
56
- </style>
@@ -1,9 +0,0 @@
1
- const storeArr = import.meta.glob("@/stores/modules/*.ts", { eager: true });
2
- let store: Record<string, any> = {};
3
- Object.entries(storeArr).forEach(([key, useStore]) => {
4
- for (const useKey in useStore as object) {
5
- store[(useStore as any)[useKey].$id] = (useStore as any)[useKey]().$state;
6
- }
7
- });
8
- // 取出项目中的所有全局变量
9
- export default store;
@@ -1,8 +0,0 @@
1
- import { createPinia } from "pinia";
2
- import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
3
-
4
- // pinia persist
5
- const pinia = createPinia();
6
- pinia.use(piniaPluginPersistedstate);
7
-
8
- export default pinia;
@@ -1 +0,0 @@
1
- export type AssemblySizeType = "large" | "default" | "small";
@@ -1,87 +0,0 @@
1
- /* flex */
2
- .flx-center {
3
- display: flex;
4
- align-items: center;
5
- justify-content: center;
6
- }
7
- .flx-justify-between {
8
- display: flex;
9
- align-items: center;
10
- justify-content: space-between;
11
- }
12
- .flx-align-center {
13
- display: flex;
14
- align-items: center;
15
- }
16
- .row-click {
17
- color: $primary-color;
18
- cursor: pointer;
19
- }
20
- .row-un-click {
21
- color: var(--el-border-color-light);
22
- cursor: not-allowed;
23
- }
24
- .full {
25
- width: 100%;
26
- height: 100%;
27
- }
28
- .w-full {
29
- width: 100%;
30
- }
31
- .h-full {
32
- height: 100%;
33
- }
34
-
35
- /* clearfix */
36
- .clearfix::after {
37
- display: block;
38
- height: 0;
39
- overflow: hidden;
40
- clear: both;
41
- content: "";
42
- }
43
-
44
- /* 文字单行省略号 */
45
- .sle {
46
- overflow: hidden;
47
- text-overflow: ellipsis;
48
- white-space: nowrap;
49
- }
50
-
51
- /* 文字多行省略号 */
52
- .mle {
53
- display: -webkit-box;
54
- overflow: hidden;
55
- -webkit-box-orient: vertical;
56
- -webkit-line-clamp: 2;
57
- }
58
-
59
- /* 文字多了自动換行 */
60
- .break-word {
61
- word-break: break-all;
62
- word-wrap: break-word;
63
- }
64
-
65
- /* scroll bar */
66
- ::-webkit-scrollbar {
67
- width: 6px;
68
- height: 6px;
69
- }
70
- ::-webkit-scrollbar-thumb {
71
- background-color: var(--el-fill-color-light) !important;
72
- border-radius: 5px;
73
- }
74
-
75
- /* nprogress */
76
- #nprogress .bar {
77
- background: var(--el-color-primary) !important;
78
- }
79
- #nprogress .spinner-icon {
80
- border-top-color: var(--el-color-primary) !important;
81
- border-left-color: var(--el-color-primary) !important;
82
- }
83
- #nprogress .peg {
84
- box-shadow:
85
- 0 0 10px var(--el-color-primary),
86
- 0 0 5px var(--el-color-primary) !important;
87
- }
@@ -1,233 +0,0 @@
1
- /* 设置 notification、message 层级在 loading 之上 */
2
- .el-message,
3
- .el-notification {
4
- z-index: 2058 !important;
5
- }
6
-
7
- /* el-alert */
8
- .el-alert {
9
- border: 1px solid;
10
- }
11
-
12
- /* 当前页面最大化 css */
13
- .main-maximize {
14
- .aside-split,
15
- .el-aside,
16
- .el-header,
17
- .el-footer,
18
- .tabs-box {
19
- display: none !important;
20
- }
21
- }
22
-
23
- /* mask image */
24
- .mask-image {
25
- padding-right: 50px;
26
- mask-image: linear-gradient(90deg, #000000 0%, #000000 calc(100% - 50px), transparent);
27
- }
28
-
29
- /* custom card */
30
- .card {
31
- box-sizing: border-box;
32
- padding: 20px;
33
- overflow-x: hidden;
34
- background-color: var(--bg-color-2);
35
- border: 1px solid var(--el-border-color-light);
36
- border-radius: 6px;
37
- box-shadow: 0 0 12px rgb(0 0 0 / 5%);
38
- }
39
-
40
- /* ProTable 不需要 card 样式(在组件内使用 ProTable 会使用到) */
41
- .no-card {
42
- .card {
43
- padding: 0;
44
- background: var(--bg-color);
45
- background-color: transparent;
46
- border: none;
47
- border-radius: 0;
48
- box-shadow: none;
49
- }
50
- .table-search {
51
- padding: 18px 0 0 !important;
52
- margin-bottom: 0 !important;
53
- }
54
- }
55
-
56
- /* proTable */
57
- .table-box,
58
- .table-main {
59
- display: flex;
60
- flex: 1;
61
- flex-direction: column;
62
- width: 100%;
63
- height: 100%;
64
-
65
- // table-search 表格搜索样式
66
- .table-search {
67
- padding: 18px 18px 0;
68
- margin-bottom: 10px;
69
- .el-form {
70
- .el-form-item__content > * {
71
- width: 100%;
72
- }
73
-
74
- // 去除时间选择器上下 padding
75
- .el-range-editor.el-input__wrapper {
76
- padding: 0 10px;
77
- }
78
- }
79
- .operation {
80
- display: flex;
81
- align-items: center;
82
- justify-content: flex-end;
83
- margin-bottom: 18px;
84
- }
85
- }
86
-
87
- // 表格 header 样式
88
- .table-header {
89
- .header-button-lf {
90
- float: left;
91
- }
92
- .header-button-ri {
93
- float: right;
94
- }
95
- .el-button {
96
- margin-bottom: 15px;
97
- }
98
- }
99
-
100
- // el-table 表格样式
101
- .el-table {
102
- flex: 1;
103
-
104
- // 修复 safari 浏览器表格错位 https://github.com/HalseySpicy/Geeker-Admin/issues/83
105
- table {
106
- width: 100%;
107
- }
108
- .el-table__header th {
109
- height: 45px;
110
- font-size: 15px;
111
- font-weight: bold;
112
- color: var(--el-text-color-primary);
113
- background: var(--el-fill-color-light);
114
- }
115
- .el-table__row {
116
- height: 45px;
117
- font-size: 14px;
118
- }
119
-
120
- // 设置 el-table 中 header 文字不换行,并省略
121
- .el-table__header .el-table__cell > .cell {
122
- white-space: nowrap;
123
- }
124
-
125
- // 解决表格数据为空时样式不居中问题(仅在element-plus中)
126
- .el-table__empty-block {
127
- position: absolute;
128
- top: 50%;
129
- left: 50%;
130
- transform: translate(-50%, -50%);
131
- .table-empty {
132
- line-height: 30px;
133
- }
134
- }
135
-
136
- // table 中 image 图片样式
137
- .table-image {
138
- width: 50px;
139
- height: 50px;
140
- border-radius: 50%;
141
- }
142
- }
143
-
144
- // 表格 pagination 样式
145
- .el-pagination {
146
- display: flex;
147
- justify-content: flex-end;
148
- margin-top: 20px;
149
- }
150
- }
151
-
152
- /* el-table 组件大小 */
153
- .el-table--small {
154
- .el-table__header th {
155
- height: 40px !important;
156
- font-size: 14px !important;
157
- }
158
- .el-table__row {
159
- height: 40px !important;
160
- font-size: 13px !important;
161
- }
162
- }
163
- .el-table--large {
164
- .el-table__header th {
165
- height: 50px !important;
166
- font-size: 16px !important;
167
- }
168
- .el-table__row {
169
- height: 50px !important;
170
- font-size: 15px !important;
171
- }
172
- }
173
-
174
- /* el-drawer */
175
- .el-drawer {
176
- .el-drawer__header {
177
- padding: 16px 20px;
178
- margin-bottom: 0;
179
- border-bottom: 1px solid var(--el-border-color-lighter);
180
- span {
181
- font-size: 17px;
182
- line-height: 17px;
183
- color: var(--el-text-color-primary) !important;
184
- }
185
- }
186
- .el-drawer__footer {
187
- border-top: 1px solid var(--el-border-color-lighter);
188
- }
189
-
190
- // select 样式
191
- .el-select {
192
- width: 100%;
193
- }
194
-
195
- // drawer-form 中存在两列 form-item 样式
196
- .drawer-multiColumn-form {
197
- display: flex;
198
- flex-wrap: wrap;
199
- .el-form-item {
200
- width: 47%;
201
- &:nth-child(2n-1) {
202
- margin-right: 5%;
203
- }
204
- }
205
- }
206
- }
207
-
208
- /* el-dialog */
209
- .el-dialog {
210
- .el-dialog__header {
211
- padding: 0 36px 15px 10px;
212
- margin: 0 0 20px;
213
-
214
- // background-color: #f1f9f9;
215
- border-bottom: 1px solid var(--el-border-color-lighter);
216
- .el-dialog__title {
217
- font-size: 17px;
218
- }
219
- }
220
- }
221
- .el-icon {
222
- box-sizing: content-box !important;
223
- }
224
- .color-primary {
225
- color: var(--el-color-primary);
226
- }
227
-
228
- /** el-table toolitp */
229
- .el-table {
230
- .el-popper.is-dark {
231
- max-width: 500px;
232
- }
233
- }
@@ -1,20 +0,0 @@
1
- html,
2
- body,
3
- #app {
4
- width: 100%;
5
- height: 100%;
6
- padding: 0;
7
- margin: 0;
8
- font-family: MiSans;
9
- }
10
- * {
11
- box-sizing: border-box !important;
12
- }
13
- .el-tooltip__trigger:focus {
14
- outline: none;
15
- }
16
-
17
- /* 解决 h1 标签在 webkit 内核浏览器中文字大小失效问题 */
18
- :-webkit-any(article, aside, nav, section) h1 {
19
- font-size: 2em;
20
- }
@@ -1,2 +0,0 @@
1
- /* global css variable */
2
- $primary-color: var(--el-color-primary);
@@ -1,37 +0,0 @@
1
- /* Vite */
2
- declare type Recordable<T = any> = Record<string, T>;
3
-
4
- declare interface ViteEnv {
5
- VITE_USER_NODE_ENV: "development" | "production" | "test";
6
- VITE_GLOB_APP_TITLE: string;
7
- VITE_PORT: number;
8
- VITE_OPEN: boolean;
9
- VITE_BUILD_COMPRESS: "gzip" | "brotli" | "gzip,brotli" | "none";
10
- VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
11
- VITE_DROP_CONSOLE: boolean;
12
- VITE_PWA: boolean;
13
- VITE_PUBLIC_PATH: string;
14
- VITE_API_URL: string;
15
- VITE_REPORT: boolean;
16
- VITE_PROXY: [string, string][];
17
- }
18
-
19
- /* __APP_INFO__ */
20
- declare const __APP_INFO__: {
21
- pkg: {
22
- name: string;
23
- version: string;
24
- dependencies: Recordable<string>;
25
- devDependencies: Recordable<string>;
26
- };
27
- lastBuildTime: string;
28
- };
29
-
30
- /* Generic Tools */
31
- type ObjToKeyValUnion<T> = {
32
- [K in keyof T]: { key: K; value: T[K] };
33
- }[keyof T];
34
-
35
- type ObjToKeyValArray<T> = {
36
- [K in keyof T]: [K, T[K]];
37
- }[keyof T];
@@ -1,8 +0,0 @@
1
- declare global {
2
- interface Navigator {
3
- msSaveOrOpenBlob: (blob: Blob, fileName: string) => void;
4
- browserLanguage: string;
5
- }
6
- }
7
-
8
- export {};
@@ -1,59 +0,0 @@
1
- import { ElMessage } from "element-plus";
2
-
3
- /**
4
- * @description hex颜色转rgb颜色
5
- * @param {String} str 颜色值字符串
6
- * @returns {String} 返回处理后的颜色值
7
- */
8
- export function hexToRgb(str: any) {
9
- let hexs: any = "";
10
- let reg = /^\#?[0-9A-Fa-f]{6}$/;
11
- if (!reg.test(str)) return ElMessage.warning("输入错误的hex");
12
- str = str.replace("#", "");
13
- hexs = str.match(/../g);
14
- for (let i = 0; i < 3; i++) hexs[i] = parseInt(hexs[i], 16);
15
- return hexs;
16
- }
17
-
18
- /**
19
- * @description rgb颜色转Hex颜色
20
- * @param {*} r 代表红色
21
- * @param {*} g 代表绿色
22
- * @param {*} b 代表蓝色
23
- * @returns {String} 返回处理后的颜色值
24
- */
25
- export function rgbToHex(r: any, g: any, b: any) {
26
- let reg = /^\d{1,3}$/;
27
- if (!reg.test(r) || !reg.test(g) || !reg.test(b)) return ElMessage.warning("输入错误的rgb颜色值");
28
- let hexs = [r.toString(16), g.toString(16), b.toString(16)];
29
- for (let i = 0; i < 3; i++) if (hexs[i].length == 1) hexs[i] = `0${hexs[i]}`;
30
- return `#${hexs.join("")}`;
31
- }
32
-
33
- /**
34
- * @description 加深颜色值
35
- * @param {String} color 颜色值字符串
36
- * @param {Number} level 加深的程度,限0-1之间
37
- * @returns {String} 返回处理后的颜色值
38
- */
39
- export function getDarkColor(color: string, level: number) {
40
- let reg = /^\#?[0-9A-Fa-f]{6}$/;
41
- if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
42
- let rgb = hexToRgb(color);
43
- for (let i = 0; i < 3; i++) rgb[i] = Math.round(20.5 * level + rgb[i] * (1 - level));
44
- return rgbToHex(rgb[0], rgb[1], rgb[2]);
45
- }
46
-
47
- /**
48
- * @description 变浅颜色值
49
- * @param {String} color 颜色值字符串
50
- * @param {Number} level 加深的程度,限0-1之间
51
- * @returns {String} 返回处理后的颜色值
52
- */
53
- export function getLightColor(color: string, level: number) {
54
- let reg = /^\#?[0-9A-Fa-f]{6}$/;
55
- if (!reg.test(color)) return ElMessage.warning("输入错误的hex颜色值");
56
- let rgb = hexToRgb(color);
57
- for (let i = 0; i < 3; i++) rgb[i] = Math.round(255 * level + rgb[i] * (1 - level));
58
- return rgbToHex(rgb[0], rgb[1], rgb[2]);
59
- }
@@ -1,175 +0,0 @@
1
- import dayjs from "dayjs";
2
-
3
- /**
4
- * @description 生成唯一 uuid
5
- * @returns {String}
6
- */
7
- export function generateUUID() {
8
- let uuid = "";
9
- for (let i = 0; i < 32; i++) {
10
- let random = (Math.random() * 16) | 0;
11
- if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-";
12
- uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16);
13
- }
14
- return uuid;
15
- }
16
-
17
- /**
18
- * @description 深拷贝
19
- */
20
- export const deepClone = (obj: { [k: string]: any }): { [k: string]: any } => {
21
- if (typeof obj !== "object" || obj === null) {
22
- return obj;
23
- }
24
- let copy: { [k: string]: any };
25
- if (Array.isArray(obj)) {
26
- copy = [] as any;
27
- for (let i = 0; i < obj.length; i++) {
28
- copy[i] = deepClone(obj[i]);
29
- }
30
- } else {
31
- copy = {} as any;
32
- for (const key in obj) {
33
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
34
- copy[key] = deepClone(obj[key]);
35
- }
36
- }
37
- }
38
- return copy;
39
- };
40
-
41
- /**
42
- * 防抖
43
- * @param fn {Function}
44
- * @param delay {number}
45
- */
46
- export function debounce<T>(fn: T, delay: number): () => void {
47
- let timer: NodeJS.Timeout;
48
- return function (): void {
49
- // eslint-disable-next-line prefer-rest-params
50
- const args: any[] = Array.prototype.map.call(arguments, val => val);
51
- if (timer) {
52
- clearTimeout(timer);
53
- }
54
- timer = setTimeout(
55
- () => {
56
- // eslint-disable-next-line prefer-spread
57
- typeof fn === "function" && fn.apply(null, args);
58
- clearTimeout(timer);
59
- },
60
- delay > 0 ? delay : 100
61
- );
62
- };
63
- }
64
-
65
- /**
66
- * @description 日期转换
67
- * @param {string} value
68
- * @param {string} format
69
- * @returns {string}
70
- */
71
- export function formatDate(value: string, format = "YYYY-MM-DD") {
72
- if (!value) return "";
73
- return dayjs(value).format(format);
74
- }
75
-
76
- /**
77
- * @description 生成随机数
78
- * @param {Number} min 最小值
79
- * @param {Number} max 最大值
80
- * @returns {Number}
81
- */
82
- export function randomNum(min: number, max: number): number {
83
- let num = Math.floor(Math.random() * (min - max) + max);
84
- return num;
85
- }
86
-
87
- /**
88
- * @description 为对象添加level层级
89
- */
90
- export const addLevel = (arr: Record<string, any>[], level: number = 1, attribute?: string) => {
91
- arr.forEach((obj: Record<string, any>) => {
92
- // && obj.hasOwnProperty(attribute)
93
- if (attribute) {
94
- obj[attribute].level = level;
95
- } else {
96
- obj.level = level;
97
- }
98
- if (obj.children && obj.children.length > 0) {
99
- addLevel(obj.children, level + 1, attribute);
100
- }
101
- });
102
- };
103
-
104
- // 深度遍历对象
105
- export function deepTraverse(obj: Record<string, any>, callback: (key: string, value: any) => any) {
106
- // 遍历对象中的每一个属性
107
- for (const key in obj) {
108
- // 检查属性是否属于对象本身而不是原型链上的属性
109
- if (obj.hasOwnProperty(key)) {
110
- // 调用回调函数处理当前属性值
111
- callback(key, obj[key]);
112
- // 如果属性值是一个对象,则递归调用 deepTraverse
113
- if (typeof obj[key] === "object" && obj[key] !== null) {
114
- deepTraverse(obj[key], callback);
115
- }
116
- }
117
- }
118
- }
119
-
120
- /**
121
- * @description 将objB与objA的交集赋值给objA
122
- * @param {Object} objA 要比较的对象一
123
- * @param {Object} objB 要比较的对象二
124
- */
125
- export const listAssign = (objA: Record<string, any>, objB: Record<string, any>) => {
126
- for (const key in objA) {
127
- objA[key] = objB[key] ?? objA[key];
128
- }
129
- return objA;
130
- };
131
-
132
- /**
133
- * 判断两个对象是否相同
134
- * @param {Object} a 要比较的对象一
135
- * @param {Object} b 要比较的对象二
136
- * @returns {Boolean} 相同返回 true,反之 false
137
- */
138
- export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string]: any }) {
139
- if (!a || !b) return false;
140
- let aProps = Object.getOwnPropertyNames(a);
141
- let bProps = Object.getOwnPropertyNames(b);
142
- if (aProps.length != bProps.length) return false;
143
- for (let i = 0; i < aProps.length; i++) {
144
- let propName = aProps[i];
145
- let propA = a[propName];
146
- let propB = b[propName];
147
- if (!b.hasOwnProperty(propName)) return false;
148
- if (propA instanceof Object) {
149
- if (!isObjectValueEqual(propA, propB)) return false;
150
- } else if (propA !== propB) {
151
- return false;
152
- }
153
- }
154
- return true;
155
- }
156
- /**
157
- * @description 传入两个数组返回两个数组的交集 只能判断简单数据类型
158
- */
159
- export function arrayIntersection(arr1: any[], arr2: any[]) {
160
- if (arr1?.length && arr2?.length) {
161
- return arr1.filter(function (value) {
162
- return value && arr2.indexOf(value) !== -1;
163
- });
164
- }
165
- return [];
166
- }
167
-
168
- /**
169
- * @description 文字size适配
170
- */
171
- export function formatFontSize(fontsize: number) {
172
- const clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
173
- if (!clientWidth) return;
174
- return ((fontsize * clientWidth) / 1920).toFixed(2);
175
- }