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 {