up. 配置对比

This commit is contained in:
u2nyakim 2025-08-26 11:58:23 +08:00
parent c8eed0f11c
commit 7007ece750
5 changed files with 101 additions and 13 deletions

View File

@ -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),
]);
}
}

View File

@ -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");
/*

View File

@ -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<ApiResult<any>>('/system/config/info');
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}

View File

@ -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;
}
}

View File

@ -12,6 +12,9 @@
<el-button type="danger" class="ele-btn-icon" :icon="Refresh" @click="sync()" :loading="syncLoading">
同步配置
</el-button>
<el-button type="success" class="ele-btn-icon" @click="info()">
配置列表
</el-button>
</el-card>
<ele-card :body-style="{ paddingTop: '8px' }" v-loading="configLoading">
@ -41,18 +44,49 @@
<el-empty v-else description="没有定义配置列表" />
</el-form>
</ele-card>
<ele-drawer
size="100%"
title="配置变更对比"
:append-to-body="true"
style="max-width: 100%"
v-model="showInfo"
:body-style="{ paddingBottom: '8px' }"
>
<div style="margin-bottom: 30px;">
<el-descriptions
class="margin-top"
title="With border"
:column="2"
border
>
<el-descriptions-item label="缓存版本号">{{ infoData.cache_version }}</el-descriptions-item>
<el-descriptions-item label="数据版本号">{{ infoData.table_version }}</el-descriptions-item>
</el-descriptions>
</div>
<monaco-editor
v-model="infoData.table_php"
language="php"
v-model:original="infoData.cache_php"
original-language="php"
:diff="true"
style="height: 460px"
/>
</ele-drawer>
</ele-page>
</template>
<script lang="ts" setup>
import {onMounted, ref } from 'vue';
import {Refresh} from '@element-plus/icons-vue';
import {listConfigs, syncConfigs} from '@/api/system/config';
import {infoConfigs, listConfigs, syncConfigs} from '@/api/system/config';
import {getSysConfig, strToBind, strToOption} from '@/utils/sys-config';
import {useFormData} from '@/utils/use-form-data';
import type {Config} from '@/api/system/config/model';
import ConfigFormList from './components/config-form-list.vue';
import {EleMessage, toTree} from 'ele-admin-plus';
import MonacoEditor from "@/components/MonacoEditor/index.vue";
defineOptions({name: 'SystemConfigSet'});
@ -92,6 +126,26 @@ const sync = () => {
});
}
const showInfo = ref(false);
const infoData = ref<any>({
cache_version: "",
cache_php: "",
table_php: "",
table_version: "",
});
const info = ()=>{
infoConfigs({}).then((data)=>{
showInfo.value = true;
infoData.value = {
table_php: data.table_php,
table_version: data.table_version,
cache_version: data.cache_version,
cache_php: data.cache_php,
};
})
}
const configFormListRef = ref(null);
const saveForm = () => {
const allValues = configFormListRef.value?.getFormData();