Browse Source

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

Caner 2 years ago
parent
commit
c450ff9f2f

+ 1 - 0
.env

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

+ 2 - 2
.eslintignore

@@ -1,4 +1,4 @@
 # 排除eslint检查文件
 # 排除eslint检查文件
-utils
 /dist
 /dist
-/public
+/public
+/main.js

+ 0 - 50
.eslintrc.js

@@ -1,50 +0,0 @@
-module.exports = {
-  root: true,
-  env: {
-    browser: true,
-    es2021: true
-  },
-  parserOptions: {
-    ecmaVersion: 12,
-    sourceType: 'module'
-  },
-  extends: [
-    'plugin:vue/vue3-recommended',
-    'airbnb-base'
-  ],
-  rules: {
-    'no-console': 0, // 禁用打印
-    'comma-dangle': [ 2, 'never' ], // 禁止使用拖尾逗号
-    'no-extra-semi': 2, // 禁止不必要的分号
-    'array-bracket-spacing': [ 2, 'always' ], // 指定数组的元素之间要以空格隔开
-    'jsx-quotes': 0, // 强制使用单引号
-    '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,
-    'import/order': 0,
-    'vue/no-deprecated-slot-attribute': 0,
-    'vue/v-on-event-hyphenation': 0,
-    'vue/no-deprecated-filter': 0,
-    'vue/require-explicit-emits': 0,
-    'vue/no-v-html': 0,
-    'vue/order-in-components': 0,
-    'no-unused-vars': 1,
-    'vue/no-reserved-component-names': 0
-  }
-}

+ 64 - 0
.eslintrc.json

@@ -0,0 +1,64 @@
+{
+  "root": true,
+  "env": {
+    "node": true,
+    "browser": true,
+    "es2021": true
+  },
+  "parserOptions": {
+    "ecmaVersion": "latest",
+    "parser": "@typescript-eslint/parser",
+    "sourceType": "module"
+  },
+  "extends": [
+    "plugin:vue/vue3-recommended",
+    "airbnb-base"
+  ],
+  "rules": {
+    "no-console": 0, // 禁用打印
+    "comma-dangle": [ 2, "never" ], // 禁止使用拖尾逗号
+    "no-extra-semi": 2, // 禁止不必要的分号
+    "array-bracket-spacing": [ 2, "always" ], // 指定数组的元素之间要以空格隔开
+    "jsx-quotes": 0, // 强制使用单引号
+    "max-len": 0, // 强制一行的最大长度
+    "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" ],
+    "import/no-unresolved": 0,
+    "import/extensions": 0,
+    "import/no-absolute-path": 0,
+    "import/no-extraneous-dependencies": 2,
+    "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,
+    "import/order": 0,
+    "vue/no-deprecated-slot-attribute": 0,
+    "vue/v-on-event-hyphenation": 0,
+    "vue/no-deprecated-filter": 0,
+    "vue/require-explicit-emits": 0,
+    "vue/no-v-html": 0,
+    "vue/order-in-components": 0,
+    "vue/no-reserved-component-names": 0,
+    "no-promise-executor-return": 0,
+    "no-sparse-arrays": 0,
+    "no-nested-ternary": 0,
+    "no-continue": 0,
+    "complexity": [ 2, 9 ],
+    "no-return-await": 0,
+    "max-classes-per-file": 0,
+    "consistent-return" : 0,
+    "no-shadow": 0
+  }
+}

+ 21 - 26
.gitignore

@@ -1,33 +1,28 @@
-# ---> Node
 # Logs
 # Logs
 logs
 logs
 *.log
 *.log
 npm-debug.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
 node_modules
 dist
 dist
-out
-
-
+dist-ssr
+*.local
+
+# Editor directories and files
+.vscode/*
+!.vscode/extensions.json
+.idea
+.DS_Store
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?
+yarn.lock
+dist
+package-lock.json
+dist-ssr

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # 桌面应用模板
 # 桌面应用模板
 ```
 ```
-eslint自动修正,其它规则请手动添加到rules。
+改版本为vue3+ts+eslint 自动修正,其它规则请手动添加到rules。
 ```
 ```
 ## 注意
 ## 注意
 ```
 ```

+ 3 - 3
index.html

@@ -3,13 +3,13 @@
 
 
 <head>
 <head>
   <meta charset="UTF-8" />
   <meta charset="UTF-8" />
-  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-  <title>CZRock</title>
+  <title>Contrl</title>
+  <style>*{margin: 0;padding: 0;}</style>
 </head>
 </head>
 
 
 <body>
 <body>
   <div id="app"></div>
   <div id="app"></div>
-  <script type="module" src="./src/pages/index/main.js"></script>
+  <script type="module" src="./src/main.ts"></script>
   <script src="./loader.js"></script>
   <script src="./loader.js"></script>
 </body>
 </body>
 
 

+ 0 - 0
loading/index.html → loading.html


+ 1 - 35
main.js

@@ -6,32 +6,6 @@ let win; let
 Menu.setApplicationMenu(null) // 去掉菜单栏
 Menu.setApplicationMenu(null) // 去掉菜单栏
 app.commandLine.appendSwitch('wm-window-animations-disabled') // 拖动闪屏
 app.commandLine.appendSwitch('wm-window-animations-disabled') // 拖动闪屏
 
 
-
-// 截图
-function screenShot () {
-  return new Promise((res) => {
-    const file = execFile(join(__dirname, './screen/PrintScr.exe'))
-    file.on('exit', (e: Any) => {
-      if (e === 1) {
-        // 剪切板读buffer图片
-        const clip = clipboard.readImage()
-        if (clip.isEmpty()) {
-          // eslint-disable-next-line prefer-promise-reject-errors
-          res(null)
-        } else {
-          // 转成buffer base64
-          const png = clipboard.readImage().toPNG()
-          const img = 'data:image/png;base64,' + png.toString('base64')
-          res(img)
-        }
-      } else {
-        // eslint-disable-next-line prefer-promise-reject-errors
-        res(null)
-      }
-    })
-  })
-}
-
 // 消息通知
 // 消息通知
 function notifiction (title, options) {
 function notifiction (title, options) {
 	const WebNotification =  window.Notification || window.mozNotification || window.webkitNotification
 	const WebNotification =  window.Notification || window.mozNotification || window.webkitNotification
@@ -56,7 +30,7 @@ const showLoading = () => {
     alwaysOnTop: true,
     alwaysOnTop: true,
     transparent: true // 窗口是否支持透明,如果想做高级效果最好为true
     transparent: true // 窗口是否支持透明,如果想做高级效果最好为true
   })
   })
-  loadingWin.loadFile('loading/index.html')
+  loadingWin.loadFile('loading.html')
   loadingWin.on('close', () => {
   loadingWin.on('close', () => {
     loadingWin = null
     loadingWin = null
   })
   })
@@ -95,14 +69,6 @@ app.on('ready', async () => {
     loadingWin.close()
     loadingWin.close()
     win.show()
     win.show()
   })
   })
-  // 监听截图
-  ipcMain.once('screen', () => {
-    screenShot().then(res => {
-      if (!res) return
-      // 发送到子进程
-      win.webContents.send('screenData', res)
-    })
-  })
 })
 })
 
 
 app.on('window-all-closed', () => {
 app.on('window-all-closed', () => {

+ 29 - 31
package.json

@@ -1,45 +1,46 @@
 {
 {
-  "name": "cz-rock",
+  "name": "contrl-client",
   "version": "1.0.0",
   "version": "1.0.0",
   "main": "main.js",
   "main": "main.js",
   "author": "Caner",
   "author": "Caner",
-  "description": "a project",
+  "description": "控制端",
   "scripts": {
   "scripts": {
-    "dev": "vite --host",
-    "edev": "electron .",
-    "preedev": "vite build",
+    "dev": "vite",
+    "edev": "yarn build && electron .",
+    "build": "vue-tsc --noEmit && vite build",
     "make": "electron-forge make",
     "make": "electron-forge make",
-    "pmake": "electron-forge package",
-    "premake": "vite build",
-    "prepmake": "vite build"
+    "pmake": "electron-forge package"
+  },
+  "dependencies": {
+    "echarts": "^5.4.2",
+    "socket.io-client": "^4.6.1",
+    "vue": "^3.3.2",
+    "vue-router": "^4.2.0"
   },
   },
   "devDependencies": {
   "devDependencies": {
-    "@electron-forge/cli": "^6.0.0-beta.63",
-    "@electron-forge/maker-zip": "^6.0.0-beta.63",
-    "axios": "^0.24.0",
-    "echarts": "^5.3.2",
-    "electron": "^17.2.0",
-    "eslint": "^8.15.0",
+    "@electron-forge/cli": "^6.1.1",
+    "@electron-forge/maker-zip": "^6.1.1",
+    "@types/node": "^18.15.3",
+    "@typescript-eslint/parser": "^5.40.0",
+    "@vitejs/plugin-vue": "^4.2.3",
+    "eslint": "^8.40.0",
     "eslint-config-airbnb-base": "^15.0.0",
     "eslint-config-airbnb-base": "^15.0.0",
-    "eslint-plugin-import": "^2.26.0",
-    "eslint-plugin-vue": "^9.1.0",
-    "glob": "^7.2.0",
-    "less": "^4.1.2",
-    "view-design": "^4.7.0",
-    "vite": "^2.8.6",
-    "vite-plugin-compression": "^0.3.6",
-    "vite-plugin-eslint": "^1.6.1",
-    "vite-plugin-vue2": "^1.9.0",
-    "vue": "^2.6.14",
-    "vue-router": "^3.5.3",
-    "vue-template-compiler": "^2.6.14",
-    "vuex": "^3.6.2"
+    "eslint-plugin-import": "^2.27.5",
+    "eslint-plugin-vue": "^9.13.0",
+    "less": "^4.1.3",
+    "typescript": "^5.0.4",
+    "vite": "^4.3.6",
+    "vite-plugin-compression": "^0.5.1",
+    "vite-plugin-eslint": "^1.8.1",
+    "vue-tsc": "^1.6.5",
+    "vite-plugin-svg-icons": "^2.0.1",
+    "electron": "^23.1.2"
   },
   },
   "config": {
   "config": {
     "forge": {
     "forge": {
       "packagerConfig": {
       "packagerConfig": {
         "asar": true,
         "asar": true,
-        "ignore": "(out|vite.config.js|README.md|env.prod|env.dev|.gitignore|.eslintrc.js|src|public|node_modules|package-lock.json)"
+        "ignore": "(out|vite.config.ts|README.md|.env|.gitignore|.eslintrc.json|src|public|node_modules|package-lock.json)"
       },
       },
       "makers": [
       "makers": [
         {
         {
@@ -47,8 +48,5 @@
         }
         }
       ]
       ]
     }
     }
-  },
-  "dependencies": {
-    "vue-calendar-component": "^2.8.2"
   }
   }
 }
 }

BIN
public/screen/PrScrn.dll


BIN
public/screen/PrintScr.exe


+ 20 - 0
src/App.vue

@@ -0,0 +1,20 @@
+<template>
+  <loading v-if="showLoading" />
+  <router-view
+    v-else
+    v-resize
+  />
+</template>
+<script setup lang='ts'>
+import { ref, onMounted } from 'vue'
+import loading from '@/components/loading.vue'
+
+const showLoading = ref(false)
+onMounted(() => {
+  // 通知主进程是否完成渲染
+  const electron = window.$electron || null
+  if (electron) {
+    electron.ipcRenderer.send('close-loading')
+  }
+})
+</script>

+ 3 - 0
src/assets/icons/close.svg

@@ -0,0 +1,3 @@
+<svg width="12" height="12" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M6.71148 6.00003L9.89087 2.82065L9.17852 2.10829L5.99916 5.28765L2.81978 2.10828L2.10743 2.82063L5.28677 5.99998L2.10742 9.17933L2.81978 9.89169L5.99913 6.71234L9.17849 9.8917L9.89081 9.17938L6.71148 6.00003Z" />
+</svg>

BIN
src/assets/logo.png


+ 0 - 37
src/components/Modal.vue

@@ -1,37 +0,0 @@
-<template>
-  <div class="modal" v-if="show" @click="callBack">
-    <div class="content">
-      <template>
-        <slot name="content"></slot>
-      </template>
-    </div>
-  </div>
-</template>
-<script>
-export default {
-  props: ["show"],
-  methods: {
-    callBack() {
-      this.$emit("callBack", false);
-    },
-  },
-};
-</script>
-<style lang="less" scoped>
-.modal{
-  position: absolute;
-  width: 100%;
-  height: 100%;
-  top: 0;
-  left: 0;
-  z-index: 99;
-  background: rgba(0, 0, 0, 0.8);
-  cursor: pointer;
-  .content{
-    width: 80%;
-    height: 80%;
-    margin: 5% auto;
-    overflow: hidden;
-  }
-}
-</style>

+ 25 - 0
src/components/icon.vue

@@ -0,0 +1,25 @@
+<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"
+    />
+  </svg>
+</template>

+ 23 - 0
src/main.ts

@@ -0,0 +1,23 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+import { createRouter, RouteRecordRaw, createWebHistory } from 'vue-router'
+import Icon from '@/components/icon.vue'
+import 'virtual:svg-icons-register'
+import '@/services/rem'
+// 动态路由
+const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
+routes.push({ path: '/:path(.*)', redirect: '/' })
+
+const app = createApp(App)
+const router = createRouter({
+  history: createWebHistory(),
+  routes
+})
+app.component('Icon', Icon)
+// 路由守卫
+// router.beforeEach((to, from, next) => {
+//   // do something
+//   next()
+// })
+
+app.use(router).mount('#app')

+ 0 - 129
src/pages/index/App.vue

@@ -1,129 +0,0 @@
-<template>
-  <div id="app">
-    <div class="top">
-      <span>测试</span>
-    </div>
-    <div class="center">
-      <div class="left">
-        <Nav />
-      </div>
-      <div class="right">
-        <keep-alive>
-          <router-view />
-        </keep-alive>
-      </div>
-      <div
-        v-if="showLoading"
-        class="loading"
-      >
-        <Loading />
-      </div>
-    </div>
-  </div>
-</template>
-<script>
-import Nav from './components/Nav.vue'
-import Loading from '@/components/loading.vue'
-export default {
-  components: { Nav, Loading },
-  computed: {
-    showLoading() {
-      return this.$store.getters.GetLoading
-    }
-  },
-  mounted() {
-    // 通知主进程是否完成渲染
-    const electron = window.$electron || null
-    if (electron) {
-      electron.ipcRenderer.send('close-loading')
-    }
-  }
-}
-</script>
-<style lang="less" scoped>
-#app {
-  font-family: Avenir, Helvetica, Arial, sans-serif;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  text-align: center;
-  color: white;
-  width: 100%;
-  height: 100%;
-  min-width: 1620px;
-  min-height: 900px;
-  // max-width: 1920px;
-  // max-height: 1080px;
-  background: black;
-  margin: 0;
-  padding: 0;
-  .top {
-    width: 100%;
-    height: 60px;
-    margin-bottom: 10px;
-    background: #202532;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    font-size: 24px;
-    font-weight: bold;
-    position: relative;
-    svg {
-      width: 200px;
-      height: 50px;
-      position: absolute;
-      left: 0;
-    }
-  }
-  .center {
-    display: flex;
-    height: calc(100% - 70px);
-    width: 100%;
-    position: relative;
-    overflow: hidden;
-    & > div {
-      height: 100%;
-    }
-    .left {
-      margin-right: 10px;
-    }
-    .right {
-      flex: 1;
-      width: calc(100% - 220px);
-      position: relative;
-    }
-    .loading {
-      position: absolute;
-      width: 100%;
-      height: 100%;
-      top: 0;
-      left: 0;
-      z-index: 9999;
-      background: rgba(0, 0, 0, 0.5);
-      display: flex;
-      align-items: center;
-      justify-content: center;
-    }
-  }
-}
-</style>
-<style>
-html,
-body {
-  padding: 0;
-  margin: 0;
-  width: 100%;
-  height: 100%;
-  user-select: none;
-}
-/* 隐藏滚动条 */
-::-webkit-scrollbar {
-  width: 0 !important;
-  display: none;
-}
-/*在谷歌下移除input[number]的上下箭头*/
-input[type="number"]::-webkit-outer-spin-button,
-input[type="number"]::-webkit-inner-spin-button {
-  -webkit-appearance: none !important;
-  margin: 0;
-}
-</style>

BIN
src/pages/index/assets/logo.png


+ 0 - 97
src/pages/index/components/Nav.vue

@@ -1,97 +0,0 @@
-<template>
-  <div class="home-nva">
-    <Layout>
-      <Sider
-        v-model="isCollapsed"
-        collapsible
-        :collapsed-width="0"
-      >
-        <Menu
-          :active-name="changePath"
-          theme="dark"
-          width="auto"
-        >
-          <MenuItem
-            name="Lithology"
-            to="/"
-          >
-            <Icon type="md-analytics" />
-            <span>测试1</span>
-          </MenuItem>
-          <MenuItem
-            name="Grain"
-            to="Grain"
-          >
-            <Icon type="md-analytics" />
-            <span>测试2</span>
-          </MenuItem>
-          <MenuItem
-            name="Result"
-            to="Result"
-          >
-            <Icon type="md-analytics" />
-            <span>测试3</span>
-          </MenuItem>
-        </Menu>
-      </Sider>
-    </Layout>
-  </div>
-</template>
-<script>
-export default {
-  data() {
-    return {
-      isCollapsed: false,
-      changePath: 'Lithology'
-    }
-  },
-  mounted() {
-    this.changePath = this.$route.name
-  },
-  watch: {
-    $route(to, from) {
-      if (!from.name) this.changePath = to.name
-    }
-  }
-}
-</script>
-<style scoped lang="less">
-.home-nva {
-  height: 100%;
-  /deep/.ivu-layout {
-    height: 100%;
-  }
-  /deep/.ivu-menu-item{
-    font-size: 16px;
-  }
-  /deep/.ivu-layout-sider {
-    background: #202532;
-  }
-  /deep/.ivu-menu-dark {
-    background: #202532;
-  }
-  /deep/.ivu-layout-sider-trigger {
-    background: none;
-  }
-  /deep/.ivu-icon-ios-arrow-back:before {
-    content: "\f115";
-  }
-  /deep/.ivu-layout-sider-trigger {
-    position: absolute;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    top: 0;
-    right: 0;
-    bottom: 0;
-    margin: auto;
-    width: 20px !important;
-    height: 50px;
-    background: #4d5062;
-    clip-path: ellipse(100% 50% at 80% 50%);
-  }
-  /deep/.ivu-layout-sider-zero-width-trigger{
-    z-index: 100;
-  }
-}
-</style>

+ 0 - 12
src/pages/index/main.js

@@ -1,12 +0,0 @@
-import Vue from 'vue'
-import App from './App.vue'
-import router from './router/index'
-import ViewUI from 'view-design'
-import store from './store'
-import 'view-design/dist/styles/iview.css'
-Vue.use(ViewUI)
-new Vue({
-  router,
-  store,
-  render: (h) => h(App)
-}).$mount('#app')

+ 0 - 36
src/pages/index/router/index.js

@@ -1,36 +0,0 @@
-import Vue from 'vue'
-import VueRouter from 'vue-router'
-// 优化同一路由跳转报错
-const originalPush = VueRouter.prototype.push
-VueRouter.prototype.push = function push(location) {
-  return originalPush.call(this, location).catch((err) => err)
-}
-
-Vue.use(VueRouter)
-const routes = [
-  {
-    path: '/',
-    name: 'Lithology',
-    component: () => import('../views/Lithology.vue')
-  },
-  {
-    path: '/Grain',
-    name: 'Grain',
-    component: () => import('../views/Grain.vue')
-  },
-  {
-    path: '/Result',
-    name: 'Result',
-    component: () => import('../views/Result.vue')
-  },
-  {
-    path: '*',
-    redirect: '/Lithology'
-  }
-]
-
-const router = new VueRouter({
-  routes,
-  mode: 'hash'
-})
-export default router

+ 0 - 22
src/pages/index/store/index.js

@@ -1,22 +0,0 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-
-Vue.use(Vuex)
-
-export default new Vuex.Store({
-  state: {
-    showLoading: false
-  },
-  mutations: {
-    SetLoading(state, value) {
-      state.showLoading = value
-    }
-  },
-  getters: {
-    GetLoading(state) {
-      return state.showLoading
-    }
-  },
-  actions: {},
-  modules: {}
-})

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

@@ -1,5 +0,0 @@
-<template>
-  <div class="upfile">
-    test3
-  </div>
-</template>

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

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

+ 0 - 24
src/pages/index/views/Result.vue

@@ -1,24 +0,0 @@
-<template>
-  <div class="result">
-    <Calendar />
-  </div>
-</template>
-<script>
-import Calendar from 'vue-calendar-component'
-export default {
-  components: {
-    Calendar
-  },
-  data() {
-    return {
-      remarks: { '2021-1-13': 'some tings' }
-    }
-  }
-}
-</script>
-<style lang="less" scoped>
-.result{
-  width: 500px;
-  height: 500px;
-}
-</style>

+ 0 - 129
src/pages/test/App.vue

@@ -1,129 +0,0 @@
-<template>
-  <div id="app">
-    <div class="top">
-      <span>测试</span>
-    </div>
-    <div class="center">
-      <div class="left">
-        <Nav />
-      </div>
-      <div class="right">
-        <keep-alive>
-          <router-view />
-        </keep-alive>
-      </div>
-      <div
-        v-if="showLoading"
-        class="loading"
-      >
-        <Loading />
-      </div>
-    </div>
-  </div>
-</template>
-<script>
-import Nav from './components/Nav.vue'
-import Loading from '@/components/loading.vue'
-export default {
-  components: { Nav, Loading },
-  computed: {
-    showLoading() {
-      return this.$store.getters.GetLoading
-    }
-  },
-  mounted() {
-    // 通知主进程是否完成渲染
-    const electron = window.$electron || null
-    if (electron) {
-      electron.ipcRenderer.send('close-loading')
-    }
-  }
-}
-</script>
-<style lang="less" scoped>
-#app {
-  font-family: Avenir, Helvetica, Arial, sans-serif;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  text-align: center;
-  color: white;
-  width: 100%;
-  height: 100%;
-  min-width: 1620px;
-  min-height: 900px;
-  // max-width: 1920px;
-  // max-height: 1080px;
-  background: black;
-  margin: 0;
-  padding: 0;
-  .top {
-    width: 100%;
-    height: 60px;
-    margin-bottom: 10px;
-    background: #202532;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    font-size: 24px;
-    font-weight: bold;
-    position: relative;
-    svg {
-      width: 200px;
-      height: 50px;
-      position: absolute;
-      left: 0;
-    }
-  }
-  .center {
-    display: flex;
-    height: calc(100% - 70px);
-    width: 100%;
-    position: relative;
-    overflow: hidden;
-    & > div {
-      height: 100%;
-    }
-    .left {
-      margin-right: 10px;
-    }
-    .right {
-      flex: 1;
-      width: calc(100% - 220px);
-      position: relative;
-    }
-    .loading {
-      position: absolute;
-      width: 100%;
-      height: 100%;
-      top: 0;
-      left: 0;
-      z-index: 9999;
-      background: rgba(0, 0, 0, 0.5);
-      display: flex;
-      align-items: center;
-      justify-content: center;
-    }
-  }
-}
-</style>
-<style>
-html,
-body {
-  padding: 0;
-  margin: 0;
-  width: 100%;
-  height: 100%;
-  user-select: none;
-}
-/* 隐藏滚动条 */
-::-webkit-scrollbar {
-  width: 0 !important;
-  display: none;
-}
-/*在谷歌下移除input[number]的上下箭头*/
-input[type="number"]::-webkit-outer-spin-button,
-input[type="number"]::-webkit-inner-spin-button {
-  -webkit-appearance: none !important;
-  margin: 0;
-}
-</style>

BIN
src/pages/test/assets/logo.png


+ 0 - 97
src/pages/test/components/Nav.vue

@@ -1,97 +0,0 @@
-<template>
-  <div class="home-nva">
-    <Layout>
-      <Sider
-        v-model="isCollapsed"
-        collapsible
-        :collapsed-width="0"
-      >
-        <Menu
-          :active-name="changePath"
-          theme="dark"
-          width="auto"
-        >
-          <MenuItem
-            name="Lithology"
-            to="/"
-          >
-            <Icon type="md-analytics" />
-            <span>测试1</span>
-          </MenuItem>
-          <MenuItem
-            name="Grain"
-            to="Grain"
-          >
-            <Icon type="md-analytics" />
-            <span>测试2</span>
-          </MenuItem>
-          <MenuItem
-            name="Result"
-            to="Result"
-          >
-            <Icon type="md-analytics" />
-            <span>测试3</span>
-          </MenuItem>
-        </Menu>
-      </Sider>
-    </Layout>
-  </div>
-</template>
-<script>
-export default {
-  data() {
-    return {
-      isCollapsed: false,
-      changePath: 'Lithology'
-    }
-  },
-  mounted() {
-    this.changePath = this.$route.name
-  },
-  watch: {
-    $route(to, from) {
-      if (!from.name) this.changePath = to.name
-    }
-  }
-}
-</script>
-<style scoped lang="less">
-.home-nva {
-  height: 100%;
-  /deep/.ivu-layout {
-    height: 100%;
-  }
-  /deep/.ivu-menu-item{
-    font-size: 16px;
-  }
-  /deep/.ivu-layout-sider {
-    background: #202532;
-  }
-  /deep/.ivu-menu-dark {
-    background: #202532;
-  }
-  /deep/.ivu-layout-sider-trigger {
-    background: none;
-  }
-  /deep/.ivu-icon-ios-arrow-back:before {
-    content: "\f115";
-  }
-  /deep/.ivu-layout-sider-trigger {
-    position: absolute;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    top: 0;
-    right: 0;
-    bottom: 0;
-    margin: auto;
-    width: 20px !important;
-    height: 50px;
-    background: #4d5062;
-    clip-path: ellipse(100% 50% at 80% 50%);
-  }
-  /deep/.ivu-layout-sider-zero-width-trigger{
-    z-index: 100;
-  }
-}
-</style>

+ 0 - 12
src/pages/test/main.js

@@ -1,12 +0,0 @@
-import Vue from 'vue'
-import App from './App.vue'
-import router from './router/index'
-import ViewUI from 'view-design'
-import store from './store'
-import 'view-design/dist/styles/iview.css'
-Vue.use(ViewUI)
-new Vue({
-  router,
-  store,
-  render: (h) => h(App)
-}).$mount('#app')

+ 0 - 36
src/pages/test/router/index.js

@@ -1,36 +0,0 @@
-import Vue from 'vue'
-import VueRouter from 'vue-router'
-// 优化同一路由跳转报错
-const originalPush = VueRouter.prototype.push
-VueRouter.prototype.push = function push(location) {
-  return originalPush.call(this, location).catch((err) => err)
-}
-
-Vue.use(VueRouter)
-const routes = [
-  {
-    path: '/',
-    name: 'Lithology',
-    component: () => import('../views/Lithology.vue')
-  },
-  {
-    path: '/Grain',
-    name: 'Grain',
-    component: () => import('../views/Grain.vue')
-  },
-  {
-    path: '/Result',
-    name: 'Result',
-    component: () => import('../views/Result.vue')
-  },
-  {
-    path: '*',
-    redirect: '/Lithology'
-  }
-]
-
-const router = new VueRouter({
-  routes,
-  mode: 'hash'
-})
-export default router

+ 0 - 22
src/pages/test/store/index.js

@@ -1,22 +0,0 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-
-Vue.use(Vuex)
-
-export default new Vuex.Store({
-  state: {
-    showLoading: false
-  },
-  mutations: {
-    SetLoading(state, value) {
-      state.showLoading = value
-    }
-  },
-  getters: {
-    GetLoading(state) {
-      return state.showLoading
-    }
-  },
-  actions: {},
-  modules: {}
-})

+ 0 - 5
src/pages/test/views/Grain.vue

@@ -1,5 +0,0 @@
-<template>
-  <div class="upfile">
-    test3
-  </div>
-</template>

+ 0 - 5
src/pages/test/views/Lithology.vue

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

+ 0 - 5
src/pages/test/views/Result.vue

@@ -1,5 +0,0 @@
-<template>
-  <div class="result">
-    test1
-  </div>
-</template>

+ 19 - 0
src/services/rem.ts

@@ -0,0 +1,19 @@
+// 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 () {
+    // 1rem =100px
+    const width = docEl.clientWidth
+    docEl.style.fontSize = `${100 * (width / 1920)}px`
+  }
+  recalc()
+  if (!doc.addEventListener) { return }
+  win.addEventListener(resizeEvt, recalc, false)
+  console.log('rem自适应')
+}(document, window))

+ 0 - 21
src/utils/axios.js

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

+ 0 - 41
src/utils/resizeChart.js

@@ -1,41 +0,0 @@
-class ResizeChart {
-  /**
-     * 监听resize
-     */
-  on (chart) {
-    if (chart) {
-      window.addEventListener('resize', function () {
-        if (Array.isArray(chart) && chart.length) {
-          for (let k = 0; k < chart.length; k++) {
-            const el = chart[k]
-            el.resize()
-          }
-        } else {
-          if (chart instanceof Object) {
-            chart.resize()
-          } else {
-            return false
-          }
-        }
-      })
-    }
-  }
-  /**
-   * 关闭
-   */
-  off (chart) {
-    if (chart) {
-      window.removeEventListener('resize', function () {
-        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()

+ 10 - 0
src/views/index/index.vue

@@ -0,0 +1,10 @@
+<script setup lang="ts">
+</script>
+<template>
+  <div>
+    <icon
+      name="close"
+      :size="20"
+    />
+  </div>
+</template>

+ 9 - 0
src/views/index/route.ts

@@ -0,0 +1,9 @@
+import home from './index.vue'
+
+export default {
+  path: '/',
+  meta: {
+    authorize: true
+  },
+  component: home
+}

+ 11 - 0
src/vite-env.d.ts

@@ -0,0 +1,11 @@
+/// <reference types="vite/client" />
+
+declare module '*.vue' {
+  import type { DefineComponent } from 'vue'
+  const component: DefineComponent<{}, {}, any>
+  export default component
+}
+
+declare interface Window {
+  $electron: Any
+}

+ 38 - 0
tsconfig.json

@@ -0,0 +1,38 @@
+{
+  "compilerOptions": {
+    "target": "ESNext",
+    "useDefineForClassFields": true,
+    "experimentalDecorators": true,
+    "module": "ESNext",
+    "moduleResolution": "Node",
+    "strict": true,
+    "jsx": "preserve",
+    "sourceMap": true,
+    "resolveJsonModule": true,
+    "isolatedModules": true,
+    "esModuleInterop": true,
+    "lib": [
+      "ESNext",
+      "DOM"
+    ],
+    "skipLibCheck": true,
+    "baseUrl": "./",
+    "paths": {
+      "@/*": [
+        "src/*"
+      ]
+    },
+    "types": ["vite-plugin-svg-icons/client"]
+  },
+  "include": [
+    "src/**/*.ts",
+    "src/**/*.d.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue"
+  ],
+  "references": [
+    {
+      "path": "./tsconfig.node.json"
+    }
+  ]
+}

+ 9 - 0
tsconfig.node.json

@@ -0,0 +1,9 @@
+{
+  "compilerOptions": {
+    "composite": true,
+    "module": "ESNext",
+    "moduleResolution": "Node",
+    "allowSyntheticDefaultImports": true
+  },
+  "include": ["vite.config.ts"]
+}

+ 0 - 80
vite.config.js

@@ -1,80 +0,0 @@
-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'
-// 多页面入口配置
-const entryConfig = function () {
-  const viteconfig = {}
-  // 含有.js的文件
-  const entryFiles = glob.sync('./src/pages/*/*.js')
-  // 获取模板
-  const temp = fs.readFileSync('./index.html')
-  // 模板增加ts入口
-  entryFiles.forEach((entry) => {
-    const projectName = entry.split('/')[3]
-    try {
-      fs.accessSync(`./${projectName}.html`)
-    } catch (error) {
-      // 重构模板
-      const html = temp.toString().replace(/\.\/src\/[^\s]*/g, `${entry}"></script>`)
-      fs.writeFile(`./${projectName}.html`, html, (err) => {
-        if (err) console.error(err)
-      })
-    }
-    viteconfig[projectName] = path.resolve(__dirname, `./${projectName}.html`)
-  })
-  return viteconfig
-}
-
-export default ({ mode }) => defineConfig({
-  base: './',
-  resolve: {
-    alias: {
-      /*
-        路径别名
-        若为文件系统路径必须是绝对路径的形式,否则将以别名原样呈现,不会解析为文件系统路径路径
-      */
-      '@': path.resolve(__dirname, './src')
-    }
-  },
-  plugins: [createVuePlugin(), viteCompression({ disable: true }),eslint({ fix: true })],
-  server: {
-    host: 'localhost',
-    port: 6547,
-    open: true,
-    strictPort: false,
-    https: false,
-    // 反向代理
-    // proxy: {
-    //   '/': {
-    //     target: 'http://172.16.1.215:5000',
-    //     changeOrigin: true,
-    //     rewrite: (path) => path.replace(/^\//, '')
-    //   },
-    // }
-  },
-  build: {
-    rollupOptions: {
-      input: entryConfig(),
-      output: { //静态资源分类打包
-        chunkFileNames: 'js/[name]-[hash].js',
-        entryFileNames: 'js/[name]-[hash].js',
-        assetFileNames: 'assets/[name]-[hash].[ext]'
-      }
-    },
-    terserOptions: { //去掉打印
-      compress: {
-        drop_console: true,
-        drop_debugger: true,
-      },
-    },
-  },
-  define: { //环境变量配置
-    'process.env': {
-      'SERVERURL': mode === 'development' ? 'http://127.0.0.1:5000':'http://127.0.0.1:5000'
-    }
-  }
-})

+ 57 - 0
vite.config.ts

@@ -0,0 +1,57 @@
+import { defineConfig } from 'vite'
+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'
+
+export default () => defineConfig({
+  base: './',
+  resolve: {
+    alias: {
+      '@': resolve(__dirname, './src')
+    }
+  },
+  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: 6547,
+    open: true,
+    strictPort: false,
+    https: false,
+  },
+  esbuild: {
+    drop: ['console', 'debugger'] // build 移除打印
+  },
+  build: {
+    rollupOptions: {
+      input: {
+        index: resolve(__dirname, 'index.html')
+      },
+      output: { // 静态资源分类打包
+        chunkFileNames: 'js/[hash].js',
+        entryFileNames: 'js/[hash].js',
+        assetFileNames: 'assets/[ext]/[hash].[ext]',
+        // 拆分node_modules包
+        manualChunks: (id) => {
+          if (id.includes('node_modules')) {
+            return id.toString().split('node_modules/')[1].split('/')[0].toString()
+          }
+          return ''
+        }
+      }
+    }
+  },
+  define: {
+    __VUE_OPTIONS_API__: false
+  }
+})

File diff suppressed because it is too large
+ 346 - 527
yarn.lock


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