gaoshuaixing 3 gadi atpakaļ
vecāks
revīzija
f7abfa02db

+ 3 - 0
config/config.local.js

@@ -3,6 +3,9 @@
 const Utils = require('ee-core').Utils;
 const logDir = Utils.getLogDir();
 
+/*
+ * 日志dir目录,会随开发环境变动,请谨慎修改
+ */
 exports.logger = {
   dir: logDir,
 };

+ 3 - 0
config/config.prod.js

@@ -3,6 +3,9 @@
 const Utils = require('ee-core').Utils;
 const logDir = Utils.getLogDir();
 
+/*
+ * 日志dir目录,会随开发环境变动,请谨慎修改
+ */
 exports.logger = {
   dir: logDir,
 };

+ 2 - 0
frontend/.env

@@ -1,3 +1,5 @@
 NODE_ENV=production
 VUE_APP_PREVIEW=false
+
+# 生产环境,请留空,不要占用该属性
 VUE_APP_API_BASE_URL=

+ 3 - 0
frontend/.env.development

@@ -1,3 +1,6 @@
 NODE_ENV=development
+
 VUE_APP_PREVIEW=true
+
+# 开发环境时,要调用的egg服务地址 
 VUE_APP_API_BASE_URL=http://localhost:7068

+ 0 - 1
frontend/src/api/main.js

@@ -1,5 +1,4 @@
 import request from '@/utils/request'
-// import storage from 'store'
 
 const mainApi = {
   openDir: '/api/v1/example/openLocalDir',

+ 45 - 45
frontend/src/config/router.config.js

@@ -2,7 +2,7 @@
  * 基础路由
  * @type { *[] }
  */
- import {AppSider, DemoMenu} from '@/layouts'
+ import {AppSider, Menu} from '@/layouts'
 
  const RouteView = {
    name: 'RouteView',
@@ -14,79 +14,79 @@ export const constantRouterMap = [
     component: AppSider,
     children: [
       {
-        path: '/demo',
+        path: '/',
         name: 'Demo',
-        component: DemoMenu,
+        component: Menu,
         children: [
           {
-            path: '/demo/file/index',
-            name: 'DemoFileIndex',
-            component: () => import('@/views/demo/file/Index')
+            path: '/base/file/index',
+            name: 'BaseFileIndex',
+            component: () => import('@/views/base/file/Index')
           },
           {
-            path: '/demo/socket/index',
-            name: 'DemoSocketIndex',
-            component: () => import('@/views/demo/socket/Index')
+            path: '/base/socket/index',
+            name: 'BaseSocketIndex',
+            component: () => import('@/views/base/socket/Index')
           },
           {
-            path: '/demo/db/index',
-            name: 'DemoDBIndex',
-            component: () => import('@/views/demo/db/Index')
+            path: '/base/db/index',
+            name: 'BaseDBIndex',
+            component: () => import('@/views/base/db/Index')
           },
           {
-            path: '/demo/windowview/index',
-            name: 'DemoWindowViewIndex',
-            component: () => import('@/views/demo/windowview/Index')
+            path: '/base/windowview/index',
+            name: 'BaseWindowViewIndex',
+            component: () => import('@/views/base/windowview/Index')
           },
           {
-            path: '/demo/window/index',
-            name: 'DemoWindowIndex',
-            component: () => import('@/views/demo/window/Index')
+            path: '/base/window/index',
+            name: 'BaseWindowIndex',
+            component: () => import('@/views/base/window/Index')
           },
           {
-            path: '/demo/extension/index',
-            name: 'DemoExtensionIndex',
-            component: () => import('@/views/demo/extension/Index')
+            path: '/base/extension/index',
+            name: 'BaseExtensionIndex',
+            component: () => import('@/views/base/extension/Index')
           },
           {
-            path: '/demo/notification/index',
-            name: 'DemoNotificationIndex',
-            component: () => import('@/views/demo/notification/Index')
+            path: '/base/notification/index',
+            name: 'BaseNotificationIndex',
+            component: () => import('@/views/base/notification/Index')
           },
           {
-            path: '/demo/powermonitor/index',
-            name: 'DemoPowerMonitorIndex',
-            component: () => import('@/views/demo/powermonitor/Index')
+            path: '/base/powermonitor/index',
+            name: 'BasePowerMonitorIndex',
+            component: () => import('@/views/base/powermonitor/Index')
           },
           {
-            path: '/demo/screen/index',
-            name: 'DemoScreenIndex',
-            component: () => import('@/views/demo/screen/Index')
+            path: '/base/screen/index',
+            name: 'BaseScreenIndex',
+            component: () => import('@/views/base/screen/Index')
           },
           {
-            path: '/demo/theme/index',
-            name: 'DemoThemeIndex',
-            component: () => import('@/views/demo/theme/Index')
+            path: '/base/theme/index',
+            name: 'BaseThemeIndex',
+            component: () => import('@/views/base/theme/Index')
           },                               
           {
-            path: '/demo/shortcut/index',
-            name: 'DemoShortcutIndex',
-            component: () => import('@/views/demo/shortcut/Index')
+            path: '/base/shortcut/index',
+            name: 'BaseShortcutIndex',
+            component: () => import('@/views/base/shortcut/Index')
           },
           {
-            path: '/demo/software/open',
-            name: 'DemoSoftwareIndex',
-            component: () => import('@/views/demo/software/Index')
+            path: '/base/software/open',
+            name: 'BaseSoftwareIndex',
+            component: () => import('@/views/base/software/Index')
           },
           {
-            path: '/demo/system/index',
-            name: 'DemoSystemIndex',
-            component: () => import('@/views/demo/system/Index')
+            path: '/base/system/index',
+            name: 'BaseSystemIndex',
+            component: () => import('@/views/base/system/Index')
           },
           {
-            path: '/demo/testapi/index',
-            name: 'DemoTestApiIndex',
-            component: () => import('@/views/demo/testapi/Index')
+            path: '/base/testapi/index',
+            name: 'BaseTestApiIndex',
+            component: () => import('@/views/base/testapi/Index')
           },
         ]  
       },

+ 16 - 16
frontend/src/layouts/DemoMenu.vue → frontend/src/layouts/Menu.vue

@@ -1,5 +1,5 @@
 <template>
-  <a-layout id="app-demo-menu">
+  <a-layout id="app-menu">
     <a-layout-sider
       theme="light"
       class="layout-sider"
@@ -27,85 +27,85 @@ export default {
         'menu_100' : {
           icon: 'profile',
           title: '文件',
-          pageName: 'DemoFileIndex',
+          pageName: 'BaseFileIndex',
           params: {}
         },
         'menu_300' : {
           icon: 'profile',
           title: '通信',
-          pageName: 'DemoSocketIndex',
+          pageName: 'BaseSocketIndex',
           params: {}
         },
         'menu_301' : {
           icon: 'profile',
           title: '数据库',
-          pageName: 'DemoDBIndex',
+          pageName: 'BaseDBIndex',
           params: {}
         },
         'menu_400' : {
           icon: 'profile',
           title: '视图',
-          pageName: 'DemoWindowViewIndex',
+          pageName: 'BaseWindowViewIndex',
           params: {}
         },
         'menu_401' : {
           icon: 'profile',
           title: '窗口',
-          pageName: 'DemoWindowIndex',
+          pageName: 'BaseWindowIndex',
           params: {}
         },
         'menu_403' : {
           icon: 'profile',
           title: '扩展程序',
-          pageName: 'DemoExtensionIndex',
+          pageName: 'BaseExtensionIndex',
           params: {}
         },
         'menu_405' : {
           icon: 'profile',
           title: '桌面通知',
-          pageName: 'DemoNotificationIndex',
+          pageName: 'BaseNotificationIndex',
           params: {}
         },
         'menu_407' : {
           icon: 'profile',
           title: '电源监控',
-          pageName: 'DemoPowerMonitorIndex',
+          pageName: 'BasePowerMonitorIndex',
           params: {}
         },
         'menu_409' : {
           icon: 'profile',
           title: '屏幕信息',
-          pageName: 'DemoScreenIndex',
+          pageName: 'BaseScreenIndex',
           params: {}
         },
         'menu_411' : {
           icon: 'profile',
           title: '系统主题',
-          pageName: 'DemoThemeIndex',
+          pageName: 'BaseThemeIndex',
           params: {}
         },       
         'menu_500' : {
           icon: 'profile',
           title: '软件调用',
-          pageName: 'DemoSoftwareIndex',
+          pageName: 'BaseSoftwareIndex',
           params: {}
         },
         'menu_600' : {
           icon: 'profile',
           title: '系统',
-          pageName: 'DemoSystemIndex',
+          pageName: 'BaseSystemIndex',
           params: {}
         },
         'menu_800' : {
           icon: 'profile',
           title: '快捷键',
-          pageName: 'DemoShortcutIndex',
+          pageName: 'BaseShortcutIndex',
           params: {}
         },
         'menu_900' : {
           icon: 'profile',
           title: '测试',
-          pageName: 'DemoTestApiIndex',
+          pageName: 'BaseTestApiIndex',
           params: {}
         }                                                 
       }
@@ -125,7 +125,7 @@ export default {
 };
 </script>
 <style lang="less" scoped>
-#app-demo-menu {
+#app-menu {
   height: 100%;
   text-align: center;
   .layout-sider {

+ 2 - 2
frontend/src/layouts/index.js

@@ -1,7 +1,7 @@
 import AppSider from '@/layouts/AppSider'
-import DemoMenu from '@/layouts/DemoMenu'
+import Menu from '@/layouts/Menu'
 
 export {
     AppSider, 
-    DemoMenu
+    Menu
 }

+ 4 - 4
frontend/src/main.js

@@ -5,15 +5,15 @@ import App from './App'
 import router from './router'
 import { VueAxios } from './utils/request'
 import IpcRenderer from '@/utils/ipcRenderer'
-import HotKeyInput from '@/utils/shortcut/index.js'
 
+// 使用antd
 Vue.use(antd)
+
 // mount axios to `Vue.$http` and `this.$http`
 Vue.use(VueAxios)
-// 全局注入IPC
+
+// 全局注入IPC通信
 Vue.use(IpcRenderer)
-// 快捷键框组件
-Vue.use(HotKeyInput)
 
 Vue.config.productionTip = false
 

+ 0 - 0
frontend/src/utils/shortcut/hot-key-input/codeMap.js


+ 0 - 10
frontend/src/utils/shortcut/hot-key-input/index.js

@@ -1,10 +0,0 @@
-// 导入组件,组件必须声明 name
-import myComponent from './index.vue'
-
-// 为组件提供 install 安装方法,供按需引入
-myComponent.install = function (Vue) {
-  Vue.component(myComponent.name, myComponent)
-}
-
-// 默认导出组件
-export default myComponent

+ 0 - 317
frontend/src/utils/shortcut/hot-key-input/index.vue

@@ -1,317 +0,0 @@
-<template>
-  <div
-    class="hot-key-input-component"
-    :class="{ cursor: focus, 'hot-key-input-shark': isShark }"
-    :style="$props.style"
-    tabindex="0"
-    :placeholder="list.length ? '' : placeholder"
-    @focus="handleFocus"
-    @blur="focus = false"
-    @keydown.prevent="handleKeydown"
-  >
-    <div v-for="(item, index) in list" :key="index" class="hot-item">
-      <span class="hot-text">{{ formatItemText(item.text) }} </span>
-      <i class="icon-close" @click="handleDeleteKey(index)"></i>
-    </div>
-  </div>
-</template>
-
-<script>
-const CODE_NUMBER = Array.from({ length: 10 }, (v, k) => `Digit${k + 1}`)
-const CODE_NUMPAD = Array.from({ length: 10 }, (v, k) => `Numpad${k + 1}`)
-const CODE_ABC = Array.from(
-  { length: 26 },
-  (v, k) => `Key${String.fromCharCode(k + 65).toUpperCase()}`
-)
-const CODE_FN = Array.from({ length: 12 }, (v, k) => `F${k + 1}`)
-const CODE_CONTROL = [
-  "Shift",
-  "ShiftLeft",
-  "ShiftRight",
-  "Control",
-  "ControlLeft",
-  "ControlRight",
-  "Alt",
-  "AltLeft",
-  "AltRight",
-] // ShiftKey Control(Ctrl) Alt
-
-export default {
-  name: "HotKeyInput",
-  props: {
-    type: {
-      type: String,
-      // lowser upper
-      default: ()=> 'defalut'
-    },
-    // 默认绑定值
-    // 传入 ['Ctrl+d'] 格式时会自动处理成 [{ text: 'Ctrl+d', controlKey: { altKey: false, ctrlKey: true, shiftKey: false, key: 'd', code: 'KeyD } }]
-    hotkey: {
-      type: [Array , Object],
-      required: true,
-    },
-    // 校验函数 判断是否允许显示快捷键
-    verify: {
-      type: Function,
-      default: () => true,
-    },
-    // 无绑定时提示文字
-    placeholder: {
-      type: String,
-      default: "",
-    },
-    // 限制最大数量
-    max: {
-      type: [String, Number],
-      default: 0,
-    },
-    // 当max时,再次输入快捷键 - true: 清空后输入,false:无操作
-    reset: {
-      type: Boolean,
-      default: false,
-    },
-    shake: {
-      type: Boolean,
-      default: true,
-    },
-    // 快捷键使用范围
-    range: {
-      type: Array,
-      default: () => ["NUMBER", "NUMPAD", "ABC", "FN"],
-    },
-  },
-  data() {
-    return {
-      isShark: false,
-      focus: false,
-      hotkeyBackups: this.hotkey || '' ,
-      list: [],
-      keyRange: [],
-    }
-  },
-  watch: {
-    list: function (list) {
-      list.length ? (this.focus = false) : (this.focus = true)
-      // .sync修饰符
-      this.$emit(
-        "update:hotkey",
-        this.list.map((item) => {
-          return this.formatItemText(item.text)
-          // if(item.text && this.type != 'default'){
-          //   return this.type == 'lowser' ? item.text.toLowerCase():item.text.toUpperCase()
-          // }
-          // return item.text
-        })
-      )
-    },
-    
-    hotkeyBackups: {
-      handler: function (val) {
-        if (!val.length) return;
-        const list = [];
-        val.forEach((item) => {
-          const arr = item.split("+");
-          const controlKey = {
-            altKey: arr.includes("Alt"),
-            ctrlKey: arr.includes("Control"),
-            shiftKey: arr.includes("Shift"),
-            key: arr[arr.length - 1],
-            code: `Key${arr[arr.length - 1].toUpperCase()}`,
-          };
-          list.push({
-            text: arr.reduce((text, item, i) => {
-              if (i) text += "+";
-              if (controlKey.key === item) text += item.toUpperCase();
-              else text += item;
-              return text;
-            }, ""),
-            controlKey,
-          });
-        });
-        this.list = list;
-      },
-      immediate: true,
-    },
-    range: {
-      handler: function (val) {
-        if(val === null){
-          this.keyRange = null
-          return
-        }
-        const keyRangeList = {
-          NUMBER: CODE_NUMBER,
-          NUMPAD: CODE_NUMPAD,
-          ABC: CODE_ABC,
-          FN: CODE_FN,
-        }
-        val.forEach((item) => {
-          this.keyRange = this.keyRange.concat(
-            keyRangeList[item.toUpperCase()]
-          )
-        })
-      },
-      immediate: true,
-    },
-  },
-  methods: {
-    formatItemText(text){
-      if(text && this.type != 'default'){
-        return this.type == 'lowser' ? text.toLowerCase() : text.toUpperCase()
-      }
-      return text
-    },
-    handleFocus() {
-      if (!this.list.length) this.focus = true
-    },
-    handleDeleteKey(index) {
-      this.list.splice(index, 1)
-    },
-    handleKeydown(e) {
-      console.log('e: ',e)
-      e.preventDefault()
-      e.stopPropagation()
-      const { altKey, ctrlKey, shiftKey, key, code } = e
-      if (!CODE_CONTROL.includes(key)) {
-        if (this.keyRange !== null && !this.keyRange.includes(code)){
-          this.shakeAction()
-          return
-        }
-        let controlKey = ''
-        let temps = [
-          { key: altKey, text: "Alt" },
-          { key: ctrlKey, text: "Ctrl" },
-          { key: shiftKey, text: "Shift" },
-        ]
-        temps.forEach((curKey) => {
-          if (curKey.key) {
-            if (controlKey) controlKey += "+"
-            controlKey += curKey.text
-          }
-        })
-        if (key) {
-          if (controlKey) controlKey += "+"
-          controlKey += key.toUpperCase()
-        }
-        this.addHotkey({
-          text: controlKey,
-          controlKey: { altKey, ctrlKey, shiftKey, key, code },
-        })
-      }
-    },
-    addHotkey(data) {
-      if (this.list.length) {
-        if (this.list.length.toString() >= this.max.toString()) {
-          if (this.reset) {
-            this.list = []
-          } else {
-            return
-          }
-        } else if (this.list.some((item) => data.text === item.text)) {
-          this.shakeAction()
-          return
-        }
-      }
-      if (!this.verify(data)) {
-        this.shakeAction()
-        return
-      }
-      this.list.push(data)
-    },
-    shakeAction(){
-      if(this.shake){
-            this.isShark = true
-            setTimeout(()=>{
-              this.isShark = false
-            }, 800)
-          }
-    }
-  },
-}
-</script>
-<style lang="less">
-@keyframes Blink {
-  0% {
-    opacity: 0;
-  }
-  100% {
-    opacity: 1;
-  }
-}
-
-@keyframes hot-key-input-shake {
-  0% {
-    transform: scale(1);
-  }
-  10%,
-  20% {
-    transform: scale(0.9) rotate(-1deg);
-  }
-  30%,
-  50%,
-  70%,
-  90% {
-    transform: scale(1.1) rotate(1deg);
-  }
-  40%,
-  60%,
-  80% {
-    transform: scale(1.1) rotate(-1deg);
-  }
-  100% {
-    transform: scale(1) rotate(0);
-  }
-}
-
-.hot-key-input-shark {
-  animation: hot-key-input-shake 0.8s 1 ease-in;
-}
-
-.hot-key-input-component {
-  display: flex;
-  padding: 5px;
-  border: 1px solid #dcdcdc;
-  background-color: #fff;
-  color: #333;
-  cursor: text;
-  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
-}
-
-.hot-key-input-component:before {
-  content: attr(placeholder);
-  color: #afafaf;
-}
-
-.hot-key-input-component.cursor::after {
-  content: "|";
-  animation: Blink 1.2s ease 0s infinite;
-  position: absolute;
-  left: 10px;
-}
-
-.hot-item {
-  display: flex;
-  align-items: center;
-  background-color: #f4f4f5;
-  border-color: #e9e9eb;
-  color: #909399;
-  padding: 0 5px;
-  margin-right: 5px;
-}
-
-.hot-key-input-component .hot-item .icon-close {
-  display: block;
-  content: "";
-  background: url("data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cpath d='M512 64C264.58 64 64 264.58 64 512s200.58 448 448 448 448-200.58 448-448S759.42 64 512 64zm0 832c-212.08 0-384-171.92-384-384s171.92-384 384-384 384 171.92 384 384-171.92 384-384 384z' fill='%23909399'/%3E%3Cpath d='M625.14 353.61L512 466.75 398.86 353.61a32 32 0 0 0-45.25 45.25L466.75 512 353.61 625.14a32 32 0 0 0 45.25 45.25L512 557.25l113.14 113.14a32 32 0 0 0 45.25-45.25L557.25 512l113.14-113.14a32 32 0 0 0-45.25-45.25z' fill='%23909399'/%3E%3C/svg%3E")
-    no-repeat center;
-  background-size: contain;
-  width: 14px;
-  height: 14px;
-  transform: scale(0.9);
-  opacity: 0.6;
-}
-
-.hot-key-input-component .hot-item .icon-close:hover {
-  cursor: pointer;
-  opacity: 1;
-}
-</style>

+ 0 - 27
frontend/src/utils/shortcut/index.js

@@ -1,27 +0,0 @@
-// 导入颜色选择器组件
-import HotKeyInput from './hot-key-input'
-
-// 存储组件列表
-const components = [
-  HotKeyInput
-]
-
-// 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册
-const install = function (Vue) {
-  // 判断是否安装
-  if (install.installed) return
-  // 遍历注册全局组件
-  components.map(component => Vue.component(component.name, component))
-}
-
-// 判断是否是直接引入文件
-if (typeof window !== 'undefined' && window.Vue) {
-  install(window.Vue)
-}
-
-export default {
-  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
-  install,
-  // 以下是具体的组件列表
-  HotKeyInput
-}

+ 0 - 0
frontend/src/views/demo/db/Index.vue → frontend/src/views/base/db/Index.vue


+ 0 - 0
frontend/src/views/demo/extension/Index.vue → frontend/src/views/base/extension/Index.vue


+ 0 - 0
frontend/src/views/demo/file/Index.vue → frontend/src/views/base/file/Index.vue


+ 0 - 0
frontend/src/views/demo/notification/Index.vue → frontend/src/views/base/notification/Index.vue


+ 0 - 0
frontend/src/views/demo/powermonitor/Index.vue → frontend/src/views/base/powermonitor/Index.vue


+ 0 - 0
frontend/src/views/demo/screen/Index.vue → frontend/src/views/base/screen/Index.vue


+ 0 - 0
frontend/src/views/demo/shortcut/Index.vue → frontend/src/views/base/shortcut/Index.vue


+ 0 - 0
frontend/src/views/demo/socket/Index.vue → frontend/src/views/base/socket/Index.vue


+ 0 - 0
frontend/src/views/demo/software/Index.vue → frontend/src/views/base/software/Index.vue


+ 0 - 0
frontend/src/views/demo/system/Index.vue → frontend/src/views/base/system/Index.vue


+ 0 - 0
frontend/src/views/demo/testapi/Index.vue → frontend/src/views/base/testapi/Index.vue


+ 0 - 0
frontend/src/views/demo/theme/Index.vue → frontend/src/views/base/theme/Index.vue


+ 0 - 0
frontend/src/views/demo/window/Index.vue → frontend/src/views/base/window/Index.vue


+ 0 - 0
frontend/src/views/demo/windowview/Index.vue → frontend/src/views/base/windowview/Index.vue


+ 0 - 12
preload.js

@@ -1,12 +0,0 @@
-// All of the Node.js APIs are available in the preload process.
-// It has the same sandbox as a Chrome extension.
-window.addEventListener('DOMContentLoaded', () => {
-  const replaceText = (selector, text) => {
-    const element = document.getElementById(selector)
-    if (element) element.innerText = text
-  }
-
-  for (const type of ['chrome', 'node', 'electron']) {
-    replaceText(`${type}-version`, process.versions[type])
-  }
-})

+ 0 - 6
renderer.js

@@ -1,6 +0,0 @@
-// This file is required by the index.html file and will
-// be executed in the renderer process for that window.
-// No Node.js APIs are available in this process because
-// `nodeIntegration` is turned off. Use `preload.js` to
-// selectively enable features needed in the rendering
-// process.