haiwei-module-common 1.0.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/.browserslistrc +2 -0
- package/.eslintrc.js +18 -0
- package/.prettierrc +6 -0
- package/.vscode/settings.json +10 -0
- package/babel.config.js +10 -0
- package/package.json +41 -0
- package/postcss.config.js +5 -0
- package/script/npm_install.bat +4 -0
- package/script/npm_install.ps1 +10 -0
- package/script/npm_publish.bat +4 -0
- package/script/npm_publish.ps1 +10 -0
- package/script/npm_update.bat +4 -0
- package/script/npm_update.ps1 +10 -0
- package/src/api/components/area.js +22 -0
- package/src/api/components/attachment.js +30 -0
- package/src/api/components/dict.js +24 -0
- package/src/api/components/dictGroup.js +17 -0
- package/src/api/components/dictItem.js +10 -0
- package/src/api/components/mediaType.js +10 -0
- package/src/api/index.js +11 -0
- package/src/components/area-select/index.vue +147 -0
- package/src/components/area-select/item.vue +85 -0
- package/src/components/attachment-download/index.vue +70 -0
- package/src/components/attachment-img/index.vue +58 -0
- package/src/components/attachment-upload-img/index.vue +244 -0
- package/src/components/attachment-upload-single/index.vue +143 -0
- package/src/components/ccdieet-upload/index_.vue +51 -0
- package/src/components/config-common/index.vue +41 -0
- package/src/components/dict-checkbox/index.vue +29 -0
- package/src/components/dict-radio/index.vue +29 -0
- package/src/components/dict-select/index.vue +29 -0
- package/src/components/dict-tree/index.vue +97 -0
- package/src/components/index.js +10 -0
- package/src/components/upload-mixins.js +118 -0
- package/src/config/index.js +11 -0
- package/src/index.js +23 -0
- package/src/main.js +9 -0
- package/src/module.js +10 -0
- package/src/routes/index.js +3 -0
- package/src/store/index.js +3 -0
- package/src/views/area/components/cascader/index.vue +16 -0
- package/src/views/area/components/save/index.vue +96 -0
- package/src/views/area/index/cols.js +47 -0
- package/src/views/area/index/index.vue +126 -0
- package/src/views/area/index/page.js +42 -0
- package/src/views/attachment/index/cols.js +59 -0
- package/src/views/attachment/index/index.vue +60 -0
- package/src/views/attachment/index/page.js +36 -0
- package/src/views/dict/components/save/index.vue +63 -0
- package/src/views/dict/index/cols.js +35 -0
- package/src/views/dict/index/index.vue +79 -0
- package/src/views/dict/index/page.js +49 -0
- package/src/views/dictGroup/components/save/index.vue +57 -0
- package/src/views/dictGroup/components/select/index.vue +14 -0
- package/src/views/dictGroup/index/cols.js +36 -0
- package/src/views/dictGroup/index/index.vue +67 -0
- package/src/views/dictGroup/index/page.js +42 -0
- package/src/views/dictItem/components/extend-editor/index.vue +57 -0
- package/src/views/dictItem/components/index/cols.js +40 -0
- package/src/views/dictItem/components/index/index.vue +86 -0
- package/src/views/dictItem/components/save/index.vue +94 -0
- package/src/views/dictItem/components/tree/index.vue +133 -0
- package/src/views/dictItem/index.vue +51 -0
- package/src/views/mediaType/components/save/index.vue +45 -0
- package/src/views/mediaType/index/cols.js +16 -0
- package/src/views/mediaType/index/index.vue +55 -0
- package/src/views/mediaType/index/page.js +42 -0
- package/vue.config.js +108 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-form-dialog ref="form" v-bind="form" v-on="on" :visible.sync="visible_">
|
|
3
|
+
<el-row>
|
|
4
|
+
<el-col :span="20" :offset="1">
|
|
5
|
+
<el-form-item label="名称:" prop="name">
|
|
6
|
+
<el-input ref="name" v-model="form.model.name" clearable />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
<el-form-item label="值:" prop="value">
|
|
9
|
+
<el-input v-model="form.model.value" clearable />
|
|
10
|
+
</el-form-item>
|
|
11
|
+
<el-form-item label="扩展数据:" prop="extend">
|
|
12
|
+
<extend-editor v-model="form.model.extend" />
|
|
13
|
+
</el-form-item>
|
|
14
|
+
<el-form-item label="图标:" prop="icon">
|
|
15
|
+
<nm-icon-picker v-model="form.model.icon" clearable />
|
|
16
|
+
</el-form-item>
|
|
17
|
+
<el-form-item label="排序:" prop="sort">
|
|
18
|
+
<el-input type="number" v-model.number="form.model.sort" clearable />
|
|
19
|
+
</el-form-item>
|
|
20
|
+
</el-col>
|
|
21
|
+
</el-row>
|
|
22
|
+
</nm-form-dialog>
|
|
23
|
+
</template>
|
|
24
|
+
<script>
|
|
25
|
+
import { mixins } from 'haiwei-ui'
|
|
26
|
+
import ExtendEditor from '../extend-editor'
|
|
27
|
+
|
|
28
|
+
// 接口
|
|
29
|
+
const { add, edit, update } = $api.common.dictItem
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
mixins: [mixins.formSave],
|
|
33
|
+
components: { ExtendEditor },
|
|
34
|
+
data() {
|
|
35
|
+
return {
|
|
36
|
+
title: '字典数据项',
|
|
37
|
+
actions: { add, edit, update },
|
|
38
|
+
form: {
|
|
39
|
+
width: '650px',
|
|
40
|
+
model: {
|
|
41
|
+
groupCode: '',
|
|
42
|
+
dictCode: '',
|
|
43
|
+
parentId: 0,
|
|
44
|
+
/** 名称 */
|
|
45
|
+
name: '',
|
|
46
|
+
/** 值 */
|
|
47
|
+
value: '',
|
|
48
|
+
extend: '',
|
|
49
|
+
icon: '',
|
|
50
|
+
/** 排序 */
|
|
51
|
+
sort: 0
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
groupCode: [{ required: true, message: '请选择分组' }],
|
|
55
|
+
dictCode: [{ required: true, message: '请选择字典' }],
|
|
56
|
+
name: [{ required: true, message: '请输入名称' }],
|
|
57
|
+
value: [{ required: true, message: '请输入值' }],
|
|
58
|
+
sort: [
|
|
59
|
+
{ required: true, message: '请输入序号' },
|
|
60
|
+
{ type: 'number', message: '序号必须为数字' }
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
on: {
|
|
65
|
+
reset: this.onReset
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
props: {
|
|
70
|
+
dict: Object,
|
|
71
|
+
parentId: Number,
|
|
72
|
+
total: Number
|
|
73
|
+
},
|
|
74
|
+
methods: {
|
|
75
|
+
onSuccess(newId) {
|
|
76
|
+
if (this.isAdd_) {
|
|
77
|
+
this.form.model.id = newId
|
|
78
|
+
}
|
|
79
|
+
const { id, name } = this.form.model
|
|
80
|
+
this.$emit('success', this.isAdd_, { id, label: name, item: Object.assign({}, this.form.model) })
|
|
81
|
+
},
|
|
82
|
+
onReset() {
|
|
83
|
+
if (this.isAdd_) {
|
|
84
|
+
let model = this.form.model
|
|
85
|
+
model.groupCode = this.dict.groupCode
|
|
86
|
+
model.dictCode = this.dict.code
|
|
87
|
+
model.parentId = this.parentId
|
|
88
|
+
model.sort = this.total
|
|
89
|
+
}
|
|
90
|
+
this.$refs.name.focus()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-box page header title="字典结构" icon="tree">
|
|
3
|
+
<el-tree class="nm-tree" ref="tree" v-bind="tree" v-on="on">
|
|
4
|
+
<span slot-scope="{ data }">
|
|
5
|
+
<nm-icon :name="data.item.icon || 'attachment'" />
|
|
6
|
+
<span class="nm-m-l-5">{{ data.label }}</span>
|
|
7
|
+
</span>
|
|
8
|
+
</el-tree>
|
|
9
|
+
</nm-box>
|
|
10
|
+
</template>
|
|
11
|
+
<script>
|
|
12
|
+
const api = $api.common.dict
|
|
13
|
+
export default {
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
tree: {
|
|
17
|
+
data: [],
|
|
18
|
+
nodeKey: 'id',
|
|
19
|
+
highlightCurrent: true,
|
|
20
|
+
props: { children: 'children', label: 'label' },
|
|
21
|
+
currentNodeKey: 0,
|
|
22
|
+
expandOnClickNode: false,
|
|
23
|
+
defaultExpandedKeys: [0]
|
|
24
|
+
},
|
|
25
|
+
on: {
|
|
26
|
+
'current-change': this.onChange,
|
|
27
|
+
'node-expand': this.onNodeExpand,
|
|
28
|
+
'node-collapse': this.onNodeCollapse
|
|
29
|
+
},
|
|
30
|
+
selection: null
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
props: {
|
|
34
|
+
dict: Object
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
//刷新
|
|
38
|
+
refresh(init) {
|
|
39
|
+
const params = { group: this.dict.groupCode, code: this.dict.code }
|
|
40
|
+
api.tree(params).then(data => {
|
|
41
|
+
this.tree.data = [data]
|
|
42
|
+
if (init) {
|
|
43
|
+
//初始化触发一次change事件
|
|
44
|
+
this.onChange(data)
|
|
45
|
+
} else {
|
|
46
|
+
//刷新要保留当前选中节点
|
|
47
|
+
this.$nextTick(() => {
|
|
48
|
+
this.$refs.tree.setCurrentKey(this.tree.currentNodeKey)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
onChange(data) {
|
|
54
|
+
if (this.selection === data) return
|
|
55
|
+
this.tree.currentNodeKey = data.id
|
|
56
|
+
this.selection = data
|
|
57
|
+
this.$emit('change', this.selection)
|
|
58
|
+
},
|
|
59
|
+
onNodeExpand(data) {
|
|
60
|
+
//记录展开的节点
|
|
61
|
+
this.tree.defaultExpandedKeys.push(data.id)
|
|
62
|
+
},
|
|
63
|
+
onNodeCollapse(data) {
|
|
64
|
+
//移除展开的节点
|
|
65
|
+
this.$_.pull(this.tree.defaultExpandedKeys, data.id)
|
|
66
|
+
},
|
|
67
|
+
/**插入 */
|
|
68
|
+
insert(data) {
|
|
69
|
+
//设置子节点
|
|
70
|
+
if (!data.children) {
|
|
71
|
+
data.children = []
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let children = this.selection.children
|
|
75
|
+
//如果不包含子节点,直接push
|
|
76
|
+
if (children.length < 1) {
|
|
77
|
+
children.push(data)
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
for (let i = 0; i < children.length; i++) {
|
|
81
|
+
if (data.item.sort < children[i].item.sort) {
|
|
82
|
+
children.splice(i, 0, data)
|
|
83
|
+
break
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//如果是最后一个,则附加到最后一个节点后面
|
|
87
|
+
if (i === children.length - 1) {
|
|
88
|
+
children.push(data)
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
/**删除 */
|
|
94
|
+
remove(id) {
|
|
95
|
+
let children = this.selection.children
|
|
96
|
+
for (let i = 0; i < children.length; i++) {
|
|
97
|
+
let child = children[i]
|
|
98
|
+
if (id === child.id) {
|
|
99
|
+
children.splice(i, 1)
|
|
100
|
+
return child
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
/**更新 */
|
|
105
|
+
update(model) {
|
|
106
|
+
//先判断是否展开,已展开的先删除
|
|
107
|
+
let expanded = this.$refs.tree.getNode(model.id).expanded
|
|
108
|
+
if (!expanded) {
|
|
109
|
+
this.$_.pull(this.tree.defaultExpandedKeys, model.id)
|
|
110
|
+
}
|
|
111
|
+
//保存原来的子节点,同时先删除,再添加,这样可以保证排序
|
|
112
|
+
model.children = this.remove(model.id).children
|
|
113
|
+
this.insert(model)
|
|
114
|
+
//若是展开状态要再次展开
|
|
115
|
+
if (expanded) {
|
|
116
|
+
this.tree.defaultExpandedKeys.push(model.id)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
/**排序,重新刷新 */
|
|
120
|
+
sort() {
|
|
121
|
+
this.refresh()
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
watch: {
|
|
125
|
+
dict() {
|
|
126
|
+
this.refresh()
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
mounted() {
|
|
130
|
+
this.refresh(true)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-dialog v-bind="dialog" :visible.sync="visible_">
|
|
3
|
+
<nm-split class="page" v-model="split">
|
|
4
|
+
<template v-slot:left>
|
|
5
|
+
<tree ref="tree" :dict="dict" @change="onTreeChange" />
|
|
6
|
+
</template>
|
|
7
|
+
<template v-slot:right>
|
|
8
|
+
<index ref="index" :dict="dict" :parent-id="parentId" @add-success="onAdd" @del-success="onDelete" @edit-success="onEdit" />
|
|
9
|
+
</template>
|
|
10
|
+
</nm-split>
|
|
11
|
+
</nm-dialog>
|
|
12
|
+
</template>
|
|
13
|
+
<script>
|
|
14
|
+
import { mixins } from 'haiwei-ui'
|
|
15
|
+
import Tree from './components/tree'
|
|
16
|
+
import Index from './components/index'
|
|
17
|
+
export default {
|
|
18
|
+
mixins: [mixins.dialog],
|
|
19
|
+
components: { Tree, Index },
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
dialog: {
|
|
23
|
+
title: '数据项配置',
|
|
24
|
+
icon: 'tag',
|
|
25
|
+
width: '80%',
|
|
26
|
+
height: '80%',
|
|
27
|
+
noScrollbar: true
|
|
28
|
+
},
|
|
29
|
+
split: 0.2,
|
|
30
|
+
parentId: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
props: {
|
|
34
|
+
dict: Object
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
onTreeChange(selection) {
|
|
38
|
+
this.parentId = selection.item.id
|
|
39
|
+
},
|
|
40
|
+
onAdd(model) {
|
|
41
|
+
this.$refs.tree.insert(model)
|
|
42
|
+
},
|
|
43
|
+
onDelete(value) {
|
|
44
|
+
this.$refs.tree.remove(value)
|
|
45
|
+
},
|
|
46
|
+
onEdit(model) {
|
|
47
|
+
this.$refs.tree.update(model)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-form-dialog ref="form" v-bind="form" v-on="on" :visible.sync="visible_">
|
|
3
|
+
<el-row>
|
|
4
|
+
<el-col :span="20" :offset="1">
|
|
5
|
+
<el-form-item label="扩展名:" prop="ext">
|
|
6
|
+
<el-input v-model="form.model.ext" clearable />
|
|
7
|
+
</el-form-item>
|
|
8
|
+
<el-form-item label="值:" prop="value">
|
|
9
|
+
<el-input v-model="form.model.value" clearable />
|
|
10
|
+
</el-form-item>
|
|
11
|
+
</el-col>
|
|
12
|
+
</el-row>
|
|
13
|
+
</nm-form-dialog>
|
|
14
|
+
</template>
|
|
15
|
+
<script>
|
|
16
|
+
import { mixins } from 'haiwei-ui'
|
|
17
|
+
|
|
18
|
+
// 接口
|
|
19
|
+
const { add, edit, update } = $api.common.mediaType
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
mixins: [mixins.formSave],
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
title: '多媒体',
|
|
26
|
+
actions: {
|
|
27
|
+
add,
|
|
28
|
+
edit,
|
|
29
|
+
update
|
|
30
|
+
},
|
|
31
|
+
form: {
|
|
32
|
+
width: '40%',
|
|
33
|
+
model: {
|
|
34
|
+
ext: '',
|
|
35
|
+
value: ''
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
ext: [{ required: true, message: '请输入扩展名' }],
|
|
39
|
+
value: [{ required: true, message: '请输入值' }]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<nm-container>
|
|
3
|
+
<nm-list ref="list" v-bind="list">
|
|
4
|
+
<!--查询条件-->
|
|
5
|
+
<template v-slot:querybar>
|
|
6
|
+
<el-form-item label="扩展名:" prop="ext">
|
|
7
|
+
<el-input v-model="list.model.ext" clearable />
|
|
8
|
+
</el-form-item>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<!--按钮-->
|
|
12
|
+
<template v-slot:querybar-buttons>
|
|
13
|
+
<nm-button v-bind="buttons.add" @click="add" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<!--操作列-->
|
|
17
|
+
<template v-slot:col-operation="{ row }">
|
|
18
|
+
<nm-button v-bind="buttons.edit" @click="edit(row)" />
|
|
19
|
+
<nm-button-delete v-bind="buttons.del" :id="row.id" :action="removeAction" @success="refresh" />
|
|
20
|
+
</template>
|
|
21
|
+
</nm-list>
|
|
22
|
+
|
|
23
|
+
<!--编辑-->
|
|
24
|
+
<save-page :id="curr.id" :visible.sync="dialog.save" @success="refresh" />
|
|
25
|
+
</nm-container>
|
|
26
|
+
</template>
|
|
27
|
+
<script>
|
|
28
|
+
import { mixins } from 'haiwei-ui'
|
|
29
|
+
import page from './page'
|
|
30
|
+
import cols from './cols'
|
|
31
|
+
import SavePage from '../components/save'
|
|
32
|
+
|
|
33
|
+
// 接口
|
|
34
|
+
const api = $api.common.mediaType
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
name: page.name,
|
|
38
|
+
mixins: [mixins.list],
|
|
39
|
+
components: { SavePage },
|
|
40
|
+
data() {
|
|
41
|
+
return {
|
|
42
|
+
list: {
|
|
43
|
+
title: page.title,
|
|
44
|
+
cols,
|
|
45
|
+
action: api.query,
|
|
46
|
+
model: {
|
|
47
|
+
ext: ''
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
removeAction: api.remove,
|
|
51
|
+
buttons: page.buttons
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** 页面信息 */
|
|
2
|
+
const page = new (function() {
|
|
3
|
+
this.title = '多媒体'
|
|
4
|
+
this.icon = 'media'
|
|
5
|
+
this.name = 'common_mediatype'
|
|
6
|
+
this.path = '/common/mediatype'
|
|
7
|
+
|
|
8
|
+
// 关联权限
|
|
9
|
+
this.permissions = [`${this.name}_query_get`]
|
|
10
|
+
|
|
11
|
+
this.buttons = {
|
|
12
|
+
add: {
|
|
13
|
+
text: '添加',
|
|
14
|
+
type: 'success',
|
|
15
|
+
code: `${this.name}_add`,
|
|
16
|
+
icon: 'add',
|
|
17
|
+
permissions: [`${this.name}_add_post`]
|
|
18
|
+
},
|
|
19
|
+
edit: {
|
|
20
|
+
text: '编辑',
|
|
21
|
+
type: 'text',
|
|
22
|
+
icon: 'edit',
|
|
23
|
+
code: `${this.name}_edit`,
|
|
24
|
+
permissions: [`${this.name}_edit_get`, `${this.name}_update_post`]
|
|
25
|
+
},
|
|
26
|
+
del: {
|
|
27
|
+
text: '删除',
|
|
28
|
+
type: 'text',
|
|
29
|
+
icon: 'delete',
|
|
30
|
+
code: `${this.name}_del`,
|
|
31
|
+
permissions: [`${this.name}_delete_delete`]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})()
|
|
35
|
+
|
|
36
|
+
/** 路由信息 */
|
|
37
|
+
export const route = {
|
|
38
|
+
page,
|
|
39
|
+
component: () => import(/* webpackChunkName: "Common.MediaType" */ './index')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default page
|
package/vue.config.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
2
|
+
const TerserPlugin = require('terser-webpack-plugin')
|
|
3
|
+
|
|
4
|
+
// 增加环境变量
|
|
5
|
+
process.env.VUE_APP_COPYRIGHT = '版权所有:尼古拉斯·老李 | 用代码改变世界'
|
|
6
|
+
process.env.VUE_APP_BUILD_TIME = require('dayjs')().format('YYYYMDHHmmss')
|
|
7
|
+
/**第三方依赖组件,写法示例:<script src="./lib/font.js"></script> */
|
|
8
|
+
process.env.VUE_APP_CUSTOM_SCRIPTS = ''
|
|
9
|
+
|
|
10
|
+
const path = require('path')
|
|
11
|
+
// 开发环境
|
|
12
|
+
const isDev = process.env.NODE_ENV === 'development'
|
|
13
|
+
// 打包输出路径
|
|
14
|
+
const outputDir = '../../WebHost/wwwroot/app'
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
outputDir: outputDir,
|
|
18
|
+
publicPath: '/app',
|
|
19
|
+
devServer: {
|
|
20
|
+
port: 5221
|
|
21
|
+
},
|
|
22
|
+
transpileDependencies: ['haiwei-*', 'element-ui'],
|
|
23
|
+
configureWebpack() {
|
|
24
|
+
let config = {
|
|
25
|
+
plugins: [
|
|
26
|
+
/**
|
|
27
|
+
* 复制haiwei-ui/public目录下的文件到输出目录
|
|
28
|
+
*/
|
|
29
|
+
new CopyWebpackPlugin([
|
|
30
|
+
{
|
|
31
|
+
from: path.join(__dirname, 'node_modules/haiwei-ui/public'),
|
|
32
|
+
to: path.join(__dirname, outputDir),
|
|
33
|
+
ignore: ['index.html']
|
|
34
|
+
}
|
|
35
|
+
])
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!isDev) {
|
|
40
|
+
//自定义代码压缩
|
|
41
|
+
config.optimization = {
|
|
42
|
+
minimize: true,
|
|
43
|
+
minimizer: [
|
|
44
|
+
new TerserPlugin({
|
|
45
|
+
cache: true,
|
|
46
|
+
parallel: true,
|
|
47
|
+
sourceMap: false,
|
|
48
|
+
terserOptions: {
|
|
49
|
+
compress: {
|
|
50
|
+
drop_console: true,
|
|
51
|
+
drop_debugger: true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return config
|
|
59
|
+
},
|
|
60
|
+
chainWebpack: config => {
|
|
61
|
+
/**
|
|
62
|
+
* 删除懒加载模块的 prefetch preload,降低带宽压力
|
|
63
|
+
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
|
|
64
|
+
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
|
|
65
|
+
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
|
|
66
|
+
*/
|
|
67
|
+
config.plugins.delete('prefetch').delete('preload')
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 设置index.html模板路径,使用haiwei-ui/public中的模板
|
|
71
|
+
*/
|
|
72
|
+
config.plugin('html').tap(args => {
|
|
73
|
+
args[0].template = './node_modules/haiwei-ui/public/index.html'
|
|
74
|
+
return args
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
config
|
|
78
|
+
// 开发环境
|
|
79
|
+
.when(
|
|
80
|
+
isDev,
|
|
81
|
+
// sourcemap不包含列信息
|
|
82
|
+
config => config.devtool('cheap-source-map')
|
|
83
|
+
)
|
|
84
|
+
// 非开发环境
|
|
85
|
+
.when(!isDev, config => {
|
|
86
|
+
// 拆分
|
|
87
|
+
config.optimization.splitChunks({
|
|
88
|
+
chunks: 'all',
|
|
89
|
+
cacheGroups: {
|
|
90
|
+
elementUI: {
|
|
91
|
+
name: 'chunk-element-ui',
|
|
92
|
+
priority: 20,
|
|
93
|
+
test: /[\\/]node_modules[\\/]element-ui(.*)/
|
|
94
|
+
},
|
|
95
|
+
skins: {
|
|
96
|
+
name: 'chunk-haiwei-ui',
|
|
97
|
+
priority: 10,
|
|
98
|
+
test: /[\\/]node_modules[\\/]haiwei-ui(.*)/
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
config.optimization.runtimeChunk({
|
|
104
|
+
name: 'manifest'
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
}
|