From 0a0e6677cefba79322b866be92f5353461a52373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Thu, 5 Aug 2021 09:26:13 +0800 Subject: [PATCH] feat: supported psar package --- package.json | 16 +++--- src/common/patch.ts | 3 +- src/main/index.ts | 3 +- src/render/main.ts | 4 +- yarn.lock | 132 ++++++++++++++++++++++---------------------- 5 files changed, 80 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index bce7347..58f6e51 100644 --- a/package.json +++ b/package.json @@ -6,16 +6,18 @@ "license": "MIT", "scripts": { "dev": "npm run dev:all", - "dev:all": "concurrently -n=vue,ele -c=green,blue \"npm run dev:vue\" \"npm run dev:ele\"", + "dev:all": "concurrently -n=vue,pre,ele -c=green,blue \"npm run dev:vue\" \"npm run dev:pre\" \"npm run dev:ele\"", "dev:vue": "vite", + "dev:pre": "node -r ts-node/register script/build-preload --env=development --watch", "dev:ele": "node -r ts-node/register script/build-main --env=development --watch", "build:vue": "vite build", + "build:pre": "node -r ts-node/register script/build-preload --env=production", "build:ele": "node -r ts-node/register script/build-main --env=production", - "build": "rimraf dist && npm run build:vue && npm run build:ele && electron-builder" + "build": "rimraf dist && npm run build:vue && npm run build:pre && npm run build:ele && electron-builder" }, "build": { "appId": "308487730@qq.com", - "asar": false, + "asar": true, "directories": { "output": "release/${version}" }, @@ -52,7 +54,7 @@ } }, "dependencies": { - "vue": "^3.1.2" + "vue": "^3.1.5" }, "devDependencies": { "@rollup/plugin-alias": "^3.1.2", @@ -61,8 +63,8 @@ "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-typescript": "^8.2.1", "@types/minimist": "^1.2.1", - "@vitejs/plugin-vue": "^1.2.3", - "@vue/compiler-sfc": "^3.1.2", + "@vitejs/plugin-vue": "^1.3.0", + "@vue/compiler-sfc": "^3.1.5", "acorn": "^8.2.4", "chalk": "^4.1.0", "concurrently": "^6.0.0", @@ -75,7 +77,7 @@ "rollup-plugin-esbuild": "^4.5.0", "ts-node": "^9.1.1", "typescript": "^4.3.4", - "vite": "^2.3.8", + "vite": "^2.4.4", "vitejs-plugin-electron": "^0.1.3" }, "keywords": [ diff --git a/src/common/patch.ts b/src/common/patch.ts index 4ebac47..e886dfb 100644 --- a/src/common/patch.ts +++ b/src/common/patch.ts @@ -1,4 +1,5 @@ /** * !!! ensure process.cwd() correct + * for load-on preload.js */ -process.chdir(__dirname.slice(0, __dirname.lastIndexOf('dist'))) +// process.chdir(__dirname.slice(0, __dirname.lastIndexOf('dist'))) 21-08-05 remove diff --git a/src/main/index.ts b/src/main/index.ts index 40a1a51..cf6821f 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,7 +1,6 @@ /** * electron 主文件 */ -import '@src/common/patch' import { join } from 'path' import { app, BrowserWindow } from 'electron' import dotenv from 'dotenv' @@ -18,7 +17,7 @@ function createWin() { webPreferences: { nodeIntegration: true, contextIsolation: false, - preload: join(__dirname, '../../src/preload/index.js'), + preload: join(__dirname, '../preload/index.js'), }, }) diff --git a/src/render/main.ts b/src/render/main.ts index 3348700..3bf864a 100644 --- a/src/render/main.ts +++ b/src/render/main.ts @@ -1,4 +1,3 @@ -import '@src/common/patch' import { createApp } from 'vue' import App from './App.vue' import fs = require('fs') @@ -12,7 +11,8 @@ setTimeout(() => { // Configuration name causes hot updates to be slow | 传递 name 后会导致热更新很慢 // console.log('electron-store', new Store({ name: 'electron-vue' })) // https://github.com/caoxiemeihao/electron-vue-vite/issues/10 - console.log('electron-store', new Store()) + + // console.log('electron-store', new Store()) 21-08-05 remove // new Store 会阻塞线程,导致 preload 动画卡顿 }, 2999) diff --git a/yarn.lock b/yarn.lock index a6886fa..e1f728a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -271,42 +271,42 @@ dependencies: "@types/yargs-parser" "*" -"@vitejs/plugin-vue@^1.2.3": - version "1.2.3" - resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-1.2.3.tgz#2e8e008b1cc3a6ad1dfbec75743c7ffd9b4872a6" - integrity sha512-LlnLpObkGKZ+b7dcpL4T24l13nPSHLjo+6Oc7MbZiKz5PMAUzADfNJ3EKfYIQ0l0969nxf2jp/9vsfnuJ7h6fw== +"@vitejs/plugin-vue@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-1.3.0.tgz#fc89a6c9b5a5157916afece4edc8fb55bf1bbc42" + integrity sha512-wJvuJdTBjvucUX0vK4fuy60t+A9bJSZxc59vp1Y+8kiOd0NU5kFt4lay72gMWPeR+lSUjrTmGUq8Uzb99Jbw3A== -"@vue/compiler-core@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.1.2.tgz#31ab1d88e1706a5c7a545faeeb64c31bd0101db0" - integrity sha512-nHmq7vLjq/XM2IMbZUcKWoH5sPXa2uR/nIKZtjbK5F3TcbnYE/zKsrSUR9WZJ03unlwotNBX1OyxVt9HbWD7/Q== +"@vue/compiler-core@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.1.5.tgz#298f905b6065d6d81ff63756f98c60876b393c87" + integrity sha512-TXBhFinoBaXKDykJzY26UEuQU1K07FOp/0Ie+OXySqqk0bS0ZO7Xvl7UmiTUPYcLrWbxWBR7Bs/y55AI0MNc2Q== dependencies: "@babel/parser" "^7.12.0" "@babel/types" "^7.12.0" - "@vue/shared" "3.1.2" + "@vue/shared" "3.1.5" estree-walker "^2.0.1" source-map "^0.6.1" -"@vue/compiler-dom@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.1.2.tgz#75a7731bcc5d9718183a3c56c18e992f7c13e7b1" - integrity sha512-k2+SWcWH0jL6WQAX7Or2ONqu5MbtTgTO0dJrvebQYzgqaKMXNI90RNeWeCxS4BnNFMDONpHBeFgbwbnDWIkmRg== +"@vue/compiler-dom@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.1.5.tgz#cbb97020c62a5faa3fbc2a97916bd98041ac9856" + integrity sha512-ZsL3jqJ52OjGU/YiT/9XiuZAmWClKInZM2aFJh9gnsAPqOrj2JIELMbkIFpVKR/CrVO/f2VxfPiiQdQTr65jcQ== dependencies: - "@vue/compiler-core" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/compiler-core" "3.1.5" + "@vue/shared" "3.1.5" -"@vue/compiler-sfc@^3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.1.2.tgz#23ff1e366d887b964899568bffcb11e3d0511fc4" - integrity sha512-SeG/2+DvwejQ7oAiSx8BrDh5qOdqCYHGClPiTvVIHTfSIHiS2JjMbCANdDCjHkTOh/O7WZzo2JhdKm98bRBxTw== +"@vue/compiler-sfc@^3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.1.5.tgz#e61e54f3a963b0f4a8e523fbb8632390dc52b0d6" + integrity sha512-mtMY6xMvZeSRx9MTa1+NgJWndrkzVTdJ1pQAmAKQuxyb5LsHVvrgP7kcQFvxPHVpLVTORbTJWHaiqoKrJvi1iA== dependencies: "@babel/parser" "^7.13.9" "@babel/types" "^7.13.0" "@types/estree" "^0.0.48" - "@vue/compiler-core" "3.1.2" - "@vue/compiler-dom" "3.1.2" - "@vue/compiler-ssr" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/compiler-core" "3.1.5" + "@vue/compiler-dom" "3.1.5" + "@vue/compiler-ssr" "3.1.5" + "@vue/shared" "3.1.5" consolidate "^0.16.0" estree-walker "^2.0.1" hash-sum "^2.0.0" @@ -318,42 +318,42 @@ postcss-selector-parser "^6.0.4" source-map "^0.6.1" -"@vue/compiler-ssr@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.1.2.tgz#e33ad0876d9b96f0950e22b0e174b94c1b049d2d" - integrity sha512-BwXo9LFk5OSWdMyZQ4bX1ELHX0Z/9F+ld/OaVnpUPzAZCHslBYLvyKUVDwv2C/lpLjRffpC2DOUEdl1+RP1aGg== +"@vue/compiler-ssr@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.1.5.tgz#f068652774293256a1e53084bed48a67682df9d2" + integrity sha512-CU5N7Di/a4lyJ18LGJxJYZS2a8PlLdWpWHX9p/XcsjT2TngMpj3QvHVRkuik2u8QrIDZ8OpYmTyj1WDNsOV+Dg== dependencies: - "@vue/compiler-dom" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/compiler-dom" "3.1.5" + "@vue/shared" "3.1.5" -"@vue/reactivity@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.1.2.tgz#66fa530dd726d2fef285ae55d02106a727db463b" - integrity sha512-glJzJoN2xE7I2lRvwKM5u1BHRPTd1yc8iaf//Lai/78/uYAvE5DXp5HzWRFOwMlbRvMGJHIQjOqoxj87cDAaag== +"@vue/reactivity@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.1.5.tgz#dbec4d9557f7c8f25c2635db1e23a78a729eb991" + integrity sha512-1tdfLmNjWG6t/CsPldh+foumYFo3cpyCHgBYQ34ylaMsJ+SNHQ1kApMIa8jN+i593zQuaw3AdWH0nJTARzCFhg== dependencies: - "@vue/shared" "3.1.2" + "@vue/shared" "3.1.5" -"@vue/runtime-core@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.1.2.tgz#f4dbc503cfc9a02ab5f1ebe002c3322512064a54" - integrity sha512-gsPZG4dRIkixuuKmoj4P9IHgfT0yaFLcqWOM5F/bCk0nxQn1XtxH8oUehWuET726KhbukvDoJfe9G2CKviy80w== +"@vue/runtime-core@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.1.5.tgz#a545b7f146092929cb5e833e85439150f17ac87b" + integrity sha512-YQbG5cBktN1RowQDKA22itmvQ+b40f0WgQ6CXK4VYoYICAiAfu6Cc14777ve8zp1rJRGtk5oIeS149TOculrTg== dependencies: - "@vue/reactivity" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/reactivity" "3.1.5" + "@vue/shared" "3.1.5" -"@vue/runtime-dom@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.1.2.tgz#0fd8724f14bc7ba64b6c954d874a8d8a4fcb5fe9" - integrity sha512-QvINxjLucEZFzp5f0NVu7JqWYCv5TKQfkH2FDs/N6QNE4iKcYtKrWdT0HKfABnVXG28Znqv6rIH0dH4ZAOwxpA== +"@vue/runtime-dom@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.1.5.tgz#4fa28947d408aa368fa17ea0edc1beb9af1472a1" + integrity sha512-tNcf3JhVR0RfW0kw1p8xZgv30nvX8Y9rsz7eiQ0dHe273sfoCngAG0y4GvMaY4Xd8FsjUwFedd4suQ8Lu8meXg== dependencies: - "@vue/runtime-core" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/runtime-core" "3.1.5" + "@vue/shared" "3.1.5" csstype "^2.6.8" -"@vue/shared@3.1.2": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.2.tgz#1069c0bc7d6f4bd15ccf3a5f3be29450aca368f9" - integrity sha512-EmH/poaDWBPJaPILXNI/1fvUbArJQmmTyVCwvvyDYDFnkPoTclAbHRAtyIvqfez7jybTDn077HTNILpxlsoWhg== +"@vue/shared@3.1.5": + version "3.1.5" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.1.5.tgz#74ee3aad995d0a3996a6bb9533d4d280514ede03" + integrity sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA== acorn@^8.2.4: version "8.2.4" @@ -2162,10 +2162,10 @@ postcss@^8.1.10: nanoid "^3.1.20" source-map "^0.6.1" -postcss@^8.3.4: - version "8.3.5" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.5.tgz#982216b113412bc20a86289e91eb994952a5b709" - integrity sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA== +postcss@^8.3.6: + version "8.3.6" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.6.tgz#2730dd76a97969f37f53b9a6096197be311cc4ea" + integrity sha512-wG1cc/JhRgdqB6WHEuyLTedf3KIRuD0hG6ldkFEZNCjRxiC+3i6kkWUUbiJQayP28iwG35cEmAbe98585BYV0A== dependencies: colorette "^1.2.2" nanoid "^3.1.23" @@ -2831,13 +2831,13 @@ version-range@^1.0.0: dependencies: version-compare "^1.0.0" -vite@^2.3.8: - version "2.3.8" - resolved "https://registry.yarnpkg.com/vite/-/vite-2.3.8.tgz#42e3e03953859fd410e4e6ab3d1cca0aab2adc3c" - integrity sha512-QiEx+iqNnJntSgSF2fWRQvRey9pORIrtNJzNyBJXwc+BdzWs83FQolX84cTBo393cfhObrtWa6180dAa4NLDiQ== +vite@^2.4.4: + version "2.4.4" + resolved "https://registry.yarnpkg.com/vite/-/vite-2.4.4.tgz#8c402a07ad45f168f6eb5428bead38f3e4363e47" + integrity sha512-m1wK6pFJKmaYA6AeZIUXyiAgUAAJzVXhIMYCdZUpCaFMGps0v0IlNJtbmPvkUhVEyautalajmnW5X6NboUPsnw== dependencies: esbuild "^0.12.8" - postcss "^8.3.4" + postcss "^8.3.6" resolve "^1.20.0" rollup "^2.38.5" optionalDependencies: @@ -2848,14 +2848,14 @@ vitejs-plugin-electron@^0.1.3: resolved "https://registry.yarnpkg.com/vitejs-plugin-electron/-/vitejs-plugin-electron-0.1.3.tgz#a45ff488f6ddf577d6dd1f6a7e52dbee26955f13" integrity sha512-xZBFj1IbycpSOSp27J+kD/0PQ+W5GDdF9nBxuZs75MPl1W37Blh4+WjBXZHNwpuTxEonPlcqUvEP+FGgUzjkpQ== -vue@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/vue/-/vue-3.1.2.tgz#647f8e3949a3d600771dca25d50225dc3e594c64" - integrity sha512-q/rbKpb7aofax4ugqu2k/uj7BYuNPcd6Z5/qJtfkJQsE0NkwVoCyeSh7IZGH61hChwYn3CEkh4bHolvUPxlQ+w== +vue@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/vue/-/vue-3.1.5.tgz#12879b11d0685ee4478c8869551799630a52f9fe" + integrity sha512-Ho7HNb1nfDoO+HVb6qYZgeaobt1XbY6KXFe4HGs1b9X6RhkWG/113n4/SrtM1LUclM6OrP/Se5aPHHvAPG1iVQ== dependencies: - "@vue/compiler-dom" "3.1.2" - "@vue/runtime-dom" "3.1.2" - "@vue/shared" "3.1.2" + "@vue/compiler-dom" "3.1.5" + "@vue/runtime-dom" "3.1.5" + "@vue/shared" "3.1.5" wcwidth@^1.0.1: version "1.0.1"