From 49f4b9618e89104d84525306be70e74c8b5e355f Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sun, 10 Sep 2023 02:10:57 +0800 Subject: [PATCH] Add: AppAsarUpdate and GitOverCdn --- config/deploy.template-cn.yaml | 3 +++ config/deploy.template.yaml | 3 +++ deploy/Windows/app.py | 4 ++-- deploy/Windows/config.py | 14 +++++++++++++- deploy/Windows/template.yaml | 3 +++ module/config/config_updater.py | 16 ++++++++++++++++ webapp/packages/main/public/deploy.yaml.tpl | 8 ++++---- .../renderer/src/logics/initAppConfigStore.ts | 2 +- webapp/types/index.d.ts | 1 + 9 files changed, 46 insertions(+), 8 deletions(-) diff --git a/config/deploy.template-cn.yaml b/config/deploy.template-cn.yaml index 7ada7614a..4afd7c6c5 100644 --- a/config/deploy.template-cn.yaml +++ b/config/deploy.template-cn.yaml @@ -157,6 +157,9 @@ Deploy: # '["alas"]' specified "alas" config # '["alas","alas2"]' specified "alas" "alas2" configs Run: null + # To update app.asar + # [In most cases] true + AppAsarUpdate: true # --no-sandbox. https://github.com/electron/electron/issues/30966 # Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode NoSandbox: false diff --git a/config/deploy.template.yaml b/config/deploy.template.yaml index 8d9fa3c53..cbeee0cb6 100644 --- a/config/deploy.template.yaml +++ b/config/deploy.template.yaml @@ -157,6 +157,9 @@ Deploy: # '["alas"]' specified "alas" config # '["alas","alas2"]' specified "alas" "alas2" configs Run: null + # To update app.asar + # [In most cases] true + AppAsarUpdate: true # --no-sandbox. https://github.com/electron/electron/issues/30966 # Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode NoSandbox: false diff --git a/deploy/Windows/app.py b/deploy/Windows/app.py index 80733af02..c558a1a3f 100644 --- a/deploy/Windows/app.py +++ b/deploy/Windows/app.py @@ -48,8 +48,8 @@ class AppManager(DeployConfig): def app_update(self): logger.hr(f'Update app', 0) - if not self.AutoUpdate: - logger.info('AutoUpdate is disabled, skip') + if not self.AppAsarUpdate: + logger.info('AppAsarUpdate is disabled, skip') Progress.UpdateAlasApp() return False diff --git a/deploy/Windows/config.py b/deploy/Windows/config.py index 58dfece14..6939d9cc8 100644 --- a/deploy/Windows/config.py +++ b/deploy/Windows/config.py @@ -55,13 +55,18 @@ class ConfigModel: # Webui WebuiHost: str = "0.0.0.0" - WebuiPort: int = 22267 + WebuiPort: int = 22367 Language: str = "en-US" Theme: str = "default" DpiScaling: bool = True Password: Optional[str] = None CDN: Union[str, bool] = False Run: Optional[str] = None + AppAsarUpdate: bool = True + NoSandbox: bool = True + + # Dynamic + GitOverCdn: bool = False class DeployConfig(ConfigModel): @@ -75,6 +80,13 @@ class DeployConfig(ConfigModel): self.config_template = {} self.read() + self.GitOverCdn = self.Repository in ['cn'] + if self.Repository in [ + 'cn', + 'global', + ]: + self.Repository = 'https://github.com/LmeSzinc/StarRailCopilot' + self.write() self.show_config() diff --git a/deploy/Windows/template.yaml b/deploy/Windows/template.yaml index 540f28ef4..045b076a8 100644 --- a/deploy/Windows/template.yaml +++ b/deploy/Windows/template.yaml @@ -157,6 +157,9 @@ Deploy: # '["alas"]' specified "alas" config # '["alas","alas2"]' specified "alas" "alas2" configs Run: null + # To update app.asar + # [In most cases] true + AppAsarUpdate: true # --no-sandbox. https://github.com/electron/electron/issues/30966 # Some Windows systems cannot call the GPU normally for virtualization, and you need to manually turn off sandbox mode NoSandbox: false diff --git a/module/config/config_updater.py b/module/config/config_updater.py index 8b12d3618..bd9f8fae3 100644 --- a/module/config/config_updater.py +++ b/module/config/config_updater.py @@ -504,6 +504,22 @@ class ConfigGenerator: # update('template-docker', docker) # update('template-docker-cn', docker, cn) + tpl = { + 'Repository': '{{repository}}', + 'GitExecutable': '{{gitExecutable}}', + 'PythonExecutable': '{{pythonExecutable}}', + 'AdbExecutable': '{{adbExecutable}}', + 'Language': '{{language}}', + 'Theme': '{{theme}}', + } + def update(file, *args): + new = deepcopy(template) + for dic in args: + new.update(dic) + poor_yaml_write(data=new, file=file) + + update('./webapp/packages/main/public/deploy.yaml.tpl', tpl) + def insert_assignment(self): from tasks.assignment.keywords import AssignmentEntry assignments = [entry.name for entry in AssignmentEntry.instances.values()] diff --git a/webapp/packages/main/public/deploy.yaml.tpl b/webapp/packages/main/public/deploy.yaml.tpl index 58732023f..b10205915 100644 --- a/webapp/packages/main/public/deploy.yaml.tpl +++ b/webapp/packages/main/public/deploy.yaml.tpl @@ -1,8 +1,8 @@ Deploy: Git: # URL of AzurLaneAutoScript repository - # [CN user] Use 'git://git.lyoko.io/AzurLaneAutoScript' for faster and more stable download - # [Other] Use 'https://github.com/LmeSzinc/AzurLaneAutoScript' + # [CN user] Use 'cn' to get update from git-over-cdn service + # [Other] Use 'global' to get update from https://github.com/LmeSzinc/StarRailCopilot Repository: {{repository}} # Branch of Alas # [Developer] Use 'dev', 'app', etc, to try new features @@ -128,8 +128,8 @@ Deploy: WebuiHost: 0.0.0.0 # --port. Port to listen # You will be able to access webui via `http://{host}:{port}` - # [In most cases] Default to 22267 - WebuiPort: 22267 + # [In most cases] Default to 22367 + WebuiPort: 22367 # Language to use on web ui # 'zh-CN' for Chinese simplified # 'en-US' for English diff --git a/webapp/packages/renderer/src/logics/initAppConfigStore.ts b/webapp/packages/renderer/src/logics/initAppConfigStore.ts index c7eeb1866..11b61c617 100644 --- a/webapp/packages/renderer/src/logics/initAppConfigStore.ts +++ b/webapp/packages/renderer/src/logics/initAppConfigStore.ts @@ -9,6 +9,6 @@ export async function initAppConfigStore() { appStore.setRepository( (repositoryValueMap[config?.repository] as 'global' | 'china') ?? 'global', ); - appStore.setWebuiUrl(config?.webuiUrl ?? '127.0.0.1:22267'); + appStore.setWebuiUrl(config?.webuiUrl ?? '127.0.0.1:22367'); appStore.setAlasPath(config?.alasPath ?? ''); } diff --git a/webapp/types/index.d.ts b/webapp/types/index.d.ts index 7e62fef5e..94074b52d 100644 --- a/webapp/types/index.d.ts +++ b/webapp/types/index.d.ts @@ -64,6 +64,7 @@ declare interface DefAlasConfig { Password: null | string; CDN: boolean; Run: null | string; + AppAsarUpdate: boolean; NoSandbox: boolean; }; };