Browse Source

fix: 新增EsLint及编辑器规范

zhangyuhan 4 years ago
parent
commit
823d6689ea

+ 5 - 0
jydocs-pc/.editorconfig

@@ -0,0 +1,5 @@
+[*.{js,jsx,ts,tsx,vue}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 20 - 0
jydocs-pc/.eslintrc.js

@@ -0,0 +1,20 @@
+module.exports = {
+  root: true,
+  env: {
+    node: true
+  },
+  extends: [
+    'plugin:vue/essential',
+    '@vue/standard'
+  ],
+  globals: {
+    loginflag: true
+  },
+  parserOptions: {
+    parser: 'babel-eslint'
+  },
+  rules: {
+    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
+    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
+  }
+}

+ 4 - 4
jydocs-pc/babel.config.js

@@ -2,12 +2,12 @@ module.exports = {
   presets: [
     '@vue/cli-plugin-babel/preset'
   ],
-  "plugins": [
+  plugins: [
     [
-      "component",
+      'component',
       {
-        "libraryName": "element-ui",
-        "styleLibraryName": "theme-chalk"
+        libraryName: 'element-ui',
+        styleLibraryName: 'theme-chalk'
       }
     ]
   ]

+ 12 - 2
jydocs-pc/package.json

@@ -5,7 +5,8 @@
   "scripts": {
     "serve": "vue-cli-service serve --port 8080",
     "serve:alone": "vue-cli-service serve --mode alone",
-    "build": "vue-cli-service build"
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint --fix"
   },
   "dependencies": {
     "axios": "^0.21.1",
@@ -18,12 +19,21 @@
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^4.1.0",
+    "@vue/cli-plugin-eslint": "~4.5.0",
+    "@vue/eslint-config-standard": "^5.1.2",
     "@vue/cli-plugin-router": "^4.1.0",
     "@vue/cli-service": "^4.1.0",
     "babel-plugin-component": "^1.1.1",
     "vue-cli-plugin-single-spa": "^1.0.1",
     "vue-template-compiler": "^2.6.10",
     "sass": "^1.26.5",
-    "sass-loader": "^8.0.2"
+    "sass-loader": "^8.0.2",
+    "babel-eslint": "^10.1.0",
+    "eslint": "^6.7.2",
+    "eslint-plugin-import": "^2.20.2",
+    "eslint-plugin-node": "^11.1.0",
+    "eslint-plugin-promise": "^4.2.1",
+    "eslint-plugin-standard": "^4.0.0",
+    "eslint-plugin-vue": "^6.2.2"
   }
 }

+ 27 - 27
jydocs-pc/src/App.vue

@@ -6,35 +6,35 @@
 </template>
 
 <script>
-  export default {
-    components: {},
-    data () {
-      return {
-        links: [
-          {
-            to: '/',
-            text:'首页'
-          },
-          {
-            to: '/content/12',
-            text:'内容页'
-          },
-          {
-            to: '/search',
-            text:'列表页'
-          },
-          {
-            to: '/keep',
-            text:'收藏页'
-          },
-          {
-            to: '/mine',
-            text:'我的'
-          }
-        ]
-      }
+export default {
+  components: {},
+  data () {
+    return {
+      links: [
+        {
+          to: '/',
+          text: '首页'
+        },
+        {
+          to: '/content/12',
+          text: '内容页'
+        },
+        {
+          to: '/search',
+          text: '列表页'
+        },
+        {
+          to: '/keep',
+          text: '收藏页'
+        },
+        {
+          to: '/mine',
+          text: '我的'
+        }
+      ]
     }
   }
+}
 </script>
 <style lang="scss">
     .link-item {

+ 5 - 5
jydocs-pc/src/components/CardItem.vue

@@ -13,12 +13,12 @@
 </template>
 
 <script>
-  export default {
-    name: 'Card-Item',
-    props: {
-      msg: String
-    }
+export default {
+  name: 'Card-Item',
+  props: {
+    msg: String
   }
+}
 </script>
 
 <style scoped lang="scss">

+ 0 - 32
jydocs-pc/src/components/HelloWorld.vue

@@ -1,32 +0,0 @@
-<template>
-  <div class="hello">
-    {{msg}}
-  </div>
-</template>
-
-<script>
-export default {
-  name: 'HelloWorld',
-  props: {
-    msg: String
-  }
-}
-</script>
-
-<!-- Add "scoped" attribute to limit CSS to this component only -->
-<style scoped>
-h3 {
-  margin: 40px 0 0;
-}
-ul {
-  list-style-type: none;
-  padding: 0;
-}
-li {
-  display: inline-block;
-  margin: 0 10px;
-}
-a {
-  color: #42b983;
-}
-</style>

+ 1 - 1
jydocs-pc/src/components/List.vue

@@ -9,7 +9,7 @@
 </template>
 
 <script>
-import ListItem from "./ListItem";
+import ListItem from './ListItem'
 export default {
   name: 'List-Group',
   components: {

+ 30 - 14
jydocs-pc/src/components/Search.vue

@@ -4,30 +4,46 @@
                 placeholder="搜索文档"
                 v-model="input"
                 clearable>
+            <el-button slot="append" icon="el-icon-jy-search"></el-button>
         </el-input>
     </div>
 </template>
 
 <script>
-  import { Input } from 'element-ui'
-  export default {
-    name: 'Search-Input',
-    props: {
-      msg: String
-    },
-    components: {
-      [Input.name]: Input
-    },
-    data() {
-      return {
-        input: ''
-      }
+import { Input, Button } from 'element-ui'
+export default {
+  name: 'Search-Input',
+  props: {
+    msg: String
+  },
+  components: {
+    [Input.name]: Input,
+    [Button.name]: Button
+  },
+  data () {
+    return {
+      input: ''
     }
   }
+}
 </script>
 
 <style scoped lang="scss">
     .search-input {
-
+        width: 640px;
+        margin: 0 auto;
+        @include diy-icon('search', 24);
+        ::v-deep .el-input__inner {
+            border-radius: 22px 0 0 22px;
+            background: #FFFFFF;
+            border: 1px solid #E0E0E0;
+        }
+        ::v-deep .el-input-group__append {
+            box-sizing: border-box;
+            text-align: center;
+            border: none;
+            border-radius: 0px 22px 22px 0px;
+            background: #2CB7CA;
+        }
     }
 </style>

+ 11 - 13
jydocs-pc/src/main.js

@@ -1,17 +1,16 @@
-import Vue from 'vue';
-import App from './App.vue';
-import router from './router';
-import singleSpaVue from 'single-spa-vue';
+import Vue from 'vue'
+import App from './App.vue'
+import router from './router'
+import singleSpaVue from 'single-spa-vue'
 
-Vue.config.productionTip = false;
+Vue.config.productionTip = false
 
 const vueOptions = {
   el: '#single-spa-app',
   router,
-  render: (h) => h(App),
+  render: (h) => h(App)
 }
 
-
 let vueLifecycles = {}
 if (process.env.VUE_APP_ALONE) {
   delete vueOptions.el
@@ -19,13 +18,12 @@ if (process.env.VUE_APP_ALONE) {
 } else {
   vueLifecycles = singleSpaVue({
     Vue,
-    appOptions: vueOptions,
-  });
+    appOptions: vueOptions
+  })
 }
 
-export const bootstrap = vueLifecycles.bootstrap;
-export const mount = vueLifecycles.mount;
-export const unmount = vueLifecycles.unmount;
+export const bootstrap = vueLifecycles.bootstrap
+export const mount = vueLifecycles.mount
+export const unmount = vueLifecycles.unmount
 
 export default vueLifecycles
-

+ 1 - 1
jydocs-pc/src/router.js

@@ -6,7 +6,7 @@ Vue.use(Router)
 
 export default new Router({
   mode: 'history',
-  base:  process.env.VUE_APP_BASE_URL,
+  base: process.env.VUE_APP_BASE_URL,
   routes: [
     {
       path: '/',

+ 0 - 1
jydocs-pc/src/set-public-path.js

@@ -3,4 +3,3 @@ import { setPublicPath } from 'systemjs-webpack-interop'
 if (!process.env.VUE_APP_ALONE) {
   setPublicPath('app', 2)
 }
-

+ 0 - 1
jydocs-pc/src/views/404.vue

@@ -3,4 +3,3 @@
     <h3>这里什么也没有</h3>
   </div>
 </template>
-

+ 2 - 4
jydocs-pc/src/views/Content.vue

@@ -6,14 +6,12 @@
 </template>
 
 <script>
-import HelloWorld from '@/components/HelloWorld.vue'
-import { ajaxGetTest } from "../api/modules/user";
-import { Button } from 'element-ui';
+import { ajaxGetTest } from '../api/modules/user'
+import { Button } from 'element-ui'
 
 export default {
   name: 'home',
   components: {
-    HelloWorld,
     [Button.name]: Button
   },
   data () {

+ 6 - 8
jydocs-pc/src/views/Home.vue

@@ -37,12 +37,11 @@
 </template>
 
 <script>
-import HelloWorld from '@/components/HelloWorld.vue'
-import { ajaxGetTest } from "../api/modules/user";
-import { Button } from 'element-ui';
-import SearchInput from "../components/Search";
-import ListItem from "../components/ListItem";
-import CardItem from "../components/CardItem";
+import { ajaxGetTest } from '../api/modules/user'
+import { Button } from 'element-ui'
+import SearchInput from '../components/Search'
+import ListItem from '../components/ListItem'
+import CardItem from '../components/CardItem'
 
 export default {
   name: 'home',
@@ -50,12 +49,11 @@ export default {
     CardItem,
     ListItem,
     SearchInput,
-    HelloWorld,
     [Button.name]: Button
   },
   data () {
     return {
-      fullscreenLoading: false,
+      fullscreenLoading: false
     }
   },
   methods: {

+ 2 - 4
jydocs-pc/src/views/Keep.vue

@@ -6,14 +6,12 @@
 </template>
 
 <script>
-import HelloWorld from '@/components/HelloWorld.vue'
-import { ajaxGetTest } from "../api/modules/user";
-import { Button } from 'element-ui';
+import { ajaxGetTest } from '../api/modules/user'
+import { Button } from 'element-ui'
 
 export default {
   name: 'home',
   components: {
-    HelloWorld,
     [Button.name]: Button
   },
   data () {

+ 2 - 4
jydocs-pc/src/views/Mine.vue

@@ -6,14 +6,12 @@
 </template>
 
 <script>
-import HelloWorld from '@/components/HelloWorld.vue'
-import { ajaxGetTest } from "../api/modules/user";
-import { Button } from 'element-ui';
+import { ajaxGetTest } from '../api/modules/user'
+import { Button } from 'element-ui'
 
 export default {
   name: 'home',
   components: {
-    HelloWorld,
     [Button.name]: Button
   },
   data () {

+ 2 - 4
jydocs-pc/src/views/Search.vue

@@ -6,14 +6,12 @@
 </template>
 
 <script>
-import HelloWorld from '@/components/HelloWorld.vue'
-import { ajaxGetTest } from "../api/modules/user";
-import { Button } from 'element-ui';
+import { ajaxGetTest } from '../api/modules/user'
+import { Button } from 'element-ui'
 
 export default {
   name: 'home',
   components: {
-    HelloWorld,
     [Button.name]: Button
   },
   data () {

+ 1 - 1
jydocs-pc/vue.config.js

@@ -29,7 +29,7 @@ module.exports = {
       config.devServer.set('inline', false)
       config.devServer.set('hot', true)
       if (process.env.NODE_ENV !== 'production') {
-        config.output.filename(`js/[name].js`)
+        config.output.filename('js/[name].js')
       }
       config.externals(['vue', 'vue-router'])
     }

File diff suppressed because it is too large
+ 564 - 18
jydocs-pc/yarn.lock


Some files were not shown because too many files changed in this diff