|
|
@@ -6,24 +6,28 @@
|
|
|
|
|
|
// @ts-ignore - 路径别名在构建时会被正确解析
|
|
|
import { generateImagesBase64 } from '@/views/components/marketingEdit/generateImagesRender'
|
|
|
+import pinia from "@/stores/index";
|
|
|
|
|
|
// @ts-ignore - Node.js require 在Electron环境中可用
|
|
|
type NodeRequire = typeof require
|
|
|
|
|
|
let started = false
|
|
|
|
|
|
-export function startGenerateServer() {
|
|
|
+export async function startGenerateServer( ) {
|
|
|
+ setTimeout(() => {
|
|
|
+
|
|
|
if (started) return
|
|
|
+
|
|
|
// 仅在具有 Node 能力(Electron 渲染进程)时启动
|
|
|
const nodeRequire: NodeRequire | undefined = (window as any)?.require
|
|
|
if (!nodeRequire) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ const appConfig = pinia.state.value.config?.appConfig;
|
|
|
+ const PORT = appConfig.PORT || 3001
|
|
|
const http = nodeRequire('http')
|
|
|
-
|
|
|
- const PORT = 3001
|
|
|
- started = true
|
|
|
+ started = true
|
|
|
|
|
|
http
|
|
|
.createServer(async (req: any, res: any) => {
|
|
|
@@ -64,6 +68,7 @@ export function startGenerateServer() {
|
|
|
.listen(PORT, () => {
|
|
|
console.log(`[generateServer] listening on http://localhost:${PORT}/generate`)
|
|
|
})
|
|
|
+ }, 2000)
|
|
|
}
|
|
|
|
|
|
// 自动启动(在 Electron 渲染进程)
|