fix(admin): 重构知识库配置布局
This commit is contained in:
1 parent
70d7435b5f
commit
25876f94bd
18 files changed
+556
-229
No files matched your search
@@ -0,0 +1,127 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/KbGroupDrawer.vue
|
||||
* 知识库分组新建/编辑抽屉表单。
|
||||
* 依赖:Vue I18n、lucide-vue-next、父级 KbAdminPanel 传入的表单状态。
|
||||
* 逻辑:只负责抽屉展示、表单双向同步和提交/关闭事件;接口调用与列表刷新由父组件处理。
|
||||
*/
|
||||
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { FolderPlus, X } from 'lucide-vue-next';
|
||||
|
||||
export interface KbGroupFormValue {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
mode: 'create' | 'edit';
|
||||
form: KbGroupFormValue;
|
||||
submitting: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:form', value: KbGroupFormValue): void;
|
||||
(e: 'submit'): void;
|
||||
(e: 'close'): void;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const formTitle = computed(() => props.mode === 'edit' ? t('kbAdmin.form.editTitle') : t('kbAdmin.form.createTitle'));
|
||||
const formDescription = computed(() => props.mode === 'edit' ? t('kbAdmin.form.editDesc') : t('kbAdmin.form.createDesc'));
|
||||
const submitText = computed(() => {
|
||||
if (props.submitting) return props.mode === 'edit' ? t('kbAdmin.form.saving') : t('kbAdmin.form.submitting');
|
||||
return props.mode === 'edit' ? t('kbAdmin.form.saveChanges') : t('kbAdmin.form.create');
|
||||
});
|
||||
|
||||
/** 更新指定表单字段,并将完整表单值同步回父组件。 */
|
||||
const updateField = (field: keyof KbGroupFormValue, value: string) => {
|
||||
emit('update:form', {
|
||||
...props.form,
|
||||
[field]: value,
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="kb-admin-drawer">
|
||||
<div v-if="open" class="fixed inset-0 z-[100] bg-overlay backdrop-blur-sm" @click.self="emit('close')">
|
||||
<aside class="ml-auto flex h-full w-full max-w-[440px] flex-col border-l border-default bg-surface shadow-elevated">
|
||||
<header class="flex items-start justify-between gap-4 border-b border-default px-6 py-5">
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-lg font-semibold text-primary">{{ formTitle }}</h3>
|
||||
<p class="section-desc mt-1">{{ formDescription }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds shrink-0" @click="emit('close')" :title="t('common.close')">
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="flex-1 space-y-5 overflow-y-auto px-6 py-5">
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupName') }}</label>
|
||||
<input
|
||||
:value="form.name"
|
||||
class="input-field"
|
||||
:placeholder="t('kbAdmin.form.groupNamePlaceholder')"
|
||||
@input="updateField('name', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field mb-2 block">{{ t('kbAdmin.form.groupDesc') }}</label>
|
||||
<textarea
|
||||
:value="form.description"
|
||||
rows="8"
|
||||
class="input-field"
|
||||
:placeholder="t('kbAdmin.form.groupDescPlaceholder')"
|
||||
@input="updateField('description', ($event.target as HTMLTextAreaElement).value)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="flex justify-end gap-2 border-t border-default px-6 py-4">
|
||||
<button type="button" class="btn-secondary inline-flex items-center gap-1.5 px-4 py-2 text-sm" @click="emit('close')">
|
||||
<X class="h-4 w-4 shrink-0" />
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex items-center gap-1.5 px-5 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="submitting"
|
||||
@click="emit('submit')"
|
||||
>
|
||||
<FolderPlus v-if="!submitting" class="h-4 w-4 shrink-0" />
|
||||
{{ submitText }}
|
||||
</button>
|
||||
</footer>
|
||||
</aside>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.kb-admin-drawer-enter-active,
|
||||
.kb-admin-drawer-leave-active {
|
||||
transition: opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-active aside,
|
||||
.kb-admin-drawer-leave-active aside {
|
||||
transition: transform 0.18s ease;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-from,
|
||||
.kb-admin-drawer-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.kb-admin-drawer-enter-from aside,
|
||||
.kb-admin-drawer-leave-to aside {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user