@@ -952,6 +952,7 @@ import {
952952 toRef ,
953953 nextTick ,
954954 onMounted ,
955+ type Ref ,
955956} from " vue" ;
956957import { useI18n } from " vue-i18n" ;
957958import {
@@ -1045,6 +1046,7 @@ import type {
10451046import type {
10461047 ModelSelectOption ,
10471048 TemplateSelectOption ,
1049+ TestAreaPanelInstance ,
10481050} from " @prompt-optimizer/ui" ;
10491051
10501052// 1. 基础 composables
@@ -1090,9 +1092,13 @@ const saveFavoriteData = ref<{
10901092 originalContent? : string ;
10911093} | null >(null );
10921094const optimizeModelSelect = ref (null );
1093- const testPanelRef = ref (null );
1094- const systemWorkspaceRef = ref (null );
1095- const userWorkspaceRef = ref (null );
1095+ type ContextWorkspaceExpose = {
1096+ testAreaPanelRef? : Ref <TestAreaPanelInstance | null >;
1097+ };
1098+
1099+ const testPanelRef = ref <TestAreaPanelInstance | null >(null );
1100+ const systemWorkspaceRef = ref <ContextWorkspaceExpose | null >(null );
1101+ const userWorkspaceRef = ref <ContextWorkspaceExpose | null >(null );
10961102const promptPanelRef = ref <{
10971103 refreshIterateTemplateSelect? : () => void ;
10981104} | null >(null );
@@ -2057,6 +2063,23 @@ const promptInputPlaceholder = computed(() => {
20572063});
20582064
20592065// 真实测试处理函数
2066+ const getActiveTestPanelInstance = (): TestAreaPanelInstance | null => {
2067+ if (functionMode .value === " pro" ) {
2068+ if (contextMode .value === " system" ) {
2069+ return (
2070+ systemWorkspaceRef .value ?.testAreaPanelRef ?.value ?? null
2071+ );
2072+ }
2073+ return userWorkspaceRef .value ?.testAreaPanelRef ?.value ?? null ;
2074+ }
2075+
2076+ if (functionMode .value === " basic" ) {
2077+ return testPanelRef .value ;
2078+ }
2079+
2080+ return null ;
2081+ };
2082+
20602083const handleTestAreaTest = async (testVariables ? : Record <string , string >) => {
20612084 // 调用 promptTester 的 executeTest 方法
20622085 await promptTester .executeTest (
@@ -2065,7 +2088,7 @@ const handleTestAreaTest = async (testVariables?: Record<string, string>) => {
20652088 testContent .value ,
20662089 isCompareMode .value ,
20672090 testVariables ,
2068- testPanelRef . value
2091+ getActiveTestPanelInstance ()
20692092 );
20702093};
20712094
0 commit comments