Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions dashboard/src/components/folder/BaseFolderItemSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@
</v-list-item-subtitle>

<template v-slot:append>
<v-icon v-if="selectedItemId === getItemId(item)"
color="primary" size="22">mdi-check-circle</v-icon>
<div class="d-flex align-center ga-1">
<v-btn v-if="showEditButton && !isDefaultItem(item)"
icon="mdi-pencil"
size="small"
variant="text"
@click.stop="handleEditItem(item)"
:title="labels.editButton || 'Edit'"
/>
<v-icon v-if="selectedItemId === getItemId(item)"
color="primary" size="22">mdi-check-circle</v-icon>
</div>
</template>
</v-list-item>
</template>
Expand Down Expand Up @@ -197,6 +206,11 @@ export default defineComponent({
type: Boolean,
default: false
},
// 是否显示编辑按钮
showEditButton: {
type: Boolean,
default: false
},
// 默认项(如 "默认人格")
defaultItem: {
type: Object as PropType<SelectableItem | null>,
Expand All @@ -221,7 +235,7 @@ export default defineComponent({
default: null
}
},
emits: ['update:modelValue', 'navigate', 'create'],
emits: ['update:modelValue', 'navigate', 'create', 'edit'],
data() {
return {
dialog: false,
Expand Down Expand Up @@ -370,6 +384,17 @@ export default defineComponent({
cancelSelection() {
this.selectedItemId = this.modelValue || '';
this.dialog = false;
},

isDefaultItem(item: SelectableItem): boolean {
if (this.defaultItem === null) {
return false;
}
return this.getItemId(item) === this.getItemId(this.defaultItem);
},

handleEditItem(item: SelectableItem) {
this.$emit('edit', item);
}
}
});
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/components/folder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export interface FolderItemSelectorLabels {

// 按钮
createButton?: string;
editButton?: string;
confirmButton?: string;
cancelButton?: string;

Expand Down
32 changes: 22 additions & 10 deletions dashboard/src/components/shared/PersonaSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@
:items-loading="itemsLoading"
:labels="labels"
:show-create-button="true"
:show-edit-button="true"
:default-item="defaultPersona"
item-id-field="persona_id"
item-name-field="persona_id"
item-description-field="system_prompt"
:display-value-formatter="formatDisplayValue"
@navigate="handleNavigate"
@create="openCreatePersona"
@edit="openEditPersona"
/>

<!-- 创建人格对话框 -->
<!-- 创建/编辑人格对话框 -->
<PersonaForm
v-model="showCreateDialog"
:editing-persona="undefined"
v-model="showPersonaDialog"
:editing-persona="editingPersona ?? undefined"
:current-folder-id="currentFolderId ?? undefined"
:current-folder-name="currentFolderName ?? undefined"
@saved="handlePersonaCreated"
@saved="handlePersonaSaved"
@error="handleError" />
</template>

Expand Down Expand Up @@ -62,7 +64,8 @@ const folderTree = ref<FolderTreeNode[]>([])
const currentPersonas = ref<Persona[]>([])
const treeLoading = ref(false)
const itemsLoading = ref(false)
const showCreateDialog = ref(false)
const showPersonaDialog = ref(false)
const editingPersona = ref<Persona | null>(null)
const currentFolderId = ref<string | null>(null)

// 默认人格
Expand Down Expand Up @@ -104,6 +107,7 @@ const labels = computed(() => ({
defaultItem: tm('personaSelector.defaultPersona'),
noDescription: tm('personaSelector.noDescription'),
createButton: tm('personaSelector.createPersona'),
editButton: tm('personaSelector.editPersona') || 'Edit',
confirmButton: t('core.common.confirm'),
cancelButton: t('core.common.cancel'),
rootFolder: tm('personaSelector.rootFolder') || '全部人格',
Expand Down Expand Up @@ -171,13 +175,21 @@ async function handleNavigate(folderId: string | null) {

// 打开创建人格对话框
function openCreatePersona() {
showCreateDialog.value = true
editingPersona.value = null
showPersonaDialog.value = true
}

// 人格创建成功
async function handlePersonaCreated(message: string) {
console.log('人格创建成功:', message)
showCreateDialog.value = false
// 打开编辑人格对话框
function openEditPersona(persona: Persona) {
editingPersona.value = persona
showPersonaDialog.value = true
}

// 人格保存成功(创建或编辑)
async function handlePersonaSaved(message: string) {
console.log('人格保存成功:', message)
showPersonaDialog.value = false
editingPersona.value = null
// 刷新当前文件夹的人格列表
await loadPersonasInFolder(currentFolderId.value)
}
Expand Down