Browse Source

取消多入口

caner 2 years ago
parent
commit
22b99e9858

+ 4 - 2
.eslintrc.json

@@ -22,7 +22,7 @@
     "jsx-quotes": 0, // 强制使用单引号
     "jsx-quotes": 0, // 强制使用单引号
     "max-len": 0, // 强制一行的最大长度
     "max-len": 0, // 强制一行的最大长度
     "semi": [ 2, "never" ], // 禁止使用分号
     "semi": [ 2, "never" ], // 禁止使用分号
-    "no-unused-vars": 0,
+    "no-unused-vars": 1,
     "no-unneeded-ternary": 2, // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
     "no-unneeded-ternary": 2, // 禁止不必要的嵌套 var isYes = answer === 1 ? true : false;
     "no-unreachable": 2, // 不能有无法执行的代码
     "no-unreachable": 2, // 不能有无法执行的代码
     "no-unused-expressions": 1, // 禁止无用的表达式
     "no-unused-expressions": 1, // 禁止无用的表达式
@@ -59,6 +59,8 @@
     "no-return-await": 0,
     "no-return-await": 0,
     "max-classes-per-file": 0,
     "max-classes-per-file": 0,
     "consistent-return" : 0,
     "consistent-return" : 0,
-    "no-shadow": 0
+    "no-shadow": 0,
+    "no-undef":0,
+    "no-throw-literal":0
   }
   }
 }
 }

+ 1 - 1
index.html

@@ -7,6 +7,6 @@
   </head>
   </head>
   <body>
   <body>
     <div id="app"></div>
     <div id="app"></div>
-    <script type="module" src="/src/pages/index/main.ts"></script>
+    <script type="module" src="/src/pages/main.ts"></script>
   </body>
   </body>
 </html>
 </html>

+ 0 - 16
login.html

@@ -1,16 +0,0 @@
-<!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>登录</title>
-</head>
-
-<body>
-  <div id="app"></div>
-  <script type="module" src="/src/pages/login/main.ts"></script>
-</body>
-
-</html>

+ 1 - 1
src/pages/index/App.vue → src/pages/App.vue

@@ -17,7 +17,7 @@ import loading from '@/components/loading.vue'
 import useStore from './store/index'
 import useStore from './store/index'
 import { computed } from 'vue'
 import { computed } from 'vue'
 import { zhCN, dateZhCN } from 'naive-ui'
 import { zhCN, dateZhCN } from 'naive-ui'
-import Theme from '../../assets/naiveTheme.json'
+import Theme from '@/assets/naiveTheme.json'
 
 
 const store = useStore()
 const store = useStore()
 const show = computed(() => store.loading)
 const show = computed(() => store.loading)

+ 0 - 0
src/pages/index/assets/plugin/nativeUiPluginPublic.ts → src/pages/assets/plugin/nativeUiPluginPublic.ts


+ 0 - 12
src/pages/login/App.vue

@@ -1,12 +0,0 @@
-<template>
-  <test />
-</template>
-<script setup lang='ts'>
-import test from './views/index.vue'
-</script>
-<style>
-html,body{
-  margin: 0;
-  padding: 0;
-}
-</style>

+ 0 - 5
src/pages/login/main.ts

@@ -1,5 +0,0 @@
-import { createApp } from 'vue'
-import App from './App.vue'
-import '@/utils/rem'
-const app = createApp(App)
-app.mount('#app')

+ 0 - 5
src/pages/login/views/index.vue

@@ -1,5 +0,0 @@
-<template>
-  <div>
-    321
-  </div>
-</template>

+ 0 - 4
src/pages/index/main.ts → src/pages/main.ts

@@ -3,10 +3,7 @@ import App from './App.vue'
 import { createPinia } from 'pinia'
 import { createPinia } from 'pinia'
 import naive from './assets/plugin/nativeUiPluginPublic'
 import naive from './assets/plugin/nativeUiPluginPublic'
 import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
 import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
-import '@/services/rem'
-import DirectiveService from '@/services/vue.directive.service'
 
 
-const directive = new DirectiveService()
 // 动态路由
 // 动态路由
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
 routes.push({ path: '/:path(.*)', redirect: '/' })
 routes.push({ path: '/:path(.*)', redirect: '/' })
@@ -24,7 +21,6 @@ const router = createRouter({
 app.use(store)
 app.use(store)
   .use(naive)
   .use(naive)
   .use(router)
   .use(router)
-  .directive('longPress', directive.longpress)
 
 
 router.isReady().then(() => {
 router.isReady().then(() => {
   const vm = app.mount('#app')
   const vm = app.mount('#app')

+ 0 - 0
src/pages/index/store/index.ts → src/pages/store/index.ts


+ 0 - 3
src/pages/index/views/home/index.vue → src/pages/views/home/index.vue

@@ -17,8 +17,5 @@ function sendAudio() {
     >
     >
       我不是全局组件
       我不是全局组件
     </n-button>
     </n-button>
-    <button v-longPress="sendAudio">
-      test
-    </button>
   </div>
   </div>
 </template>
 </template>

+ 0 - 0
src/pages/index/views/home/route.ts → src/pages/views/home/route.ts


+ 0 - 0
src/pages/index/views/test/index.vue → src/pages/views/test/index.vue


+ 0 - 0
src/pages/index/views/test/route.ts → src/pages/views/test/route.ts


+ 0 - 208
src/services/export.service.ts

@@ -1,208 +0,0 @@
-import { injectable, Service } from './service'
-import * as XLSX from 'xlsx'
-import html2canvas from 'html2canvas'
-import JSPDF from 'jspdf'
-
-/** 文件导出方法 */
-@injectable
-export default class EexportService extends Service {
-
-    /**
-     * 自动下载
-     * @param url 保存地址|blob
-     * @param saveName 文件名
-     */
-    download(url: string | Blob | object, saveName: string) {
-        if (typeof url === 'object' && url instanceof Blob) {
-            url = URL.createObjectURL(url) // 创建blob地址
-        }
-        const aLink = document.createElement('a')
-        aLink.href = url as any
-        aLink.download = saveName || '' // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
-        let event
-        if (window.MouseEvent) event = new MouseEvent('click')
-        else {
-            event = document.createEvent('MouseEvents')
-            event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
-        }
-        aLink.dispatchEvent(event)
-    }
-
-    /**
-     * 解析excel表格
-     * @param file 文件
-     * @returns
-     */
-    exp2json = async (file: File) => new Promise((resolve, reject) => {
-        try {
-            const reader = new FileReader()
-            reader.onload = (e) => {
-                const wb = XLSX.read(e.target?.result, {
-                    type: 'binary'
-                }) // 读取完成的数据
-                // 转成json header解析第一行标题
-                const data = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]], { header: 1 })
-                resolve(data)
-            }
-            reader.readAsBinaryString(file)
-        } catch (error) {
-            console.log('解析错误')
-            reject(error)
-        }
-    })
-
-    /**
-     * 导出excel表格
-     * @param arr 数据是数组包含的对象
-     * @param fileName 名字
-     */
-    exp2excel = (arr: object[], fileName: string, cellMerges?: Array<any>) => {
-        const sheet = XLSX.utils.json_to_sheet(arr)
-        // excel宽高设置
-        sheet['!cols'] = arr.map(() => ({ wch: 30 }))
-        if (cellMerges) {
-            sheet['!merges'] = cellMerges // <====合并单元格
-        }
-        // 转blob
-        const sheet2blob = (sheets: any, sheetName = 'sheet1') => {
-            const workbook = {
-                SheetNames: [sheetName],
-                Sheets: {} as any
-            }
-            workbook.Sheets[sheetName] = sheets
-            // 生成excel的配置项
-            const wopts = {
-                bookType: 'xlsx', // 要生成的文件类型
-                bookSST: false, // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
-                type: 'binary'
-            } as any
-            const wbout = XLSX.write(workbook, wopts)
-            // 字符串转ArrayBuffer
-            const s2ab = (s: string) => {
-                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
-            }
-            const blob = new Blob([s2ab(wbout)], { type: 'application/octet-stream' })
-
-            return blob
-        }
-        this.download(sheet2blob(sheet), `${fileName}.xlsx`)
-    }
-
-    /**
-     * dom导出excel
-     * @param domID domID
-     * @param fileName 文件名
-     */
-    dom2excel = (domID: string, fileName: string) => {
-        const dom = document.getElementsByTagName(domID)
-        if (!dom) return
-        const wb = XLSX.utils.table_to_book(dom[0])
-        const baty = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary' })
-        // 字符串转ArrayBuffer
-        const s2ab = (s: any) => {
-            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
-        }
-        const blob = new Blob([s2ab(baty)], { type: 'application/octet-stream' })
-        this.download(blob, `${fileName}.xlsx`)
-    }
-
-    /**
-     * 导出PDF
-     * @param domID 需要输出PDF的页面id
-     * @param fileName 文件名
-     * @param type  默认A4分页
-     * @param wMultiple 宽倍数
-     * @param hMultiple 高倍数
-     * @returns
-     */
-    exp2pdf = async (domID: string, fileName: string, type = 'A4', wMultiple = null, hMultiple = null) => {
-        const dom = document.getElementById(domID)
-        if (!dom) return
-        const domHeight = dom.offsetHeight // 获取DOM高度
-        const domWidth = dom.offsetWidth // 获取DOM宽度
-        const canvas = await html2canvas(dom, {
-            logging: false,
-            useCORS: true, // 允许图片跨域
-            scale: 1.5,
-            width: wMultiple ? wMultiple * domWidth : undefined,
-            height: hMultiple ? hMultiple * domHeight : undefined
-        })
-
-        if (type === 'A4') {
-            // A4分页
-            const pdf = new JSPDF('p', 'mm', 'a4') // A4纸,纵向
-            const ctx = canvas.getContext('2d') as any
-            const a4w = 200
-            const a4h = 277 // A4大小,210mm x 297mm,四边各保留20mm的边距
-            const imgHeight = Math.floor(a4h * canvas.width / a4w) // 按A4显示比例换算一页图像的像素高度
-            let renderedHeight = 0
-            while (renderedHeight < canvas.height) {
-                const page = document.createElement('canvas')
-                page.width = canvas.width
-                page.height = Math.min(imgHeight, canvas.height - renderedHeight) // 可能内容不足一页
-                // 用getImageData剪裁指定区域,并画到前面创建的canvas对象中
-                page.getContext('2d')?.putImageData(ctx.getImageData(0, renderedHeight, canvas.width, Math.min(imgHeight, canvas.height - renderedHeight)), 0, 0)
-                pdf.addImage(page.toDataURL('image/jpeg', 1.0), 'JPEG', 10, 10, a4w, Math.min(a4h, a4w * page.height / page.width)) // 添加图像到页面,保留10mm边距
-                renderedHeight += imgHeight
-                if (renderedHeight < canvas.height) { pdf.addPage() } // 如果后面还有内容,添加一个空页
-                // delete page;
-            }
-            pdf.save(fileName)
-        } else {
-            // 整张
-            const pdf = new JSPDF('p', 'px', [domWidth, domHeight])
-            pdf.addImage(canvas.toDataURL('image/jpeg', 1.0), 'JPEG', 10, 10, domWidth, domHeight)
-            pdf.save(fileName)
-        }
-    }
-
-    /**
-     * 导出PNG
-     * @param domID 需要输出PDF的页面id
-     * @param fileName 文件名
-     * @param bkcolor 背景色
-     */
-    exp2png = async (domID: string, fileName: string, bkcolor: string) => {
-        window.scroll(0, 0) // 首先先顶部
-        const design = document.getElementById(domID) as HTMLElement
-        if (!design) return
-        const imgHeight = design.offsetHeight // 获取DOM高度
-        const imgWidth = design.offsetWidth // 获取DOM宽度
-        const scale = window.devicePixelRatio <= 3 ? 3 : window.devicePixelRatio // 获取设备像素比
-        const canvas = await html2canvas(design, {
-            backgroundColor: bkcolor, // 设置背景颜色
-            useCORS: true, // 允许图片跨域
-            scale, // 缩放3倍,使得图片更加清晰=>越清晰图片越大
-            width: imgWidth,
-            height: imgHeight,
-            imageTimeout: 5000 // 设置图片的超时,设置0为禁用
-        })
-
-        // 两种下载方式url + blob
-        let imgURL = canvas.toDataURL('image/png') as any
-        if (typeof imgURL === 'object' && imgURL instanceof Blob) {
-            imgURL = URL.createObjectURL(imgURL) // 创建blob地址
-            this.download(imgURL, fileName)
-        } else {
-            // url  +  请求得到blob
-            const htmlrq = new XMLHttpRequest() as any
-            htmlrq.open('GET', imgURL, true)
-            htmlrq.responseType = 'blob'
-            htmlrq.onload = (e: { target: { status: number; response: Blob | MediaSource; } }) => {
-                if (e.target.status === 200) {
-                    imgURL = URL.createObjectURL(e.target.response) // 创建blob地址
-                    this.download(imgURL, fileName)
-                } else {
-                    console.error('下载错误')
-                }
-            }
-            htmlrq.send()
-        }
-    }
-}

+ 0 - 245
src/services/fn.service.ts

@@ -1,245 +0,0 @@
-import { injectable, Service } from './service'
-
-/** 常用方法 */
-@injectable
-export default class FnService extends Service {
-
-    /**
-      * 格式化日期
-      * @param date Date
-      * @param fmt 日期格式
-      * @returns 
-      */
-    fomartTime(date: Date, fmt = 'yyyy-MM-dd hh:mm:ss') {
-        if (!date) return ''
-        const o = {
-            'M+': date.getMonth() + 1,                 //月份 
-            'd+': date.getDate(),                    //日 
-            'h+': date.getHours(),                   //小时 
-            'm+': date.getMinutes(),                 //分 
-            's+': date.getSeconds(),                 //秒 
-            'q+': Math.floor((date.getMonth() + 3) / 3), //季度 
-            'S': date.getMilliseconds()             //毫秒 
-        } as any
-        if (/(y+)/.test(fmt)) {
-            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
-        }
-        for (let k in o) {
-            if (new RegExp('(' + k + ')').test(fmt)) {
-                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
-            }
-        }
-        return fmt
-    }
-
-    /**
-      * 距当前时间点的时长
-      * @prama time 13位时间戳
-      * @return str x秒 / x分钟 / x小时
-      */
-    timeDuration(datetime: string) {
-        if (datetime == null) return ''
-
-        datetime = datetime.replace(/-/g, '/')
-
-        const time = new Date()
-        let outTime = new Date(datetime)
-        if (/^[1-9]\d*$/.test(datetime)) {
-            outTime = new Date(parseInt(datetime) * 1000)
-        }
-
-        if (
-            time.getTime() < outTime.getTime() ||
-            time.getFullYear() !== outTime.getFullYear()
-        ) {
-            return this.fomartTime(outTime, 'yyyy-MM-dd hh:mm')
-        }
-
-        if (time.getMonth() !== outTime.getMonth()) {
-            return this.fomartTime(outTime, 'MM-dd hh:mm')
-        }
-
-        if (time.getDate() !== outTime.getDate()) {
-            const day = outTime.getDate() - time.getDate()
-            if (day === -1) {
-                return this.fomartTime(outTime, '昨天 hh:mm')
-            }
-
-            if (day === -2) {
-                return this.fomartTime(outTime, '前天 hh:mm')
-            }
-
-            return this.fomartTime(outTime, 'MM-dd hh:mm')
-        }
-
-        const diff = time.getTime() - outTime.getTime()
-
-        if (time.getHours() !== outTime.getHours() || diff > 30 * 60 * 1000) {
-            return this.fomartTime(outTime, 'hh:mm')
-        }
-
-        let minutes = outTime.getMinutes() - time.getMinutes()
-        if (minutes === 0) {
-            return '刚刚'
-        }
-
-        minutes = Math.abs(minutes)
-        return `${minutes}分钟前`
-    }
-
-    /**
-     * 简单防抖
-     * @param fn 
-     * @param interval 
-     * @returns 
-     */
-    debounce(fn: (...arg: any[]) => any, duration = 300) {
-        let timer = -1
-        return function (this: unknown, ...args: any[]) {
-            if (timer > -1) {
-                clearTimeout(timer)
-            }
-            timer = window.setTimeout(() => {
-                fn.bind(this)(...args)
-                timer = -1
-            }, duration)
-        }
-    }
-
-    /**
-     * 简单节流
-     * @param fn 
-     * @param interval 
-     * @returns 
-     */
-    throttle(fn: (...arg: any[]) => any, interval = 300) {
-        let lock = false
-        return function (this: unknown, ...args: any[]) {
-            if (lock) return
-            lock = true
-            setTimeout(() => lock = false, interval)
-            fn.bind(this)(...args)
-        }
-    }
-
-    /**
-     * base64 转file
-     * @param dataurl base64
-     * @param filename 
-     * @returns 
-     */
-    base64ImgtoFile(base64: string, filename = 'file') {
-        const arr = base64.split(',') as any
-        const mime = arr[0].match(/:(.*?);/)[1]
-        const suffix = mime.split('/')[1]
-        const bstr = atob(arr[1])
-        let n = bstr.length
-        const u8arr = new Uint8Array(n)
-        while (n--) {
-            u8arr[n] = bstr.charCodeAt(n)
-        }
-        return new File([u8arr], `${filename}.${suffix}`, {
-            type: mime
-        })
-    }
-
-    /**
-     *  关键字去重
-     * @param arr 数组
-     * @param key 关键字
-     * @returns 去重后
-     */
-    unique(arr: Array<any>, key: string) {
-        const res = []
-        const obj = {} as any
-        for (let i = 0; i < arr.length; i++) {
-            if (!obj[arr[i][key]]) {
-                res.push(arr[i])
-                obj[arr[i][key]] = true
-            }
-        }
-        return res
-    }
-
-    /**
-     * 同步睡眠
-     * @param ms 毫秒
-     */
-    sleep = (ms: number) => new Promise((resolve) => { setTimeout(resolve, ms) })
-
-    /**
-     * 多维数组转一维
-     * @param arr
-     * @returns
-     */
-    flatten: any = (arr: Array<any>) => [].concat(...arr.map((x) => (Array.isArray(x) ? this.flatten(x) : x)))
-
-    /**
-     * 多字段匹配
-     * @param  data 数组|数组对象
-     * @param  key
-     * @returns
-     */
-    search(data: Array<any>, key: string) {
-        const list = data.filter((el) => {
-            let bt = ''
-            bt += el.name
-            bt += el.eg
-            return bt.match(key)
-        })
-        return list
-    }
-
-    /**
-    * 格式化掌子面里程
-    * @param num 里程
-    * @returns
-    */
-    mileage2string(num: number) {
-        const a = Math.floor(num / 1000).toString()
-        const ab = parseFloat((num % 1000).toFixed(1))
-        const b = Math.floor(num % 1000).toString()
-        const c = b.length === 1 ? `00${ab}` : b.length === 2 ? `0${ab}` : ab
-        return `${a}+${c}`
-    }
-
-    /**
-     * 对象数组去重
-     * @param arr 传入数组
-     * @param key 需要对比的键
-     * @returns 去重后的数组
-     */
-    uniqueArr<T = any>(arr: T[], key: keyof T) {
-        const newArr = [] as T[]
-        const valueList = [] as any[]
-
-        for (const item of arr) {
-            if (valueList.indexOf(item[key]) === -1) {
-                valueList.push(item[key])
-                newArr.push(item)
-            }
-        }
-        return newArr
-    }
-
-    /**
-     * 数组按指定key值分组
-     * @param {*} array
-     * @param {*} id
-     * @returns
-     */
-    groupBy(array: Array<any>, id: string) {
-        const groups = {} as any
-        array.forEach((o) => {
-            let group = JSON.stringify(o[id])
-            if (typeof o[id] === 'string') {
-                group = o[id]
-            }
-            groups[group] = groups[group] || []
-            groups[group].push(o)
-        })
-        // return Object.values(groups);
-        return groups
-    }
-    
-}

+ 29 - 66
src/services/net.service.ts

@@ -1,13 +1,9 @@
 import { injectable, Service } from './service'
 import { injectable, Service } from './service'
-import StoreService from './store.service'
-const storeService = new StoreService()
-const urls = '/api' // import.meta.env.VITE_PROXY_URL
+
 /** api接口返回值类型 */
 /** api接口返回值类型 */
 declare type NetResult = {
 declare type NetResult = {
   success: boolean,
   success: boolean,
-  data: any,
-  msg: string,
-  code: number
+  data: Any
 }
 }
 
 
 /**
 /**
@@ -15,22 +11,15 @@ declare type NetResult = {
  */
  */
 @injectable
 @injectable
 export default class NetService extends Service {
 export default class NetService extends Service {
-  /**
-   * post方法请求接口
-   * @param url 接口地址
-   * @param params 接口参数
-   */
-  post(url: string, params: Any = {}, timeout = 6000): Promise<NetResult> {
-    return this.fetch('/api' + url, { method: 'POST', body: JSON.stringify(params) }, timeout)
-  }
+  protected url = import.meta.env.VITE_PROXY_URL
 
 
   /**
   /**
-   * upload上传文件接口
+   * post方法请求接口
    * @param url 接口地址
    * @param url 接口地址
    * @param params 接口参数
    * @param params 接口参数
    */
    */
-  upload(url: string, params: Any, timeout = 0): Promise<NetResult> {
-    return this.fetch('/api' + url, { method: 'POST', body: params }, timeout)
+  post(url: string, params: Any = {}, timeout = 6000): Promise<any> {
+    return this.fetch(url, { method: 'POST', body: JSON.stringify(params) }, timeout)
   }
   }
 
 
   /**
   /**
@@ -38,7 +27,7 @@ export default class NetService extends Service {
    * @param url 接口地址
    * @param url 接口地址
    */
    */
   get(url: string, timeout = 6000): Promise<NetResult> {
   get(url: string, timeout = 6000): Promise<NetResult> {
-    return this.fetch('/api' + url, { method: 'get' }, timeout)
+    return this.fetch(url, { method: 'GET' }, timeout)
   }
   }
 
 
   /**
   /**
@@ -46,7 +35,7 @@ export default class NetService extends Service {
    * @param url 接口地址
    * @param url 接口地址
    */
    */
   del(url: string, timeout = 6000): Promise<NetResult> {
   del(url: string, timeout = 6000): Promise<NetResult> {
-    return this.fetch('/api' + url, { method: 'DELETE' }, timeout)
+    return this.fetch(url, { method: 'DELETE' }, timeout)
   }
   }
 
 
   /**
   /**
@@ -55,16 +44,22 @@ export default class NetService extends Service {
    * @param params 接口参数
    * @param params 接口参数
    */
    */
   put(url: string, params: Any = {}, timeout = 6000): Promise<NetResult> {
   put(url: string, params: Any = {}, timeout = 6000): Promise<NetResult> {
-    return this.fetch('/api' + url, { method: 'put', body: JSON.stringify(params) }, timeout)
+    return this.fetch(url, { method: 'PUT', body: JSON.stringify(params) }, timeout)
   }
   }
 
 
+  /** token 续期 */
+  async refresh(token: string) {
+    this.post('', { token }).then((res) => {
+      console.log('刷新token', res)
+    })
+  }
 
 
   /**
   /**
    * fetch
    * fetch
-   * @param url 
-   * @param opt 
+   * @param url
+   * @param opt
    * @param timeout 0 默认不超时
    * @param timeout 0 默认不超时
-   * @returns 
+   * @returns
    */
    */
   private fetch(url: string, opt: RequestInit, timeout = 0): Promise<NetResult> {
   private fetch(url: string, opt: RequestInit, timeout = 0): Promise<NetResult> {
     return new Promise((resolve) => {
     return new Promise((resolve) => {
@@ -75,53 +70,21 @@ export default class NetService extends Service {
           controller.abort()
           controller.abort()
         }, timeout)
         }, timeout)
       }
       }
-      fetch(url, {
+      fetch(this.url + url, {
         signal,
         signal,
         ...opt,
         ...opt,
-        headers: opt.headers || {
-          'Content-Type': 'application/json',
-          Authorization: this.tokenService.token
-        }
-      }).then(res => {
-        if (res.status !== 200) {
-          throw res.status
-        }
+        headers: opt.headers || { 'Content-Type': 'application/json' }
+      }).then((res) => {
+        if (res.status === 500) return { success: false, data: '请求错误' }
         return res.json()
         return res.json()
-      }).then(res => {
-        if (res?.code !== 200) {
-          throw res?.msg || '接口调用失败'
-        }
-        resolve({
-          success: res?.success || false,
-          data: res?.data || null,
-          msg: res?.msg || null,
-          code: res?.code || 200
-        })
-      }).catch((err: Any) => {
-        resolve({
-          success: false,
-          data: null,
-          msg: `网络请求超时`,
-          code: -1
-        })
-        if (err.code === 20) {
-          throw '网络请求超时'
-        }
-        let error = err?.message || err
-        if (typeof err === 'number') {
-          if (err === 401 || err === 404) {
-            if (window.electron) { window.electron.send('mainLoginOut') }
-            throw err
-          }
-          error = NET_ERRORS[err] || `系统错误 [${err}]`
+      }).then((res) => {
+        const obj = { data: res.data, success: res.data instanceof Object }
+        if (!obj.success && obj.data.includes('need authrize')) {
+          throw 401
         }
         }
-        resolve({
-          success: false,
-          data: null,
-          msg: `接口 [${url.split('?')[0]}] 错误: ${error}`,
-          code: -1
-        })
-        throw error
+        resolve(obj)
+      }).catch((er) => {
+        throw er
       })
       })
     })
     })
   }
   }

+ 0 - 32
src/services/rem.ts

@@ -1,32 +0,0 @@
-// 18fontsize = (18/100)rem
-(function (doc, win) {
-  const docEl = doc.documentElement
-  const head = docEl.getElementsByTagName('head')[0]
-  const resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
-  const metaEl = doc.createElement('meta')
-  metaEl.name = 'viewport'
-  metaEl.content = 'initial-scale=1,maximum-scale=1, minimum-scale=1'
-  head.appendChild(metaEl)
-  const recalc = function () {
-    // 增加判断PC/and/ios
-    const isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
-    const isAndroid = navigator.userAgent.includes('Android') || navigator.userAgent.includes('Linux') // g
-    // 1rem =100px
-    let width = docEl.clientWidth
-    if (isAndroid || isIOS) {
-      docEl.style.fontSize = `${Math.floor((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`
-    }
-  }
-  recalc()
-  if (!doc.addEventListener) { return }
-  win.addEventListener(resizeEvt, recalc, false)
-  console.log('rem自适应')
-}(document, window))
-export {}

+ 0 - 85
src/services/store.service.ts

@@ -1,85 +0,0 @@
-import { injectable, Service } from './service'
-
-/**
- * 存储服务,只允许存有的字段
- */
-@injectable
-export default class StoreService extends Service {
-  private _tokenInfo!: {
-    type: string,
-    access_token: string
-  }
-
-  private _userInfo!: {
-    avatar?: string,
-    created_at?: string,
-    email?: string,
-    gender?: number,
-    id: number,
-    is_qiye?: boolean,
-    is_robot?: number,
-    mobile?: string,
-    nickname?: string,
-    password?: string,
-    updated_at?: string,
-    username?: string
-  }
-
-  constructor() {
-    super()
-    this._tokenInfo = { type: 'Bearer', access_token: '' }
-    this._getAll()
-  }
-
-  public get tokenInfo() {
-    return this._tokenInfo
-  }
-
-  public get userInfo() {
-    return this._userInfo
-  }
-
-  /** 保存 */
-  save(key: string, data: object | string) {
-    try {
-      // 只允许服务存在属性才能保存
-      const k = `_${key}`
-      if (Object.prototype.hasOwnProperty.call(this, k)) {
-        const db = JSON.stringify(data)
-        sessionStorage.setItem(key, db)
-        const that = this as any
-        that[k] = data
-      } else {
-        this.throw('存储错误')
-      }
-    } catch (error) {
-      this.throw('存储错误')
-    }
-  }
-
-  private _getAll() {
-    const all = sessionStorage
-    for (const key in all) {
-      if (typeof all[key] === 'string') {
-        const k = `_${key}`
-        const that = this as any
-        that[k] = JSON.parse(all[key])
-      }
-    }
-  }
-
-  clear() {
-    const all = sessionStorage
-    for (const key in all) {
-      if (typeof all[key] === 'string') {
-        const k = `_${key}`
-        const that = this as any
-        that[k] = undefined
-      }
-    }
-    sessionStorage.clear()
-    this._tokenInfo = { type: 'Bearer', access_token: '' }
-    const db = JSON.stringify(this._tokenInfo)
-    sessionStorage.setItem('_tokenInfo', db)
-  }
-}

+ 0 - 157
src/services/vue.directive.service.ts

@@ -1,157 +0,0 @@
-import { injectable, Service } from './service'
-
-/** vue 自定义指令 */
-@injectable
-export default class directiveService extends Service {
-  /** 长按 */
-  longpress = {
-
-    beforeMount(el: any, binding: any) {
-      const cb = binding.value
-      el.$durations = binding.arg || 3000 // 获取长按时长, 默认3秒执行长按事件
-      if (typeof cb !== 'function') return console.warn('v-longpress指令必须接收一个回调函数')
-      let timer: any = null
-      const add = (e: { type: string; button: number; preventDefault: () => void }) => {
-        // 排除点击与右键情况, event.button: 0-左键  2-右键
-        if (e.type === 'click' && e.button !== 0) return
-        e.preventDefault()
-        if (timer === null) {
-          timer = setTimeout(() => {
-            cb('start')
-            timer = null
-          }, el.$durations)
-        }
-      }
-      const cancel = () => {
-        if (timer !== null) {
-          clearTimeout(timer)
-          timer = null
-        }
-        cb('end')
-      }
-
-      // 添加计时器
-      el.addEventListener('mousedown', add)
-      el.addEventListener('touchstart', add)
-      // 取消计时器
-      el.addEventListener('mouseout', cancel)
-      el.addEventListener('touchend', cancel)
-      el.addEventListener('touchcancel', cancel)
-    },
-    updated(el: any, binding: any) {
-      // 可以实时更新时长
-      el.$durations = binding.arg
-    },
-    unmounted(el: any) {
-      el.removeEventListener('mousedown', () => { })
-      el.removeEventListener('touchstart', () => { })
-      el.removeEventListener('click', () => { })
-      el.removeEventListener('mouseout', () => { })
-      el.removeEventListener('touchend', () => { })
-      el.removeEventListener('touchcancel', () => { })
-    }
-
-  }
-
-  /** 拖拽 */
-  drag = {
-
-    mounted(el: HTMLElement | null) {
-      const oDiv = el // 当前元素
-      // el!.style.pointerEvents = null // 防止触发点击事件
-      oDiv!.onmousedown = (e) => {
-        // 找父级 是否是absolute来进行移动
-        let target = oDiv
-        while (window.getComputedStyle(target!).position !== 'absolute' && target !== document.body) {
-          target = target!.parentElement
-        }
-        // 找父级 是否是relative来进行宽度计算
-        let targetParent = target!.parentElement
-        while (window.getComputedStyle(targetParent!).position !== 'relative' && targetParent !== document.body) {
-          targetParent = targetParent!.parentElement
-        }
-
-        document.onselectstart = () => false
-
-        // 鼠标按下,计算当前元素距离可视区的距离
-        const disX = e.clientX - target!.offsetLeft
-        const disY = e.clientY - target!.offsetTop
-        const cW = +window.getComputedStyle(target!).width.replace('px', '')
-        const cH = +window.getComputedStyle(target!).height.replace('px', '')
-        const maxW = +window.getComputedStyle(targetParent!).width.replace('px', '')
-        const maxH = +window.getComputedStyle(targetParent!).height.replace('px', '')
-        document.onmousemove = (e) => {
-          // 通过事件委托,计算移动的距离
-          // 因为浏览器里并不能直接取到并且使用clientX、clientY,所以使用事件委托在内部做完赋值
-          // el!.style.pointerEvents = 'none'
-          const l = e.clientX - disX
-          const t = e.clientY - disY
-          const cl = maxW - cW
-          const ct = maxH - cH
-          // 计算移动当前元素的位置,并且给该元素样式中的left和top值赋值
-          target!.style.left = `${l < 0 ? 0 : l > cl ? cl : l}px`
-          target!.style.top = `${t < 0 ? 0 : t > ct ? ct : t}px`
-        }
-        document.onmouseup = (e) => {
-          // el!.style.pointerEvents = 'none'
-          document.onmousemove = null
-          document.onmouseup = null
-          document.onselectstart = null
-        }
-        // return false不加的话可能导致黏连,拖到一个地方时div粘在鼠标上不下来,相当于onmouseup失效
-        return false
-      }
-    }
-
-  }
-
-  /** 点击其它地方消失 */
-  clickoutside = {
-
-    beforeMount(el: { contains: (arg0: EventTarget | null) => any; }, binding: { value: () => any; }) {
-      document.addEventListener('click', (e) => {
-        el.contains(e.target) && binding.value()
-      }, false)
-    },
-    unmounted() {
-      document.removeEventListener('click', () => { })
-    }
-
-  }
-
-  /** 复制 */
-  copy = {
-
-    beforeMount(el: { targetContent: string; addEventListener: (arg0: string, arg1: () => void) => void; }, binding: { arg: any; value: any; }) {
-      el.targetContent = binding.value
-      const success = binding.arg
-      el.addEventListener('click', () => {
-        if (!el.targetContent) return console.warn('没有需要复制的目标内容')
-        // 创建textarea标签
-        const textarea = document.createElement('textarea')
-        // 设置相关属性
-        textarea.readOnly = true
-        textarea.style.position = 'fixed'
-        textarea.style.top = '-99999px'
-        // 把目标内容赋值给它的value属性
-        textarea.value = el.targetContent
-        // 插入到页面
-        document.body.appendChild(textarea)
-        // 调用onselect()方法
-        textarea.select()
-        // 把目标内容复制进剪贴板, 该API会返回一个Boolean
-        const res = document.execCommand('Copy')
-        res && success ? success(el.targetContent) : console.log(`复制成功,剪贴板内容:${el.targetContent}`)
-        // 移除textarea标签
-        document.body.removeChild(textarea)
-      })
-    },
-    updated(el: { targetContent: any; }, binding: { value: any; }) {
-      // 实时更新最新的目标内容
-      el.targetContent = binding.value
-    },
-    unmounted(el: { removeEventListener: (arg0: string, arg1: () => void) => void; }) {
-      el.removeEventListener('click', () => { })
-    }
-  }
-}

+ 5 - 4
src/vite-env.d.ts

@@ -1,11 +1,12 @@
 /// <reference types="vite/client" />
 /// <reference types="vite/client" />
 
 
+/** 代指任意类型 请不要随意使用 */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+declare type Any = any
+
 declare module '*.vue' {
 declare module '*.vue' {
   import type { DefineComponent } from 'vue'
   import type { DefineComponent } from 'vue'
-  const component: DefineComponent<{}, {}, any>
+  const component: DefineComponent<{}, {}, Any>
   export default component
   export default component
 }
 }
 
 
-declare module 'xlsx'
-declare module 'html2canvas'
-declare module 'jspdf'

+ 13 - 14
vite.config.ts

@@ -22,21 +22,21 @@ export default ({ mode }) => {
     plugins: [ vue(), viteCompression(), eslint({ fix: true, include: [ '**/*.ts', '**/*.vue' ] }) ],
     plugins: [ vue(), viteCompression(), eslint({ fix: true, include: [ '**/*.ts', '**/*.vue' ] }) ],
     server: {
     server: {
       host: '0.0.0.0',
       host: '0.0.0.0',
-      port: 5888,
+      port: 6888,
       open: true,
       open: true,
       strictPort: false,
       strictPort: false,
       https: false,
       https: false,
-      proxy: {
-        '/api': {
-          target: env.VITE_PROXY_URL,
-          changeOrigin: true,
-          rewrite: (path) => path.replace(/^\/api/, ''),
-          secure: false,
-          headers: {
-            Referer: 'https://example.com'
-          }
-        }
-      }
+      // proxy: {
+      //   '/api': {
+      //     target: env.VITE_PROXY_URL,
+      //     changeOrigin: true,
+      //     rewrite: (path) => path.replace(/^\/api/, ''),
+      //     secure: false,
+      //     headers: {
+      //       Referer: 'https://example.com'
+      //     }
+      //   }
+      // }
     },
     },
     esbuild: {
     esbuild: {
       drop: [ 'console', 'debugger' ] // build 移除打印
       drop: [ 'console', 'debugger' ] // build 移除打印
@@ -44,8 +44,7 @@ export default ({ mode }) => {
     build: {
     build: {
       rollupOptions: {
       rollupOptions: {
         input: {
         input: {
-          index: resolve(__dirname, 'index.html'),
-          login: resolve(__dirname, 'login.html')
+          index: resolve(__dirname, 'index.html')
         },
         },
         output: { // 静态资源分类打包
         output: { // 静态资源分类打包
           chunkFileNames: 'js/[hash].js',
           chunkFileNames: 'js/[hash].js',