Browse Source

Signed-off-by: caner <5658514@qq.com>

caner 3 years ago
parent
commit
72697d299c

+ 0 - 11
.vscode/settings.json

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

+ 10 - 11
package.json

@@ -11,25 +11,24 @@
   "dependencies": {
     "@wangeditor/editor": "^5.1.18",
     "@wangeditor/editor-for-vue": "^5.1.12",    
-    "axios": "^0.27.2",
+    "axios": "^1.1.3",
     "js-md5": "^0.7.3",
-    "naive-ui": "^2.32.1",
+    "naive-ui": "^2.33.5",
     "pinia": "^2.0.18",
     "vue": "^3.2.37",
-    "vue-router": "^4.1.3",
-    "xlsx": "^0.18.5"
+    "vue-router": "^4.1.3"
   },
   "devDependencies": {
-    "@typescript-eslint/parser": "^5.33.0",
-    "@vitejs/plugin-vue": "^3.0.2",
-    "eslint": "^8.21.0",
+    "@typescript-eslint/parser": "^5.40.0",
+    "@vitejs/plugin-vue": "^3.1.2",
+    "eslint": "^8.25.0",
     "eslint-config-airbnb-base": "^15.0.0",
     "eslint-plugin-import": "^2.26.0",
-    "eslint-plugin-vue": "^9.3.0",
+    "eslint-plugin-vue": "^9.6.0",
     "less": "^4.1.3",
-    "typescript": "^4.6.4",
-    "vite": "^3.0.6",
+    "typescript": "^4.8.4",
+    "vite": "^3.1.8",
     "vite-plugin-eslint": "^1.8.0",
-    "vue-tsc": "^0.39.5"
+    "vue-tsc": "^1.0.8"
   }
 }

+ 70 - 0
src/assets/naiveTheme.json

@@ -0,0 +1,70 @@
+{
+  "common": {
+    "primaryColor": "#2791FEFF",
+    "primaryColorHover": "#67B2FEFF",
+    "primaryColorPressed": "#1F74CBFF",
+    "primaryColorSuppl": "#93C8FEFF",
+    "errorColorHover": "#EC787BFF",
+    "errorColor": "#E8575AFF",
+    "errorColorPressed": "#B94548FF",
+    "errorColorSuppl": "#EE898BFF",
+    "warningColor": "#FAAD38FF",
+    "warningColorPressed": "#C88A2CFF",
+    "textColorBase": "#17233EFF",
+    "textColor1": "rgba(80, 90, 110, 1)",
+    "textColor2": "rgba(128, 134, 148, 1)",
+    "textColor3": "rgba(196, 200, 206, 1)",
+    "placeholderColor": "rgba(196, 200, 206, 1)",
+    "iconColor": "rgba(196, 200, 206, 1)",
+    "iconColorHover": "rgba(103, 178, 254, 1)",
+    "iconColorPressed": "rgba(31, 116, 203, 1)",
+    "iconColorDisabled": "rgba(196, 200, 206, 1)",
+    "dividerColor": "rgba(220, 222, 226, 1)",
+    "borderColor": "rgba(196, 200, 206, 1)",
+    "closeIconColor": "rgba(80, 90, 110, 1)",
+    "closeIconColorHover": "rgba(103, 178, 254, 1)",
+    "closeIconColorPressed": "rgba(31, 116, 203, 1)",
+    "closeColorHover": "rgba(0, 0, 0, 0.1)",
+    "closeColorPressed": "rgba(0, 0, 0, 0.15)",
+    "scrollbarColor": "rgba(126, 133, 160, 1)",
+    "scrollbarColorHover": "rgba(103, 178, 254, 1)",
+    "tagColor": "#F5F5F5FF",
+    "inputColorDisabled": "rgba(233, 234, 236, 1)",
+    "fontSize": "0.14rem",
+    "fontSizeMini": "0.12rem",
+    "fontSizeTiny": "0.12rem",
+    "fontSizeSmall": "0.14rem",
+    "fontSizeMedium": "0.14rem",
+    "fontSizeLarge": "0.15rem",
+    "fontSizeHuge": "0.16rem"
+  },
+  "Icon": {
+    "color": "white"
+  },
+  "Menu": {
+    "itemColorActive": "rgba(39, 145, 254, 0.3)",
+    "itemTextColor": "white",
+    "itemTextColorActive": "white",
+    "itemTextColorActiveHoverHorizontal": "white",
+    "arrowColor": "white",
+    "itemHeight":"0.35rem",
+    "arrowColorChildActive":"none",
+    "itemIconColorHover": "white",
+    "itemTextColorHover": "none",
+    "itemColorHover": "none",
+    "itemTextColorChildActive": "#FFFFFFFF",
+    "itemTextColorHorizontal": "#FFFFFFFF",
+    "itemIconColorActive": "#FFFFFFFF",
+    "itemIconColorChildActive": "#FFFFFFFF",
+    "itemColorHoverInverted":"none",
+    "itemTextColorActiveHover":"none",
+    "itemIconColorActiveHorizontal":"none",
+    "itemTextColorChildActiveHover":"none",
+    "itemColorActiveHover":"rgba(39, 145, 254, 0.3)",
+    "itemIconColor":"white",
+    "itemIconColorActiveHover":"white"
+  },
+  "Tree": {
+    "nodeTextColor": "#505A6EFF"
+  }
+}

+ 23 - 0
src/assets/naiveui.less

@@ -0,0 +1,23 @@
+// 数字输入框样式修改
+  :deep(.n-input-number) {
+    .n-input-wrapper {
+      padding-right: 0;
+      .n-input__suffix {
+        display: flex;
+        flex-direction: column-reverse;
+        border-left: 1px solid #DCDEE2;
+        button {
+          width: 0.21rem;
+          &:first-of-type{
+             border-top: 1px solid #DCDEE2;
+          }
+        }
+        .iconfont {
+          font-size: 0.12rem;
+        }
+        .bold{
+            font-weight: bold;
+        }
+      }
+    }
+  }

+ 0 - 1
src/assets/vue.svg

@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

+ 0 - 37
src/pages/admin/App.vue

@@ -1,37 +0,0 @@
-<template>
-  <loading v-if="show" />
-  <router-view />
-</template>
-<script setup lang='ts'>
-import loading from '@/components/loading.vue'
-import useStore from './store/index'
-import { computed } from 'vue'
-const store = useStore()
-const show = computed(() => store.loading)
-</script>
-<style lang="less">
-html,
-body {
-  margin: 0;
-  padding: 0;
-}
-#app {
-  background: #335391;
-  min-width: 1440px;
-  min-height: 800px;
-  user-select: none;
-  width: 19.2rem;
-  height: 10.8rem;
-  overflow: hidden;
-  font-family: "iconfont";
-  font-style: normal;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-}
-
-/* 隐藏滚动条 */
-::-webkit-scrollbar {
-  width: 0 !important;
-  display: none;
-}
-</style>

+ 0 - 3
src/pages/admin/assets/js/interfacePublic.ts

@@ -1,3 +0,0 @@
-export interface test{
-    a:string
-}

+ 0 - 9
src/pages/admin/assets/js/nativeUiPluginPublic.ts

@@ -1,9 +0,0 @@
-import {
-  create, NButton
-} from 'naive-ui'
-
-const naive = create({
-  components: [ NButton ]
-})
-
-export default naive

+ 0 - 22
src/pages/admin/main.ts

@@ -1,22 +0,0 @@
-import { createApp } from 'vue'
-import App from './App.vue'
-import { createPinia } from 'pinia'
-import naive from './assets/js/nativeUiPluginPublic'
-import { createRouter, createWebHashHistory } from 'vue-router'
-import '@/utils/rem'
-// 动态路由
-const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true })).map((m) => (m as any).default || m)
-console.log(routes)
-
-const store = createPinia()
-const app = createApp(App)
-const router = createRouter({
-  history: createWebHashHistory(),
-  routes
-})
-// 路由守卫
-
-app.use(store)
-  .use(naive)
-  .use(router)
-  .mount('#app')

+ 0 - 12
src/pages/admin/store/index.ts

@@ -1,12 +0,0 @@
-import { defineStore } from 'pinia'
-// id必填,且需要唯一
-import { ref } from 'vue'
-const useStore = defineStore('admin', () => {
-  const loading = ref(false)
-
-  const setLoading = (data: boolean) => {
-    loading.value = data
-  }
-  return { loading, setLoading }
-})
-export default useStore

+ 0 - 7
src/pages/admin/views/home/index.vue

@@ -1,7 +0,0 @@
-<template>
-  <div>
-    <n-button type="primary">
-      Primary
-    </n-button>
-  </div>
-</template>

+ 0 - 10
src/pages/admin/views/home/route.ts

@@ -1,10 +0,0 @@
-import { RouteRecordRaw } from 'vue-router'
-
-export default {
-  path: '/',
-  meta: {
-    authorize: true
-  },
-  component: () => import('./index.vue' as any),
-  children: []
-} as RouteRecordRaw

+ 0 - 3
src/pages/admin/views/test/index.vue

@@ -1,3 +0,0 @@
-<template>
-  <div>345</div>
-</template>

+ 0 - 11
src/pages/admin/views/test/route.ts

@@ -1,11 +0,0 @@
-import { RouteRecordRaw } from 'vue-router'
-
-export default {
-  path: '/test',
-  meta: {
-    authorize: true
-  },
-  component: () => import('./index.vue' as any),
-  children: [
-  ]
-} as RouteRecordRaw

+ 20 - 3
src/pages/index/App.vue

@@ -1,14 +1,31 @@
 <template>
   <loading v-if="show" />
-  <router-view />
+  <n-config-provider
+    preflight-style-disabled
+    inline-theme-disabled
+    :theme-overrides="themeOverrides"
+    :locale="zhCN"
+    :date-locale="dateZhCN"
+  >
+    <n-dialog-provider>
+      <n-message-provider>
+        <n-notification-provider>
+          <router-view />
+        </n-notification-provider>
+      </n-message-provider>
+    </n-dialog-provider>
+  </n-config-provider>
 </template>
 <script setup lang='ts'>
 import loading from '@/components/loading.vue'
 import useStore from './store/index'
-import { computed, ref } from 'vue'
+import { computed } from 'vue'
+import { zhCN, dateZhCN } from 'naive-ui'
+import Theme from '../../assets/naiveTheme.json'
+
 const store = useStore()
 const show = computed(() => store.loading)
-const a = ref(0)
+const themeOverrides = Theme
 </script>
 <style>
 html,

+ 0 - 3
src/pages/index/assets/js/interfacePublic.ts

@@ -1,3 +0,0 @@
-export interface test{
-    a:string
-}

+ 7 - 2
src/pages/index/assets/js/nativeUiPluginPublic.ts

@@ -1,9 +1,14 @@
 import {
-  create, NButton
+  create,
+  NConfigProvider,
+  NNotificationProvider,
 } from 'naive-ui'
 
 const naive = create({
-  components: [ NButton ]
+  components: [
+    NConfigProvider,
+    NNotificationProvider,
+  ]
 })
 
 export default naive

+ 3 - 2
src/pages/index/main.ts

@@ -2,13 +2,14 @@ import { createApp } from 'vue'
 import App from './App.vue'
 import { createPinia } from 'pinia'
 import naive from './assets/js/nativeUiPluginPublic'
-import { createRouter, createWebHistory } from 'vue-router'
+import { createRouter, createWebHashHistory } from 'vue-router'
+import '@/utils/rem'
 // 动态路由
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true })).map((m) => (m as any).default || m)
 const store = createPinia()
 const app = createApp(App)
 const router = createRouter({
-  history: createWebHistory(),
+  history: createWebHashHistory(),
   routes
 })
 // 路由守卫

+ 0 - 115
src/utils/JsFn.js

@@ -1,115 +0,0 @@
-/**
- *  关键字去重
- * @param arr 数组
- * @param key 关键字
- * @returns 去重后
- */
-function unique(arr, key) {
-  const res = []
-  const obj = {}
-  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 {Number} ms
- * @returns
- */
-function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms) }) }
-
-/**
- * 多维数组转一维
- * @param {Array} arr
- * @returns
- */
-function flatten(arr) {
-  return [].concat(
-    ...arr.map((x) => (Array.isArray(x) ? this.flatten(x) : x))
-  )
-}
-
-/**
- * 随机数
- * @param {minNum} minNum 最小值
- * @param {maxNum} maxNum 最大值
- * @return {Number} 返回一个最大值和最小值之间的随机数
- */
-function randomNum(minNum, maxNum) {
-  switch (arguments.length) {
-    case 1:
-      return parseInt(Math.random() * minNum + 1, 10)
-    case 2:
-      return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)
-    default:
-      return 0
-  }
-}
-
-/**
- * 多字段匹配
- * @param {ArryObject} data 数组|数组对象
- * @param {string} key
- * @returns
- */
-function search(data, key) {
-  const list = data.filter((el) => {
-    let bt = ''
-    bt += el.name
-    bt += el.eg
-    return bt.match(key)
-  })
-  return list
-}
-
-/**
- * admin时间格式化
- * @param {date} date 
- * @returns
- */
-function adminFormatTime(date) {
-  const h = date.getHours()
-  const m = date.getMinutes()
-  const mon = date.getMonth() + 1
-  const day = date.getDate()
-  const wk = date.getDay()
-  let txt = ''
-  switch (wk) {
-    case 1:
-      txt = '一'
-      break
-    case 2:
-      txt = '二'
-      break
-    case 3:
-      txt = '三'
-      break
-    case 4:
-      txt = '四'
-      break
-    case 5:
-      txt = '五'
-      break
-    case 6:
-      txt = '六'
-      break
-    case 7:
-      txt = '天'
-      break
-    default:
-      break
-  }
-  const obj = {
-    time: `${h < 10 ? `0${h}` : h}:${m < 10 ? `0${m}` : m}`,
-    day: `${mon < 10 ? `0${mon}` : mon}月${day < 10 ? `0${day}` : day}日 星期${txt}`
-  }
-  return obj
-}
-
-
-export { unique, sleep, flatten, randomNum, search, adminFormatTime }

+ 92 - 0
src/utils/JsFn.ts

@@ -0,0 +1,92 @@
+/**
+ *  关键字去重
+ * @param arr 数组
+ * @param key 关键字
+ * @returns 去重后
+ */
+export const 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 毫秒
+ * @returns
+ */
+export const sleep = (ms: number) => { return new Promise((resolve) => { setTimeout(resolve, ms) }) }
+
+/**
+ * 多维数组转一维
+ * @param arr
+ * @returns
+ */
+export const flatten:any = (arr: Array<any>) => {
+  return [].concat(
+    ...arr.map((x) => (Array.isArray(x) ? flatten(x) : x))
+  )
+}
+
+/**
+ * 多字段匹配
+ * @param  data 数组|数组对象
+ * @param  key
+ * @returns
+ */
+export const 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 date Date
+ * @param fmt 日期格式
+ * @returns 
+ */
+export const 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;
+}
+
+/**
+* 格式化掌子面里程
+* @param num 里程
+* @returns 
+*/
+export const mileage2string = (num: number) => {
+  const a = Math.floor(num / 1000).toString()
+  const ab = (num % 1000).toString()
+  const b = Math.floor(num % 1000).toString()
+  const c = b.length === 1 ? `00${ab}` : b.length === 2 ? `0${ab}` : ab
+  return `${a}+${c}`
+}

+ 0 - 57
src/utils/exportExcel.js

@@ -1,57 +0,0 @@
-import * as XLSX from 'xlsx'
-function openDownloadDialog(url, saveName) {
-    if (typeof url == 'object' && url instanceof Blob) {
-        url = URL.createObjectURL(url); // 创建blob地址
-    }
-    let aLink = document.createElement('a');
-    aLink.href = url;
-    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);
-}
-
-// 将一个sheet转成最终的excel文件的blob对象,然后利用URL.createObjectURL下载
-function sheet2blob(sheet, sheetName) {
-    sheetName = sheetName || 'sheet1';
-    let workbook = {
-        SheetNames: [sheetName],
-        Sheets: {}
-    };
-    workbook.Sheets[sheetName] = sheet;
-    // 生成excel的配置项
-    let wopts = {
-        bookType: 'xlsx', // 要生成的文件类型
-        bookSST: false, // 是否生成Shared String Table,官方解释是,如果开启生成速度会下降,但在低版本IOS设备上有更好的兼容性
-        type: 'binary'
-    };
-    let wbout = XLSX.write(workbook, wopts);
-    let blob = new Blob([s2ab(wbout)], {type: "application/octet-stream"});
-    // 字符串转ArrayBuffer
-    function s2ab(s) {
-        let buf = new ArrayBuffer(s.length);
-        let view = new Uint8Array(buf);
-        for (let i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
-        return buf;
-    }
-    return blob;
-}
- /**
-  * @description: 导出excel
-  * @param {*} arr 数据是数组包含的对象
-  * @param {*} name 名字
-  * @return {*}
-  */
- function exp(arr,name="导出") {
-    var sheet = XLSX.utils.json_to_sheet(arr);
-    // excel宽高设置
-    sheet["!cols"]= arr.map(item=>{
-        return {wch:30}
-    })
-    openDownloadDialog(sheet2blob(sheet), name+'.xlsx')
-}
-export default exp;

+ 0 - 46
src/utils/resizeChart.js

@@ -1,46 +0,0 @@
-class ResizeChart {
-  /**
-     * 监听resize
-     */
-  on(chart) {
-    if (chart) {
-      window.addEventListener('resize', () => {
-        if (Array.isArray(chart) && chart.length) {
-          for (let k = 0; k < chart.length; k++) {
-            const el = chart[k]
-            el.resize()
-          }
-        } else {
-          chart.resize()
-        }
-      })
-    }
-  }
-
-  /**
-   * 关闭
-   */
-  off(chart) {
-    if (chart) {
-      window.removeEventListener('resize', () => {
-        if (Array.isArray(chart) && chart.length) {
-          for (let k = 0; k < chart.length; k++) {
-            const el = chart[k]
-            el.resize()
-          }
-        } else {
-          chart.resize()
-        }
-      })
-      if (Array.isArray(chart) && chart.length) {
-        for (let k = 0; k < chart.length; k++) {
-          const el = chart[k]
-          el.dispose()
-        }
-      } else {
-        chart.dispose()
-      }
-    }
-  }
-}
-export default new ResizeChart()