From d29dd915c1fa71f7320afea10f9e2376a5e1f5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=99=E7=A0=81=E7=94=9F=E8=8A=B1?= <18523774412@qq.com> Date: Wed, 3 Jan 2024 15:00:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E8=87=AA=E5=AE=9A=E4=B9=89=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=85=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/routine/Config.php | 16 +++++++++------- web/src/views/backend/routine/config/index.vue | 12 +++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/routine/Config.php b/app/admin/controller/routine/Config.php index c3f0d86b..de6cdf3d 100644 --- a/app/admin/controller/routine/Config.php +++ b/app/admin/controller/routine/Config.php @@ -102,11 +102,11 @@ class Config extends Backend // 修改 adminBaseRoutePath $adminBaseFilePath = Filesystem::fsFit(root_path() . $this->filePath['webAdminBase']); $adminBaseContent = @file_get_contents($adminBaseFilePath); - if (!$adminBaseContent) $this->error('Configuration write failed: %s', [$this->filePath['webAdminBase']]); + if (!$adminBaseContent) $this->error(__('Configuration write failed: %s', [$this->filePath['webAdminBase']])); $adminBaseContent = str_replace("export const adminBaseRoutePath = '$backendEntrance'", "export const adminBaseRoutePath = '{$data[$item->name]}'", $adminBaseContent); $result = @file_put_contents($adminBaseFilePath, $adminBaseContent); - if (!$result) $this->error('Configuration write failed: %s', [$this->filePath['webAdminBase']]); + if (!$result) $this->error(__('Configuration write failed: %s', [$this->filePath['webAdminBase']])); // 去除后台入口开头的斜杠 $oldBackendEntrance = ltrim($backendEntrance, '/'); @@ -117,7 +117,7 @@ class Config extends Backend if (!in_array('admin', $denyAppList)) { $appConfigFilePath = Filesystem::fsFit(root_path() . $this->filePath['appConfig']); $appConfigContent = @file_get_contents($appConfigFilePath); - if (!$appConfigContent) $this->error('Configuration write failed: %s', [$this->filePath['appConfig']]); + if (!$appConfigContent) $this->error(__('Configuration write failed: %s', [$this->filePath['appConfig']])); $denyAppListStr = ''; foreach ($denyAppList as $appName) { @@ -129,7 +129,7 @@ class Config extends Backend $appConfigContent = preg_replace("/'deny_app_list'(\s+)=>(\s+)(.*)/", "'deny_app_list'\$1=>\$2$denyAppListStr,", $appConfigContent); $result = @file_put_contents($appConfigFilePath, $appConfigContent); - if (!$result) $this->error('Configuration write failed: %s', [$this->filePath['appConfig']]); + if (!$result) $this->error(__('Configuration write failed: %s', [$this->filePath['appConfig']])); } // 建立API入口文件 @@ -137,9 +137,11 @@ class Config extends Backend $newBackendEntranceFile = Filesystem::fsFit(public_path() . $newBackendEntrance . '.php'); if (file_exists($oldBackendEntranceFile)) @unlink($oldBackendEntranceFile); - $backendEntranceStub = @file_get_contents(Filesystem::fsFit($this->filePath['backendEntranceStub'])); - $result = @file_put_contents($newBackendEntranceFile, $backendEntranceStub); - if (!$result) $this->error('Configuration write failed: %s', [$newBackendEntranceFile]); + $backendEntranceStub = @file_get_contents(Filesystem::fsFit(root_path() . $this->filePath['backendEntranceStub'])); + if (!$backendEntranceStub) $this->error(__('Configuration write failed: %s', [$this->filePath['backendEntranceStub']])); + + $result = @file_put_contents($newBackendEntranceFile, $backendEntranceStub); + if (!$result) $this->error(__('Configuration write failed: %s', [$newBackendEntranceFile])); } } } diff --git a/web/src/views/backend/routine/config/index.vue b/web/src/views/backend/routine/config/index.vue index 84c7ff52..fbfabca9 100644 --- a/web/src/views/backend/routine/config/index.vue +++ b/web/src/views/backend/routine/config/index.vue @@ -108,7 +108,7 @@