Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ asarUnpack:
- "**/node_modules/sharp/**"

# 图标配置
icon: build/icon.ico
icon: build/icon.png

win:
executableName: moyin-creator
Expand All @@ -29,6 +29,17 @@ win:
arch:
- x64

mac:
icon: build/icon.png
target:
- dmg
- zip

linux:
icon: build/icon.png
target:
- AppImage

# NSIS 安装包配置
nsis:
artifactName: ${name}-${version}-setup.${ext}
Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "moyin-creator",
"productName": "魔因漫创",
"version": "0.1.7",
"version": "0.1.7",
"description": "AI 驱动的动漫/短剧分镜创作工具",
"author": "MemeCalculate",
"license": "AGPL-3.0-or-later",
Expand All @@ -16,9 +16,15 @@
"type": "module",
"scripts": {
"dev": "electron-vite dev",
"build": "electron-vite build && electron-builder --win",
"prebuild": "powershell -Command \"Stop-Process -Name 'moyin-creator' -ErrorAction SilentlyContinue; Stop-Process -Name '魔因漫创' -ErrorAction SilentlyContinue; Stop-Process -Name 'moyin-creator-*-setup' -ErrorAction SilentlyContinue; if (Test-Path release) { Remove-Item -Recurse -Force release -ErrorAction SilentlyContinue }\"",
"build:win": "electron-vite build && electron-builder --win",
"clean:release": "node ./scripts/clean-release.mjs",
"build:app": "electron-vite build",
"pack:win": "electron-builder --win",
"pack:mac": "electron-builder --mac",
"pack:linux": "electron-builder --linux",
"build": "node ./scripts/build-by-platform.mjs",
"build:win": "npm run clean:release && npm run build:app && npm run pack:win",
"build:mac": "npm run clean:release && npm run build:app && npm run pack:mac",
"build:linux": "npm run clean:release && npm run build:app && npm run pack:linux",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "electron-vite preview"
},
Expand Down
24 changes: 24 additions & 0 deletions scripts/build-by-platform.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { spawnSync } from 'node:child_process'

const buildScriptByPlatform = {
win32: 'build:win',
darwin: 'build:mac',
linux: 'build:linux'
}

const selectedScript = buildScriptByPlatform[process.platform]

if (!selectedScript) {
console.error(`Unsupported platform: ${process.platform}`)
process.exit(1)
}

const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const child = spawnSync(npmCommand, ['run', selectedScript], { stdio: 'inherit' })

if (child.error) {
console.error(child.error.message)
process.exit(1)
}

process.exit(child.status ?? 1)
28 changes: 28 additions & 0 deletions scripts/clean-release.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { existsSync, rmSync } from 'node:fs'
import { spawnSync } from 'node:child_process'

const processPatterns = ['moyin-creator', '魔因漫创']

function killRunningProcesses() {
if (process.platform === 'win32') {
for (const pattern of processPatterns) {
spawnSync('taskkill', ['/F', '/IM', `${pattern}.exe`], { stdio: 'ignore' })
}
return
}

for (const pattern of processPatterns) {
spawnSync('pkill', ['-f', pattern], { stdio: 'ignore' })
}
}

function cleanReleaseDirectory() {
if (!existsSync('release')) {
return
}
rmSync('release', { recursive: true, force: true })
}

killRunningProcesses()
cleanReleaseDirectory()
console.log('Cleaned release directory and attempted to stop running app processes.')