1.排程管理新增检核规则提示词维护,用于传入Dify中作为检核规则
2.聊天界面内容不可复制问题修复
This commit is contained in:
1 parent
452f6ebc6d
commit
ff2d02051f
17 files changed
+355
-20
No files matched your search
@@ -40,6 +40,7 @@ export interface ScheduleRun {
|
||||
api_response_json?: Record<string, any> | null;
|
||||
response_summary_json?: Record<string, any> | null;
|
||||
step_logs?: StepLog[] | null;
|
||||
dify_execution_snapshot?: DifyExecutionSnapshot | null;
|
||||
error_message?: string | null;
|
||||
excel_file_name?: string | null;
|
||||
excel_file_size?: number | null;
|
||||
@@ -59,6 +60,15 @@ export interface StepLog {
|
||||
detail?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DifyExecutionSnapshot {
|
||||
dify_enabled?: boolean;
|
||||
dify_agent_id?: number | null;
|
||||
dify_agent_name?: string | null;
|
||||
dify_app_id?: string | null;
|
||||
dify_system_prompt?: string;
|
||||
captured_at?: string;
|
||||
}
|
||||
|
||||
async function getJson<T>(url: string): Promise<T> {
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) throw new Error((await res.json().catch(() => ({})))?.error || 'Request failed');
|
||||
@@ -119,6 +129,7 @@ export interface TestScheduleRunResult {
|
||||
errors: string[];
|
||||
step_logs: StepLog[];
|
||||
dify_agent_id: number | null;
|
||||
dify_execution_snapshot?: DifyExecutionSnapshot | null;
|
||||
}
|
||||
|
||||
export const testAdminScheduleRun = (taskId: number, payload: { fetch_where_conditions?: string; fetch_order_by?: string; limit?: number }) =>
|
||||
|
||||
+40
-4
@@ -983,7 +983,16 @@ const messages = {
|
||||
oaDataConnected: 'Connected to OA database view query.',
|
||||
searchByNameOrEmployeeId: 'Search by name or employee ID, press Enter',
|
||||
name: 'Name',
|
||||
employeeIdRequired: 'Employee ID is required.'
|
||||
employeeIdRequired: 'Employee ID is required.',
|
||||
actions: {
|
||||
copy: 'Copy',
|
||||
edit: 'Edit',
|
||||
resend: 'Resend',
|
||||
regenerate: 'Regenerate',
|
||||
copySuccess: 'Copied',
|
||||
copyFailed: 'Copy failed. Please allow clipboard access or try again.',
|
||||
copyEmpty: 'Nothing to copy'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: 'Profile',
|
||||
@@ -1975,7 +1984,16 @@ const messages = {
|
||||
oaDataConnected: '已接入 OA 数据库视图查询。',
|
||||
searchByNameOrEmployeeId: '输入姓名或工号搜索,按回车键查询',
|
||||
name: '姓名',
|
||||
employeeIdRequired: '工号不能为空。'
|
||||
employeeIdRequired: '工号不能为空。',
|
||||
actions: {
|
||||
copy: '复制',
|
||||
edit: '编辑',
|
||||
resend: '重新发送',
|
||||
regenerate: '重新生成',
|
||||
copySuccess: '已复制',
|
||||
copyFailed: '复制失败,请允许剪贴板权限后重试',
|
||||
copyEmpty: '没有可复制的内容'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: '个人资料',
|
||||
@@ -2956,7 +2974,16 @@ const messages = {
|
||||
oaDataConnected: '已接入 OA 資料庫視圖查詢。',
|
||||
searchByNameOrEmployeeId: '輸入姓名或工號搜尋,按 Enter 查詢',
|
||||
name: '姓名',
|
||||
employeeIdRequired: '工號不能為空。'
|
||||
employeeIdRequired: '工號不能為空。',
|
||||
actions: {
|
||||
copy: '複製',
|
||||
edit: '編輯',
|
||||
resend: '重新發送',
|
||||
regenerate: '重新生成',
|
||||
copySuccess: '已複製',
|
||||
copyFailed: '複製失敗,請允許剪貼簿權限後重試',
|
||||
copyEmpty: '沒有可複製的內容'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: '個人資料',
|
||||
@@ -3937,7 +3964,16 @@ const messages = {
|
||||
oaDataConnected: 'เชื่อมต่อการค้นหามุมมองฐานข้อมูล OA แล้ว',
|
||||
searchByNameOrEmployeeId: 'ค้นหาด้วยชื่อหรือรหัสพนักงาน แล้วกด Enter',
|
||||
name: 'ชื่อ',
|
||||
employeeIdRequired: 'รหัสพนักงานห้ามว่าง'
|
||||
employeeIdRequired: 'รหัสพนักงานห้ามว่าง',
|
||||
actions: {
|
||||
copy: 'คัดลอก',
|
||||
edit: 'แก้ไข',
|
||||
resend: 'ส่งอีกครั้ง',
|
||||
regenerate: 'สร้างใหม่',
|
||||
copySuccess: 'คัดลอกแล้ว',
|
||||
copyFailed: 'คัดลอกไม่สำเร็จ โปรดอนุญาตการเข้าถึงคลิปบอร์ดแล้วลองอีกครั้ง',
|
||||
copyEmpty: 'ไม่มีเนื้อหาให้คัดลอก'
|
||||
}
|
||||
},
|
||||
profile: {
|
||||
title: 'โปรไฟล์',
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Copy plain text to the clipboard with fallbacks for restricted browsers
|
||||
* (e.g. WeCom embedded WebView, HTTP deployments).
|
||||
*/
|
||||
export async function copyTextToClipboard(text: string): Promise<boolean> {
|
||||
const value = String(text ?? '');
|
||||
if (!value.trim()) return false;
|
||||
|
||||
if (navigator.clipboard?.writeText) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
return true;
|
||||
} catch {
|
||||
// Fall through to legacy copy.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = value;
|
||||
textarea.setAttribute('readonly', 'true');
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.left = '-9999px';
|
||||
textarea.style.top = '0';
|
||||
textarea.style.opacity = '0';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
textarea.setSelectionRange(0, value.length);
|
||||
const ok = document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
return ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -702,6 +702,7 @@ const resetScheduleCreateForm = () => {
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
};
|
||||
scheduleTestResult.value = null;
|
||||
scheduleCronDesigner.value = {
|
||||
@@ -768,6 +769,7 @@ const openScheduleEditModal = async (task: ScheduleTask) => {
|
||||
api_method: cfg.external_api?.method || 'POST',
|
||||
api_headers_str: cfg.external_api?.headers ? JSON.stringify(cfg.external_api.headers, null, 2) : '{}',
|
||||
api_body_template: cfg.external_api?.body_template || '',
|
||||
dify_system_prompt: cfg.dify_system_prompt || '',
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
@@ -795,6 +797,7 @@ const openScheduleEditModal = async (task: ScheduleTask) => {
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -836,6 +839,11 @@ const formatDateTime = (iso?: string | null) => {
|
||||
|
||||
const expandedScheduleRunId = ref<number | null>(null);
|
||||
|
||||
const expandedScheduleRun = computed(() => {
|
||||
if (!expandedScheduleRunId.value) return null;
|
||||
return filteredScheduleRuns.value.find((x) => x.id === expandedScheduleRunId.value) || null;
|
||||
});
|
||||
|
||||
const stepLabelMap: Record<string, string> = {
|
||||
fetch_srm: '抓取外部系统数据',
|
||||
call_dify: '调用Dify服务',
|
||||
@@ -972,6 +980,7 @@ const scheduleSqlEditForm = ref({
|
||||
api_method: 'POST',
|
||||
api_headers_str: '{}',
|
||||
api_body_template: '',
|
||||
dify_system_prompt: '',
|
||||
});
|
||||
const scheduleSqlSaving = ref(false); void scheduleSqlSaving;
|
||||
const scheduleTestLoading = ref(false);
|
||||
@@ -999,6 +1008,12 @@ const handleTestScheduleSql = async () => {
|
||||
|
||||
const scheduleNotifyDropdownOpen = ref(false);
|
||||
|
||||
watch(() => scheduleCreateForm.value.dify_agent_id, (agentId) => {
|
||||
if (!agentId) {
|
||||
scheduleSqlEditForm.value.dify_system_prompt = '';
|
||||
}
|
||||
});
|
||||
|
||||
const getUserName = (uid: number) => {
|
||||
const u = users.value.find(x => x.id === uid);
|
||||
return u ? (u.real_name || u.username) : String(uid);
|
||||
@@ -1076,6 +1091,7 @@ const createSchedule = async () => {
|
||||
headers: apiHeaders,
|
||||
body_template: scheduleSqlEditForm.value.api_body_template,
|
||||
} : undefined,
|
||||
dify_system_prompt: hasAgent ? scheduleSqlEditForm.value.dify_system_prompt : '',
|
||||
};
|
||||
|
||||
scheduleCreateSaving.value = true;
|
||||
@@ -4621,7 +4637,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<td class="px-4 py-2.5">
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
v-if="r.step_logs && r.step_logs.length > 0"
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot"
|
||||
@click="expandedScheduleRunId = expandedScheduleRunId === r.id ? null : r.id"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
>
|
||||
@@ -4635,17 +4651,49 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="expandedScheduleRunId && filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)"
|
||||
v-if="expandedScheduleRun"
|
||||
:key="'expanded-' + expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="10" class="px-4 py-3 bg-slate-50/60">
|
||||
<div class="space-y-2">
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-if="expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h5 class="text-xs font-bold uppercase text-indigo-800">Dify 执行快照(审计)</h5>
|
||||
<span class="text-[10px] text-indigo-600/80">
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.captured_at || '-' }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-slate-700">
|
||||
<div>
|
||||
<span class="font-semibold text-slate-500">Agent:</span>
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-slate-400">(ID: {{ expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }})</span>
|
||||
</div>
|
||||
<div v-if="expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-slate-500">Dify App ID:</span>
|
||||
{{ expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-slate-500">System Prompt:</span>
|
||||
<pre
|
||||
v-if="expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-white p-3 font-mono text-[11px] leading-relaxed text-slate-800"
|
||||
>{{ expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-slate-400">(未配置,使用 Dify 编排内默认提示词)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-slate-500">本次执行未启用 Dify Agent</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<h5 class="text-xs font-bold text-slate-600 uppercase">执行日志</h5>
|
||||
<span class="text-xs text-slate-400">共 {{ filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs?.length || 0 }} 步</span>
|
||||
<span class="text-xs text-slate-400">共 {{ expandedScheduleRun.step_logs?.length || 0 }} 步</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in filteredScheduleRuns.find(x => x.id === expandedScheduleRunId)?.step_logs || []"
|
||||
v-for="(log, li) in expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-slate-200 bg-white'"
|
||||
@@ -4664,6 +4712,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-slate-800 p-2 text-[10px] text-slate-200 font-mono max-h-[200px] overflow-auto">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -5680,6 +5729,29 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="testRunResult.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<h4 class="mb-2 text-sm font-bold text-indigo-900">Dify 执行快照(审计)</h4>
|
||||
<div v-if="testRunResult.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-slate-700">
|
||||
<div>
|
||||
<span class="font-semibold text-slate-500">Agent:</span>
|
||||
{{ testRunResult.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
(ID: {{ testRunResult.dify_execution_snapshot.dify_agent_id ?? '-' }})
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-slate-500">System Prompt:</span>
|
||||
<pre
|
||||
v-if="testRunResult.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[200px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-white p-3 font-mono text-[11px] text-slate-800"
|
||||
>{{ testRunResult.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-slate-400">(未配置)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-slate-500">本次测试未启用 Dify</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-bold text-slate-700 mb-2">步骤日志</h4>
|
||||
<div class="space-y-2">
|
||||
@@ -5995,6 +6067,18 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="scheduleCreateForm.dify_agent_id" class="rounded-2xl border border-indigo-200 bg-indigo-50/40 p-4">
|
||||
<div class="mb-2">
|
||||
<label class="block text-sm font-medium text-slate-700">Dify System Prompt</label>
|
||||
<p class="mt-1 text-xs text-slate-500">仅在启用 Dify Agent 时可配置。保存后将作为 <code class="rounded bg-white px-1 py-0.5 text-indigo-700">system_prompt</code> 传入 Workflow;编排中 LLM 节点需引用该变量。</p>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="scheduleSqlEditForm.dify_system_prompt"
|
||||
class="w-full min-h-[140px] rounded-xl border border-indigo-200 bg-white p-3 text-sm leading-relaxed text-slate-700 font-mono focus:border-indigo-300 focus:outline-none focus:ring-1 focus:ring-indigo-200 resize-y"
|
||||
placeholder="例如:你是物料合规判定助手。根据 record 中的检测数据判定是否合格,仅返回 JSON:dify_result(合格/不合格/人工判定)与 dify_message。"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50/40 p-4">
|
||||
<div class="mb-3">
|
||||
<h4 class="text-base font-bold text-slate-900">Cron 图形化设置</h4>
|
||||
|
||||
@@ -23,6 +23,7 @@ import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
import { useIsMobile } from '../composables/useIsMobile';
|
||||
import { useTheme } from '../composables/useTheme';
|
||||
import { getAuthHeaders, getStoredAuthUser, clearAuthUser } from '../utils/auth';
|
||||
import { copyTextToClipboard } from '../utils/clipboard';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { appliedTheme, toggleLightDark } = useTheme();
|
||||
@@ -1583,16 +1584,29 @@ const confirmLeaveSubmission = async (msg: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const copyToClipboard = async (text: string, index: number) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
const getMessageCopyText = (msg: { role?: string; content?: string; type?: string }) => {
|
||||
const content = String(msg?.content ?? '').trim();
|
||||
if (content) return content;
|
||||
return '';
|
||||
};
|
||||
|
||||
const copyToClipboard = async (msg: { role?: string; content?: string; type?: string }, index: number) => {
|
||||
const text = getMessageCopyText(msg);
|
||||
if (!text) {
|
||||
showMessageDialog('warning', t('chat.actions.copyEmpty'));
|
||||
return;
|
||||
}
|
||||
|
||||
const ok = await copyTextToClipboard(text);
|
||||
if (ok) {
|
||||
copiedIndex.value = index;
|
||||
setTimeout(() => {
|
||||
copiedIndex.value = null;
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error('Failed to copy:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
showMessageDialog('error', t('chat.actions.copyFailed'));
|
||||
};
|
||||
|
||||
const regenerate = () => {
|
||||
@@ -2332,7 +2346,8 @@ const showChatRating = ref(false);
|
||||
:class="msg.role === 'user' ? 'justify-end text-slate-500' : 'justify-start text-slate-500'"
|
||||
>
|
||||
<button
|
||||
@click="copyToClipboard(msg.content, index)"
|
||||
type="button"
|
||||
@click.stop="copyToClipboard(msg, index)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.copy')"
|
||||
>
|
||||
@@ -2342,14 +2357,16 @@ const showChatRating = ref(false);
|
||||
|
||||
<template v-if="msg.role === 'user'">
|
||||
<button
|
||||
@click="input = msg.content"
|
||||
type="button"
|
||||
@click.stop="input = msg.content"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.edit')"
|
||||
>
|
||||
<Edit2 class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button
|
||||
@click="handleSend(msg.content)"
|
||||
type="button"
|
||||
@click.stop="handleSend(msg.content)"
|
||||
class="rounded-md p-1.5 text-xs transition-colors hover:bg-slate-100 dark:hover:bg-slate-800"
|
||||
:title="$t('chat.actions.resend')"
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user