Browse Source

增加ESlint校验+ESlint修正,IDE无需插手自动修正
Signed-off-by: Caner <40012261+Canees@users.noreply.github.com>

Caner 3 years ago
parent
commit
1c3e3da8e6

+ 22 - 15
.eslintrc.js

@@ -6,8 +6,7 @@ module.exports = {
   },
   parserOptions: {
     ecmaVersion: 12,
-    sourceType: 'module',
-    parser: '@typescript-eslint/parser'
+    sourceType: 'module'
   },
   extends: [
     'plugin:vue/vue3-recommended',
@@ -15,20 +14,28 @@ module.exports = {
   ],
   rules: {
     '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': [1, 200], // 强制一行的最大长度
-    'semi': [2, 'never'], // 禁止使用分号
-    'linebreak-style': [0, 'error', 'windows'],
-    'import/no-unresolved': 'off',
-    'import/extensions': 'off',
-    'import/no-absolute-path': 'off',
-    'import/no-extraneous-dependencies': 'off',
-    'class-methods-use-this': 'off',
-    'no-mixed-operators': 'off',
-    'allowForLoopAfterthoughts': true,
-    'treatUndefinedAsUnspecified': true
+    'max-len': 0, // 强制一行的最大长度
+    semi: [ 2, 'never' ], // 禁止使用分号
+    'linebreak-style': [ 0, 'error', 'windows' ],
+    'import/no-unresolved': 0,
+    'import/extensions': 0,
+    'import/no-absolute-path': 0,
+    'import/no-extraneous-dependencies': 0,
+    'class-methods-use-this': 0,
+    'no-mixed-operators': 0,
+    'eol-last': 0,
+    'import/newline-after-import': 0,
+    'vue/multi-word-component-names': 0,
+    'no-param-reassign': 0,
+    'no-restricted-syntax': 0,
+    'no-underscore-dangle': 0,
+    'no-plusplus': 0,
+    'no-bitwise': 0,
+    'guard-for-in': 0,
+    'func-names': 0
   }
 }

+ 0 - 10
.vscode/settings.json

@@ -1,10 +0,0 @@
-{
-    "editor.formatOnSave": true,
-    // #每次保存的时候将代码按eslint格式进行修复
-    "editor.codeActionsOnSave": {
-        "source.fixAll.eslint": true
-    },
-    "[vue]": {
-        "editor.defaultFormatter": "Vue.volar"
-    }
-}

+ 3 - 6
package.json

@@ -14,19 +14,16 @@
     "vuex": "^3.6.2"
   },
   "devDependencies": {
-    "@types/glob": "^7.2.0",
-    "@types/node": "^17.0.1",
-    "@types/vue-router": "^2.0.0",
-    "@typescript-eslint/parser": "^5.25.0",
     "eslint": "^8.15.0",
     "eslint-config-airbnb-base": "^15.0.0",
     "eslint-plugin-import": "^2.26.0",
-    "eslint-plugin-vue": "^9.0.1",
+    "eslint-plugin-vue": "^9.1.0",
     "glob": "^8.0.3",
     "less": "^4.1.2",
     "vite": "^2.9.9",
     "vite-plugin-compression": "^0.5.1",
+    "vite-plugin-eslint": "^1.6.1",
     "vite-plugin-vue2": "^2.0.1",
     "vue-template-compiler": "^2.6.14"
   }
-}
+}

+ 16 - 0
pageB.html

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8" />
+  <link rel="icon" href="/favicon.ico" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <title>Vite App</title>
+</head>
+
+<body>
+  <div id="app"></div>
+  <script type="module" src="./src/pages/pageB/main.js"></script>
+</body>
+
+</html>

+ 6 - 2
src/pages/index/views/test.vue

@@ -1,14 +1,18 @@
 <template>
   <div>
-    111111
     <test />
   </div>
 </template>
 <script>
-import test from "@/components/1.vue";
+import test from '@/components/1.vue'
 export default {
   components: {
     test
+  },
+  methods: {
+    test() {
+      console.log(123)
+    }
   }
 }
 </script>

+ 69 - 66
src/utils/FormAnalyticalServer.js

@@ -6,7 +6,7 @@ import axios from 'axios'
  * 来源以模板为准
  */
 class FormAnalyticalServer {
-  constructor () {
+  constructor() {
     console.warn('该服务需要特定数据模板')
     this.XLSX = XLSX
     this.X2js = new X2js()
@@ -18,15 +18,15 @@ class FormAnalyticalServer {
    *  @param {File} file file
    *  @return srcData
    */
-  async CountdrillingParameterObj (file) {
+  async CountdrillingParameterObj(file) {
     const url = window.URL.createObjectURL(file)
     const res = await this.Axios.get(url)
     const jsonObj = this.X2js.xml2js(res)
     const xmlData = jsonObj.Workbook.Worksheet.Table.Row
-    let srcData = []
+    const srcData = []
     for (const i in xmlData) {
-      let rowData = xmlData[i].Cell
-      let arr = []
+      const rowData = xmlData[i].Cell
+      const arr = []
       for (const j in rowData) {
         if (rowData[j].Data && rowData[j].Data.__text) {
           arr.push(rowData[j].Data.__text)
@@ -42,52 +42,52 @@ class FormAnalyticalServer {
    * @param {File} file file
    * @return geologicalSketchObj
    */
-  async CountGeologicalSketchObj (file) {
+  async CountGeologicalSketchObj(file) {
     const data = await this.XLSX2JSON(file)
-    const mileageTime = new Date(data[0]['__EMPTY_9']).getTime() / 1000
-    const date = new Date(data[23]['__EMPTY_5']).getTime() / 1000
+    const mileageTime = new Date(data[0].__EMPTY_9).getTime() / 1000
+    const date = new Date(data[23].__EMPTY_5).getTime() / 1000
     const geologicalSketchObj = {
-      tunnelName: data[0]['__EMPTY'], // 隧道
-      workArea: data[0]['__EMPTY_2'], // 工区
-      workFace: data[0]['__EMPTY_4'], // 工作面
-      mileage: data[0]['__EMPTY_6'], // 断面里程
+      tunnelName: data[0].__EMPTY, // 隧道
+      workArea: data[0].__EMPTY_2, // 工区
+      workFace: data[0].__EMPTY_4, // 工作面
+      mileage: data[0].__EMPTY_6, // 断面里程
       mileageTime: mileageTime || '', // 时间
-      tunnelNumber: data[1]['__EMPTY'], // 项目编号
+      tunnelNumber: data[1].__EMPTY, // 项目编号
       faceSize: {
-        width: data[2]['__EMPTY_2'], // 开挖宽度
-        height: data[2]['__EMPTY_4'], // 开挖高度
-        faceNum: data[2]['__EMPTY_6'], // 开挖面积
-        methods: data[2]['__EMPTY_8'], // 开挖方法
-        support: data[2]['__EMPTY_10'] // 超前支护类型
+        width: data[2].__EMPTY_2, // 开挖宽度
+        height: data[2].__EMPTY_4, // 开挖高度
+        faceNum: data[2].__EMPTY_6, // 开挖面积
+        methods: data[2].__EMPTY_8, // 开挖方法
+        support: data[2].__EMPTY_10 // 超前支护类型
       },
-      lithology: data[3]['__EMPTY_1'], // 地层岩性
-      choose1: data[4]['__EMPTY_1'], // 风化程度
-      choose2: data[5]['__EMPTY_1'], // 岩石强度(MPa)
-      choose12: data[6]['__EMPTY_1'], // 岩体结构类型
-      choose3: data[7]['__EMPTY_1'], // 主要结构面组数
-      choose4: data[8]['__EMPTY_1'], // 结构面平均间距(m)
-      choose5: data[9]['__EMPTY_1'], // 结构面发育程度
-      choose6: data[10]['__EMPTY_1'], // 裂隙宽度(mm)
-      choose7: data[11]['__EMPTY_1'], // 裂隙充填物
-      choose13: data[12]['__EMPTY_1'], // 结构面粗糙程度
-      choose8: data[13]['__EMPTY_1'], // 结合程度
-      choose9: data[14]['__EMPTY_1'], // 完整程度
-      choose10: data[15]['__EMPTY_1'], // 地下水状态
-      choose11: data[17]['__EMPTY_1'], // 地应力状态
+      lithology: data[3].__EMPTY_1, // 地层岩性
+      choose1: data[4].__EMPTY_1, // 风化程度
+      choose2: data[5].__EMPTY_1, // 岩石强度(MPa)
+      choose12: data[6].__EMPTY_1, // 岩体结构类型
+      choose3: data[7].__EMPTY_1, // 主要结构面组数
+      choose4: data[8].__EMPTY_1, // 结构面平均间距(m)
+      choose5: data[9].__EMPTY_1, // 结构面发育程度
+      choose6: data[10].__EMPTY_1, // 裂隙宽度(mm)
+      choose7: data[11].__EMPTY_1, // 裂隙充填物
+      choose13: data[12].__EMPTY_1, // 结构面粗糙程度
+      choose8: data[13].__EMPTY_1, // 结合程度
+      choose9: data[14].__EMPTY_1, // 完整程度
+      choose10: data[15].__EMPTY_1, // 地下水状态
+      choose11: data[17].__EMPTY_1, // 地应力状态
       mainStructural: {
-        text1: data[16]['__EMPTY_2'], // 主要结构面走向
-        text2: data[16]['__EMPTY_4'], // 主要结构面倾角
-        text3: data[16]['__EMPTY_6'], // 与洞轴线夹角
-        text4: data[16]['__EMPTY_8'] // 备注
+        text1: data[16].__EMPTY_2, // 主要结构面走向
+        text2: data[16].__EMPTY_4, // 主要结构面倾角
+        text3: data[16].__EMPTY_6, // 与洞轴线夹角
+        text4: data[16].__EMPTY_8 // 备注
       }, // 主要结构面产状及与洞轴线夹角
-      grade: data[18]['__EMPTY_1'], // 围岩亚级划分
-      stability: data[19]['__EMPTY_1'], // 掌子面稳定性划分
-      describeText: data[20]['__EMPTY_1'], // 描述
+      grade: data[18].__EMPTY_1, // 围岩亚级划分
+      stability: data[19].__EMPTY_1, // 掌子面稳定性划分
+      describeText: data[20].__EMPTY_1, // 描述
       personCompany: {
-        tabulation: data[22]['__EMPTY_1'], // 制表
-        review: data[22]['__EMPTY_5'], // 复核
-        supervisor: data[22]['__EMPTY_9'], // 监理工程师
-        company: data[23]['__EMPTY_1'], // 施工单位
+        tabulation: data[22].__EMPTY_1, // 制表
+        review: data[22].__EMPTY_5, // 复核
+        supervisor: data[22].__EMPTY_9, // 监理工程师
+        company: data[23].__EMPTY_1, // 施工单位
         date: date || '' // 日期
       }
     }
@@ -99,9 +99,9 @@ class FormAnalyticalServer {
    * @param {File} file file
    * @return DesignDb
    */
-  async CountDesign (file) {
+  async CountDesign(file) {
     const data = await this.XLSX2JSON(file)
-    let DesignDb = []
+    const DesignDb = []
     for (let j = 0; j < data.length; j++) {
       const el = data[j]
       DesignDb.push({
@@ -124,43 +124,47 @@ class FormAnalyticalServer {
    * @param {FILE} FILE
    * @return JSON
    */
-  async XLSX2JSON (FILE) {
+  async XLSX2JSON(FILE) {
     const reader = new FileReader()
     reader.readAsBinaryString(FILE)
     const JSON = await new Promise((resolve, reject) => {
-      reader.onload = e => {
-        let wb = this.XLSX.read(e.target.result, {
+      reader.onload = (e) => {
+        const wb = this.XLSX.read(e.target.result, {
           type: 'binary'
         }) // 读取完成的数据
         // 转成json header解析第一行标题,只解析最后一个标签
         const lastexcel = wb.SheetNames[wb.SheetNames.length - 1]
-        let data = this.XLSX.utils.sheet_to_json(wb.Sheets[lastexcel], { dateNF: 'yyyy/mm/dd', raw: false })
+        const data = this.XLSX.utils.sheet_to_json(wb.Sheets[lastexcel], { dateNF: 'yyyy/mm/dd', raw: false })
         resolve(data)
       }
     })
     return JSON
   }
+
   /**
    * 导出excel
    * @param fileName 保存文件名
    * @param table table表格DOM
    */
-  outfile (fileName, table) {
+  outfile(fileName, table) {
     try {
-      let sheet1 = XLSX.utils.table_to_sheet(table, { raw: true })
-      let blob2 = this.sheets2book2blob([sheet1])
+      const sheet1 = XLSX.utils.table_to_sheet(table, { raw: true })
+      const blob2 = this.sheets2book2blob([ sheet1 ])
       this.openDownloadDialog(blob2, `${fileName}.xlsx`)
     } catch (error) {
       console.error('导出错误')
     }
   }
+
   /**
    * sheet转blob
    * @param params sheet参数arr|obj
+   * @returns
    */
-  sheets2book2blob (params) {
+  sheets2book2blob(params) {
+    let blob = null
     if (params && params.length > 0) {
-      let workbook = {
+      const workbook = {
         SheetNames: [],
         Sheets: {}
       }
@@ -176,39 +180,38 @@ class FormAnalyticalServer {
         }
       }
       // 生成excel的配置项
-      let wopts = {
+      const wopts = {
         bookType: 'xlsx', // 要生成的文件类型
         bookSST: false, // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
         type: 'binary'
       }
-      let wbout = XLSX.write(workbook, wopts)
-      let blob = new Blob([this.s2ab(wbout)], { type: 'application/octet-stream' })
-
-      return blob
-    } else {
-      console.error('参数错误(need arr and arr obj)')
+      const wbout = XLSX.write(workbook, wopts)
+      blob = new Blob([ this.s2ab(wbout) ], { type: 'application/octet-stream' })
     }
+    return blob
   }
+
   /**
    * 字符串转ArrayBuffer
    * @param s 字符串
    */
-  s2ab (s) {
-    let buf = new ArrayBuffer(s.length)
-    let view = new Uint8Array(buf)
+  s2ab(s) {
+    const buf = new ArrayBuffer(s.length)
+    const view = new Uint8Array(buf)
     for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff
     return buf
   }
+
   /**
    * 下载
    * @param url 文件blob
    * @param fileName 文件名
    */
-  openDownloadDialog (url, fileName) {
+  openDownloadDialog(url, fileName) {
     if (typeof url === 'object' && url instanceof Blob) {
       url = URL.createObjectURL(url) // 创建blob地址
     }
-    let aLink = document.createElement('a')
+    const aLink = document.createElement('a')
     aLink.href = url
     aLink.download = fileName || '' // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
     let event

+ 78 - 77
src/utils/MoveService.js

@@ -1,98 +1,99 @@
 export default class MoveService {
-    constructor(DOM) {
-        if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
-            this.DviceType = true
-        } else {
-            this.DviceType = false
-        }
-        this.movedom = null
-        this.w = document.body.clientWidth
-        this.h = document.body.clientHeight
-        this.PX = 0
-        this.PY = 0
-        this.domw = 0
-        this.domh = 0
-        this.on(DOM)
+  constructor(DOM) {
+    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
+      this.DviceType = true
+    } else {
+      this.DviceType = false
     }
-    /**
+    this.movedom = null
+    this.w = document.body.clientWidth
+    this.h = document.body.clientHeight
+    this.PX = 0
+    this.PY = 0
+    this.domw = 0
+    this.domh = 0
+    this.on(DOM)
+  }
+
+  /**
        * 移动
        */
-    mousemove (event) {
-        const e = event || window.event
-        const x = this.DviceType ? e.touches[0].clientX : e.clientX
-        const y = this.DviceType ? e.touches[0].clientY : e.clientY
-        const mx = x - this.PX
-        const my = y - this.PY
-        const outx = this.w - this.domw
-        const outy = this.h - this.domh
-        this.movedom.style.left = mx + 'px'
-        this.movedom.style.top = my + 'px'
-        if (mx >= outx) {
-            this.movedom.style.left = outx + 'px'
-        }
-        if (my >= outy) {
-            this.movedom.style.top = outy + 'px'
-        }
-        if (mx <= 0) {
-            this.movedom.style.left = '0px'
-        }
-        if (my <= 0) {
-            this.movedom.style.top = '0px'
-        }
+  mousemove(event) {
+    const e = event || window.event
+    const x = this.DviceType ? e.touches[0].clientX : e.clientX
+    const y = this.DviceType ? e.touches[0].clientY : e.clientY
+    const mx = x - this.PX
+    const my = y - this.PY
+    const outx = this.w - this.domw
+    const outy = this.h - this.domh
+    this.movedom.style.left = `${mx}px`
+    this.movedom.style.top = `${my}px`
+    if (mx >= outx) {
+      this.movedom.style.left = `${outx}px`
+    }
+    if (my >= outy) {
+      this.movedom.style.top = `${outy}px`
+    }
+    if (mx <= 0) {
+      this.movedom.style.left = '0px'
     }
+    if (my <= 0) {
+      this.movedom.style.top = '0px'
+    }
+  }
 
-    /**
+  /**
        * 鼠标按下
        */
-    mousedown (event) {
-        // 获取点击DOM
-        const e = event || window.event
-        if (this.DviceType) {
-            this.PX = e.touches[0].clientX - this.movedom.offsetLeft
-            this.PY = e.touches[0].clientY - this.movedom.offsetTop
-            this.movedom.ontouchmove = this.mousemove.bind(this)
-            this.movedom.ontouchend = this.mouseup.bind(this)
-        } else {
-            this.PX = e.clientX - this.movedom.offsetLeft
-            this.PY = e.clientY - this.movedom.offsetTop
-            this.movedom.onmousemove = this.mousemove.bind(this)
-            this.movedom.onmouseup = this.mouseup.bind(this)
-        }
+  mousedown(event) {
+    // 获取点击DOM
+    const e = event || window.event
+    if (this.DviceType) {
+      this.PX = e.touches[0].clientX - this.movedom.offsetLeft
+      this.PY = e.touches[0].clientY - this.movedom.offsetTop
+      this.movedom.ontouchmove = this.mousemove.bind(this)
+      this.movedom.ontouchend = this.mouseup.bind(this)
+    } else {
+      this.PX = e.clientX - this.movedom.offsetLeft
+      this.PY = e.clientY - this.movedom.offsetTop
+      this.movedom.onmousemove = this.mousemove.bind(this)
+      this.movedom.onmouseup = this.mouseup.bind(this)
     }
+  }
 
-    /**
+  /**
        * 鼠标松开
        */
-    mouseup () {
-        this.off()
-    }
+  mouseup() {
+    this.off()
+  }
 
-    /**
+  /**
        * 监听鼠标
        * @param dom dom元素
        */
-    on (dom) {
-        this.movedom = dom
-        try {
-            if (this.DviceType) {
-                this.movedom.ontouchstart = this.mousedown.bind(this)
-            } else {
-                this.movedom.onmousedown = this.mousedown.bind(this)
-            }
-            this.domw = parseInt(window.getComputedStyle(this.movedom).width)
-            this.domh = parseInt(window.getComputedStyle(this.movedom).height)
-        } catch (error) {
-            console.warn('dom 获取失败')
-        }
+  on(dom) {
+    this.movedom = dom
+    try {
+      if (this.DviceType) {
+        this.movedom.ontouchstart = this.mousedown.bind(this)
+      } else {
+        this.movedom.onmousedown = this.mousedown.bind(this)
+      }
+      this.domw = parseInt(window.getComputedStyle(this.movedom).width)
+      this.domh = parseInt(window.getComputedStyle(this.movedom).height)
+    } catch (error) {
+      console.warn('dom 获取失败')
     }
+  }
 
-    /**
+  /**
        * 移除监听
        */
-    off () {
-        this.movedom.onmousemove = null
-        this.movedom.onmouseup = null
-        this.movedom.ontouchmove = null
-        this.movedom.ontouchend = null
-    }
+  off() {
+    this.movedom.onmousemove = null
+    this.movedom.onmouseup = null
+    this.movedom.ontouchmove = null
+    this.movedom.ontouchend = null
+  }
 }

+ 4 - 10
src/utils/axios.js

@@ -1,21 +1,15 @@
 import axios from 'axios'
 // http request 拦截
 axios.interceptors.request.use(
-  config => {
+  (config) => {
     config.baseURL = process.env.SERVERURL
     return config
   },
-  err => {
-    return Promise.reject(err)
-  }
+  (err) => Promise.reject(err)
 )
 // http response 拦截
 axios.interceptors.response.use(
-  response => {
-    return response.data
-  },
-  error => {
-    return Promise.reject(error)
-  }
+  (response) => response.data,
+  (error) => Promise.reject(error)
 )
 export default axios

+ 18 - 16
src/utils/openseadragon-svg-overlay.js

@@ -1,12 +1,12 @@
 // OpenSeadragon SVG Overlay plugin 0.0.4
 
-export let svgOverlay = function (OpenSeadragon) {
+export const svgOverlay = function (OpenSeadragon) {
   if (!OpenSeadragon) {
     console.error('[openseadragon-svg-overlay] requires OpenSeadragon')
     return
   }
 
-  var svgNS = 'http://www.w3.org/2000/svg'
+  const svgNS = 'http://www.w3.org/2000/svg'
 
   // ----------
   OpenSeadragon.Viewer.prototype.svgOverlay = function () {
@@ -20,7 +20,7 @@ export let svgOverlay = function (OpenSeadragon) {
 
   // ----------
   var Overlay = function (viewer) {
-    var self = this
+    const self = this
 
     this._viewer = viewer
     this._containerWidth = 0
@@ -37,19 +37,19 @@ export let svgOverlay = function (OpenSeadragon) {
     this._node = document.createElementNS(svgNS, 'g')
     this._svg.appendChild(this._node)
 
-    this._viewer.addHandler('animation', function () {
+    this._viewer.addHandler('animation', () => {
       self.resize()
     })
 
-    this._viewer.addHandler('open', function () {
+    this._viewer.addHandler('open', () => {
       self.resize()
     })
 
-    this._viewer.addHandler('rotate', function (evt) {
+    this._viewer.addHandler('rotate', (evt) => {
       self.resize()
     })
 
-    this._viewer.addHandler('resize', function () {
+    this._viewer.addHandler('resize', () => {
       self.resize()
     })
 
@@ -59,12 +59,12 @@ export let svgOverlay = function (OpenSeadragon) {
   // ----------
   Overlay.prototype = {
     // ----------
-    node: function () {
+    node() {
       return this._node
     },
 
     // ----------
-    resize: function () {
+    resize() {
       if (this._containerWidth !== this._viewer.container.clientWidth) {
         this._containerWidth = this._viewer.container.clientWidth
         this._svg.setAttribute('width', this._containerWidth)
@@ -75,17 +75,19 @@ export let svgOverlay = function (OpenSeadragon) {
         this._svg.setAttribute('height', this._containerHeight)
       }
 
-      var p = this._viewer.viewport.pixelFromPoint(new OpenSeadragon.Point(0, 0), true)
-      var zoom = this._viewer.viewport.getZoom(true)
-      var rotation = this._viewer.viewport.getRotation()
+      const p = this._viewer.viewport.pixelFromPoint(new OpenSeadragon.Point(0, 0), true)
+      const zoom = this._viewer.viewport.getZoom(true)
+      const rotation = this._viewer.viewport.getRotation()
       // TODO: Expose an accessor for _containerInnerSize in the OSD API so we don't have to use the private variable.
-      var scale = this._viewer.viewport._containerInnerSize.x * zoom
-      this._node.setAttribute('transform',
-        'translate(' + p.x + ',' + p.y + ') scale(' + scale + ') rotate(' + rotation + ')')
+      const scale = this._viewer.viewport._containerInnerSize.x * zoom
+      this._node.setAttribute(
+        'transform',
+        `translate(${p.x},${p.y}) scale(${scale}) rotate(${rotation})`
+      )
     },
 
     // ----------
-    onClick: function (node, handler) {
+    onClick(node, handler) {
       // TODO: Fast click for mobile browsers
 
       new OpenSeadragon.MouseTracker({

+ 4 - 3
src/utils/rem.js

@@ -14,18 +14,19 @@
     // 1rem =100px
     let width = docEl.clientWidth
     if (isAndroid || isIOS) {
-      docEl.style.fontSize = parseInt((100 * (width / 750)) * 2) + 'px'
+      // eslint-disable-next-line radix
+      docEl.style.fontSize = `${parseInt((100 * (width / 750)) * 2)}px`
     } else {
       if (width < 1920) {
         width = 1920
         docEl.style.minWidth = '1440px'
         docEl.style.minHeight = '800px'
       }
-      docEl.style.fontSize = (100 * (width / 1920)) + 'px'
+      docEl.style.fontSize = `${100 * (width / 1920)}px`
     }
   }
   recalc()
   if (!doc.addEventListener) { return }
   win.addEventListener(resizeEvt, recalc, false)
   console.log('已自适应')
-})(document, window)
+}(document, window))

+ 14 - 12
src/utils/userdata.js

@@ -3,24 +3,26 @@ import MD5 from 'js-md5'
  * 用户加密操作
  */
 class Userservice {
-  constructor () {
+  constructor() {
     this.setTime()
   }
+
   /**
      * 加密
      * @param {string} txt 密码
      */
-  encryPassword (txt) {
+  encryPassword(txt) {
     const md5 = MD5(txt)
-    const password = MD5(md5 + 'Homey')
+    const password = MD5(`${md5}Homey`)
     return password
   }
+
   /**
      * 存储
      * @param {string} phone 手机号
      * @param {string} password 密码
      */
-  saveUserData (phone, password) {
+  saveUserData(phone, password) {
     const psd = this.encryPassword(password)
     const lastLogin = Date.now()
     const uses = {
@@ -32,17 +34,19 @@ class Userservice {
     localStorage.setItem('userDATA', USERS)
     return uses
   }
+
   /**
      * 获取
      */
-  getUserData () {
+  getUserData() {
     const uses = localStorage.getItem('userDATA')
     return uses
   }
+
   /**
      * 时间限制24小时
      */
-  async setTime () {
+  async setTime() {
     const nowtime = Date.now()
     const UserData = this.getUserData()
     const lasttime = await JSON.parse(UserData)
@@ -51,14 +55,12 @@ class Userservice {
         console.log('需要重新登录', lasttime)
         localStorage.clear()
         return false
-      } else {
-        console.log('不需要重新登录', lasttime)
-        return true
       }
-    } else {
-      localStorage.clear()
-      return false
+      console.log('不需要重新登录', lasttime)
+      return true
     }
+    localStorage.clear()
+    return false
   }
 }
 export default new Userservice()

+ 6 - 4
src/utils/weather.js

@@ -1,7 +1,7 @@
-import store from '../store/index'
 import axios from 'axios'
+import store from '../store/index'
 class WeatherService {
-  constructor () {
+  constructor() {
     this.axios = axios
     this.store = store
     this.WeatherInfo = ''
@@ -41,15 +41,16 @@ class WeatherService {
 
     this.getCurrentCity()
   }
+
   /**
    * 获取当前城市天气预报
    * 天气图标请使用SVG+PATH
    *
    */
-  async getCurrentCity () {
+  async getCurrentCity() {
     const city = await this.axios.get('https://restapi.amap.com/v3/ip?key=76f9007ba8c4c44bb9ad757fe27acb44')
     if (city.info === 'OK') {
-      const wht = await this.axios.get('https://restapi.amap.com/v3/weather/weatherInfo?key=76f9007ba8c4c44bb9ad757fe27acb44&city=' + city.adcode + '&extensions=all')
+      const wht = await this.axios.get(`https://restapi.amap.com/v3/weather/weatherInfo?key=76f9007ba8c4c44bb9ad757fe27acb44&city=${city.adcode}&extensions=all`)
       if (wht.info === 'OK') {
         for (let j = 0; j < wht.forecasts[0].casts.length; j++) {
           const el = wht.forecasts[0].casts[j]
@@ -60,6 +61,7 @@ class WeatherService {
             }
           }
         }
+        // eslint-disable-next-line prefer-destructuring
         this.WeatherInfo = wht.forecasts[0]
       }
     }

+ 10 - 11
vite.config.js

@@ -1,6 +1,7 @@
 import { defineConfig } from 'vite'
 import { createVuePlugin } from 'vite-plugin-vue2'
 import viteCompression from 'vite-plugin-compression'
+import eslint from 'vite-plugin-eslint'
 import path from 'path'
 import glob from 'glob'
 import fs from 'fs'
@@ -39,15 +40,13 @@ export default ({ mode }) => defineConfig({
       '@': path.resolve(__dirname, './src')
     }
   },
-  plugins: [createVuePlugin(), viteCompression({ //gzip压缩
-    disable: true,
-  })],
+  plugins: [ createVuePlugin(), viteCompression({ disable: true }), eslint({ fix: true }) ],
   server: {
     host: 'localhost',
     port: 6547,
     open: true,
     strictPort: false,
-    https: false,
+    https: false
     // 反向代理
     // proxy: {
     //   '/': {
@@ -60,22 +59,22 @@ export default ({ mode }) => defineConfig({
   build: {
     rollupOptions: {
       input: entryConfig(),
-      output: { //静态资源分类打包
+      output: { // 静态资源分类打包
         chunkFileNames: 'js/[name]-[hash].js',
         entryFileNames: 'js/[name]-[hash].js',
         assetFileNames: 'assets/[name]-[hash].[ext]'
       }
     },
-    terserOptions: { //去掉打印
+    terserOptions: { // 去掉打印
       compress: {
         drop_console: true,
-        drop_debugger: true,
-      },
-    },
+        drop_debugger: true
+      }
+    }
   },
-  define: { //环境变量配置
+  define: { // 环境变量配置
     'process.env': {
-      'SERVERURL': mode === 'development' ? 'http://127.0.0.1:5000':'http://127.0.0.1:5000'
+      SERVERURL: mode === 'development' ? 'http://127.0.0.1:5000' : 'http://127.0.0.1:5000'
     }
   }
 })

File diff suppressed because it is too large
+ 285 - 439
yarn.lock


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