zyf-model-engine 0.0.1 → 0.1.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.
- package/index.cjs +293 -0
- package/index.d.mts +1 -0
- package/index.d.ts +1 -0
- package/index.mjs +21645 -0
- package/package.json +29 -99
- package/style.css +1 -0
- package/types/components/CSvgIcon/components/SvgPathIcon.vue.d.ts +9 -0
- package/types/components/CSvgIcon/defaultIcons.d.ts +23 -0
- package/types/components/CSvgIcon/index.vue.d.ts +30 -0
- package/types/components/Empty/index.vue.d.ts +16 -0
- package/types/components/Overflow/index.vue.d.ts +11 -0
- package/types/components/UtilsMenu/components/BaseInfo/index.vue.d.ts +122 -0
- package/types/components/UtilsMenu/components/Card/index.vue.d.ts +42 -0
- package/types/components/UtilsMenu/components/ComInfo/index.vue.d.ts +128 -0
- package/types/components/UtilsMenu/components/Config/index.vue.d.ts +8 -0
- package/types/components/UtilsMenu/components/Cutting/clipping.d.ts +56 -0
- package/types/components/UtilsMenu/components/Cutting/index.vue.d.ts +128 -0
- package/types/components/UtilsMenu/components/Measure/index.vue.d.ts +122 -0
- package/types/components/UtilsMenu/components/Measure/interface/index.d.ts +5 -0
- package/types/components/UtilsMenu/components/Measure/measure.d.ts +106 -0
- package/types/components/UtilsMenu/components/ModelTree/index.vue.d.ts +875 -0
- package/types/components/UtilsMenu/components/ModelTree/interface/index.d.ts +19 -0
- package/types/components/UtilsMenu/components/ModelTree/utils/index.d.ts +13 -0
- package/types/components/UtilsMenu/components/Roam/index.vue.d.ts +125 -0
- package/types/components/UtilsMenu/components/SubMenu/index.vue.d.ts +18 -0
- package/types/components/UtilsMenu/index.vue.d.ts +15 -0
- package/types/components/UtilsMenu/interface/index.d.ts +129 -0
- package/types/index-dxf.vue.d.ts +15 -0
- package/types/index.d.ts +209 -0
- package/types/index.vue.d.ts +18 -0
- package/types/libs/CFace.d.ts +16 -0
- package/types/libs/CLabel.d.ts +13 -0
- package/types/libs/CLine.d.ts +49 -0
- package/types/libs/CText.d.ts +17 -0
- package/types/libs/MathUtils.d.ts +26 -0
- package/types/libs/ViewCube.d.ts +21 -0
- package/types/libs/materials.d.ts +4 -0
- package/types/libs/svg.d.ts +26 -0
- package/types/libs/types.d.ts +177 -0
- package/types/main.d.ts +22 -0
- package/types/manager/highLightMeshManager.d.ts +31 -0
- package/types/manager/lightManager.d.ts +35 -0
- package/types/manager/rayCasterManager.d.ts +18 -0
- package/types/tools/Events.d.ts +15 -0
- package/types/tools/math.d.ts +13 -0
- package/types/vendor/DXFPaser/BatchingKey.d.ts +25 -0
- package/types/vendor/DXFPaser/DxfFetcher.d.ts +6 -0
- package/types/vendor/DXFPaser/DxfScene.d.ts +95 -0
- package/types/vendor/DXFPaser/DxfWorker.d.ts +44 -0
- package/types/vendor/DXFPaser/DynamicBuffer.d.ts +30 -0
- package/types/vendor/DXFPaser/Entity.d.ts +18 -0
- package/types/vendor/DXFPaser/MTextFormatParser.d.ts +15 -0
- package/types/vendor/DXFPaser/MaterialKey.d.ts +8 -0
- package/types/vendor/DXFPaser/RBTree.d.ts +5 -0
- package/types/vendor/DXFPaser/TextRenderer.d.ts +43 -0
- package/types/vendor/DXFPaser/index.d.ts +26 -0
- package/types/vendor/controls/BaseArrow.d.ts +20 -0
- package/types/vendor/controls/FirstPersonControls.d.ts +32 -0
- package/types/vendor/controls/FlyControls.d.ts +18 -0
- package/types/vendor/controls/OrbitControls.d.ts +75 -0
- package/types/vendor/controls/TransformControls.d.ts +41 -0
- package/types/vendor/controls/directionControls.d.ts +26 -0
- package/types/vendor/loaders/GLTFLoader.d.ts +71 -0
- package/types/workbench/DxfViewer.d.ts +16 -0
- package/types/workbench/clickInfo.d.ts +24 -0
- package/types/workbench/clipping.d.ts +62 -0
- package/types/workbench/dxfMeasure.d.ts +92 -0
- package/types/workbench/dxfTools.d.ts +78 -0
- package/types/workbench/functionalComponent.d.ts +127 -0
- package/types/workbench/modelTree.d.ts +89 -0
- package/.editorconfig +0 -15
- package/.env +0 -13
- package/.env.development +0 -20
- package/.env.production +0 -25
- package/.env.test +0 -25
- package/.eslintignore +0 -15
- package/.eslintrc-auto-import.json +0 -65
- package/.eslintrc.cjs +0 -66
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -5
- package/.prettierignore +0 -9
- package/.prettierrc.cjs +0 -41
- package/.stylelintignore +0 -4
- package/.stylelintrc.cjs +0 -40
- package/.vscode/extensions.json +0 -14
- package/.vscode/settings.json +0 -92
- package/CHANGELOG.md +0 -246
- package/LICENSE +0 -21
- package/README.md +0 -205
- package/auto-imports.d.ts +0 -132
- package/build/getEnv.ts +0 -46
- package/build/plugins.ts +0 -138
- package/build/proxy.ts +0 -28
- package/commitlint.config.cjs +0 -84
- package/components.d.ts +0 -28
- package/index.html +0 -105
- package/lint-staged.config.cjs +0 -8
- package/postcss.config.cjs +0 -5
- package/public/logo.png +0 -0
- package/src/App.vue +0 -16
- package/src/api/config/servicePort.ts +0 -3
- package/src/api/enums/httpEnum.ts +0 -35
- package/src/api/helper/axiosCancel.ts +0 -50
- package/src/api/helper/axiosFileCancel.ts +0 -62
- package/src/api/helper/checkStatus.ts +0 -97
- package/src/api/index.ts +0 -142
- package/src/api/interface/index.ts +0 -27
- package/src/assets/global-icons/icon-demo.svg +0 -1
- package/src/assets/iconfont/iconfont.scss +0 -44
- package/src/assets/iconfont/iconfont.ttf +0 -0
- package/src/assets/images/empty-img.png +0 -0
- package/src/assets/option-icons/add.svg +0 -1
- package/src/assets/option-icons/check.svg +0 -1
- package/src/assets/option-icons/config.svg +0 -1
- package/src/assets/option-icons/del.svg +0 -1
- package/src/assets/option-icons/detail.svg +0 -1
- package/src/assets/option-icons/edit.svg +0 -2
- package/src/assets/option-icons/export.svg +0 -1
- package/src/assets/option-icons/folder.svg +0 -1
- package/src/assets/option-icons/full-screen.svg +0 -1
- package/src/assets/option-icons/more.svg +0 -1
- package/src/assets/option-icons/return.svg +0 -1
- package/src/assets/option-icons/search.svg +0 -1
- package/src/components/CSvgIcon/index.scss +0 -23
- package/src/components/CSvgIcon/index.vue +0 -74
- package/src/components/CTree/index.scss +0 -48
- package/src/components/CTree/index.vue +0 -176
- package/src/components/CTree/interface/index.ts +0 -6
- package/src/components/Dialog/index.scss +0 -74
- package/src/components/Dialog/index.vue +0 -87
- package/src/components/Empty/index.scss +0 -16
- package/src/components/Empty/index.vue +0 -43
- package/src/components/Grid/components/GridItem.vue +0 -68
- package/src/components/Grid/index.vue +0 -167
- package/src/components/Grid/interface/index.ts +0 -6
- package/src/components/Loading/index.scss +0 -67
- package/src/components/Loading/index.vue +0 -13
- package/src/components/Overflow/index.vue +0 -76
- package/src/components/ProTable/components/ColSetting.vue +0 -45
- package/src/components/ProTable/components/Pagination.vue +0 -29
- package/src/components/ProTable/components/SearchForm/components/SearchFormItem.vue +0 -93
- package/src/components/ProTable/components/SearchForm/index.scss +0 -12
- package/src/components/ProTable/components/SearchForm/index.vue +0 -91
- package/src/components/ProTable/components/TableColumn.vue +0 -56
- package/src/components/ProTable/index.scss +0 -14
- package/src/components/ProTable/index.vue +0 -274
- package/src/components/ProTable/interface/index.ts +0 -86
- package/src/components/ScrollBox/index.vue +0 -44
- package/src/components/SvgIcon/index.vue +0 -20
- package/src/components/Tabs/index.vue +0 -142
- package/src/config/index.ts +0 -12
- package/src/config/nprogress.ts +0 -12
- package/src/config/piniaPersist.ts +0 -19
- package/src/config/serviceLoading.ts +0 -45
- package/src/enums/httpEnum.ts +0 -24
- package/src/hooks/interface/index.ts +0 -32
- package/src/hooks/useOnline.ts +0 -27
- package/src/hooks/useTable.ts +0 -167
- package/src/main.ts +0 -35
- package/src/plugins/button/button.vue +0 -56
- package/src/plugins/index.js +0 -26
- package/src/plugins/index.vue +0 -24
- package/src/plugins/msg/msg.vue +0 -56
- package/src/stores/commonStore.ts +0 -9
- package/src/stores/index.ts +0 -8
- package/src/stores/interface/index.ts +0 -1
- package/src/styles/common.scss +0 -87
- package/src/styles/element.scss +0 -233
- package/src/styles/reset.scss +0 -20
- package/src/styles/var.scss +0 -2
- package/src/typings/global.d.ts +0 -37
- package/src/typings/window.d.ts +0 -8
- package/src/utils/color.ts +0 -59
- package/src/utils/commonUtils.ts +0 -175
- package/src/utils/errorHandler.ts +0 -28
- package/src/utils/is.ts +0 -147
- package/src/utils/layoutUtils.ts +0 -83
- package/src/utils/localUtils.ts +0 -42
- package/src/utils/serviceDict.ts +0 -9
- package/src/vite-env.d.ts +0 -6
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -76
package/src/styles/element.scss
DELETED
|
@@ -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
|
-
}
|
package/src/styles/reset.scss
DELETED
|
@@ -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
|
-
}
|
package/src/styles/var.scss
DELETED
package/src/typings/global.d.ts
DELETED
|
@@ -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];
|
package/src/typings/window.d.ts
DELETED
package/src/utils/color.ts
DELETED
|
@@ -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
|
-
}
|
package/src/utils/commonUtils.ts
DELETED
|
@@ -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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ElNotification } from "element-plus";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @description 全局代码错误捕捉
|
|
5
|
-
* */
|
|
6
|
-
const errorHandler = (error: any) => {
|
|
7
|
-
console.log(error);
|
|
8
|
-
// 过滤 HTTP 请求错误
|
|
9
|
-
if (error.status || error.status == 0) return false;
|
|
10
|
-
let errorMap: { [key: string]: string } = {
|
|
11
|
-
InternalError: "Javascript引擎内部错误",
|
|
12
|
-
ReferenceError: "未找到对象",
|
|
13
|
-
TypeError: "使用了错误的类型或对象",
|
|
14
|
-
RangeError: "使用内置对象时,参数超范围",
|
|
15
|
-
SyntaxError: "语法错误",
|
|
16
|
-
EvalError: "错误的使用了Eval",
|
|
17
|
-
URIError: "URI错误"
|
|
18
|
-
};
|
|
19
|
-
let errorName = errorMap[error.name] || "未知错误";
|
|
20
|
-
ElNotification({
|
|
21
|
-
title: errorName,
|
|
22
|
-
message: error,
|
|
23
|
-
type: "error",
|
|
24
|
-
duration: 3000
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default errorHandler;
|
package/src/utils/is.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description: 判断值是某个类型
|
|
3
|
-
*/
|
|
4
|
-
export function is(val: unknown, type: string) {
|
|
5
|
-
return Object.prototype.toString.call(val) === `[object ${type}]`;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @description 判断数据类型
|
|
10
|
-
* @param {*} val 需要判断类型的数据
|
|
11
|
-
* @returns {String}
|
|
12
|
-
*/
|
|
13
|
-
export function isType(val: any) {
|
|
14
|
-
if (val === null) return "null";
|
|
15
|
-
if (typeof val !== "object") return typeof val;
|
|
16
|
-
else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @description: 是否为空
|
|
21
|
-
*/
|
|
22
|
-
export const isEmpty = (val: any) => {
|
|
23
|
-
if (val !== null && val !== undefined && val !== "") {
|
|
24
|
-
return false;
|
|
25
|
-
} else {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @description: 是否为函数
|
|
32
|
-
*/
|
|
33
|
-
export function isFunction<T = Function>(val: unknown): val is T {
|
|
34
|
-
return is(val, "Function");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @description: 是否已定义
|
|
39
|
-
*/
|
|
40
|
-
export const isDef = <T = unknown>(val?: T): val is T => {
|
|
41
|
-
return typeof val !== "undefined";
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @description: 是否未定义
|
|
46
|
-
*/
|
|
47
|
-
export const isUnDef = <T = unknown>(val?: T): val is T => {
|
|
48
|
-
return !isDef(val);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @description: 是否为对象
|
|
53
|
-
*/
|
|
54
|
-
export const isObject = (val: any): val is Record<any, any> => {
|
|
55
|
-
return val !== null && is(val, "Object");
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @description: 是否为时间
|
|
60
|
-
*/
|
|
61
|
-
export function isDate(val: unknown): val is Date {
|
|
62
|
-
return is(val, "Date");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @description: 是否为数值
|
|
67
|
-
*/
|
|
68
|
-
export function isNumber(val: unknown): val is number {
|
|
69
|
-
return is(val, "Number");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @description: 是否为AsyncFunction
|
|
74
|
-
*/
|
|
75
|
-
export function isAsyncFunction<T = any>(val: unknown): val is Promise<T> {
|
|
76
|
-
return is(val, "AsyncFunction");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @description: 是否为promise
|
|
81
|
-
*/
|
|
82
|
-
export function isPromise<T = any>(val: unknown): val is Promise<T> {
|
|
83
|
-
return is(val, "Promise") && isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @description: 是否为字符串
|
|
88
|
-
*/
|
|
89
|
-
export function isString(val: unknown): val is string {
|
|
90
|
-
return is(val, "String");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @description: 是否为boolean类型
|
|
95
|
-
*/
|
|
96
|
-
export function isBoolean(val: unknown): val is boolean {
|
|
97
|
-
return is(val, "Boolean");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @description: 是否为数组
|
|
102
|
-
*/
|
|
103
|
-
export function isArray(val: any): val is Array<any> {
|
|
104
|
-
return val && Array.isArray(val);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @description: 是否客户端
|
|
109
|
-
*/
|
|
110
|
-
export const isClient = () => {
|
|
111
|
-
return typeof window !== "undefined";
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* @description: 是否为浏览器
|
|
116
|
-
*/
|
|
117
|
-
export const isWindow = (val: any): val is Window => {
|
|
118
|
-
return typeof window !== "undefined" && is(val, "Window");
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @description: 是否为 element 元素
|
|
123
|
-
*/
|
|
124
|
-
export const isElement = (val: unknown): val is Element => {
|
|
125
|
-
return isObject(val) && !!val.tagName;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @description: 是否为 null
|
|
130
|
-
*/
|
|
131
|
-
export function isNull(val: unknown): val is null {
|
|
132
|
-
return val === null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @description: 是否为 null || undefined
|
|
137
|
-
*/
|
|
138
|
-
export function isNullOrUnDef(val: unknown): val is null | undefined {
|
|
139
|
-
return isUnDef(val) || isNull(val);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @description: 是否为 16 进制颜色
|
|
144
|
-
*/
|
|
145
|
-
export const isHexColor = (str: string) => {
|
|
146
|
-
return /^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(str);
|
|
147
|
-
};
|