am-freescan/am-web/src/cmvr/setup.ts
lixiaolong 64db825a9f feat: 完善设备工作流集成、组合执行与主题适配
集成旋转底座、机械臂示教与坐标系,完善扫描参数、电量和框架点复用。增加组合执行、步骤进度与日志,优化首屏和流程画布性能,修复表头主题适配,并保留验证脚本和回归测试。
2026-11-02 17:38:34 +08:00

50 lines
2.5 KiB
TypeScript

// @ts-nocheck
import type { App } from 'vue'
import * as ElementIcons from '@element-plus/icons-vue'
import Pagination from './common/components/Pagination/index.vue'
import RightToolbar from './common/components/RightToolbar/index.vue'
import DictTag from './common/components/DictTag/index.vue'
import FileUpload from './common/components/FileUpload/index.vue'
import ImageUpload from './common/components/ImageUpload/index.vue'
import ImagePreview from './common/components/ImagePreview/index.vue'
import SvgIcon from './common/components/SvgIcon/index.vue'
import { useDict } from './common/utils/dict'
import * as ruoyi from './common/utils/ruoyi'
import modal from './common/plugins/modal'
import cache from './common/plugins/cache'
import { download, cmvrApiBase } from './request'
import { runtimeConfig } from './common/runtime/config'
import { getConfigKey } from './common/api/system/config'
import WebSocketPlugin from './common/plugins/websocket'
import { getCurrentUserId, getAccessToken } from '@/utils/auth'
import { useUserStore } from '@/store/modules/user'
import { defineAsyncComponent, watch } from 'vue'
import './styles.scss'
export function setupCmvr(app: App) {
Object.assign(runtimeConfig, { apiBaseURL: cmvrApiBase, storagePrefix: 'am-freescan:cmvr' })
for (const [name, component] of Object.entries(ElementIcons)) app.component(name, component)
for (const [name, component] of Object.entries({ Pagination, RightToolbar, DictTag, FileUpload, ImageUpload, ImagePreview, SvgIcon })) app.component(`Cmvr${name}`, component)
app.component('CmvrEditor', defineAsyncComponent(() => import('./common/components/Editor/index.vue')))
app.component('JsonViewer', defineAsyncComponent(async () => {
const [{ JsonViewer }] = await Promise.all([
import('vue3-json-viewer'),
import('vue3-json-viewer/dist/index.css')
])
return JsonViewer
}))
Object.assign(app.config.globalProperties, ruoyi, { useDict, download, getConfigKey, $modal: modal, $cache: cache })
const wsUrl = new URL(cmvrApiBase, window.location.origin).href.replace(/^http/, 'ws') + '/ws'
app.use(WebSocketPlugin, { url: wsUrl, userId: () => getAccessToken() ? getCurrentUserId() : 0 })
// The host loads identity after login; connect once it becomes available.
const user = useUserStore()
watch(() => user.user.id, (id) => {
const socket = app.config.globalProperties.$ws
if (!id) socket.close()
else if (socket.connectionUserId !== id || !socket.status) {
socket.isManualClose = false
socket.connect()
}
})
}