feat(content): 增加对白与叙述排版预览
- DigitalMessageText.vue: 为角色预览与聊天记录提供统一的受限文本展示 - content.vue: 增加首次问候、备用开场、示例对白的实时预览与格式说明 - users.vue: 按相同规则展示角色聊天记录,保留用户纯文本 - digital-message-format.ts、tests、README.md: 同步前台格式实现、兼容用例与目录说明
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/** 数字人内容库:角色、世界书、叙事预设分别编辑,发布状态显式可见。 */
|
||||
/** 数字人内容库:角色、世界书、预设分别编辑,开场与示例使用聊天格式实时预览。 */
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { digital, type Content, type Entry } from "@/api/access";
|
||||
import DigitalMessageText from "@/components/DigitalMessageText.vue";
|
||||
const contents = ref<Content[]>([]),
|
||||
kind = ref("character"),
|
||||
query = ref(""),
|
||||
@@ -29,6 +30,12 @@ const statusNames: Record<string, string> = {
|
||||
published: "已发布",
|
||||
archived: "已下架"
|
||||
};
|
||||
/** 占位符仅用于当前预览,不改写编辑内容或数据库中的角色模板。 */
|
||||
function previewText(value: string) {
|
||||
return value
|
||||
.replaceAll("{{char}}", edit.value?.name || "角色")
|
||||
.replaceAll("{{user}}", "旅人");
|
||||
}
|
||||
const books = computed(() =>
|
||||
contents.value.filter(c => c.kind === "worldbook" && c.status === "published")
|
||||
);
|
||||
@@ -323,7 +330,12 @@ onMounted(load);
|
||||
v-if="edit.kind === 'character'"
|
||||
label="人格与开场"
|
||||
name="persona"
|
||||
><el-form-item label="性格、背景和关系"
|
||||
><el-alert
|
||||
class="format-guide"
|
||||
title="对白与叙述分段书写"
|
||||
description="对白使用成对引号,如:“你来了。”;动作、神态、心理和环境用单星号包裹,如:*她合上书,抬头微笑。*。切换时空一行,下方预览与聊天使用相同的格式规则。"
|
||||
:closable="false"
|
||||
/><el-form-item label="性格、背景和关系"
|
||||
><el-input
|
||||
v-model="edit.body.personality"
|
||||
type="textarea"
|
||||
@@ -334,15 +346,36 @@ onMounted(load);
|
||||
type="textarea"
|
||||
:rows="3" /></el-form-item
|
||||
><el-form-item label="首次问候(支持 {{char}} / {{user}} 占位符)"
|
||||
><el-input
|
||||
v-model="edit.body.greeting"
|
||||
type="textarea"
|
||||
:rows="4" /></el-form-item
|
||||
><div class="format-editor">
|
||||
<el-input
|
||||
v-model="edit.body.greeting"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="*她合上书,抬头看向你。* “你来了。”"
|
||||
/>
|
||||
<div
|
||||
v-if="edit.body.greeting.trim()"
|
||||
class="format-preview"
|
||||
aria-label="首次问候展示预览"
|
||||
>
|
||||
<small>首次问候 · 展示效果</small>
|
||||
<DigitalMessageText :text="previewText(edit.body.greeting)" />
|
||||
</div></div></el-form-item
|
||||
><el-form-item label="示例对白"
|
||||
><el-input
|
||||
v-model="edit.body.examples"
|
||||
type="textarea"
|
||||
:rows="4" /></el-form-item
|
||||
><div class="format-editor">
|
||||
<el-input
|
||||
v-model="edit.body.examples"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
/>
|
||||
<div
|
||||
v-if="edit.body.examples.trim()"
|
||||
class="format-preview"
|
||||
aria-label="示例对白展示预览"
|
||||
>
|
||||
<small>示例对白 · 展示效果</small>
|
||||
<DigitalMessageText :text="previewText(edit.body.examples)" />
|
||||
</div></div></el-form-item
|
||||
><el-form-item label="角色系统指令"
|
||||
><el-input
|
||||
v-model="edit.body.systemPrompt"
|
||||
@@ -355,12 +388,24 @@ onMounted(load);
|
||||
:key="i"
|
||||
class="entry-row"
|
||||
>
|
||||
<el-input
|
||||
v-model="edit.body.alternateGreetings[i]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/><el-button
|
||||
@click="edit.body.alternateGreetings.splice(i, 1)"
|
||||
<div class="format-editor">
|
||||
<el-input
|
||||
v-model="edit.body.alternateGreetings[i]"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
/>
|
||||
<div
|
||||
v-if="edit.body.alternateGreetings[i].trim()"
|
||||
class="format-preview"
|
||||
:aria-label="`其他开场 ${i + 1} 展示预览`"
|
||||
>
|
||||
<small>其他开场 {{ i + 1 }} · 展示效果</small>
|
||||
<DigitalMessageText
|
||||
:text="previewText(edit.body.alternateGreetings[i])"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<el-button @click="edit.body.alternateGreetings.splice(i, 1)"
|
||||
>移除</el-button
|
||||
>
|
||||
</div>
|
||||
@@ -465,7 +510,11 @@ onMounted(load);
|
||||
v-if="edit.kind === 'preset'"
|
||||
label="生成编排"
|
||||
name="generation"
|
||||
><el-form-item label="系统指令"
|
||||
><el-alert
|
||||
class="format-guide"
|
||||
title="系统统一区分对白和叙述"
|
||||
description="本页设置叙事风格;对白使用引号、叙述使用单星号并分段的排版规则始终生效,发送、继续与重新生成共用。"
|
||||
:closable="false" /><el-form-item label="系统指令"
|
||||
><el-input
|
||||
v-model="edit.body.systemPrompt"
|
||||
type="textarea"
|
||||
@@ -512,6 +561,37 @@ onMounted(load);
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.format-guide {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.format-editor {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.format-preview {
|
||||
--digital-dialogue-ink: #fff5fc;
|
||||
--digital-narration-ink: #c2b6c4;
|
||||
|
||||
max-height: 300px;
|
||||
padding: 14px 18px;
|
||||
margin-top: 10px;
|
||||
overflow: auto;
|
||||
font-size: 14px;
|
||||
color: #e6dfe7;
|
||||
background: #211c23;
|
||||
border: 1px solid #ffffff12;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.format-preview > small {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
font-size: 11px;
|
||||
color: #b5a6b8;
|
||||
}
|
||||
|
||||
.heading {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
|
||||
Reference in New Issue
Block a user