From 7007ece7504b5d7b982180acf5f3465cb650758a Mon Sep 17 00:00:00 2001 From: u2nyakim Date: Tue, 26 Aug 2025 11:58:23 +0800 Subject: [PATCH] =?UTF-8?q?up.=20=E9=85=8D=E7=BD=AE=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/system/ConfigController.php | 18 +++++- route/api.php | 2 +- z_ele/src/api/system/config/index.ts | 11 ++++ z_ele/src/utils/sys-config.ts | 25 +++++--- z_ele/src/views/system/config-set/index.vue | 58 ++++++++++++++++++- 5 files changed, 101 insertions(+), 13 deletions(-) diff --git a/app/controller/admin/system/ConfigController.php b/app/controller/admin/system/ConfigController.php index aaf1f57..e56728f 100644 --- a/app/controller/admin/system/ConfigController.php +++ b/app/controller/admin/system/ConfigController.php @@ -124,8 +124,20 @@ class ConfigController extends BaseController public function info() { - $info = Cache::get('sysConfigInfo'); - $version = Cache::get('sysConfigVersion'); - return $this->writeSuccess('success', ['info'=>$info, 'version'=>$version]); + $table_php = SysConfig::where(['status'=>1])->order(['name'=>'asc']) + ->select(); + $table_version = md5($table_php->toJson()); + + $cache_php = Cache::get('sysConfigInfo'); + $cache_version = Cache::get('sysConfigVersion'); + + return $this->writeSuccess('success', [ + // 表版本 + 'table_version'=> $table_version, + 'table_php' => var_export($table_php->column('value','name'), true), + // 缓存版本 + 'cache_version'=> $cache_version, + 'cache_php' => var_export($cache_php, true), + ]); } } \ No newline at end of file diff --git a/route/api.php b/route/api.php index b2ae749..bf399b2 100644 --- a/route/api.php +++ b/route/api.php @@ -69,13 +69,13 @@ Route::group("adminapi", function () { * 配置管理 */ Route::get('config$', [ConfigController::class, "list"])->name("system.listConfig"); + Route::get("config/info", [ConfigController::class, "info"])->name("system.getConfigInfo"); Route::get('config/data', [ConfigController::class, "data"])->name("system.getConfigData"); Route::get('config/existence', [ConfigController::class, "existence"])->name("system.configExistence"); Route::post("config", [ConfigController::class, "add"])->name("system.addConfig"); Route::put("config$", [ConfigController::class, "update"])->name("system.updateConfig"); Route::delete("config/batch", [ConfigController::class, "batchDelete"])->name("system.batchDeleteConfig"); Route::put("config/sync", [ConfigController::class, "sync"])->name("system.syncConfig"); - Route::put("config/info", [ConfigController::class, "info"])->name("system.getConfigInfo"); Route::put("config/status", [ConfigController::class, "updateStatus"])->name("system.updateConfigStatus"); /* diff --git a/z_ele/src/api/system/config/index.ts b/z_ele/src/api/system/config/index.ts index 33edf7c..dc01a5e 100644 --- a/z_ele/src/api/system/config/index.ts +++ b/z_ele/src/api/system/config/index.ts @@ -104,3 +104,14 @@ export async function syncConfigs() { } return Promise.reject(new Error(res.data.message)); } + +/** + * 获取当前配置表数据 + */ +export async function infoConfigs() { + const res = await request.get>('/system/config/info'); + if (res.data.code === 0 && res.data.data) { + return res.data.data; + } + return Promise.reject(new Error(res.data.message)); +} diff --git a/z_ele/src/utils/sys-config.ts b/z_ele/src/utils/sys-config.ts index eb45244..42d2f47 100644 --- a/z_ele/src/utils/sys-config.ts +++ b/z_ele/src/utils/sys-config.ts @@ -28,12 +28,6 @@ export function strToValue(type: string, value: string): any { case 'time_range': case 'datetime_range': return [null, null]; - case 'alert': - // 提示 - return '-'; - case '-': - // 分割线 - return '-'; default: return value } @@ -95,7 +89,24 @@ export function valueToStr(type: string, value: any) { switch (type) { case 'json': return value ? JSON.stringify(value) : "{}"; + case 'int': + case 'number': + return value.toString(); + case 'switch': + return value ? '1' : '0' + case 'checkbox': + return value.join(",") + case 'text': + case 'textarea': + case 'date': + case 'datetime': + case 'time': + return value === null ? "" : value; + case 'date_range': + case 'time_range': + case 'datetime_range': + return value.join(","); default: - return value; + return value === null ? "" : value; } } diff --git a/z_ele/src/views/system/config-set/index.vue b/z_ele/src/views/system/config-set/index.vue index 1244410..d6f02df 100644 --- a/z_ele/src/views/system/config-set/index.vue +++ b/z_ele/src/views/system/config-set/index.vue @@ -12,6 +12,9 @@ 同步配置 + + 配置列表 + @@ -33,7 +36,7 @@ ref="configFormListRef" :config-list="configList" /> - +
保存配置
@@ -41,18 +44,49 @@
+ + + +
+ + {{ infoData.cache_version }} + {{ infoData.table_version }} + +
+ +