fix: 修复 pywebview 参数序列化问题

This commit is contained in:
dmy
2026-03-04 15:54:48 +08:00
parent d1baa87ae4
commit 9d69b1bad2

View File

@@ -421,7 +421,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue' import { ref, reactive, computed, onMounted, onUnmounted, watch, toRaw } from 'vue'
import type { AllParameters } from '@/types' import type { AllParameters } from '@/types'
import LogComponent from './Log.vue' import LogComponent from './Log.vue'
import Animation from './Animation.vue' import Animation from './Animation.vue'
@@ -638,8 +638,12 @@ const calculate = async () => {
// 后台线程启动计算,实时日志通过 addLogFromBackend 推送 // 后台线程启动计算,实时日志通过 addLogFromBackend 推送
// 结果通过 receiveResult 回调接收 // 结果通过 receiveResult 回调接收
// 传递动画启用状态 // 传递动画启用状态
// 使用 toRaw 解包响应式对象,确保 pywebview 能正确序列化参数
const rawParams = toRaw(params)
const paramsWithAnimation = { const paramsWithAnimation = {
...params, parameter: toRaw(rawParams.parameter),
advance: toRaw(rawParams.advance),
optional: toRaw(rawParams.optional),
animation_enabled: animationRef.value?.isEnabled() ?? false animation_enabled: animationRef.value?.isEnabled() ?? false
} }
await window.pywebview.api.calculate(paramsWithAnimation) await window.pywebview.api.calculate(paramsWithAnimation)