commit 18d8ff77504b496d09c9bb86a71a949cc6103501 Author: lichong <18518571399@163.com> Date: Tue Nov 19 09:07:03 2024 +0800 11.18 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..3dce414 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d920a1f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +dist +out +*.log* +package-lock.json diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..fdc1a98 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..9c6b791 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +out +dist +pnpm-lock.yaml +LICENSE.md +tsconfig.json +tsconfig.*.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..f3050e8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "singleQuote": true, + "semi": false, + "printWidth": 100, + "trailingComma": "none" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..169e509 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# my-app + +An Electron application with Vue + +## Recommended IDE Setup + +- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) + +## Project Setup + +### Install(node 16.20.1) + +```bash +$ npm install +``` + +### Development + +```bash +$ npm run dev +``` + +### Build + +```bash +# For windows +$ npm run build:win + +# For macOS +$ npm run build:mac + +# For Linux +$ npm run build:linux +``` diff --git a/build/entitlements.mac.plist b/build/entitlements.mac.plist new file mode 100644 index 0000000..38c887b --- /dev/null +++ b/build/entitlements.mac.plist @@ -0,0 +1,12 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.allow-dyld-environment-variables + + + diff --git a/build/icon.icns b/build/icon.icns new file mode 100644 index 0000000..63d4bb7 Binary files /dev/null and b/build/icon.icns differ diff --git a/build/icon.ico b/build/icon.ico new file mode 100644 index 0000000..6441ff6 Binary files /dev/null and b/build/icon.ico differ diff --git a/build/notarize.js b/build/notarize.js new file mode 100644 index 0000000..116e5e0 --- /dev/null +++ b/build/notarize.js @@ -0,0 +1,36 @@ +const { notarize } = require('electron-notarize') + +module.exports = async (context) => { + if (process.platform !== 'darwin') return + + console.log('aftersign hook triggered, start to notarize app.') + + if (!process.env.CI) { + console.log(`skipping notarizing, not in CI.`) + return + } + + if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) { + console.warn('skipping notarizing, APPLE_ID and APPLE_ID_PASS env variables must be set.') + return + } + + const appId = 'com.electron.app' + + const { appOutDir } = context + + const appName = context.packager.appInfo.productFilename + + try { + await notarize({ + appBundleId: appId, + appPath: `${appOutDir}/${appName}.app`, + appleId: process.env.APPLE_ID, + appleIdPassword: process.env.APPLEIDPASS + }) + } catch (error) { + console.error(error) + } + + console.log(`done notarizing ${appId}.`) +} diff --git a/electron-builder.yml b/electron-builder.yml new file mode 100644 index 0000000..48e30cf --- /dev/null +++ b/electron-builder.yml @@ -0,0 +1,43 @@ +appId: com.electron.lichong +productName: 表格数据管理 +directories: + buildResources: build +files: + - '!**/.vscode/*' + - '!src/*' + - '!electron.vite.config.{js,ts,mjs,cjs}' + - '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}' +asarUnpack: + - '**/*.{node,dll}' +afterSign: build/notarize.js +win: + executableName: lichong-app +nsis: + oneClick: false + artifactName: 表格数据管理-${version}-setup.${ext} + allowToChangeInstallationDirectory: true + shortcutName: ${productName} + uninstallDisplayName: ${productName} + createDesktopShortcut: always +mac: + entitlementsInherit: build/entitlements.mac.plist + extendInfo: + - NSCameraUsageDescription: Application requests access to the device's camera. + - NSMicrophoneUsageDescription: Application requests access to the device's microphone. + - NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder. + - NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder. +dmg: + artifactName: ${name}-${version}.${ext} +linux: + target: + - AppImage + - snap + - deb + maintainer: electronjs.org + category: Utility +appImage: + artifactName: ${name}-${version}.${ext} +npmRebuild: false +publish: + provider: generic + url: https://example.com/auto-updates diff --git a/electron.vite.config.js b/electron.vite.config.js new file mode 100644 index 0000000..152a70d --- /dev/null +++ b/electron.vite.config.js @@ -0,0 +1,28 @@ +import { resolve } from 'path' +import { defineConfig, externalizeDepsPlugin } from 'electron-vite' +import vue from '@vitejs/plugin-vue' + +export default defineConfig({ + main: { + plugins: [externalizeDepsPlugin()] + }, + preload: { + plugins: [externalizeDepsPlugin()], + build: { + rollupOptions: { + input: { + dl: resolve(__dirname, 'src/preload/dl.js'), + index: resolve(__dirname, 'src/preload/index.js') + } + } + } + }, + renderer: { + resolve: { + alias: { + '@renderer': resolve('src/renderer/src') + } + }, + plugins: [vue()] + } +}) diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..b50f09d --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,6 @@ +{ + "exclude": [ + "node_modules", + "public" + ] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2cf89d2 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "electron", + "version": "1.0.0", + "description": "An Electron application with Vue", + "main": "./out/main/index.js", + "author": "lichong", + "homepage": "https://www.electronjs.org", + "scripts": { + "npmi": "npm i", + "dev": "electron-vite dev", + "build": "electron-vite build", + "build:win": "npm run build && electron-builder --win --config", + "build:mac": "npm run build && electron-builder --mac --config", + "build:linux": "npm run build && electron-builder --linux --config" + }, + "dependencies": { + "@electron-toolkit/preload": "^1.0.2", + "@electron-toolkit/utils": "^1.0.2", + "dayjs": "^1.11.11", + "dexie": "^4.0.8", + "element-plus": "^2.7.1", + "lodash": "^4.17.21", + "vxe-table": "^4.7.87" + }, + "devDependencies": { + "@rushstack/eslint-patch": "^1.2.0", + "@vitejs/plugin-vue": "^3.1.2", + "@vue/eslint-config-prettier": "^7.0.0", + "electron": "^20.3.2", + "electron-builder": "^23.6.0", + "electron-notarize": "^1.2.1", + "electron-vite": "^1.0.11", + "less": "^4.1.3", + "prettier": "^2.7.1", + "vite": "^3.1.8", + "vue": "^3.2.41" + } +} diff --git a/public/icon/icon.jpg b/public/icon/icon.jpg new file mode 100644 index 0000000..4ed6253 Binary files /dev/null and b/public/icon/icon.jpg differ diff --git a/src/main/index.js b/src/main/index.js new file mode 100644 index 0000000..f1e8f34 --- /dev/null +++ b/src/main/index.js @@ -0,0 +1,71 @@ +import { app, shell, BrowserWindow, nativeImage } from 'electron' +import * as path from 'path' +import { electronApp, optimizer, is } from '@electron-toolkit/utils' + +// logo +const logoIcon = nativeImage.createFromPath(path.join(__dirname, '../../public/icon/icon.jpg')) +// 主窗口 +let mainWindow +function createWindow() { + mainWindow = new BrowserWindow({ + minWidth: 1366, + minHeight: 900, + height: 1260, + width: 1730, + show: false, + autoHideMenuBar: true, + icon: logoIcon, + webPreferences: { + preload: path.resolve(__dirname, '../preload/index.js'), + sandbox: false, + nodeIntegration: true, + contextIsolation: false + } + }) + mainWindow.on('ready-to-show', () => { + mainWindow.show() + // mainWindow.webContents.openDevTools() + }) + mainWindow.webContents.setWindowOpenHandler((details) => { + shell.openExternal(details.url) + return { action: 'deny' } + }) + // mainWindow.loadURL('http://localhost:5173/') + + mainWindow.on('close', () => { + app.exit() + }) + if (is.dev && process.env['ELECTRON_RENDERER_URL']) { + mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) + } else { + mainWindow.loadFile(path.join(__dirname, '../renderer/index.html')) + } +} +app.whenReady().then(() => { + electronApp.setAppUserModelId('com.electron') + // Default open or close DevTools by F12 in development + // and ignore CommandOrControl + R in production. + // see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils + app.on('browser-window-created', (_, window) => { + optimizer.watchWindowShortcuts(window) + }) + + createWindow() + + app.on('activate', function () { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) +app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required'); +// Quit when all windows are closed, except on macOS. There, it's common +// for applications and their menu bar to stay active until the user quits +// explicitly with Cmd + Q. +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) +// In this file you can include the rest of your app"s specific main process +// code. You can also put them in separate files and require them here. diff --git a/src/preload/dl.js b/src/preload/dl.js new file mode 100644 index 0000000..2604961 --- /dev/null +++ b/src/preload/dl.js @@ -0,0 +1,21 @@ +import { contextBridge, clipboard } from 'electron' +import { electronAPI } from '@electron-toolkit/preload' + +// Custom APIs for renderer +const api = {} + +// Use `contextBridge` APIs to expose Electron APIs to +// renderer only if context isolation is enabled, otherwise +// just add to the DOM global. +if (process.contextIsolated) { + try { + contextBridge.exposeInMainWorld('electron', electronAPI) + contextBridge.exposeInMainWorld('api', api) + contextBridge.exposeInMainWorld('elecClipboard', clipboard) + } catch (error) { + console.error(error) + } +} else { + window.electron = electronAPI + window.api = api +} diff --git a/src/preload/index.js b/src/preload/index.js new file mode 100644 index 0000000..2604961 --- /dev/null +++ b/src/preload/index.js @@ -0,0 +1,21 @@ +import { contextBridge, clipboard } from 'electron' +import { electronAPI } from '@electron-toolkit/preload' + +// Custom APIs for renderer +const api = {} + +// Use `contextBridge` APIs to expose Electron APIs to +// renderer only if context isolation is enabled, otherwise +// just add to the DOM global. +if (process.contextIsolated) { + try { + contextBridge.exposeInMainWorld('electron', electronAPI) + contextBridge.exposeInMainWorld('api', api) + contextBridge.exposeInMainWorld('elecClipboard', clipboard) + } catch (error) { + console.error(error) + } +} else { + window.electron = electronAPI + window.api = api +} diff --git a/src/renderer/index.html b/src/renderer/index.html new file mode 100644 index 0000000..1fcaec7 --- /dev/null +++ b/src/renderer/index.html @@ -0,0 +1,18 @@ + + + + + + 表格数据管理 + + + + + + +
+ + + + \ No newline at end of file diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue new file mode 100644 index 0000000..17fd3e0 --- /dev/null +++ b/src/renderer/src/App.vue @@ -0,0 +1,65 @@ + + + + \ No newline at end of file diff --git a/src/renderer/src/assets/css/base.css b/src/renderer/src/assets/css/base.css new file mode 100644 index 0000000..4dc4eeb --- /dev/null +++ b/src/renderer/src/assets/css/base.css @@ -0,0 +1,5 @@ +html, +body { + margin: 0; + padding: 0; +} diff --git a/src/renderer/src/assets/excel/WKM25471-02D ASN .xlsx b/src/renderer/src/assets/excel/WKM25471-02D ASN .xlsx new file mode 100644 index 0000000..7adbcdf Binary files /dev/null and b/src/renderer/src/assets/excel/WKM25471-02D ASN .xlsx differ diff --git a/src/renderer/src/assets/excel/WKM25471-02D装箱单(1).xlsx b/src/renderer/src/assets/excel/WKM25471-02D装箱单(1).xlsx new file mode 100644 index 0000000..c5ccb69 Binary files /dev/null and b/src/renderer/src/assets/excel/WKM25471-02D装箱单(1).xlsx differ diff --git a/src/renderer/src/assets/json/shujuguanli.json b/src/renderer/src/assets/json/shujuguanli.json new file mode 100644 index 0000000..89e58b3 --- /dev/null +++ b/src/renderer/src/assets/json/shujuguanli.json @@ -0,0 +1,50 @@ +[ + { + "label": "姓名", + "prop": "xingming", + "type": "text", + "isSort": false, + "tableShow": true, + "formShow": true + }, + { + "label": "处方照片", + "prop": "chufang", + "type": "photo", + "isSort": false, + "tableShow": true, + "formShow": true + }, + { + "label": "舌苔照片", + "prop": "shetai", + "type": "photo", + "isSort": false, + "tableShow": true, + "formShow": true + }, + { + "label": "备注", + "prop": "note", + "type": "textarea", + "isSort": false, + "tableShow": true, + "formShow": true + }, + { + "label": "创建时间", + "prop": "create_at", + "type": "date", + "isSort": true, + "tableShow": true, + "formShow": true + }, + { + "label": "更新时间", + "prop": "update_at", + "type": "date", + "isSort": true, + "tableShow": true, + "formShow": true + } +] \ No newline at end of file diff --git a/src/renderer/src/components/tablecomponent.vue b/src/renderer/src/components/tablecomponent.vue new file mode 100644 index 0000000..df92f1a --- /dev/null +++ b/src/renderer/src/components/tablecomponent.vue @@ -0,0 +1,75 @@ + + + + diff --git a/src/renderer/src/main.js b/src/renderer/src/main.js new file mode 100644 index 0000000..96377cb --- /dev/null +++ b/src/renderer/src/main.js @@ -0,0 +1,33 @@ +// main.ts +import { createApp } from 'vue' +import ElementPlus from 'element-plus' +import zhCn from 'element-plus/es/locale/lang/zh-cn' +import 'element-plus/dist/index.css' +import App from './App.vue' +import './assets/css/base.css' +import * as ElementPlusIconsVue from '@element-plus/icons-vue' +import VxeUI from 'vxe-pc-ui' +import 'vxe-pc-ui/lib/style.css' +// ... + +// 完整导入 表格库 +import VxeUITable from 'vxe-table' +import 'vxe-table/lib/style.css' + +const app = createApp(App) +// window.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ = true +for (const [key, component] of Object.entries(ElementPlusIconsVue)) { + app.component(key, component) +} +app.use(ElementPlus, { + locale: zhCn, +}) +app.use(VxeUI).use(VxeUITable) +app.mount('#app') + +document.addEventListener('keydown', (event) => { + const { ctrlKey, shiftKey, key } = event + if ((ctrlKey && shiftKey && key === 'I') || key === 'F12') { + return event.preventDefault() + } +}) diff --git a/src/renderer/src/views/shujuguanli.vue b/src/renderer/src/views/shujuguanli.vue new file mode 100644 index 0000000..25252e2 --- /dev/null +++ b/src/renderer/src/views/shujuguanli.vue @@ -0,0 +1,220 @@ + + + +