Browse Source

更新框架

Caner 2 years ago
parent
commit
af67169b64
9 changed files with 107 additions and 37 deletions
  1. 0 1
      .env
  2. 2 0
      .env.production
  3. 1 3
      .eslintignore
  4. 35 10
      .eslintrc.json
  5. 25 19
      .gitignore
  6. 3 2
      README.md
  7. 27 0
      src/components/icon.vue
  8. 3 0
      src/pages/main.ts
  9. 11 2
      vite.config.ts

+ 0 - 1
.env

@@ -1 +0,0 @@
-VITE_PROXY_URL=http://114.114.114.114:28181

+ 2 - 0
.env.production

@@ -0,0 +1,2 @@
+VITE_SERVER_URL=https://jkbj.scrbg.com:5013
+# VITE_SERVER_URL=https://eas.any8.cc:8010

+ 1 - 3
.eslintignore

@@ -1,3 +1 @@
-# 排除eslint检查文件
-/dist
-/public
+audio-pusher.ts

+ 35 - 10
.eslintrc.json

@@ -15,22 +15,42 @@
     "airbnb-base"
   ],
   "rules": {
+    "import/prefer-default-export": "off",
+    "no-use-before-define": "off",
     "no-console": 0, // 禁用打印
-    "comma-dangle": [ 2, "never" ], // 禁止使用拖尾逗号
+    "comma-dangle": [
+      2,
+      "never"
+    ], // 禁止使用拖尾逗号
     "no-extra-semi": 2, // 禁止不必要的分号
-    "array-bracket-spacing": [ 2, "always" ], // 指定数组的元素之间要以空格隔开
+    "array-bracket-spacing": [
+      2,
+      "always"
+    ], // 指定数组的元素之间要以空格隔开
     "jsx-quotes": 0, // 强制使用单引号
     "max-len": 0, // 强制一行的最大长度
-    "semi": [ 2, "never" ], // 禁止使用分号
-    "no-unused-vars": 1,
+    "semi": [
+      2,
+      "never"
+    ], // 禁止使用分号
+    "no-unused-vars": 0,
     "no-unneeded-ternary": 2, // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
     "no-unreachable": 2, // 不能有无法执行的代码
     "no-unused-expressions": 1, // 禁止无用的表达式
-    "linebreak-style": [ 0, "error", "windows" ],
+    "linebreak-style": [
+      0,
+      "error",
+      "windows"
+    ],
     "import/no-unresolved": 0,
     "import/extensions": 0,
     "import/no-absolute-path": 0,
-    "import/no-extraneous-dependencies": 2,
+    "import/no-extraneous-dependencies": [
+      "error",
+      {
+        "devDependencies": true
+      }
+    ],
     "class-methods-use-this": 0,
     "no-mixed-operators": 0,
     "eol-last": 0,
@@ -55,12 +75,17 @@
     "no-sparse-arrays": 0,
     "no-nested-ternary": 0,
     "no-continue": 0,
-    "complexity": [ 2, 9 ],
+    "complexity": 0,
     "no-return-await": 0,
     "max-classes-per-file": 0,
-    "consistent-return" : 0,
+    "consistent-return": 0,
     "no-shadow": 0,
-    "no-undef":0,
-    "no-throw-literal":0
+    "no-undef": 0,
+    "no-throw-literal": 0,
+    "no-loss-of-precision": 0,
+    "no-prototype-builtins": 0,
+    "no-fallthrough": 0,
+    "no-case-declarations": 0,
+    "no-cond-assign": 0
   }
 }

+ 25 - 19
.gitignore

@@ -1,28 +1,34 @@
+# ---> Node
 # Logs
 logs
 *.log
 npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-pnpm-debug.log*
-lerna-debug.log*
 
+# Runtime data
+pids
+*.pid
+*.seed
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (http://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directory
+# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
 node_modules
 dist
-dist-ssr
-*.local
-
-# Editor directories and files
-.vscode/*
-!.vscode/extensions.json
-.idea
+.env.development
 .DS_Store
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
-yarn.lock
-dist
 package-lock.json
-dist-ssr
+*.lock

+ 3 - 2
README.md

@@ -1,4 +1,4 @@
-# vue3+TS+vite+eslint 模板
+# 路桥报警系统
 
 ## 目录结构
 ```
@@ -78,4 +78,5 @@ import { onMounted, ref, computed} from 'vue'
 * 多层级类名嵌套时,必须使用`scss`嵌套写法,以免污染其他样式
 
 ### Notice
-* 框架使用解构,注入方式
+* 框架使用解构,注入方式
+* 自行增加.env.development 测试环境变量

+ 27 - 0
src/components/icon.vue

@@ -0,0 +1,27 @@
+<script setup lang="ts">
+import { computed } from 'vue'
+
+const props = defineProps<{
+  name: string,
+  size?: number,
+  color?: string
+}>()
+const symbolId = computed(() => `#icon-${props.name}`)
+const newColor = computed(() => `${props.color ?? '#ccc'}`)
+const newSize = computed(() => `${props.size ?? 16}`)
+</script>
+<template>
+  <svg
+    aria-hidden="true"
+    :font-size="newSize"
+    :width="newSize"
+    :height="newSize"
+  >
+
+    <use
+      :href="symbolId"
+      :fill="newColor"
+      :fill-rule="undefined"
+    />
+  </svg>
+</template>

+ 3 - 0
src/pages/main.ts

@@ -3,6 +3,8 @@ import App from './App.vue'
 import { createPinia } from 'pinia'
 import naive from '@/assets/native-plugin'
 import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
+import Icon from '@/components/icon.vue'
+import 'virtual:svg-icons-register'
 
 // 动态路由
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
@@ -13,6 +15,7 @@ const router = createRouter({
   history: createWebHashHistory(),
   routes
 })
+app.component('Icon', Icon)
 // 路由守卫
 // router.beforeEach((to, from, next) => {
 //   // do something

+ 11 - 2
vite.config.ts

@@ -4,6 +4,7 @@ import vue from '@vitejs/plugin-vue'
 import eslint from 'vite-plugin-eslint'
 import viteCompression from 'vite-plugin-compression'
 import { resolve } from 'path'
+import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
 
 // https://vitejs.dev/config/
 export default ({ mode }) => {
@@ -19,7 +20,15 @@ export default ({ mode }) => {
         '@': resolve(__dirname, './src')
       }
     },
-    plugins: [ vue(), viteCompression(), eslint({ fix: true, include: [ '**/*.ts', '**/*.vue' ] }) ],
+    plugins: [
+      vue(), viteCompression(),
+      eslint({ fix: true, include: [ '**/*.ts', '**/*.vue' ] }),
+      createSvgIconsPlugin({
+        iconDirs: [ resolve(__dirname, './src/assets/icons') ],
+        // Specify symbolId format
+        symbolId: 'icon-[dir]-[name]'
+      })
+    ],
     server: {
       host: '0.0.0.0',
       port: 6888,
@@ -39,7 +48,7 @@ export default ({ mode }) => {
       // }
     },
     esbuild: {
-      drop: [ 'console', 'debugger' ] // build 移除打印
+      drop: mode === 'development' ? [ 'debugger' ] : [ 'debugger', 'console' ] // build 移除打印
     },
     build: {
       rollupOptions: {