修复切换消失的问题
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
- 左侧输入框支持逗号分隔的提示词,Tab 或点击建议快速补全。
|
||||
- 一键替换中文逗号、格式化为标准提示词格式。
|
||||
- 拖拽调整提示词顺序、双击编辑、删除、在后追加新词。
|
||||
- 右侧显示多语言映射,未映射项高亮,并可直接添加翻译。
|
||||
- 右侧显示映射,未映射项高亮,并可直接添加翻译。
|
||||
- 精简/详细两种视图切换,便于快速浏览或逐项编辑。
|
||||
|
||||
- 预设管理:
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
import { ref, onMounted } from 'vue'
|
||||
import PromptEditor from './components/PromptEditor.vue'
|
||||
import PromptManager from './components/PromptManager.vue'
|
||||
import { usePromptStore } from './stores/promptStore'
|
||||
|
||||
const currentView = ref<'editor' | 'manager'>('editor')
|
||||
const isDark = ref(false)
|
||||
const store = usePromptStore()
|
||||
|
||||
onMounted(() => {
|
||||
// 检测系统主题偏好
|
||||
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
isDark.value = localStorage.getItem('theme') === 'dark' || (localStorage.getItem('theme') === null && prefersDark)
|
||||
updateTheme()
|
||||
// 初始化词库与编辑器状态(仅一次)
|
||||
store.initialize()
|
||||
})
|
||||
|
||||
function toggleTheme() {
|
||||
|
||||
@@ -41,7 +41,6 @@ function handleClickOutside(event: Event) {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
store.initialize();
|
||||
document.addEventListener('click', handleClickOutside);
|
||||
});
|
||||
|
||||
@@ -75,7 +74,7 @@ watch(text, (val) => {
|
||||
// 当 store.promptText 发生变化(例如点击右侧预设加载)时,主动同步到左侧输入
|
||||
watch(() => store.promptText, (v) => {
|
||||
if (text.value !== v) text.value = v;
|
||||
});
|
||||
}, { immediate: true });
|
||||
|
||||
function updateSuggestions() {
|
||||
const text = store.promptText;
|
||||
@@ -405,7 +404,7 @@ function displayTrans(key: string): string {
|
||||
|
||||
<main class="pe-main">
|
||||
<section class="pe-left-pane">
|
||||
<div class="pe-section-title">左侧输入(逗号分隔)</div>
|
||||
<div class="pe-section-title">提示词输入(逗号分隔)</div>
|
||||
<textarea ref="inputEl" class="pe-input" v-model="text" @keydown="onKeyDown" placeholder="例如:1girl, aaa, bbb, ccc"></textarea>
|
||||
<div class="pe-input-actions">
|
||||
<button @click="replaceCnComma" title="将中文逗号替换为英文逗号">
|
||||
@@ -440,7 +439,7 @@ function displayTrans(key: string): string {
|
||||
</section>
|
||||
<section class="pe-right-pane">
|
||||
<div class="pe-section-title mode">
|
||||
<span>右侧映射</span>
|
||||
<span>提示词映射</span>
|
||||
<div class="pe-mode-switch">
|
||||
<button :class="{ active: viewMode==='compact' }" @click="viewMode='compact'">精简视图</button>
|
||||
<button :class="{ active: viewMode==='detail' }" @click="viewMode='detail'">详细视图</button>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, computed } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { usePromptStore } from '../stores/promptStore';
|
||||
import type { LangCode, PromptGroup, PromptTag } from '../types';
|
||||
|
||||
@@ -7,10 +7,6 @@ const store = usePromptStore();
|
||||
const draggingIndex = ref<number | null>(null);
|
||||
const overIndex = ref<number | null>(null);
|
||||
|
||||
onMounted(() => {
|
||||
store.initialize();
|
||||
});
|
||||
|
||||
const languages = computed(() => store.languages);
|
||||
const selectedLang = computed({
|
||||
get: () => store.selectedLang,
|
||||
|
||||
Reference in New Issue
Block a user