Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6c52bf7

Browse files
authored
Merge pull request #128 from solidSpoon/测试安装包
Windows 支持选择安装位置
2 parents 6420630 + e8d5d38 commit 6c52bf7

File tree

4 files changed

+65
-40
lines changed

4 files changed

+65
-40
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
uses: actions/setup-node@v4
2424
with:
2525
node-version: 20
26+
- name: Install WiX Toolset (Windows only)
27+
if: matrix.os.name == 'windows'
28+
run: |
29+
choco install wixtoolset
30+
echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH
2631
- run: yarn install --frozen-lockfile
2732
- name: Publish app
2833
env:

forge.config.ts

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
import type {ForgeConfig} from '@electron-forge/shared-types';
2-
import {MakerSquirrel} from '@electron-forge/maker-squirrel';
3-
import {MakerDeb} from '@electron-forge/maker-deb';
4-
import {MakerRpm} from '@electron-forge/maker-rpm';
5-
import {VitePlugin} from '@electron-forge/plugin-vite';
6-
import {FusesPlugin} from '@electron-forge/plugin-fuses';
7-
import {FuseV1Options, FuseVersion} from '@electron/fuses';
1+
import type { ForgeConfig } from '@electron-forge/shared-types';
2+
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
3+
import { MakerDeb } from '@electron-forge/maker-deb';
4+
import { MakerRpm } from '@electron-forge/maker-rpm';
5+
import { MakerWix } from '@electron-forge/maker-wix';
6+
import { VitePlugin } from '@electron-forge/plugin-vite';
7+
import { FusesPlugin } from '@electron-forge/plugin-fuses';
8+
import { FuseV1Options, FuseVersion } from '@electron/fuses';
89
import MakerDMG from '@electron-forge/maker-dmg';
10+
import packageJson from './package.json';
11+
import path from 'node:path';
12+
import fs from 'node:fs/promises';
13+
914

1015
const config: ForgeConfig = {
1116
packagerConfig: {
1217
asar: true,
1318
icon: './assets/icons/icon',
14-
extraResource: ["./drizzle", "./lib", "./scripts"],
19+
extraResource: ['./drizzle', './lib', './scripts'],
1520
executableName: 'dash-player',
1621
name: 'DashPlayer',
1722
},
@@ -25,46 +30,42 @@ const config: ForgeConfig = {
2530
}),
2631
new MakerDMG({
2732
icon: './assets/icons/icon.icns',
28-
format: 'ULFO'
33+
format: 'ULFO',
2934
}),
3035
new MakerRpm({
3136
options: {
3237
name: 'dash-player',
3338
productName: 'DashPlayer',
3439
icon: './assets/icons/icon.png',
35-
}
40+
},
3641
}),
3742
new MakerDeb({
3843
options: {
3944
name: 'dash-player',
4045
productName: 'DashPlayer',
4146
icon: './assets/icons/icon.png',
42-
}
43-
})],
47+
},
48+
}),
49+
new MakerWix({
50+
name: 'DashPlayer',
51+
description: 'A video player for English learning',
52+
manufacturer: 'solidSpoon',
53+
version: packageJson.version,
54+
icon: './assets/icons/icon.ico',
55+
exe: 'dash-player.exe',
56+
ui: {
57+
chooseDirectory: true,
58+
},
59+
}),
60+
],
4461
plugins: [
4562
new VitePlugin({
46-
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
47-
// If you are familiar with Vite configuration, it will look really familiar.
4863
build: [
49-
{
50-
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
51-
entry: 'src/main.ts',
52-
config: 'vite.main.config.ts',
53-
},
54-
{
55-
entry: 'src/preload.ts',
56-
config: 'vite.preload.config.ts',
57-
},
58-
],
59-
renderer: [
60-
{
61-
name: 'main_window',
62-
config: 'vite.renderer.config.ts',
63-
},
64+
{ entry: 'src/main.ts', config: 'vite.main.config.ts' },
65+
{ entry: 'src/preload.ts', config: 'vite.preload.config.ts' },
6466
],
67+
renderer: [{ name: 'main_window', config: 'vite.renderer.config.ts' }],
6568
}),
66-
// Fuses are used to enable/disable various Electron functionality
67-
// at package time, before code signing the application
6869
new FusesPlugin({
6970
version: FuseVersion.V1,
7071
[FuseV1Options.RunAsNode]: false,
@@ -79,14 +80,33 @@ const config: ForgeConfig = {
7980
{
8081
name: '@electron-forge/publisher-github',
8182
config: {
82-
repository: {
83-
owner: 'solidSpoon',
84-
name: 'DashPlayer'
85-
},
86-
prerelease: true
83+
repository: { owner: 'solidSpoon', name: 'DashPlayer' },
84+
prerelease: true,
85+
},
86+
},
87+
],
88+
hooks: {
89+
postMake: async (_forgeConfig, makeResults) => {
90+
const version = packageJson.version;
91+
for (const result of makeResults) {
92+
if (result.platform !== 'win32') continue;
93+
for (let i = 0; i < result.artifacts.length; i++) {
94+
const oldPath = result.artifacts[i];
95+
if (!oldPath.toLowerCase().endsWith('.msi')) continue;
96+
const dir = path.dirname(oldPath);
97+
const arch = result.arch; // 'x64' | 'ia32' | 'arm64'
98+
const newPath = path.join(dir, `DashPlayer-${version}-${arch}.msi`);
99+
if (oldPath !== newPath) {
100+
await fs.rename(oldPath, newPath);
101+
// 更新 artifacts,确保 Publisher 上传重命名后的文件
102+
result.artifacts[i] = newPath;
103+
console.log(`Renamed MSI: ${oldPath} -> ${newPath}`);
104+
}
105+
}
87106
}
88-
}
89-
]
107+
return makeResults;
108+
},
109+
},
90110
};
91111

92112
export default config;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dash-player",
33
"productName": "DashPlayer",
4-
"version": "5.1.7",
4+
"version": "5.1.8",
55
"description": "My Electron application description",
66
"main": ".vite/build/main.js",
77
"scripts": {

src/fronted/hooks/use-copy-to-clipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface useCopyToClipboardProps {
99
export function useCopyToClipboard({
1010
timeout = 2000
1111
}: useCopyToClipboardProps) {
12-
const [isCopied, setIsCopied] = React.useState<Boolean>(false)
12+
const [isCopied, setIsCopied] = React.useState<boolean>(false)
1313

1414
const copyToClipboard = (value: string) => {
1515
if (typeof window === 'undefined' || !navigator.clipboard?.writeText) {

0 commit comments

Comments
 (0)