fix substore server

This commit is contained in:
pompurin404 2024-09-05 12:51:58 +08:00
parent 8e00cb4bbf
commit 2f54934b85
No known key found for this signature in database

View File

@ -58,21 +58,24 @@ export async function startPacServer(): Promise<void> {
export async function startSubStoreServer(): Promise<void> { export async function startSubStoreServer(): Promise<void> {
const { useSubStore = true, useCustomSubStore = false } = await getAppConfig() const { useSubStore = true, useCustomSubStore = false } = await getAppConfig()
if (!useSubStore || useCustomSubStore) return if (!useSubStore) return
if (subStorePort) return if (!subStoreFrontendPort) {
subStorePort = await findAvailablePort(3000) subStoreFrontendPort = await findAvailablePort(4000)
subStoreFrontendPort = await findAvailablePort(4000) const app = express()
const icon = nativeImage.createFromPath(subStoreIcon) app.use(express.static(path.join(resourcesFilesDir(), 'sub-store-frontend')))
icon.toDataURL() app.listen(subStoreFrontendPort)
new Worker(path.join(resourcesFilesDir(), 'sub-store.bundle.js'), { }
env: { if (!useCustomSubStore && !subStorePort) {
SUB_STORE_BACKEND_API_PORT: subStorePort.toString(), subStorePort = await findAvailablePort(3000)
SUB_STORE_DATA_BASE_PATH: subStoreDir(), const icon = nativeImage.createFromPath(subStoreIcon)
SUB_STORE_BACKEND_CUSTOM_ICON: icon.toDataURL(), icon.toDataURL()
SUB_STORE_BACKEND_CUSTOM_NAME: 'Mihomo Party' new Worker(path.join(resourcesFilesDir(), 'sub-store.bundle.js'), {
} env: {
}) SUB_STORE_BACKEND_API_PORT: subStorePort.toString(),
const app = express() SUB_STORE_DATA_BASE_PATH: subStoreDir(),
app.use(express.static(path.join(resourcesFilesDir(), 'sub-store-frontend'))) SUB_STORE_BACKEND_CUSTOM_ICON: icon.toDataURL(),
app.listen(subStoreFrontendPort) SUB_STORE_BACKEND_CUSTOM_NAME: 'Mihomo Party'
}
})
}
} }