Refactor site update logic in ConfigStore and format JSON structure in package.json for better readability

This commit is contained in:
ethanfly 2025-12-26 03:36:29 +08:00
parent 24dc4c739b
commit 9103faec32
2 changed files with 16 additions and 13 deletions

View File

@ -187,20 +187,16 @@ export class ConfigStore {
} }
} }
updateSite(originalName: string, site: any): void {
const sites = this.store.get('sites')
const index = sites.findIndex(s => s.name === originalName)
if (index > -1) {
sites[index] = site
this.store.set('sites', sites)
}
}
updateSite(name: string, site: Partial<SiteConfig>): void { updateSite(name: string, site: Partial<SiteConfig>): void {
const sites = this.store.get('sites') const sites = this.store.get('sites')
const index = sites.findIndex(s => s.name === name) const index = sites.findIndex(s => s.name === name)
if (index > -1) { if (index > -1) {
sites[index] = { ...sites[index], ...site } // 如果传入完整对象则替换,否则合并
if (site.domain && site.rootPath) {
sites[index] = site as SiteConfig
} else {
sites[index] = { ...sites[index], ...site }
}
this.store.set('sites', sites) this.store.set('sites', sites)
} }
} }

View File

@ -53,7 +53,9 @@
"target": [ "target": [
{ {
"target": "nsis", "target": "nsis",
"arch": ["x64"] "arch": [
"x64"
]
} }
], ],
"requestedExecutionLevel": "requireAdministrator" "requestedExecutionLevel": "requireAdministrator"
@ -66,7 +68,10 @@
"createDesktopShortcut": true, "createDesktopShortcut": true,
"createStartMenuShortcut": true, "createStartMenuShortcut": true,
"shortcutName": "PHPer开发环境管理器", "shortcutName": "PHPer开发环境管理器",
"installerLanguages": ["zh_CN", "en_US"], "installerLanguages": [
"zh_CN",
"en_US"
],
"language": "2052", "language": "2052",
"runAfterFinish": true, "runAfterFinish": true,
"deleteAppDataOnUninstall": false, "deleteAppDataOnUninstall": false,
@ -76,7 +81,9 @@
{ {
"from": "public/", "from": "public/",
"to": "public/", "to": "public/",
"filter": ["**/*"] "filter": [
"**/*"
]
} }
] ]
} }