You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
238 lines
4.8 KiB
238 lines
4.8 KiB
<script setup lang="ts">
|
|
const props = defineProps<{
|
|
show: boolean;
|
|
systemPrompt: string;
|
|
isCustom: boolean;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
close: [];
|
|
save: [systemPrompt: string | null];
|
|
}>();
|
|
|
|
const editingText = ref("");
|
|
const saving = ref(false);
|
|
|
|
watch(
|
|
() => props.show,
|
|
(val) => {
|
|
if (val) {
|
|
editingText.value = props.systemPrompt;
|
|
}
|
|
},
|
|
);
|
|
|
|
async function handleSave() {
|
|
saving.value = true;
|
|
try {
|
|
const trimmed = editingText.value.trim();
|
|
emit("save", trimmed.length > 0 ? trimmed.slice(0, 5000) : null);
|
|
} finally {
|
|
saving.value = false;
|
|
}
|
|
}
|
|
|
|
function handleReset() {
|
|
editingText.value = "";
|
|
emit("save", null);
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<Teleport to="body">
|
|
<div v-if="show" class="agent-prompt-overlay" @click="emit('close')">
|
|
<div class="agent-prompt-modal" @click.stop>
|
|
<div class="modal-header">
|
|
<h3 class="modal-title">系统提示词</h3>
|
|
<button class="modal-close" @click="emit('close')">
|
|
<Icon name="lucide:x" />
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div v-if="isCustom" class="custom-badge">
|
|
<Icon name="lucide:check-circle" />
|
|
<span>当前使用会话自定义提示词</span>
|
|
</div>
|
|
<div v-else class="default-badge">
|
|
<Icon name="lucide:info" />
|
|
<span>当前使用 Agent 默认提示词,编辑后将覆盖默认值</span>
|
|
</div>
|
|
<textarea
|
|
v-model="editingText"
|
|
class="prompt-textarea"
|
|
placeholder="输入系统提示词,留空则使用 Agent 默认"
|
|
maxlength="5000"
|
|
/>
|
|
<div class="char-count">{{ editingText.length }} / 5000</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button class="btn-reset" :disabled="saving" @click="handleReset">
|
|
重置为默认
|
|
</button>
|
|
<button class="btn-save" :disabled="saving" @click="handleSave">
|
|
{{ saving ? "保存中..." : "保存" }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Teleport>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.agent-prompt-overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background: rgba(20, 20, 19, 0.4);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 100;
|
|
}
|
|
|
|
.agent-prompt-modal {
|
|
width: 90%;
|
|
max-width: 600px;
|
|
max-height: 80vh;
|
|
background: var(--color-surface-card);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 16px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.modal-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid var(--color-hairline);
|
|
}
|
|
|
|
.modal-title {
|
|
font-family: var(--font-display);
|
|
font-size: 20px;
|
|
font-weight: 400;
|
|
color: var(--color-ink);
|
|
margin: 0;
|
|
}
|
|
|
|
.modal-close {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 32px;
|
|
height: 32px;
|
|
border: none;
|
|
background: none;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
color: var(--color-muted);
|
|
font-size: 18px;
|
|
transition: all 0.15s;
|
|
}
|
|
|
|
.modal-close:hover {
|
|
background: var(--color-surface-soft);
|
|
color: var(--color-ink);
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 20px;
|
|
overflow-y: auto;
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.custom-badge,
|
|
.default-badge {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 12px;
|
|
border-radius: 8px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.custom-badge {
|
|
background: var(--color-surface-soft);
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.default-badge {
|
|
background: var(--color-surface-soft);
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.prompt-textarea {
|
|
width: 100%;
|
|
min-height: 200px;
|
|
padding: 12px;
|
|
font-family: "SF Mono", "Fira Code", monospace;
|
|
font-size: 13px;
|
|
line-height: 1.6;
|
|
color: var(--color-body);
|
|
background: var(--color-canvas);
|
|
border: 1px solid var(--color-hairline);
|
|
border-radius: 8px;
|
|
resize: vertical;
|
|
outline: none;
|
|
transition: border-color 0.15s;
|
|
}
|
|
|
|
.prompt-textarea:focus {
|
|
border-color: var(--color-primary);
|
|
}
|
|
|
|
.char-count {
|
|
text-align: right;
|
|
font-size: 12px;
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.modal-footer {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 8px;
|
|
padding: 12px 20px;
|
|
border-top: 1px solid var(--color-hairline);
|
|
}
|
|
|
|
.btn-reset,
|
|
.btn-save {
|
|
padding: 8px 16px;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.15s;
|
|
border: 1px solid var(--color-hairline);
|
|
}
|
|
|
|
.btn-reset {
|
|
background: var(--color-surface-soft);
|
|
color: var(--color-muted);
|
|
}
|
|
|
|
.btn-reset:hover {
|
|
border-color: var(--color-primary);
|
|
color: var(--color-ink);
|
|
}
|
|
|
|
.btn-save {
|
|
background: var(--color-primary);
|
|
border-color: var(--color-primary);
|
|
color: var(--color-on-primary);
|
|
}
|
|
|
|
.btn-save:hover {
|
|
opacity: 0.9;
|
|
}
|
|
|
|
.btn-reset:disabled,
|
|
.btn-save:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
}
|
|
</style>
|
|
|