初始化询价智能体新仓:同步本地工程并排除密钥与 .env。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 机器人回复语:九分类卡片 + 开关编辑,对齐原型。
|
||||
*/
|
||||
import { reactive, ref } from "vue";
|
||||
import { message } from "ant-design-vue";
|
||||
import { mockReplyCategories, type ReplyItem } from "/@/views/inquiry/mock/botReplies";
|
||||
import ProtoIcon from "/@/views/inquiry/components/ProtoIcon.vue";
|
||||
import AdminModal from "/@/views/inquiry/components/AdminModal.vue";
|
||||
|
||||
const categories = ref(structuredClone(mockReplyCategories));
|
||||
const modalOpen = ref(false);
|
||||
const editing = ref<{ categoryId: string; item: ReplyItem | null }>({
|
||||
categoryId: "",
|
||||
item: null,
|
||||
});
|
||||
const form = reactive({
|
||||
trigger: "",
|
||||
text: "",
|
||||
enabled: true,
|
||||
});
|
||||
|
||||
function toggle(item: ReplyItem) {
|
||||
item.enabled = !item.enabled;
|
||||
message.success(item.enabled ? "已启用" : "已停用");
|
||||
}
|
||||
|
||||
function openCreate(categoryId?: string) {
|
||||
editing.value = { categoryId: categoryId || categories.value[0]?.id || "inquiring", item: null };
|
||||
Object.assign(form, { trigger: "", text: "", enabled: true });
|
||||
modalOpen.value = true;
|
||||
}
|
||||
|
||||
function openEdit(categoryId: string, item: ReplyItem) {
|
||||
editing.value = { categoryId, item };
|
||||
Object.assign(form, {
|
||||
trigger: item.trigger,
|
||||
text: item.text,
|
||||
enabled: item.enabled,
|
||||
});
|
||||
modalOpen.value = true;
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (!form.trigger.trim() || !form.text.trim()) {
|
||||
message.warning("请填写触发条件与话术");
|
||||
return;
|
||||
}
|
||||
const cat = categories.value.find((c) => c.id === editing.value.categoryId);
|
||||
if (!cat) return;
|
||||
if (editing.value.item) {
|
||||
editing.value.item.trigger = form.trigger;
|
||||
editing.value.item.text = form.text;
|
||||
editing.value.item.enabled = form.enabled;
|
||||
message.success("话术已更新");
|
||||
} else {
|
||||
cat.items.push({
|
||||
id: `r${Date.now()}`,
|
||||
trigger: form.trigger,
|
||||
text: form.text,
|
||||
enabled: form.enabled,
|
||||
});
|
||||
message.success("话术已添加");
|
||||
}
|
||||
modalOpen.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport defer to="#page-topbar-actions">
|
||||
<button type="button" class="btn btn-primary" @click="openCreate()">
|
||||
<ProtoIcon name="plus" :size="16" />添加话术
|
||||
</button>
|
||||
</Teleport>
|
||||
|
||||
<article v-for="cat in categories" :key="cat.id" class="reply-category">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<h2>{{ cat.title }}</h2>
|
||||
<span class="tag" :class="cat.tagClass">{{ cat.items.length }} 条</span>
|
||||
</div>
|
||||
<p class="reply-category-desc">{{ cat.desc }}</p>
|
||||
|
||||
<div v-for="item in cat.items" :key="item.id" class="reply-item">
|
||||
<div style="min-width: 0">
|
||||
<div class="reply-meta">触发:{{ item.trigger }}</div>
|
||||
<div class="reply-text">{{ item.text }}</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 8px; flex-shrink: 0">
|
||||
<button
|
||||
type="button"
|
||||
class="switch"
|
||||
:class="{ 'is-on': item.enabled }"
|
||||
:aria-label="item.enabled ? '停用' : '启用'"
|
||||
@click="toggle(item)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-ghost btn-icon-sm"
|
||||
@click="openEdit(cat.id, item)"
|
||||
>
|
||||
<ProtoIcon name="pencil" :size="16" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<AdminModal
|
||||
v-model:open="modalOpen"
|
||||
:title="editing.item ? '编辑话术' : '添加话术'"
|
||||
size="md"
|
||||
ok-text="保存"
|
||||
@ok="save"
|
||||
>
|
||||
<div class="admin-modal-field">
|
||||
<label class="admin-modal-label">触发场景 / 条件 <span class="req">*</span></label>
|
||||
<input v-model="form.trigger" class="field" type="text" />
|
||||
</div>
|
||||
<div class="admin-modal-field">
|
||||
<label class="admin-modal-label">回复内容 <span class="req">*</span></label>
|
||||
<textarea
|
||||
v-model="form.text"
|
||||
class="field"
|
||||
rows="5"
|
||||
placeholder="支持 {{变量}} 占位符"
|
||||
/>
|
||||
</div>
|
||||
<div class="admin-modal-field">
|
||||
<label class="admin-modal-label">启用状态</label>
|
||||
<div class="status-toggle">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ 'is-selected': form.enabled }"
|
||||
@click="form.enabled = true"
|
||||
>
|
||||
启用
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ 'is-selected': !form.enabled }"
|
||||
@click="form.enabled = false"
|
||||
>
|
||||
停用
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</AdminModal>
|
||||
</template>
|
||||
Reference in New Issue
Block a user