122 lines
4.5 KiB
HTML
122 lines
4.5 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-TW">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Simple Vue.js Rendering Canvas Demo</title>
|
||
<!-- Use vue.global.prod.js for production deployment -->
|
||
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
|
||
<script src="https://cdn.jsdelivr.net/npm/@microsoft/signalr@latest/dist/browser/signalr.min.js"></script>
|
||
<style>
|
||
body {
|
||
margin: 0;
|
||
padding: 20px;
|
||
font-family: Arial, sans-serif;
|
||
}
|
||
|
||
.demo-container {
|
||
max-width: 1200px;
|
||
margin: 0 auto;
|
||
}
|
||
|
||
.canvas-wrapper {
|
||
height: 600px;
|
||
border: 1px solid #ddd;
|
||
margin: 20px 0;
|
||
}
|
||
|
||
.controls {
|
||
margin-bottom: 20px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="app">
|
||
<div class="demo-container">
|
||
<h1>Simple Rendering Canvas Demo</h1>
|
||
|
||
<div class="controls" v-if="canvas">
|
||
<!-- View dropdown component -->
|
||
<rendering-canvas-view-dropdown
|
||
:rendering-canvas="canvas"
|
||
></rendering-canvas-view-dropdown>
|
||
</div>
|
||
|
||
<div style="padding: 10px; background-color: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; border-radius: 4px; margin: 10px 0;">
|
||
<strong>操作說明:</strong>
|
||
<br><strong>滑鼠:</strong>左鍵拖動旋轉,右鍵拖動平移,滾輪縮放
|
||
<br><strong>鍵盤:</strong>F1-F4切換視圖,方向鍵旋轉,PageUp/PageDown縮放,Home重置視圖
|
||
<br><strong>觸控:</strong>單指拖動平移,雙指捏合縮放,雙指旋轉,三指上下滑動縮放
|
||
</div>
|
||
|
||
<div class="canvas-wrapper">
|
||
<!-- Self-contained canvas component -->
|
||
<rendering-canvas
|
||
ref="canvas"
|
||
:auto-connect="true"
|
||
@initialized="onCanvasInitialized"
|
||
@server-initialized="onServerInitialized"
|
||
></rendering-canvas>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script type="module">
|
||
import RenderingCanvas from '/_content/hi.webapi/disp/rendering-canvas-vue.js';
|
||
import RenderingCanvasViewDropdown from './disp/rendering-canvas-view-dropdown.js';
|
||
|
||
const { createApp } = Vue;
|
||
|
||
createApp({
|
||
components: {
|
||
RenderingCanvas,
|
||
RenderingCanvasViewDropdown
|
||
},
|
||
data() {
|
||
return {
|
||
canvas: null
|
||
}
|
||
},
|
||
mounted() {
|
||
// Make the canvas reference available after mounting
|
||
this.$nextTick(() => {
|
||
this.canvas = this.$refs.canvas;
|
||
});
|
||
},
|
||
methods: {
|
||
onCanvasInitialized(canvasId) {
|
||
console.log('Canvas initialized:', canvasId);
|
||
// Update the canvas reference to ensure dropdown is enabled
|
||
this.canvas = this.$refs.canvas;
|
||
},
|
||
|
||
async onServerInitialized(sessionId) {
|
||
console.log('Server initialized with session:', sessionId);
|
||
// Load test objects for this demo
|
||
await this.loadTestObjects(sessionId);
|
||
},
|
||
|
||
async loadTestObjects(sessionId) {
|
||
try {
|
||
const response = await fetch(`/api/rendering/test-objects/${sessionId}`, {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json'
|
||
}
|
||
});
|
||
|
||
if (response.ok) {
|
||
console.log('Test objects loaded successfully');
|
||
} else {
|
||
const errorText = await response.text();
|
||
console.error(`Failed to load test objects: ${response.status} - ${errorText}`);
|
||
}
|
||
} catch (err) {
|
||
console.error(`Error loading test objects: ${err}`);
|
||
}
|
||
}
|
||
}
|
||
}).mount('#app');
|
||
</script>
|
||
</body>
|
||
</html> |