Compare commits

..

No commits in common. "04128fac14043c5df703e11670303a6fbd120547" and "0ed262c87b1b346a7be6ce170c71bf97824d84de" have entirely different histories.

4 changed files with 7 additions and 57 deletions

View File

@ -527,8 +527,7 @@ function renderReadFile(result: any, args: any): string {
matches.forEach((match: any, idx: number) => {
if (idx > 0) html += '<div class="search-match-separator">⋯</div>';
html += '<div class="search-match-item">';
const lineLabel = match.line_start === match.line_end ? `${match.line_start}` : `${match.line_start}-${match.line_end}`;
html += `<div class="search-match-line">行 ${lineLabel}</div>`;
html += `<div class="search-match-line">行 ${match.line_number || '?'}</div>`;
html += `<pre>${escapeHtml(match.snippet || match.content || '')}</pre>`;
html += '</div>';
});

View File

@ -479,8 +479,7 @@ function renderReadFile(result: any, args: any): string {
matches.forEach((match: any, idx: number) => {
if (idx > 0) html += '<div class="search-match-separator">⋯</div>';
html += '<div class="search-match-item">';
const lineLabel = match.line_start === match.line_end ? `${match.line_start}` : `${match.line_start}-${match.line_end}`;
html += `<div class="search-match-line">行 ${lineLabel}</div>`;
html += `<div class="search-match-line">行 ${match.line_number || '?'}</div>`;
html += `<pre>${escapeHtml(match.snippet || match.content || '')}</pre>`;
html += '</div>';
});

View File

@ -27,6 +27,7 @@
<div class="personalization-body settings-redesign-body" v-if="!loading">
<form
class="personal-form settings-redesign-form"
@submit.prevent="personalization.save()"
>
<div class="settings-redesign-layout">
<nav class="settings-redesign-tabs" aria-label="个人空间分组切换">
@ -1650,6 +1651,9 @@
><span class="status error" v-if="error">{{ error }}</span></transition
>
</div>
<button type="submit" class="settings-primary-button" :disabled="saving">
{{ saving ? '保存中...' : '保存设置' }}
</button>
</div>
</section>
</div>
@ -2497,6 +2501,7 @@ const handleStackedHideBordersChange = (event: Event) => {
key: 'stacked_hide_borders',
value: target.checked
});
personalization.save();
};
const compactMessageDisplayOptions = [

View File

@ -207,9 +207,6 @@ const loadExperimentState = (): ExperimentState => {
}
};
// 防抖自动保存计时器(非响应式,避免触发不必要的重渲染)
let autoSaveTimer: ReturnType<typeof setTimeout> | null = null;
export const usePersonalizationStore = defineStore('personalization', {
state: (): PersonalizationState => ({
visible: false,
@ -594,40 +591,6 @@ export const usePersonalizationStore = defineStore('personalization', {
[payload.key]: payload.value
};
this.clearFeedback();
this.scheduleAutoSave();
},
/** 防抖自动保存500ms 内多次调用只执行最后一次 */
scheduleAutoSave() {
if (autoSaveTimer) {
clearTimeout(autoSaveTimer);
}
autoSaveTimer = setTimeout(() => {
autoSaveTimer = null;
this.autoSave();
}, 500);
},
/** 静默自动保存,成功不显示提示,失败显示错误 */
async autoSave() {
if (this.saving) {
return;
}
this.saving = true;
try {
const resp = await fetch('/api/personalization', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(this.form)
});
const result = await resp.json();
if (!resp.ok || !result.success) {
throw new Error(result.error || '自动保存失败');
}
// 静默成功,不刷新表单(避免打断用户编辑)
} catch (error: any) {
this.error = error?.message || '自动保存失败';
} finally {
this.saving = false;
}
},
setThinkingInterval(value: number | null) {
let target: number | null = value;
@ -649,7 +612,6 @@ export const usePersonalizationStore = defineStore('personalization', {
thinking_interval: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
setRecentConversationsPromptLimit(value: number | null) {
const target =
@ -661,7 +623,6 @@ export const usePersonalizationStore = defineStore('personalization', {
recent_conversations_prompt_limit: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
toggleDefaultToolCategory(categoryId: string) {
if (!categoryId) {
@ -678,7 +639,6 @@ export const usePersonalizationStore = defineStore('personalization', {
disabled_tool_categories: Array.from(current)
};
this.clearFeedback();
this.scheduleAutoSave();
},
toggleSkill(skillId: string) {
if (!skillId) {
@ -695,7 +655,6 @@ export const usePersonalizationStore = defineStore('personalization', {
enabled_skills: Array.from(current)
};
this.clearFeedback();
this.scheduleAutoSave();
},
setDefaultRunMode(mode: RunMode | null) {
let target: RunMode | null = null;
@ -707,7 +666,6 @@ export const usePersonalizationStore = defineStore('personalization', {
default_run_mode: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
setDefaultPermissionMode(mode: PermissionMode) {
const allowed: PermissionMode[] = ['readonly', 'approval', 'auto_approval', 'unrestricted'];
@ -717,7 +675,6 @@ export const usePersonalizationStore = defineStore('personalization', {
default_permission_mode: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
setVersioningRestoreMode(_mode: 'overwrite') {
const target: 'overwrite' = 'overwrite';
@ -726,7 +683,6 @@ export const usePersonalizationStore = defineStore('personalization', {
versioning_restore_mode: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
setDefaultModel(model: string | null) {
const modelStore = useModelStore();
@ -737,7 +693,6 @@ export const usePersonalizationStore = defineStore('personalization', {
default_model: target
};
this.clearFeedback();
this.scheduleAutoSave();
},
setImageCompression(mode: string) {
const allowed = ['original', '1080p', '720p', '540p'];
@ -747,7 +702,6 @@ export const usePersonalizationStore = defineStore('personalization', {
image_compression: mode
};
this.clearFeedback();
this.scheduleAutoSave();
},
applyTonePreset(preset: string) {
if (!preset) {
@ -758,7 +712,6 @@ export const usePersonalizationStore = defineStore('personalization', {
tone: preset
};
this.clearFeedback();
this.scheduleAutoSave();
},
updateNewConsideration(value: string) {
this.newConsideration = value;
@ -777,7 +730,6 @@ export const usePersonalizationStore = defineStore('personalization', {
};
this.newConsideration = '';
this.clearFeedback();
this.scheduleAutoSave();
},
removeConsideration(index: number) {
const items = [...this.form.considerations];
@ -787,7 +739,6 @@ export const usePersonalizationStore = defineStore('personalization', {
considerations: items
};
this.clearFeedback();
this.scheduleAutoSave();
},
considerationDragStart(index: number, event: DragEvent) {
this.draggedConsiderationIndex = index;
@ -818,7 +769,6 @@ export const usePersonalizationStore = defineStore('personalization', {
}
this.considerationDragEnd();
this.considerationDragOver(index, event);
this.scheduleAutoSave();
},
considerationDragEnd() {
this.draggedConsiderationIndex = null;
@ -868,7 +818,6 @@ export const usePersonalizationStore = defineStore('personalization', {
blockDisplayMode: mode
};
this.persistExperiments();
this.scheduleAutoSave();
},
setCompactMessageDisplay(mode: CompactMessageDisplay) {
const target: CompactMessageDisplay = mode === 'brief' ? 'brief' : 'full';
@ -907,7 +856,6 @@ export const usePersonalizationStore = defineStore('personalization', {
communication_style: style
};
this.clearFeedback();
this.scheduleAutoSave();
},
setConversationContinuity(value: ConversationContinuity) {
this.form = {
@ -915,7 +863,6 @@ export const usePersonalizationStore = defineStore('personalization', {
conversation_continuity: value
};
this.clearFeedback();
this.scheduleAutoSave();
}
}
});