查询列表功能

This commit is contained in:
2025-04-03 16:41:54 +08:00
parent cd884686ce
commit 32cbc6404a
15 changed files with 951 additions and 226 deletions

37
src/utils/pythonBridge.js Normal file
View File

@@ -0,0 +1,37 @@
// pythonBridge.js
import { ref, onMounted } from 'vue';
export function usePythonBridge() {
const bridge = ref(null);
// 初始化 QWebChannel
const initBridge = () => {
new QWebChannel(qt.webChannelTransport, (channel) => {
bridge.value = channel.objects.bridge;
});
};
// 调用 Python 方法
const callPython = (data) => {
if (bridge.value) {
bridge.value.stringFromJs(data);
}
};
// 从 Python 获取数据
const getPythonData = () => {
if (bridge.value) {
bridge.value.stringToJs(function (result) {
alert(result);
});
}
};
// 在组件挂载时初始化桥接
onMounted(initBridge);
return {
callPython,
getPythonData
};
}