custom substore icon

This commit is contained in:
pompurin404 2024-09-04 21:17:03 +08:00
parent 72faa1e5c2
commit 74fa513f83
No known key found for this signature in database
2 changed files with 7 additions and 1 deletions

BIN
resources/subStoreIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1,9 +1,11 @@
import { getAppConfig, getControledMihomoConfig } from '../config'
import { Worker } from 'worker_threads'
import { resourcesFilesDir, subStoreDir } from '../utils/dirs'
import subStoreIcon from '../../../resources/subStoreIcon.png?asset'
import http from 'http'
import net from 'net'
import path from 'path'
import { nativeImage } from 'electron'
export let pacPort: number
export let subStorePort: number
@ -57,10 +59,14 @@ export async function startSubStoreServer(): Promise<void> {
if (!useSubStore || useCustomSubStore) return
if (subStorePort) return
subStorePort = await findAvailablePort(3000)
const icon = nativeImage.createFromPath(subStoreIcon)
icon.toDataURL()
new Worker(path.join(resourcesFilesDir(), 'sub-store.bundle.js'), {
env: {
SUB_STORE_BACKEND_API_PORT: subStorePort.toString(),
SUB_STORE_DATA_BASE_PATH: subStoreDir()
SUB_STORE_DATA_BASE_PATH: subStoreDir(),
SUB_STORE_BACKEND_CUSTOM_ICON: icon.toDataURL(),
SUB_STORE_BACKEND_CUSTOM_NAME: 'Mihomo Party'
}
})
}