Skip to content

Commit fa5be8e

Browse files
author
longshihui
committed
release v2.0.1
2 parents cf59721 + 9809f76 commit fa5be8e

File tree

4 files changed

+58
-10
lines changed

4 files changed

+58
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
<a name="2.0.0"></a>
1+
<a name="2.0.1"></a>
22

3-
# [2.0.0](https://github.com/longshihui/vue-cli-plugin-navigator/compare/v1.3.1...v2.0.0) (2019-01-02)
3+
## [2.0.1](https://github.com/longshihui/vue-cli-plugin-navigator/compare/v1.3.1...v2.0.1) (2019-01-02)
4+
5+
### Bug Fixes
6+
7+
- 修复 OptionDefaulter 对页面名字带.等特殊字符取值不正确的问题 ([35b3208](https://github.com/longshihui/vue-cli-plugin-navigator/commit/35b3208))
48

59
### Features
610

lib/OptionsDefaulter.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,21 @@ const Defaulter = {
5454
* @param pageName
5555
*/
5656
function defaulter(pageName) {
57-
const tags = _.get(pagesConfig, pageName + '.tags', defaults.tags);
58-
const description = _.get(
59-
pagesConfig,
60-
pageName + '.description',
61-
defaults.description
62-
);
57+
let tags = defaults.tags;
58+
let description = defaults.description;
59+
if (
60+
_.isPlainObject(pagesConfig) &&
61+
pagesConfig.hasOwnProperty(pageName) &&
62+
_.isPlainObject(pagesConfig[pageName])
63+
) {
64+
const pageConfig = pagesConfig[pageName];
65+
if (Array.isArray(pageConfig.tags)) {
66+
tags = pageConfig.tags;
67+
}
68+
if (_.isString(pageConfig.description)) {
69+
description = pageConfig.description;
70+
}
71+
}
6372
return {
6473
name: pageName,
6574
tags: tags.filter(_.isString),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-navigator",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Multi-page application homepage for vue cli",
55
"repository": {
66
"type": "git",

tests/options-defaulter.test.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ describe('指定pluginOptions.navigator', () => {
9494
page1: {
9595
tags: ['page'],
9696
description: "i'm page1"
97+
},
98+
'page3.dot': {
99+
tags: ['dot page'],
100+
description: 'my name have a dot!'
97101
}
98102
}
99103
};
100104
const projectOptions = {
101105
pages: {
102106
page1: './page1.js',
103-
page2: './page2.js'
107+
page2: './page2.js',
108+
'page3.dot': './page3.js'
104109
},
105110
pluginOptions: {
106111
navigator: originalOptions
@@ -178,5 +183,35 @@ describe('指定pluginOptions.navigator', () => {
178183
}
179184
);
180185
});
186+
describe('page3.dot', () => {
187+
it(
188+
'page3.dot的tags为: ' +
189+
originalOptions.pages['page3.dot'].tags.join(','),
190+
() => {
191+
expect(
192+
Array.isArray(finalOptions.pages['page3.dot'].tags)
193+
).toBe(true);
194+
expect(finalOptions.pages['page3.dot'].tags.length).toBe(
195+
originalOptions.pages['page3.dot'].tags.length
196+
);
197+
expect(
198+
sameArray(
199+
finalOptions.pages['page3.dot'].tags,
200+
originalOptions.pages['page3.dot'].tags
201+
)
202+
).toBe(true);
203+
}
204+
);
205+
206+
it(
207+
'page3.dot的description为: ' +
208+
originalOptions.pages['page3.dot'].description,
209+
() => {
210+
expect(finalOptions.pages['page3.dot'].description).toBe(
211+
originalOptions.pages['page3.dot'].description
212+
);
213+
}
214+
);
215+
});
181216
});
182217
});

0 commit comments

Comments
 (0)