vue2-client 1.11.2 → 1.11.3
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/package.json +1 -1
- package/src/base-client/components/common/XForm/XFormItem.vue +15 -9
- package/src/base-client/components/common/XForm/XTreeSelect.vue +18 -4
- package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +1 -1
- package/src/base-client/components/common/XFormTable/demo.vue +2 -2
- package/src/mock/common/reportData.js +8 -8
- package/src/pages/ReportView.vue +1 -1
- package/src/pages/resourceManage/depListManage.vue +1 -1
- package/src/pages/resourceManage/funListManage.vue +1 -1
- package/src/pages/resourceManage/orgListManage.vue +1 -1
- package/src/pages/resourceManage/roleListManage.vue +1 -1
- package/src/pages/resourceManage/staffListManage.vue +1 -1
- package/src/router/async/router.map.js +92 -166
- package/src/utils/theme-color-replacer-extend.js +92 -91
package/package.json
CHANGED
|
@@ -774,7 +774,9 @@ export default {
|
|
|
774
774
|
},
|
|
775
775
|
labelCol: {
|
|
776
776
|
type: Object,
|
|
777
|
-
default: () => {
|
|
777
|
+
default: () => {
|
|
778
|
+
return { span: 8 }
|
|
779
|
+
}
|
|
778
780
|
}
|
|
779
781
|
},
|
|
780
782
|
provide () {
|
|
@@ -1095,6 +1097,8 @@ export default {
|
|
|
1095
1097
|
} else if (this.attr.keyName.indexOf('async ') !== -1 || this.attr.keyName.indexOf('function ') !== -1) {
|
|
1096
1098
|
this.updateOptions()
|
|
1097
1099
|
}
|
|
1100
|
+
} else if (this.attr.keys) {
|
|
1101
|
+
this.getDataCallback(this.attr.keys)
|
|
1098
1102
|
}
|
|
1099
1103
|
this.focusInput()
|
|
1100
1104
|
},
|
|
@@ -1110,14 +1114,16 @@ export default {
|
|
|
1110
1114
|
getDataCallback (res) {
|
|
1111
1115
|
this.option = res
|
|
1112
1116
|
if (this.attr.type === 'treeSelect') {
|
|
1113
|
-
this.$
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1117
|
+
this.$nextTick(() => {
|
|
1118
|
+
this.$refs.xTreeSelect.init({
|
|
1119
|
+
option: this.option,
|
|
1120
|
+
form: this.form,
|
|
1121
|
+
queryType: this.attr.queryType,
|
|
1122
|
+
name: this.attr.name,
|
|
1123
|
+
model: this.attr.model,
|
|
1124
|
+
mode: this.mode,
|
|
1125
|
+
disabled: this.disabled
|
|
1126
|
+
})
|
|
1121
1127
|
})
|
|
1122
1128
|
} else if (this.attr.type === 'radio' || ['radioGroup', 'clickChange'].includes(this.attr.showMode)) {
|
|
1123
1129
|
this.initRadioValue()
|
|
@@ -89,6 +89,7 @@ export default {
|
|
|
89
89
|
if (this.mode === '查询') {
|
|
90
90
|
const values = []
|
|
91
91
|
this.getValues(option, value, values)
|
|
92
|
+
this.$emit('onChange', values)
|
|
92
93
|
} else {
|
|
93
94
|
this.value = value
|
|
94
95
|
}
|
|
@@ -101,14 +102,25 @@ export default {
|
|
|
101
102
|
this.$emit('mounted', this)
|
|
102
103
|
this.loaded = true
|
|
103
104
|
},
|
|
104
|
-
getValues (option, value, values
|
|
105
|
+
getValues (option, value, values) {
|
|
105
106
|
for (const item of option) {
|
|
106
107
|
if (value.includes(item.value)) {
|
|
107
108
|
values.push(item.value)
|
|
108
|
-
|
|
109
|
+
// 找到匹配节点后,递归添加所有子节点的值
|
|
110
|
+
if (item.children && item.children.length) {
|
|
111
|
+
this.getAllChildrenValues(item.children, values)
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
if (item.children && item.children.length) {
|
|
111
|
-
this.getValues(item.children, value, values
|
|
115
|
+
this.getValues(item.children, value, values)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
getAllChildrenValues (children, values) {
|
|
120
|
+
for (const child of children) {
|
|
121
|
+
values.push(child.value)
|
|
122
|
+
if (child.children && child.children.length) {
|
|
123
|
+
this.getAllChildrenValues(child.children, values)
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
},
|
|
@@ -181,7 +193,9 @@ export default {
|
|
|
181
193
|
const values = []
|
|
182
194
|
if (extra.allCheckedNodes) {
|
|
183
195
|
for (const item of extra.allCheckedNodes) {
|
|
184
|
-
|
|
196
|
+
console.log(item.node.key, '=====', item.children)
|
|
197
|
+
if (item.node.key) {
|
|
198
|
+
// if (item.node.key && item.node?.data?.props?.label !== item.node?.data?.props?.value) {
|
|
185
199
|
values.push(`${item.node.key}`)
|
|
186
200
|
}
|
|
187
201
|
if (item.children && item.children.length) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<a-rate disabled v-model="formJson.default[item.groupName][col.model]" />
|
|
9
9
|
</template>
|
|
10
10
|
<template v-else>
|
|
11
|
-
{{formJson.default[item.groupName][col.model]}}
|
|
11
|
+
{{ formJson.default[item.groupName][col.model] }}
|
|
12
12
|
</template>
|
|
13
13
|
</a-descriptions-item>
|
|
14
14
|
</template>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
title="示例表单"
|
|
7
7
|
:queryParamsName="queryParamsName"
|
|
8
8
|
:fixedAddForm="fixedAddForm"
|
|
9
|
-
service-name="af-
|
|
9
|
+
service-name="af-revenue"
|
|
10
10
|
@action="action"
|
|
11
11
|
@columnClick="columnClick"
|
|
12
12
|
ref="xFormTable">
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
data () {
|
|
26
26
|
return {
|
|
27
27
|
// 查询配置文件名
|
|
28
|
-
queryParamsName: '
|
|
28
|
+
queryParamsName: 'ExceptionQueryCRUD',
|
|
29
29
|
// 查询配置左侧tree
|
|
30
30
|
// xTreeConfigName: 'addressType',
|
|
31
31
|
// 新增表单固定值
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const reportData = [
|
|
2
|
-
{
|
|
2
|
+
{ 气费: { span: 8 } },
|
|
3
3
|
['付款方式', '用户类型', '用气性质', '笔数', '气量', '应收金额', '实收金额', '滞纳金'],
|
|
4
4
|
{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
刷卡: {
|
|
6
|
+
非民用: {
|
|
7
|
+
公服用气: [3, 2777, 6998.04, 7000, 0],
|
|
8
|
+
商业用气: [17, 28720, 83811.50, 83806.70, 0]
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
民用: {
|
|
11
|
+
居民用气: [255, 19310, 44219.70, 44345.50, 0]
|
|
12
12
|
},
|
|
13
|
-
|
|
13
|
+
合计: { span: 2, value: [275, 50807, 135029.24, 135152.20, 0] }
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
]
|
package/src/pages/ReportView.vue
CHANGED
|
@@ -1,188 +1,114 @@
|
|
|
1
1
|
const { homePage } = require('../../config')
|
|
2
|
-
|
|
2
|
+
// 视图组件
|
|
3
3
|
const view = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
login: () =>
|
|
14
|
-
import('@vue2-client/pages/login/Login'),
|
|
15
|
-
loginv3: () =>
|
|
16
|
-
import('@vue2-client/pages/login/LoginV3')
|
|
17
|
-
}
|
|
18
|
-
// 动态路由对象定义
|
|
4
|
+
tabs: () => import('@vue2-client/layouts/tabs'),
|
|
5
|
+
blank: () => import('@vue2-client/layouts/BlankView'),
|
|
6
|
+
page: () => import('@vue2-client/layouts/PageView'),
|
|
7
|
+
// his-web$ceshiGrid?type=GridView&configName=RxPreparedMed
|
|
8
|
+
gridView: () => import('@vue2-client/layouts/GridView'),
|
|
9
|
+
login: () => import('@vue2-client/pages/login/Login'),
|
|
10
|
+
loginv3: () => import('@vue2-client/pages/login/LoginV3')
|
|
11
|
+
}
|
|
12
|
+
// 动态路由对象定义
|
|
19
13
|
const routerResource = {}
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
// --------------------------------------基本视图组件--------------------------------------
|
|
15
|
+
// 空白视图
|
|
22
16
|
routerResource.blank = view.blank
|
|
23
|
-
|
|
17
|
+
// 单页面视图
|
|
24
18
|
routerResource.singlePage = view.blank
|
|
25
|
-
|
|
19
|
+
// 栅格配置视图
|
|
26
20
|
routerResource.gridView = view.gridView
|
|
27
21
|
|
|
28
22
|
// --------------------------------------仪表盘--------------------------------------
|
|
29
23
|
routerResource.dashboard = view.blank
|
|
30
|
-
|
|
24
|
+
// 工作台
|
|
31
25
|
routerResource.workplace = () =>
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
import('@vue2-client/pages/dashboard/workplace')
|
|
27
|
+
// --------------------------------------系统配置--------------------------------------
|
|
34
28
|
routerResource.system = view.blank
|
|
35
|
-
|
|
36
|
-
routerResource.dictionaryManage = () =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
routerResource.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
routerResource.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
routerResource.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
import('@vue2-client/pages/AMisDemo/AMisDemo')
|
|
59
|
-
// 页面编辑器
|
|
60
|
-
routerResource.editablePage = () =>
|
|
61
|
-
import('@vue2-client/pages/lowCode/lowCodeEditor.vue')
|
|
62
|
-
// 数据检索
|
|
63
|
-
routerResource.dynamicStatistics = () =>
|
|
64
|
-
import('@vue2-client/pages/DynamicStatistics')
|
|
65
|
-
// 数据检索(新)
|
|
66
|
-
routerResource.newDynamicStatistics = () =>
|
|
67
|
-
import('@vue2-client/pages/NewDynamicStatistics')
|
|
68
|
-
// 示例页面
|
|
29
|
+
// 字典管理
|
|
30
|
+
routerResource.dictionaryManage = () => import('@vue2-client/pages/system/dictionary')
|
|
31
|
+
// 文件管理
|
|
32
|
+
routerResource.fileManager = () => import('@vue2-client/pages/system/file')
|
|
33
|
+
// 登录日志
|
|
34
|
+
routerResource.loginInfor = () => import('@vue2-client/pages/system/monitor/loginInfor')
|
|
35
|
+
// 操作日志
|
|
36
|
+
routerResource.operLog = () => import('@vue2-client/pages/system/monitor/operLog')
|
|
37
|
+
// 系统问题反馈工单
|
|
38
|
+
routerResource.submitTicket = () => import('@vue2-client/pages/system/ticket')
|
|
39
|
+
// 通用服务评价
|
|
40
|
+
routerResource.ServiceReview = () => import('@vue2-client/pages/ServiceReview')
|
|
41
|
+
// 系统设置
|
|
42
|
+
routerResource.settings = () => import('@vue2-client/pages/system/settings')
|
|
43
|
+
// AMIS示例页面
|
|
44
|
+
routerResource.amisDemo = () => import('@vue2-client/pages/AMisDemo/AMisDemo')
|
|
45
|
+
// 页面编辑器
|
|
46
|
+
routerResource.editablePage = () => import('@vue2-client/pages/lowCode/lowCodeEditor.vue')
|
|
47
|
+
// 数据检索
|
|
48
|
+
routerResource.dynamicStatistics = () => import('@vue2-client/pages/DynamicStatistics')
|
|
49
|
+
// 数据检索(新)
|
|
50
|
+
routerResource.newDynamicStatistics = () => import('@vue2-client/pages/NewDynamicStatistics')
|
|
51
|
+
// 示例页面
|
|
69
52
|
routerResource.example = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
|
|
88
|
-
// component: () => import('@vue2-client/base-client/components/common/XReport/XReportDemo.vue'),
|
|
89
|
-
component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
90
|
-
// component: () => import('@vue2-client/base-client/components/common/XDatePicker/demo.vue'),
|
|
91
|
-
// component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
|
|
92
|
-
// component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
|
|
93
|
-
// component: () => import('@vue2-client/pages/WorkflowDetail/WorkFlowDemo.vue'),
|
|
94
|
-
// component: () => import('@vue2-client/base-client/components/common/XConversation/XConversationDemo.vue'),
|
|
95
|
-
// component: () => import('@vue2-client/base-client/components/common/XButtons/XButtonDemo.vue'),
|
|
96
|
-
// component: () => import('@vue2-client/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue'),
|
|
97
|
-
// component: () => import('@vue2-client/base-client/components/common/XCheckList/XCheckList.vue'),
|
|
98
|
-
// component: () => import('@vue2-client/base-client/components/common/XPrint/Demo.vue'),
|
|
99
|
-
// component: () => import('@vue2-client/base-client/components/AI/demo.vue'),
|
|
100
|
-
// component: () => import('@vue2-client/components/g2Charts/demo.vue'),
|
|
101
|
-
meta: {
|
|
102
|
-
// 菜单中不显示
|
|
103
|
-
invisible: true,
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
path: 'sub-example',
|
|
108
|
-
name: '示例页面1',
|
|
109
|
-
component: () => import('@vue2-client/pages/SubExample'),
|
|
110
|
-
meta: {
|
|
111
|
-
// 菜单中不显示
|
|
112
|
-
invisible: true,
|
|
113
|
-
// 跳转不打开新页签
|
|
114
|
-
noPusTabs: true
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
path: 'x-tree-one-pro-example',
|
|
119
|
-
name: 'TreeView布局示例',
|
|
120
|
-
component: () => import('@vue2-client/pages/XTreeOneProExample'),
|
|
121
|
-
meta: {
|
|
122
|
-
// 菜单中不显示
|
|
123
|
-
invisible: true,
|
|
124
|
-
// 跳转不打开新页签
|
|
125
|
-
noPusTabs: true
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
path: 'page-view-example',
|
|
130
|
-
name: 'PageView示例',
|
|
131
|
-
component: () => import('@vue2-client/pages/XPageViewExample'),
|
|
132
|
-
meta: {
|
|
133
|
-
// 菜单中不显示
|
|
134
|
-
invisible: true,
|
|
135
|
-
// 跳转不打开新页签
|
|
136
|
-
noPusTabs: true
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
]
|
|
53
|
+
path: 'example',
|
|
54
|
+
name: '示例主页面',
|
|
55
|
+
// component: () => import('@vue2-client/base-client/components/common/XAddNativeForm/demo.vue'),
|
|
56
|
+
// component: () => import('@vue2-client/base-client/components/common/XFormGroup/demo.vue'),
|
|
57
|
+
// component: () => import('@vue2-client/base-client/components/common/XReport/XReportDemo.vue'),
|
|
58
|
+
component: () => import('@vue2-client/base-client/components/common/XFormTable/demo.vue'),
|
|
59
|
+
// component: () => import('@vue2-client/base-client/components/common/XDatePicker/demo.vue'),
|
|
60
|
+
// component: () => import('@vue2-client/base-client/components/common/XTab/XTabDemo.vue'),
|
|
61
|
+
// component: () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo.vue'),
|
|
62
|
+
// component: () => import('@vue2-client/pages/WorkflowDetail/WorkFlowDemo.vue'),
|
|
63
|
+
// component: () => import('@vue2-client/base-client/components/common/XConversation/XConversationDemo.vue'),
|
|
64
|
+
// component: () => import('@vue2-client/base-client/components/common/XButtons/XButtonDemo.vue'),
|
|
65
|
+
// component: () => import('@vue2-client/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue'),
|
|
66
|
+
// component: () => import('@vue2-client/base-client/components/common/XCheckList/XCheckList.vue'),
|
|
67
|
+
// component: () => import('@vue2-client/base-client/components/common/XPrint/Demo.vue'),
|
|
68
|
+
// component: () => import('@vue2-client/base-client/components/AI/demo.vue'),
|
|
69
|
+
// component: () => import('@vue2-client/components/g2Charts/demo.vue'),
|
|
140
70
|
}
|
|
141
71
|
// routerResource.example = () =>
|
|
142
72
|
// import('@vue2-client/pages/Example')
|
|
143
|
-
routerResource.XReportView = () =>
|
|
144
|
-
import('@vue2-client/pages/XReportView')
|
|
73
|
+
routerResource.XReportView = () => import('@vue2-client/pages/XReportView')
|
|
145
74
|
|
|
146
|
-
routerResource.XReportGrid = () =>
|
|
147
|
-
import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo')
|
|
75
|
+
routerResource.XReportGrid = () => import('@vue2-client/base-client/components/common/XReportGrid/XReportDemo')
|
|
148
76
|
|
|
149
|
-
routerResource.XTab = () =>
|
|
150
|
-
import('@vue2-client/base-client/components/common/XTab/XTabDemo')
|
|
77
|
+
routerResource.XTab = () => import('@vue2-client/base-client/components/common/XTab/XTabDemo')
|
|
151
78
|
|
|
152
|
-
|
|
153
|
-
// 基础路由组件注册
|
|
79
|
+
// 基础路由组件注册
|
|
154
80
|
const routerMap = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
81
|
+
login: {
|
|
82
|
+
authority: '*',
|
|
83
|
+
path: '/login',
|
|
84
|
+
component: process.env.VUE_APP_LOGIN_VERSION === 'V3'
|
|
85
|
+
? view.loginv3 : view.login
|
|
86
|
+
},
|
|
87
|
+
root: {
|
|
88
|
+
path: '/',
|
|
89
|
+
name: '首页',
|
|
90
|
+
redirect: homePage,
|
|
91
|
+
component: process.env.VUE_APP_SINGLE_PAPER === 'TRUE' ? view.blank : view.tabs,
|
|
92
|
+
},
|
|
93
|
+
exp403: {
|
|
94
|
+
authority: '*',
|
|
95
|
+
name: 'exp403',
|
|
96
|
+
path: '403',
|
|
97
|
+
component: () =>
|
|
98
|
+
import('@vue2-client/pages/exception/403')
|
|
99
|
+
},
|
|
100
|
+
exp404: {
|
|
101
|
+
name: 'exp404',
|
|
102
|
+
path: '404',
|
|
103
|
+
component: () =>
|
|
104
|
+
import('@vue2-client/pages/exception/404')
|
|
105
|
+
},
|
|
106
|
+
exp500: {
|
|
107
|
+
name: 'exp500',
|
|
108
|
+
path: '500',
|
|
109
|
+
component: () =>
|
|
110
|
+
import('@vue2-client/pages/exception/500')
|
|
111
|
+
}
|
|
186
112
|
}
|
|
187
113
|
Object.assign(routerMap, routerResource)
|
|
188
114
|
export default routerMap
|
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
const { cssResolve } = require('../config/replacer')
|
|
2
|
-
// 修正 webpack-theme-color-replacer 插件提取的 css 结果
|
|
3
|
-
function resolveCss (output, srcArr) {
|
|
4
|
-
const regExps = []
|
|
5
|
-
// 提取 resolve 配置中所有的正则配置
|
|
6
|
-
Object.keys(cssResolve).forEach(key => {
|
|
7
|
-
let isRegExp
|
|
8
|
-
let reg = {}
|
|
9
|
-
try {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
cssText
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* @
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
css.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
const { cssResolve } = require('../config/replacer')
|
|
2
|
+
// 修正 webpack-theme-color-replacer 插件提取的 css 结果
|
|
3
|
+
function resolveCss (output, srcArr) {
|
|
4
|
+
const regExps = []
|
|
5
|
+
// 提取 resolve 配置中所有的正则配置
|
|
6
|
+
Object.keys(cssResolve).forEach(key => {
|
|
7
|
+
let isRegExp
|
|
8
|
+
let reg = {}
|
|
9
|
+
try {
|
|
10
|
+
// eslint-disable-next-line no-eval
|
|
11
|
+
reg = eval(key)
|
|
12
|
+
isRegExp = reg instanceof RegExp
|
|
13
|
+
} catch (e) {
|
|
14
|
+
isRegExp = false
|
|
15
|
+
}
|
|
16
|
+
if (isRegExp) {
|
|
17
|
+
regExps.push([reg, cssResolve[key]])
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// 去重
|
|
22
|
+
srcArr = dropDuplicate(srcArr)
|
|
23
|
+
|
|
24
|
+
// 处理 css
|
|
25
|
+
const outArr = []
|
|
26
|
+
srcArr.forEach(text => {
|
|
27
|
+
// 转换为 css 对象
|
|
28
|
+
const cssObj = parseCssObj(text)
|
|
29
|
+
// 根据selector匹配配置,匹配成功,则按配置处理 css
|
|
30
|
+
if (cssResolve[cssObj.selector] !== undefined) {
|
|
31
|
+
const cfg = cssResolve[cssObj.selector]
|
|
32
|
+
if (cfg) {
|
|
33
|
+
outArr.push(cfg.resolve(text, cssObj))
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
let cssText = ''
|
|
37
|
+
// 匹配不成功,则测试是否有匹配的正则配置,有则按正则对应的配置处理
|
|
38
|
+
for (const regExp of regExps) {
|
|
39
|
+
if (regExp[0].test(cssObj.selector)) {
|
|
40
|
+
const cssCfg = regExp[1]
|
|
41
|
+
cssText = cssCfg ? cssCfg.resolve(text, cssObj) : ''
|
|
42
|
+
break
|
|
43
|
+
}
|
|
44
|
+
// 未匹配到正则,则设置 cssText 为默认的 css(即不处理)
|
|
45
|
+
cssText = text
|
|
46
|
+
}
|
|
47
|
+
if (cssText !== '') {
|
|
48
|
+
outArr.push(cssText)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
output = outArr.join('\n')
|
|
53
|
+
return output
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 数组去重
|
|
57
|
+
function dropDuplicate (arr) {
|
|
58
|
+
const map = {}
|
|
59
|
+
const r = []
|
|
60
|
+
for (const s of arr) {
|
|
61
|
+
if (!map[s]) {
|
|
62
|
+
r.push(s)
|
|
63
|
+
map[s] = 1
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return r
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 从字符串解析 css 对象
|
|
71
|
+
* @param cssText
|
|
72
|
+
* @returns {{
|
|
73
|
+
* name: String,
|
|
74
|
+
* rules: Array[String],
|
|
75
|
+
* toText: function
|
|
76
|
+
* }}
|
|
77
|
+
*/
|
|
78
|
+
function parseCssObj (cssText) {
|
|
79
|
+
const css = {}
|
|
80
|
+
const ruleIndex = cssText.indexOf('{')
|
|
81
|
+
css.selector = cssText.substring(0, ruleIndex)
|
|
82
|
+
const ruleBody = cssText.substring(ruleIndex + 1, cssText.length - 1)
|
|
83
|
+
css.rules = ruleBody.split(';')
|
|
84
|
+
css.toText = function () {
|
|
85
|
+
let body = ''
|
|
86
|
+
this.rules.forEach(item => { body += item + ';' })
|
|
87
|
+
return `${this.selector}{${body}}`
|
|
88
|
+
}
|
|
89
|
+
return css
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = { resolveCss }
|