feat: 实现Revit真实API连接测试功能
- 删除CadSidebar中的Revit模拟连接代码 - 新增revitApi.js服务,调用/api/health端点 - 修复GeometryOptimizationResult组件lint错误 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
d21dbc3b92
commit
69d21cc752
@ -66,6 +66,7 @@ import { ref, computed } from 'vue'
|
||||
import { useCADStore } from '@/stores/cad'
|
||||
import CadSoftwareGrid from '@/components/ui/CadSoftwareGrid.vue'
|
||||
import creoApi from '@/services/creoApi'
|
||||
import revitApi from '@/services/revitApi'
|
||||
import { ElNotification, ElMessageBox } from 'element-plus'
|
||||
|
||||
// 定义事件
|
||||
@ -106,15 +107,8 @@ const testConnection = async (software) => {
|
||||
const result = await creoApi.testConnection()
|
||||
cadStore.setCADConnection(software, result.success)
|
||||
} else if (software === 'revit') {
|
||||
// Revit模拟连接成功(仅供测试)
|
||||
cadStore.setCADConnection(software, true)
|
||||
ElNotification({
|
||||
title: '连接成功',
|
||||
message: 'Revit连接成功(模拟)',
|
||||
type: 'success',
|
||||
position: 'top-right',
|
||||
duration: 2000
|
||||
})
|
||||
const result = await revitApi.testConnection()
|
||||
cadStore.setCADConnection(software, result.success)
|
||||
} else if (software === 'pdms') {
|
||||
// PDMS模拟连接成功(仅供测试)
|
||||
cadStore.setCADConnection(software, true)
|
||||
|
||||
@ -98,10 +98,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
// Props
|
||||
const props = defineProps({
|
||||
defineProps({
|
||||
resultData: {
|
||||
type: Object,
|
||||
required: true
|
||||
@ -109,7 +107,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits(['back-to-analysis'])
|
||||
defineEmits(['back-to-analysis'])
|
||||
|
||||
|
||||
// 格式化导出时间
|
||||
|
||||
38
src/services/revitApi.js
Normal file
38
src/services/revitApi.js
Normal file
@ -0,0 +1,38 @@
|
||||
// Revit API服务 - 完全复制creo结构
|
||||
// 严格遵循开发规范:核心需求优先,杜绝过度工程
|
||||
|
||||
import apiClient from './apiClient'
|
||||
import { buildApiUrl } from '@/config/cad'
|
||||
|
||||
// 重复使用的常量
|
||||
const SOFTWARE_TYPE = "revit"
|
||||
|
||||
// Revit API服务类
|
||||
class RevitApiService {
|
||||
constructor() {
|
||||
this.softwareName = 'revit'
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试Revit连接
|
||||
* @returns {Promise<{success: boolean, data?: any, error?: string}>}
|
||||
*/
|
||||
async testConnection() {
|
||||
// 构建连接测试URL
|
||||
const url = buildApiUrl(this.softwareName, 'connect')
|
||||
|
||||
// 调用统一API客户端(错误处理和通知由apiClient统一管理)
|
||||
return await apiClient.get(url, {
|
||||
operationContext: {
|
||||
software: 'Revit',
|
||||
operation: '连接测试'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 导出单例实例
|
||||
export const revitApi = new RevitApiService()
|
||||
|
||||
// 默认导出
|
||||
export default revitApi
|
||||
Loading…
Reference in New Issue
Block a user