feat: 脚本录制功能完善

This commit is contained in:
duanshuwen
2026-04-12 22:12:57 +08:00
parent 6432634d17
commit 66db6c462e
16 changed files with 262 additions and 124 deletions

View File

@@ -71,7 +71,7 @@
:loading="saving"
class="!rounded-full !px-6 !h-[42px] !text-[13px] !font-semibold"
>
{{ saving ? t('common.saving', 'Saving...') : t('script.dialog.createTitle') }}
{{ saving ? t('common.saving', 'Saving...') : t('script.dialog.createAndRecord', '创建并录制') }}
</el-button>
</div>
</div>
@@ -124,7 +124,6 @@ const form = ref({
name: '',
description: '',
channel: '',
enabled: true,
});
function resetForm() {
@@ -132,7 +131,6 @@ function resetForm() {
name: '',
description: '',
channel: '',
enabled: true,
};
}
@@ -149,7 +147,7 @@ function handleSubmit() {
description: form.value.description.trim(),
code: defaultScriptTemplate,
channel: form.value.channel,
enabled: form.value.enabled,
enabled: true,
};
emit('save', payload);
visible.value = false;

View File

@@ -193,7 +193,7 @@ function openEditDialog(script: AutomationScript) {
}
function handleCreateDialogClose() {
editingScript.value = undefined;
// editingScript lifecycle is handled by handleSave / handleEditDialogClose
}
function handleEditDialogClose() {
@@ -207,8 +207,17 @@ async function handleSave(input: ScriptSaveInput) {
await store.saveScript(input);
ElMessage.success(t('script.toast.updated'));
} else {
await store.saveScript(input);
const result = await store.saveScript(input);
ElMessage.success(t('script.toast.created'));
ElMessage.info(t('script.toast.codegenStarting', '正在启动 Playwright codegen 录制,请在新窗口中操作,完成后关闭窗口即可自动保存代码'));
const codegenResult = await store.codegen(result.id, input.channel || 'about:blank');
if (codegenResult.success) {
ElMessage.success(t('script.toast.codegenFinished', '录制完成,代码已保存'));
editingScript.value = { ...result, code: codegenResult.code || '' };
editDialogVisible.value = true;
} else {
ElMessage.error(codegenResult.error || t('script.toast.codegenFailed', '录制失败'));
}
}
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);