Skip to content

Commit b871b58

Browse files
committed
refactor
1 parent 3a204be commit b871b58

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

src/utils.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,36 @@ function mergeGlobalProperties(
66
configGlobal: GlobalMountOptions = {},
77
mountGlobal: GlobalMountOptions = {}
88
): GlobalMountOptions {
9-
const {
10-
mixins: configMixins = [],
11-
plugins: configPlugins = [],
12-
...configRest
13-
} = configGlobal
14-
const {
15-
mixins: mountMixins = [],
16-
plugins: mountPlugins = [],
17-
...mountRest
18-
} = mountGlobal
19-
const mixins = [...configMixins, ...mountMixins]
20-
const plugins = [...configPlugins, ...mountPlugins]
21-
229
const stubs: Record<string, any> = {}
23-
24-
if (configRest.stubs) {
25-
if (Array.isArray(configRest.stubs)) {
26-
configRest.stubs.forEach((x) => (stubs[x] = true))
10+
if (configGlobal.stubs) {
11+
if (Array.isArray(configGlobal.stubs)) {
12+
configGlobal.stubs.forEach((x) => (stubs[x] = true))
2713
} else {
28-
for (const [k, v] of Object.entries(configRest.stubs)) {
14+
for (const [k, v] of Object.entries(configGlobal.stubs)) {
2915
stubs[k] = v
3016
}
3117
}
3218
}
3319

34-
if (mountRest.stubs) {
35-
if (mountRest.stubs && Array.isArray(mountRest.stubs)) {
36-
mountRest.stubs.forEach((x) => (stubs[x] = true))
20+
if (mountGlobal.stubs) {
21+
if (mountGlobal.stubs && Array.isArray(mountGlobal.stubs)) {
22+
mountGlobal.stubs.forEach((x) => (stubs[x] = true))
3723
} else {
38-
for (const [k, v] of Object.entries(mountRest.stubs)) {
24+
for (const [k, v] of Object.entries(mountGlobal.stubs)) {
3925
stubs[k] = v
4026
}
4127
}
4228
}
4329

4430
return {
45-
mixins,
46-
plugins,
31+
mixins: [...(configGlobal.mixins || []), ...(mountGlobal.mixins || [])],
32+
plugins: [...(configGlobal.plugins || []), ...(mountGlobal.plugins || [])],
4733
stubs,
48-
components: { ...configRest.components, ...mountRest.components },
49-
provide: { ...configRest.provide, ...mountRest.provide },
50-
mocks: { ...configRest.mocks, ...mountRest.mocks },
51-
config: { ...configRest.config, ...mountRest.config },
52-
directives: { ...configRest.directives, ...mountRest.directives }
53-
// stubs: { configRest.stubs, ...mountRest.stubs }
34+
components: { ...configGlobal.components, ...mountGlobal.components },
35+
provide: { ...configGlobal.provide, ...mountGlobal.provide },
36+
mocks: { ...configGlobal.mocks, ...mountGlobal.mocks },
37+
config: { ...configGlobal.config, ...mountGlobal.config },
38+
directives: { ...configGlobal.directives, ...mountGlobal.directives }
5439
}
5540
}
5641

0 commit comments

Comments
 (0)