From 4b7d9d46ad8cef0c3c0561807580e71a5ba4ffce Mon Sep 17 00:00:00 2001 From: gsx <530353222@qq.com> Date: Sat, 15 Jul 2023 12:51:58 +0800 Subject: [PATCH] vue3 demo --- frontend/.editorconfig | 14 ++++++++ frontend/src/api/main.js | 35 +++++------------- frontend/src/components/global/iconFont.js | 18 ++++++++++ frontend/src/components/global/index.js | 12 +++++++ frontend/src/layouts/AppSider.vue | 36 ++++--------------- frontend/src/main.js | 21 ++++++----- frontend/src/router/routerMap.js | 6 ---- frontend/src/utils/iconList.js | 27 ++++++++++++++ .../src/views/framework/socket/HttpServer.vue | 32 ++++++++++++----- .../views/framework/socket/SocketServer.vue | 2 +- .../src/views/framework/testapi/Index.vue | 11 ++++++ frontend/vite.config.js | 18 ---------- 12 files changed, 132 insertions(+), 100 deletions(-) create mode 100644 frontend/.editorconfig create mode 100644 frontend/src/components/global/iconFont.js create mode 100644 frontend/src/components/global/index.js create mode 100644 frontend/src/utils/iconList.js diff --git a/frontend/.editorconfig b/frontend/.editorconfig new file mode 100644 index 0000000..3454886 --- /dev/null +++ b/frontend/.editorconfig @@ -0,0 +1,14 @@ +# https://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false diff --git a/frontend/src/api/main.js b/frontend/src/api/main.js index a7838d6..5c2b93f 100644 --- a/frontend/src/api/main.js +++ b/frontend/src/api/main.js @@ -1,8 +1,7 @@ -import request from '@/utils/request' -import storage from 'store2' /** - * 路由定义(主进程与渲染进程通信频道定义) + * 主进程与渲染进程通信频道定义 + * Definition of communication channels between main process and rendering process */ const ipcApiRoute = { // framework @@ -54,34 +53,16 @@ const ipcApiRoute = { } /** - * 特殊的路由(频道)定义 + * 自定义频道 + * custom chennel */ const specialIpcRoute = { - appUpdater: 'app.updater', // 此频道在后端也有相同定义 - window1ToWindow2: 'window1-to-window2', // 窗口之间通信 - window2ToWindow1: 'window2-to-window1', // 窗口之间通信 -} - -/** - * 访问内置http服务 - */ -const requestHttp = (uri, parameter) => { - // url转换 - const config = storage.get('httpServiceConfig'); - const host = config.server || 'http://localhost:7071'; - let url = uri.split('.').join('/'); - url = host + '/' + url; - console.log('url:', url); - return request({ - url: url, - method: 'post', - data: parameter, // body - params: {}, // URL 参数 - timeout: 60000, - }) + appUpdater: 'app.updater', // updater channel + window1ToWindow2: 'window1-to-window2', // windows channel + window2ToWindow1: 'window2-to-window1', // windows channel } export { - ipcApiRoute, requestHttp, specialIpcRoute + ipcApiRoute, specialIpcRoute } diff --git a/frontend/src/components/global/iconFont.js b/frontend/src/components/global/iconFont.js new file mode 100644 index 0000000..fddd07b --- /dev/null +++ b/frontend/src/components/global/iconFont.js @@ -0,0 +1,18 @@ +import { createFromIconfontCN } from '@ant-design/icons-vue' +import { h } from 'vue' + +const IconFont = createFromIconfontCN({ + scriptUrl: '//at.alicdn.com/t/font_2456157_4ovzopz659q.js', + extraCommonProps: { + type: 'icon-fengche', + style: { + fontSize: '18px', + }, + }, +}) + +const DynamicIconFont = props => { + return h(IconFont, { type: props.type || 'icon-fengche' }) +} + +export default DynamicIconFont diff --git a/frontend/src/components/global/index.js b/frontend/src/components/global/index.js new file mode 100644 index 0000000..9227d20 --- /dev/null +++ b/frontend/src/components/global/index.js @@ -0,0 +1,12 @@ +import iconFont from './iconFont' +const modules = import.meta.globEager('./*.vue') +const map = {} +Object.keys(modules).forEach(file => { + const modulesName = file.replace('./', '').replace('.vue', '') + map[modulesName] = modules[file].default +}) +const globalComponents = { + ...map, + iconFont, +} +export default globalComponents diff --git a/frontend/src/layouts/AppSider.vue b/frontend/src/layouts/AppSider.vue index 26e0d2e..aa2a62c 100644 --- a/frontend/src/layouts/AppSider.vue +++ b/frontend/src/layouts/AppSider.vue @@ -4,7 +4,7 @@ v-model="collapsed" theme="light" class="layout-sider" - width="80" + width="100" >