diff --git a/frontend/env.d.ts b/frontend/env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/frontend/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..9de13bc --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,105 @@ + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..499cab7 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,41 @@ +{ + "name": "frontend", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite --host --port 18091", + "serve": "vite --host --port 18091", + "build-staging": "vite build --mode staging", + "build": "vite build", + "preview": "vite preview", + "build-only": "vite build", + "type-check": "vue-tsc --build --force", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" + }, + "dependencies": { + "@element-plus/icons-vue": "^2.3.1", + "element-plus": "^2.7.8", + "pinia": "^2.1.7", + "vue": "^3.4.29", + "vue-router": "^4.3.3" + }, + "devDependencies": { + "@rushstack/eslint-patch": "^1.8.0", + "@tsconfig/node20": "^20.1.4", + "@types/node": "^20.14.14", + "@vitejs/plugin-vue": "^5.0.5", + "@vue/eslint-config-typescript": "^13.0.0", + "@vue/tsconfig": "^0.5.1", + "autoprefixer": "^10.4.20", + "eslint": "^8.57.0", + "eslint-plugin-vue": "^9.23.0", + "npm-run-all2": "^6.2.0", + "postcss": "^8.4.41", + "tailwindcss": "^3.4.7", + "typescript": "~5.4.0", + "vite": "^5.3.1", + "vite-plugin-node-polyfills": "^0.22.0", + "vue-tsc": "^2.0.21" + } +} diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js new file mode 100644 index 0000000..2e7af2b --- /dev/null +++ b/frontend/postcss.config.js @@ -0,0 +1,6 @@ +export default { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/frontend/src/api/main.js b/frontend/src/api/main.js new file mode 100644 index 0000000..d3adbbb --- /dev/null +++ b/frontend/src/api/main.js @@ -0,0 +1,13 @@ + +/** + * 主进程与渲染进程通信频道定义 + * Definition of communication channels between main process and rendering process + */ +const ipcApiRoute = { + test: 'controller.example.test', +} + +export { + ipcApiRoute +} + diff --git a/frontend/src/assets/logo.png b/frontend/src/assets/logo.png new file mode 100644 index 0000000..95dc60b Binary files /dev/null and b/frontend/src/assets/logo.png differ diff --git a/frontend/src/assets/styles/tailMain.css b/frontend/src/assets/styles/tailMain.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/frontend/src/assets/styles/tailMain.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/frontend/src/constants/localStore.ts b/frontend/src/constants/localStore.ts new file mode 100644 index 0000000..32605df --- /dev/null +++ b/frontend/src/constants/localStore.ts @@ -0,0 +1,2 @@ +/*文件说明:本文件用来定义一些本地缓存的key*/ + diff --git a/frontend/src/main.ts b/frontend/src/main.ts new file mode 100644 index 0000000..2de9396 --- /dev/null +++ b/frontend/src/main.ts @@ -0,0 +1,37 @@ + +import {createApp} from 'vue' +// element-plus +import ElementPlus from 'element-plus' +import 'element-plus/dist/index.css' +import * as ElementPlusIconsVue from "@element-plus/icons-vue"; + +// 使用pinia +import { createPinia } from 'pinia' + +import App from './App.vue' +import Router from './router/index'; + +// 引入tailwindcss +import '@/assets/styles/tailMain.css' + +//创建实例 +const app = createApp(App) +const setupAll = async () => { + app + .use(Router) // 使用路由 + .use(ElementPlus) // 使用ele-plus组件 + .use(createPinia()) // 使用pinia + + // 自动引入图标 + Object.keys(ElementPlusIconsVue).forEach((key) => { + app.component(key, ElementPlusIconsVue[key]); + }); + + //待路由初始化完毕后,挂载app + await Router.isReady() +} + +//挂载app +setupAll().then(() => { + app.mount('#app') +}) \ No newline at end of file diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts new file mode 100644 index 0000000..1db417b --- /dev/null +++ b/frontend/src/router/index.ts @@ -0,0 +1,20 @@ +import { createRouter, createWebHashHistory } from 'vue-router' +import routerMap from './routerMap' + +const Router = createRouter({ + history: createWebHashHistory(), + routes: routerMap, +}) + + +Router.beforeEach((to, from, next) => { + next() +}) + +// 路由加载后 +Router.afterEach(() => { + +}) + + +export default Router diff --git a/frontend/src/router/routerMap.ts b/frontend/src/router/routerMap.ts new file mode 100644 index 0000000..45da679 --- /dev/null +++ b/frontend/src/router/routerMap.ts @@ -0,0 +1,15 @@ +import Login from '@/views/Login.vue' + +/** + * 基础路由 + * @type { *[] } + */ +const constantRouterMap = [ + { + path: '/', + name: 'login', + component: Login + }, +] + +export default constantRouterMap \ No newline at end of file diff --git a/frontend/src/utils/ipcRenderer.js b/frontend/src/utils/ipcRenderer.js new file mode 100644 index 0000000..b229b36 --- /dev/null +++ b/frontend/src/utils/ipcRenderer.js @@ -0,0 +1,33 @@ +const Renderer = (window.require && window.require('electron')) || window.electron || {}; + +/** + * ipc + * 官方api说明:https://www.electronjs.org/zh/docs/latest/api/ipc-renderer + * + * 属性/方法 + * ipc.invoke(channel, param) - 发送异步消息(invoke/handle 模型) + * ipc.sendSync(channel, param) - 发送同步消息(send/on 模型) + * ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener + * ipc.once(channel, listener) - 添加一次性 listener 函数 + * ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者 + * ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器 + * ipc.send(channel, ...args) - 通过channel向主进程发送异步消息 + * ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程 + * ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口 + * ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 元素 + */ + +/** + * ipc + */ +const ipc = Renderer.ipcRenderer || undefined; + +/** + * 是否为EE环境 + */ +const isEE = ipc ? true : false; + +export { + Renderer, ipc, isEE +}; + diff --git a/frontend/src/views/Child.vue b/frontend/src/views/Child.vue new file mode 100644 index 0000000..f76de52 --- /dev/null +++ b/frontend/src/views/Child.vue @@ -0,0 +1,15 @@ + + + diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue new file mode 100644 index 0000000..d164cab --- /dev/null +++ b/frontend/src/views/Login.vue @@ -0,0 +1,36 @@ + + + + diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js new file mode 100644 index 0000000..6ec11f7 --- /dev/null +++ b/frontend/tailwind.config.js @@ -0,0 +1,9 @@ +/** @type {import('tailwindcss').Config} */ +export default { + content: ["index.html", "./src/**/*.{html,js,ts,jsx,tsx,vue}"], + theme: { + extend: {}, + }, + plugins: [], +} + diff --git a/frontend/tsconfig.app.json b/frontend/tsconfig.app.json new file mode 100644 index 0000000..db4bf17 --- /dev/null +++ b/frontend/tsconfig.app.json @@ -0,0 +1,13 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "exclude": ["src/**/__tests__/*"], + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + } +} diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json new file mode 100644 index 0000000..06df06c --- /dev/null +++ b/frontend/tsconfig.json @@ -0,0 +1,16 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.node.json" + }, + { + "path": "./tsconfig.app.json" + } + ], + "compilerOptions": { + "types": [ + "node" + ] + } +} diff --git a/frontend/tsconfig.node.json b/frontend/tsconfig.node.json new file mode 100644 index 0000000..f094063 --- /dev/null +++ b/frontend/tsconfig.node.json @@ -0,0 +1,19 @@ +{ + "extends": "@tsconfig/node20/tsconfig.json", + "include": [ + "vite.config.*", + "vitest.config.*", + "cypress.config.*", + "nightwatch.conf.*", + "playwright.config.*" + ], + "compilerOptions": { + "composite": true, + "noEmit": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + + "module": "ESNext", + "moduleResolution": "Bundler", + "types": ["node"] + } +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts new file mode 100644 index 0000000..53403c4 --- /dev/null +++ b/frontend/vite.config.ts @@ -0,0 +1,44 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import path from 'path' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [ + vue(), + ], + // 基础配置 + base: './', + publicDir: 'public', + resolve: { + alias: { + '@': path.resolve(__dirname, 'src') + } + }, + css: { + preprocessorOptions: { + less: { + modifyVars: { + '@border-color-base': '#dce3e8', + }, + javascriptEnabled: true, + }, + }, + }, + build: { + outDir: 'dist', + assetsDir: 'assets', + assetsInlineLimit: 4096, + cssCodeSplit: true, + brotliSize: false, + sourcemap: false, + minify: 'terser', + terserOptions: { + compress: { + // 生产环境去除console及debug + drop_console: false, + drop_debugger: true, + }, + }, + }, +})