├── src ├── store │ ├── modules │ │ └── user │ │ │ ├── type.ts │ │ │ └── index.ts │ ├── types.ts │ └── index.ts ├── style │ └── base.less ├── assets │ └── logo.png ├── declaration.d.ts ├── shims-vue.d.ts ├── config │ ├── conf.mock.ts │ ├── conf.test.ts │ ├── conf.prod.ts │ ├── conf.dev.ts │ ├── conf.d.ts │ └── index.ts ├── router │ └── index.ts ├── shims-tsx.d.ts ├── utils │ └── fetch.js ├── main.ts ├── views │ └── page │ │ └── index.vue ├── App.vue └── components │ ├── message │ └── message.vue │ └── Message │ └── index.js ├── .env.development ├── .env.production ├── public ├── robots.txt ├── favicon.ico ├── img │ └── icons │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── mstile-150x150.png │ │ ├── apple-touch-icon.png │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-512x512.png │ │ ├── apple-touch-icon-60x60.png │ │ ├── apple-touch-icon-76x76.png │ │ ├── apple-touch-icon-120x120.png │ │ ├── apple-touch-icon-152x152.png │ │ ├── apple-touch-icon-180x180.png │ │ ├── msapplication-icon-144x144.png │ │ └── safari-pinned-tab.svg ├── manifest.json └── index.html ├── .browserslistrc ├── babel.config.js ├── postcss.config.js ├── README.md ├── .gitignore ├── tslint.json ├── tsconfig.json ├── package.json └── vue.config.js /src/store/modules/user/type.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/style/base.less: -------------------------------------------------------------------------------- 1 | @primary: #333; -------------------------------------------------------------------------------- /.env.development: -------------------------------------------------------------------------------- 1 | VUE_APP_REQUEST_URL=development.com -------------------------------------------------------------------------------- /.env.production: -------------------------------------------------------------------------------- 1 | VUE_APP_REQUEST_URL=production.com -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/favicon.ico -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/src/assets/logo.png -------------------------------------------------------------------------------- /src/declaration.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@/components/Message'; 2 | declare module 'vue-wechat-title'; -------------------------------------------------------------------------------- /src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import Vue from 'vue'; 3 | export default Vue; 4 | } 5 | -------------------------------------------------------------------------------- /public/img/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/favicon-16x16.png -------------------------------------------------------------------------------- /public/img/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/favicon-32x32.png -------------------------------------------------------------------------------- /public/img/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/mstile-150x150.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /public/img/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/img/icons/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/android-chrome-512x512.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /src/config/conf.mock.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: 'mock', 3 | HOST: 'https://mock.com', 4 | API_HOST: 'https://mock.com/api' 5 | } 6 | -------------------------------------------------------------------------------- /src/config/conf.test.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: 'test', 3 | HOST: 'https://test.com', 4 | API_HOST: 'https://test.com/api' 5 | } 6 | -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /public/img/icons/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /public/img/icons/msapplication-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IFmiss/vue-template/master/public/img/icons/msapplication-icon-144x144.png -------------------------------------------------------------------------------- /src/config/conf.prod.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: 'production', 3 | HOST: 'https://production.com', 4 | API_HOST: 'https://production.com/api' 5 | } 6 | -------------------------------------------------------------------------------- /src/config/conf.dev.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | env: 'development', 3 | HOST: 'https://development.com', 4 | API_HOST: 'https://development.com/api' 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## vue-template 2 | vue-cli3.0搭建的通用vue项目 3 | 4 | ### 内容 5 | - Vuex 6 | - axios 7 | - Vue-router 8 | - d-js-utlis 9 | - typescript 10 | - pug模板语法 11 | - less全局变量配置 12 | - .env.development + .env.production 13 | - 配置rem移动端初始化字体大小 14 | -------------------------------------------------------------------------------- /src/store/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 此文件是用于定义变量名称 3 | * state 4 | * getters 5 | * action 6 | * mutation 7 | */ 8 | export const USER_INFO_STATE = 'USER_INFO_STATE' 9 | export const USER_INFO_GETTER = 'USER_INFO_GETTER' 10 | export const USER_INFO_SETTER = 'USER_INFO_SETTER' 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /src/store/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | // 日志打印配置 4 | import createLogger from 'vuex/dist/logger' 5 | 6 | import user from './modules/user/index' 7 | 8 | Vue.use(Vuex) 9 | const store = new Vuex.Store({ 10 | plugins: [createLogger()], 11 | modules: { 12 | user 13 | } 14 | }) 15 | export default store 16 | -------------------------------------------------------------------------------- /src/router/index.ts: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | Vue.use(Router); 4 | 5 | export default new Router({ 6 | routes: [ 7 | { 8 | path: '/', 9 | name: 'page', 10 | component: () => import('@/views/page/index.vue'), 11 | meta: { 12 | title: '首页' 13 | } 14 | } 15 | ] 16 | }); 17 | -------------------------------------------------------------------------------- /src/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VNode } from 'vue'; 2 | 3 | declare global { 4 | namespace JSX { 5 | // tslint:disable no-empty-interface 6 | interface Element extends VNode {} 7 | // tslint:disable no-empty-interface 8 | interface ElementClass extends Vue {} 9 | interface IntrinsicElements { 10 | [elem: string]: any; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/config/conf.d.ts: -------------------------------------------------------------------------------- 1 | interface Config { 2 | env: string; 3 | HOST: string; 4 | API_HOST: string; 5 | } 6 | 7 | declare enum URL_HOST_NAME { 8 | /** 9 | * 开发环境hostname 10 | */ 11 | DEV = 'd-hfjzkt.hfjy.com', 12 | /** 13 | * 测试环境hostname 14 | */ 15 | TEST = 't-hfjzkt.hfjy.com', 16 | /** 17 | * 正式环境hostname 18 | */ 19 | PROD = 'hfjzkt.hfjy.com' 20 | } 21 | -------------------------------------------------------------------------------- /src/utils/fetch.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | axios.interceptors.request.use(function (config) { 3 | return config 4 | }, function (error) { 5 | return Promise.reject(error) 6 | }) 7 | 8 | axios.interceptors.response.use(res => { 9 | const { code, data, msg } = res.data 10 | if (parseInt(code, 10) != 200) { 11 | // 失败 需要添加提示 12 | return Promise.reject(res) 13 | } 14 | return data 15 | }, err => { 16 | return Promise.reject(err) 17 | }) 18 | 19 | export default axios 20 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-template", 3 | "short_name": "vue-template", 4 | "icons": [ 5 | { 6 | "src": "./img/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "./img/icons/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "start_url": "./index.html", 17 | "display": "standalone", 18 | "background_color": "#000000", 19 | "theme_color": "#4DBA87" 20 | } 21 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "warning", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "linterOptions": { 7 | "exclude": [ 8 | "node_modules/**" 9 | ] 10 | }, 11 | "rules": { 12 | "quotemark": [true, "single"], 13 | "indent": [true, "spaces", 2], 14 | "interface-name": false, 15 | "ordered-imports": false, 16 | "object-literal-sort-keys": false, 17 | "no-consecutive-blank-lines": false, 18 | "no-console": false, 19 | "semicolon": false, 20 | "space-before-function-paren": false, 21 | "trailing-comma": false 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/store/modules/user/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as types from './../../types' 3 | const state = { 4 | [types.USER_INFO_STATE]: {} 5 | } 6 | 7 | const getters = { 8 | [types.USER_INFO_GETTER]: (s: any) => s.USER_INFO_STATE 9 | } 10 | 11 | const mutations = { 12 | [types.USER_INFO_SETTER]: (s: any, data: any) => { 13 | s[types.USER_INFO_STATE] = data 14 | } 15 | } 16 | 17 | const actions = { 18 | [types.USER_INFO_SETTER]: ({ commit }: any, data: any) => { 19 | commit(types.USER_INFO_SETTER, data) 20 | } 21 | } 22 | 23 | export default { 24 | state, 25 | getters, 26 | actions, 27 | mutations 28 | } 29 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |