mirror of
https://github.com/Powerful-517/yys-editor.git
synced 2026-03-06 07:25:27 +00:00
test: 集成 Vitest 测试框架和开发规范
- 安装 vitest, @vue/test-utils, jsdom 等测试依赖 - 配置 vitest.config.js 测试环境 - 添加 schema.test.ts (7个数据结构验证测试) - 添加 useStore.test.ts (7个状态管理测试) - 创建测试指南文档 (docs/testing.md) - 创建测试规范文档 (docs/testing-rules.md) - 创建开发规范文档 (docs/development-rules.md) - 创建开发工作流程文档 (docs/1management/workflow.md) - 添加测试相关 npm scripts (test, test:watch, test:ui, test:coverage) - 所有测试通过 (14/14)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<div>
|
||||
<el-button icon="Upload" type="primary" @click="handleImport">{{ t('import') }}</el-button>
|
||||
<el-button icon="Download" type="primary" @click="handleExport">{{ t('export') }}</el-button>
|
||||
<el-button icon="View" type="success" @click="handlePreviewData">数据预览</el-button>
|
||||
<el-button icon="Share" type="primary" @click="prepareCapture">{{ t('prepareCapture') }}</el-button>
|
||||
<el-button icon="Setting" type="primary" @click="state.showWatermarkDialog = true">{{ t('setWatermark') }}</el-button>
|
||||
<el-button type="info" @click="loadExample">{{ t('loadExample') }}</el-button>
|
||||
@@ -97,6 +98,19 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 数据预览对话框 -->
|
||||
<el-dialog v-model="state.showDataPreviewDialog" title="数据预览" width="70%">
|
||||
<div style="max-height: 600px; overflow-y: auto;">
|
||||
<pre style="background: #f5f5f5; padding: 16px; border-radius: 4px; font-size: 12px; line-height: 1.5;">{{ state.previewDataContent }}</pre>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="state.showDataPreviewDialog = false">关闭</el-button>
|
||||
<el-button type="primary" @click="copyDataToClipboard">复制到剪贴板</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -124,6 +138,8 @@ const state = reactive({
|
||||
showWatermarkDialog: false, // 控制水印设置弹窗的显示状态,
|
||||
showUpdateLogDialog: false, // 控制更新日志对话框的显示状态
|
||||
showFeedbackFormDialog: false, // 控制反馈表单对话框的显示状态
|
||||
showDataPreviewDialog: false, // 控制数据预览对话框的显示状态
|
||||
previewDataContent: '', // 存储预览的数据内容
|
||||
});
|
||||
|
||||
// 重新渲染 LogicFlow 画布的通用方法
|
||||
@@ -216,6 +232,39 @@ const handleExport = () => {
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
const handlePreviewData = () => {
|
||||
// 预览前先更新当前数据
|
||||
filesStore.updateTab();
|
||||
|
||||
// 延迟一点确保更新完成后再预览
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const activeName = filesStore.fileList.find(f => f.id === filesStore.activeFileId)?.name || '';
|
||||
const dataObj = {
|
||||
schemaVersion: 1,
|
||||
fileList: filesStore.fileList,
|
||||
activeFileId: filesStore.activeFileId,
|
||||
activeFile: activeName,
|
||||
};
|
||||
state.previewDataContent = JSON.stringify(dataObj, null, 2);
|
||||
state.showDataPreviewDialog = true;
|
||||
} catch (error) {
|
||||
console.error('生成预览数据失败:', error);
|
||||
showMessage('error', '数据预览失败');
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const copyDataToClipboard = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(state.previewDataContent);
|
||||
showMessage('success', '已复制到剪贴板');
|
||||
} catch (error) {
|
||||
console.error('复制失败:', error);
|
||||
showMessage('error', '复制失败');
|
||||
}
|
||||
};
|
||||
|
||||
const handleImport = () => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
|
||||
Reference in New Issue
Block a user