Skip to content

Commit

Permalink
Feature/vue (#3)
Browse files Browse the repository at this point in the history
add vue-router support
  • Loading branch information
Jetsly authored Sep 19, 2018
1 parent cd508cf commit 3067988
Show file tree
Hide file tree
Showing 30 changed files with 553 additions and 93 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/examples
/src
/src
/templates
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# umi-plugin

### template

* [create-umi-vue](https://www.npmjs.com/package/create-umi-vue)

### plugins

* [@ddot/umi-plugin-service](https://www.npmjs.com/package/@ddot/umi-plugin-service)
* [@ddot/umi-plugin-vue](https://www.npmjs.com/package/@ddot/umi-plugin-vue)
23 changes: 4 additions & 19 deletions packages/create-umi-vue/lib/BasicGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,16 @@ module.exports = class BasicGenerator extends Generator {
this.destinationPath("mock")
);
this.fs.copy(
this.templatePath("app", "src", "assets"),
this.destinationPath("src/assets")
this.templatePath("app", "src", "pages"),
this.destinationPath("src/pages")
);
this.fs.copy(
this.templatePath("app", "src", "layouts"),
this.destinationPath("src/layouts")
);
this.fs.copy(
this.templatePath("app", "src", "pages"),
this.destinationPath("src/pages")
);
this.fs.copy(
this.templatePath("app", "src", "global.css"),
this.destinationPath("src/global.css")
this.templatePath("app", "src", "global.less"),
this.destinationPath("src/global.less")
);
this.fs.copyTpl(
this.templatePath("app", "package.json"),
Expand Down Expand Up @@ -83,16 +79,5 @@ module.exports = class BasicGenerator extends Generator {
this.templatePath("app", ".prettierignore"),
this.destinationPath(".prettierignore")
);

if (this.props.react.includes("dva")) {
this.fs.copy(
this.templatePath("app", "src", "models", ".*"),
this.destinationPath("src/models")
);
this.fs.copy(
this.templatePath("app", "src", "dva.js"),
this.destinationPath("src/dva.js")
);
}
}
};
4 changes: 2 additions & 2 deletions packages/create-umi-vue/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "create-umi-vue",
"version": "0.0.2",
"version": "0.0.8",
"description": "Creates a vue UmiJS application using the command line.",
"bin": {
"create-umi": "./bin/cli.js"
"create-umi-vue": "./bin/cli.js"
},
"dependencies": {
"chalk": "^2.4.1",
Expand Down
27 changes: 0 additions & 27 deletions packages/create-umi-vue/template/app/package.json

This file was deleted.

File renamed without changes.
4 changes: 4 additions & 0 deletions packages/create-umi-vue/templates/app/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["plugin:vue/essential"]
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
**/*.ejs
**/*.html
dist
package.json
.umi
.umi-production
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
export default {
plugins: [
// ref: https://github.com/jetsly/umi-plugin/tree/master/packages/create-umi-vue
["@ddot/umi-plugin-vue"]
]
[
'@ddot/umi-plugin-vue',
{
routes: {
exclude: [/model/],
},
},
],
],
};
26 changes: 26 additions & 0 deletions packages/create-umi-vue/templates/app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"private": true,
"scripts": {
"start": "umi dev",
"build": "umi build",
"test": "umi test",
"lint": "pretty-quick --staged"
},
"devDependencies": {
"@ddot/umi-plugin-vue": "^0.0.2",
"eslint": "^5.6.0",
"eslint-plugin-vue": "^5.0.0-beta.3",
"husky": "^1.0.0-rc.14",
"prettier": "^1.14.2",
"pretty-quick": "^1.6.0",
"umi": "^2.0.3"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
},
"engines": {
"node": ">=8.0.0"
}
}
3 changes: 3 additions & 0 deletions packages/create-umi-vue/templates/app/src/global.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html {
background: #fff;
}
3 changes: 3 additions & 0 deletions packages/create-umi-vue/templates/app/src/layouts/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<router-view></router-view>
</template>
4 changes: 2 additions & 2 deletions packages/umi-plugin-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

## 配置

**.umirc.service.yaml**
**.umirc.js**

```js
export default {
plugins: [
[
'umi-plugin-service'
'@ddot/umi-plugin-service'
]
]
};
Expand Down
2 changes: 1 addition & 1 deletion packages/umi-plugin-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ddot/umi-plugin-service",
"version": "0.1.1",
"version": "0.1.2",
"description": "A umi plugin for provide service function.",
"main": "./lib/index.js",
"authors": [
Expand Down
21 changes: 21 additions & 0 deletions packages/umi-plugin-vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# umi-plugin-vue
[![NPM version](https://img.shields.io/npm/v/@ddot/umi-plugin-vue.svg?style=flat-square)](https://npmjs.org/package/@ddot/umi-plugin-vue)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![MIT](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](http://opensource.org/licenses/MIT)


`umi`服务接口插件。

## 配置

**.umirc.js**

```js
export default {
plugins: [
[
'@ddot/umi-plugin-vue'
]
]
};
```
32 changes: 32 additions & 0 deletions packages/umi-plugin-vue/lib/excludeRoute.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var assert = require("assert");
function default_1(routes, excludes) {
function exclude(routes) {
return routes.filter(function(route) {
for (var _i = 0, excludes_1 = excludes; _i < excludes_1.length; _i++) {
var exclude_1 = excludes_1[_i];
assert(
typeof exclude_1 === "function" || exclude_1 instanceof RegExp,
"exclude should be function or RegExp"
);
if (typeof exclude_1 === "function" && exclude_1(route)) {
return false;
}
if (
!route.component.startsWith("() =>") &&
exclude_1 instanceof RegExp &&
exclude_1.test(route.component)
) {
return false;
}
}
if (route.children) {
route.children = exclude(route.children);
}
return true;
});
}
return exclude(routes);
}
exports.default = default_1;
Loading

0 comments on commit 3067988

Please sign in to comment.