From fcd4a2d0169ed0c77da702e92d6302e31361eb42 Mon Sep 17 00:00:00 2001 From: yiqiu Date: Sun, 28 Dec 2025 16:29:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../theme_configurator/model/ThemeConfigModel.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/addon/theme_configurator/model/ThemeConfigModel.php b/plugins/addon/theme_configurator/model/ThemeConfigModel.php index b42f39f..883aeb2 100644 --- a/plugins/addon/theme_configurator/model/ThemeConfigModel.php +++ b/plugins/addon/theme_configurator/model/ThemeConfigModel.php @@ -51,7 +51,7 @@ class ThemeConfigModel */ // 缓存未命中,从数据库读取 - $row = $this->query()->order('id', 'asc')->find(); + $row = $this->query()->order('id', 'desc')->find(); error_log('ThemeConfigModel::getConfig() - 查询结果: ' . ($row ? 'found' : 'not found')); if ($row) { error_log('config字段长度: ' . strlen($row['config'])); @@ -87,12 +87,11 @@ class ThemeConfigModel 'update_time' => time(), ]; - $exists = $this->query()->find(); - if ($exists) { - $this->query()->where('id', $exists['id'])->update($payload); - } else { - $this->query()->insert($payload); - } + // 删除所有旧记录,确保只有一条最新记录 + $this->query()->delete(); + + // 插入新记录 + $this->query()->insert($payload); // 清除缓存,确保下次读取最新数据 try {