21
This commit is contained in:
parent
fcceafe535
commit
e80930e996
|
|
@ -149,4 +149,23 @@ public class ConfigController : BusinessControllerBase
|
||||||
{
|
{
|
||||||
return Ok(ConfigKeys.AllKeys);
|
return Ok(ConfigKeys.AllKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除所有用户海报缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>清除结果</returns>
|
||||||
|
[HttpDelete("poster-cache")]
|
||||||
|
[BusinessPermission("config:edit")]
|
||||||
|
public async Task<IActionResult> ClearAllPosterCache()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var count = await _configService.ClearAllPosterCacheAsync();
|
||||||
|
return Ok(new { message = $"成功清除 {count} 条海报缓存", count });
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return Error(BusinessErrorCodes.InternalError, "清除海报缓存失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,23 @@ public class AdminConfigService : IAdminConfigService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<int> ClearAllPosterCacheAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 删除所有海报缓存记录
|
||||||
|
var count = await _dbContext.Database.ExecuteSqlRawAsync("DELETE FROM user_poster_cache");
|
||||||
|
_logger.LogInformation("Cleared {Count} poster cache records", count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Failed to clear poster cache");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Private Validation Methods
|
#region Private Validation Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -52,4 +52,10 @@ public interface IAdminConfigService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">配置键</param>
|
/// <param name="key">配置键</param>
|
||||||
Task ClearConfigCacheAsync(string key);
|
Task ClearConfigCacheAsync(string key);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除所有用户海报缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>清除的记录数</returns>
|
||||||
|
Task<int> ClearAllPosterCacheAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -708,3 +708,22 @@ export function getRankSettingSetting(): Promise<ApiResponse<ConfigResponse<Rank
|
||||||
export function updateRankSettingSetting(value: RankSettingSetting): Promise<ApiResponse<string>> {
|
export function updateRankSettingSetting(value: RankSettingSetting): Promise<ApiResponse<string>> {
|
||||||
return updateConfig('rank_setting', value)
|
return updateConfig('rank_setting', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 海报缓存管理 ====================
|
||||||
|
|
||||||
|
/** 清除海报缓存响应 */
|
||||||
|
export interface ClearPosterCacheResponse {
|
||||||
|
message: string
|
||||||
|
count: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有用户海报缓存
|
||||||
|
* @returns 清除结果
|
||||||
|
*/
|
||||||
|
export function clearPosterCache(): Promise<ApiResponse<ClearPosterCacheResponse>> {
|
||||||
|
return request({
|
||||||
|
url: `${CONFIG_BASE_URL}/poster-cache`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item label="二维码X坐标" prop="poster_qr_x">
|
<el-form-item label="二维码X坐标" prop="poster_qr_x">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model.number="formData.poster_qr_x"
|
v-model.number="formData.poster_qr_x"
|
||||||
|
|
@ -278,7 +278,7 @@
|
||||||
<div class="form-tip">二维码在海报上的X坐标(像素)</div>
|
<div class="form-tip">二维码在海报上的X坐标(像素)</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item label="二维码Y坐标" prop="poster_qr_y">
|
<el-form-item label="二维码Y坐标" prop="poster_qr_y">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model.number="formData.poster_qr_y"
|
v-model.number="formData.poster_qr_y"
|
||||||
|
|
@ -290,7 +290,7 @@
|
||||||
<div class="form-tip">二维码在海报上的Y坐标(像素)</div>
|
<div class="form-tip">二维码在海报上的Y坐标(像素)</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item label="二维码大小" prop="poster_qr_size">
|
<el-form-item label="二维码大小" prop="poster_qr_size">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model.number="formData.poster_qr_size"
|
v-model.number="formData.poster_qr_size"
|
||||||
|
|
@ -302,6 +302,14 @@
|
||||||
<div class="form-tip">二维码宽高(像素)</div>
|
<div class="form-tip">二维码宽高(像素)</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="6">
|
||||||
|
<el-form-item label="清除海报缓存">
|
||||||
|
<el-button type="danger" :loading="clearingCache" @click="handleClearPosterCache">
|
||||||
|
<el-icon><Delete /></el-icon>清除所有缓存
|
||||||
|
</el-button>
|
||||||
|
<div class="form-tip">修改海报配置后需清除缓存才能生效</div>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- 开关配置 -->
|
<!-- 开关配置 -->
|
||||||
|
|
@ -340,14 +348,15 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||||
import { Check } from '@element-plus/icons-vue'
|
import { Check, Delete } from '@element-plus/icons-vue'
|
||||||
import ImageUpload from '@/components/ImageUpload/index.vue'
|
import ImageUpload from '@/components/ImageUpload/index.vue'
|
||||||
import { getBaseSetting, updateBaseSetting, type BaseSetting } from '@/api/business/config'
|
import { getBaseSetting, updateBaseSetting, clearPosterCache, type BaseSetting } from '@/api/business/config'
|
||||||
|
|
||||||
// 加载状态
|
// 加载状态
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
|
const clearingCache = ref(false)
|
||||||
|
|
||||||
// 表单引用
|
// 表单引用
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
|
|
@ -521,6 +530,34 @@ const handleSave = async () => {
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadData()
|
loadData()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 清除海报缓存
|
||||||
|
const handleClearPosterCache = async () => {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
'确定要清除所有用户的海报缓存吗?清除后用户下次访问推广页面时会重新生成海报。',
|
||||||
|
'确认清除',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
clearingCache.value = true
|
||||||
|
try {
|
||||||
|
const res = await clearPosterCache()
|
||||||
|
ElMessage.success(res.data?.message || '清除成功')
|
||||||
|
} catch (error) {
|
||||||
|
ElMessage.error('清除失败')
|
||||||
|
console.error('清除海报缓存失败:', error)
|
||||||
|
} finally {
|
||||||
|
clearingCache.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user