Commit 6f1b2412 authored by 曾沂轮's avatar 曾沂轮

Feat: 添加模板

parents
# svi-cli vue-openlayers Template
> 一个基于vue-cli3.x搭建的vue + router + openlayers路由应用模板,提供给svi-cli脚手架获取.
> 提供内部用Vuejs开发页面的初始模板
> 主要依赖 `vue` `vue-router` `ol` `@smart/eslint-config-stadard` 智能的规范
## Usage / 用法
``` bash
$ npm install -g svi-cli
$ svi init vue-openlayers my-project
$ cd my-project
$ npm install
$ npm run serve
```
module.exports = {
renderFiles: [
'package.json',
'README.md'
],
filters: {
},
prompts: {
name: {
type: 'string',
required: true,
message: 'Project name'
},
description: {
type: 'string',
required: false,
message: 'Project description',
default: 'a openlayers project for vuejs.',
},
author: {
type: 'string',
message: 'Author'
}
}
}
\ No newline at end of file
{
"name": "vue-openlayers",
"version": "0.0.1",
"description": "a svi CLI vue-openlayers template.",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"template"
],
"author": "zengyl@southzn.com",
"license": "MIT"
}
> 1%
last 2 versions
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@smart/standard'
],
plugins: [
'vue'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
};
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# {{name}}
> {{description}}
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Run your tests
```
npm run test
```
### Lints and fixes files
```
npm run lint
```
### Run your unit tests
```
npm run test:unit
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: [
'@vue/app'
]
};
{
"compilerOptions": {
"checkJs": true,
// Point to the JSDoc typed sources when using modules from the ol package
"baseUrl": "./",
"paths": {
"ol": ["node_modules/ol/src"],
"ol/*": ["node_modules/ol/src/*"]
}
},
"include": [
"**/*.js",
"node_modules/ol/**/*.js"
]
}
{
"name": "{{name}}",
"description": "{{description}}",
"version": "0.1.0",
"author": "{{author}}",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"core-js": "^2.6.5",
"ol": "^5.3.3",
"vue": "^2.6.10",
"vue-router": "^3.0.3"
},
"devDependencies": {
"@smart/eslint-config-standard": "^0.1.0",
"@vue/cli-plugin-babel": "^3.10.0",
"@vue/cli-plugin-eslint": "^3.10.0",
"@vue/cli-plugin-unit-mocha": "^3.10.0",
"@vue/cli-service": "^3.10.0",
"@vue/test-utils": "1.0.0-beta.29",
"babel-eslint": "^10.0.1",
"chai": "^4.1.2",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"sass": "^1.22.10",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
}
}
module.exports = {
plugins: {
autoprefixer: {}
}
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>vue-template</title>
</head>
<body>
<noscript>
<strong>We're sorry but vue-template doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<router-view/>
</div>
</template>
<template>
<div class="app-map" id="appMap">
</div>
</template>
<script>
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
export default {
name: 'AppMap',
mounted() {
this.init();
},
methods: {
init() {
/* eslint-disable no-new */
new Map({
target: 'appMap',
layers: [
new TileLayer({
source: new XYZ({
url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
})
})
],
view: new View({
center: [0, 0],
zoom: 2
})
});
}
}
};
</script>
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import './styles/index.scss';
Vue.config.productionTip = false;
/* eslint-disable */
new Vue({
router,
render: h => h(App)
}).$mount('#app');
import Vue from 'vue';
import Router from 'vue-router';
import Home from './views/Home.vue';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: Home
}
]
});
%placehodler {
width: 100%;
height: 100%;
}
html, body, #app {
@extend %placehodler;
overflow: hidden;
}
body {
margin: 0;
}
\ No newline at end of file
<template>
<div class="home">
<app-map></app-map>
</div>
</template>
<script>
import AppMap from '@/components/map/Map';
export default {
name: 'home',
components: {
AppMap
}
};
</script>
<style lang="scss">
.home {
width: 100%;
height: 100%;
}
</style>
module.exports = {
env: {
mocha: true
}
};
import { expect } from 'chai';
import { shallowMount } from '@vue/test-utils';
import HelloWorld from '@/components/HelloWorld.vue';
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message';
const wrapper = shallowMount(HelloWorld, {
propsData: { msg }
});
expect(wrapper.text()).to.include(msg);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment