| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /**
- * Vue3 调用示例
- *
- * 架构:Vue3 -> Electron IPC (或 Node.js API) -> child_process -> laser_wrapper.py -> entry.pyd/.so
- */
- const VUE3_CODE = `
- // 在 Vue3 中调用
- import { ref } from 'vue';
- // 假设通过 Electron IPC 调用
- const invokeLaser = async (apiName, dataObj = null) => {
- let b64Data = null;
- if (dataObj) {
- b64Data = btoa(unescape(encodeURIComponent(JSON.stringify(dataObj))));
- }
- // 调用 electron 暴露的 API
- return await window.electronAPI.callPythonAPI(apiName, b64Data);
- };
- export default {
- setup() {
- const result = ref(null);
- const handleGetPath = async () => {
- try {
- result.value = await invokeLaser('getpath');
- } catch (e) {
- console.error(e);
- }
- };
- const handleLoadData = async () => {
- const params = [
- "path/to/locate.csv",
- "path/to/measure.csv",
- "5.0", // angle_cone
- "2.0" // axial_inclination
- ];
- try {
- result.value = await invokeLaser('loaddata', params);
- } catch (e) {
- console.error(e);
- }
- };
- return { handleGetPath, handleLoadData, result };
- }
- }
- `;
- console.log("Vue3 Example Code generated.");
|