not store context
This commit is contained in:
11
src/App.vue
11
src/App.vue
@@ -129,6 +129,7 @@ onUnmounted(() => {
|
||||
|
||||
// Translation State
|
||||
const sourceText = ref('');
|
||||
const context = ref('');
|
||||
const targetText = ref('');
|
||||
const isTranslating = ref(false);
|
||||
const showCopyFeedback = ref(false);
|
||||
@@ -212,8 +213,8 @@ const translate = async () => {
|
||||
.replace(/{SPEAKER_IDENTITY}/g, settings.speakerIdentity)
|
||||
.replace(/{TONE_REGISTER}/g, settings.toneRegister);
|
||||
|
||||
const userMessage = settings.context
|
||||
? `[Context]\n${settings.context}\n\n[Text to Translate]\n${sourceText.value}`
|
||||
const userMessage = context.value
|
||||
? `[Context]\n${context.value}\n\n[Text to Translate]\n${sourceText.value}`
|
||||
: `[Text to Translate]\n${sourceText.value}`;
|
||||
|
||||
const requestBody = {
|
||||
@@ -351,8 +352,8 @@ const translate = async () => {
|
||||
<span class="text-[12px] font-bold text-slate-400 uppercase tracking-widest">情景背景 (可选)</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="settings.context"
|
||||
@click="settings.context = ''"
|
||||
v-if="context"
|
||||
@click="context = ''"
|
||||
class="p-1 hover:bg-slate-200 dark:hover:bg-slate-700 rounded opacity-0 group-hover/context:opacity-100 transition-opacity"
|
||||
title="清空背景"
|
||||
>
|
||||
@@ -360,7 +361,7 @@ const translate = async () => {
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="settings.context"
|
||||
v-model="context"
|
||||
placeholder="在此输入背景信息,有助于提升翻译准确度..."
|
||||
class="w-full bg-transparent border-none outline-none text-sm text-slate-500 dark:text-slate-400 resize-none h-14 leading-normal placeholder:italic placeholder:text-slate-300 dark:placeholder:text-slate-600"
|
||||
></textarea>
|
||||
|
||||
@@ -67,7 +67,6 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
const profiles = useLocalStorage<ApiProfile[]>('api-profiles', []);
|
||||
const enableStreaming = useLocalStorage('enable-streaming', true);
|
||||
const systemPromptTemplate = useLocalStorage('system-prompt-template', DEFAULT_TEMPLATE);
|
||||
const context = useLocalStorage('translation-context', '');
|
||||
|
||||
// 存储整个对象以保持一致性
|
||||
const sourceLang = useLocalStorage<Language>('source-lang-v2', LANGUAGES[0]);
|
||||
@@ -98,7 +97,6 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||
profiles,
|
||||
enableStreaming,
|
||||
systemPromptTemplate,
|
||||
context,
|
||||
sourceLang,
|
||||
targetLang,
|
||||
speakerIdentity,
|
||||
|
||||
Reference in New Issue
Block a user