mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-06-11 10:40:00 +08:00
fix(web-mode): consolidate Tauri event subscription helper to silence transformCallback errors (#256)
- Add shared safeTauriListen helper in tauri-api.js that returns a noop unsubscriber when running outside Tauri, so dynamic-importing @tauri-apps/api/event in the browser no longer throws 'Cannot read properties of undefined (reading transformCallback)'. - Replace 4 bare 'await import(@tauri-apps/api/event)' call sites (about.js hermes upgrade button + channels.js three install/action flows) that previously crashed the page on web mode. - Drop the duplicated local tauriListen helpers in hermes dashboard / chat store and route them through the shared helper.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* 关于页面
|
||||
* 版本信息、项目链接、相关项目、系统环境
|
||||
*/
|
||||
import { api } from '../lib/tauri-api.js'
|
||||
import { api, safeTauriListen } from '../lib/tauri-api.js'
|
||||
import { toast } from '../components/toast.js'
|
||||
import { showUpgradeModal, showConfirm, showContentModal } from '../components/modal.js'
|
||||
import { setUpgrading } from '../lib/app-state.js'
|
||||
@@ -217,8 +217,7 @@ async function loadHermesData(page) {
|
||||
|
||||
let unlisten = null
|
||||
try {
|
||||
const { listen } = await import('@tauri-apps/api/event')
|
||||
unlisten = await listen('hermes-install-log', (e) => {
|
||||
unlisten = await safeTauriListen('hermes-install-log', (e) => {
|
||||
modal.appendLog(String(e.payload))
|
||||
})
|
||||
} catch (_) {}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 消息渠道管理
|
||||
* 渠道列表 + Agent 对接(多绑定、独立配置、渠道测试)
|
||||
*/
|
||||
import { api, invalidate } from '../lib/tauri-api.js'
|
||||
import { api, invalidate, safeTauriListen } from '../lib/tauri-api.js'
|
||||
import { toast } from '../components/toast.js'
|
||||
import { showContentModal, showConfirm } from '../components/modal.js'
|
||||
import { icon } from '../lib/icons.js'
|
||||
@@ -1530,7 +1530,7 @@ async function openConfigDialog(pid, page, state, accountId) {
|
||||
const logBox = actionResultEl.querySelector('#channel-action-log-box')
|
||||
const progressBar = actionResultEl.querySelector('#channel-action-progress-bar')
|
||||
const progressText = actionResultEl.querySelector('#channel-action-progress-text')
|
||||
const { listen } = await import('@tauri-apps/api/event')
|
||||
const listen = safeTauriListen
|
||||
let unlistenLog = null, unlistenProgress = null
|
||||
let _qrTimer = null
|
||||
const cleanup = () => { unlistenLog?.(); unlistenProgress?.(); clearTimeout(_qrTimer) }
|
||||
@@ -1923,7 +1923,7 @@ async function openConfigDialog(pid, page, state, accountId) {
|
||||
const logBox = actionResultEl.querySelector('#channel-action-log-box')
|
||||
const progressBar = actionResultEl.querySelector('#channel-action-progress-bar')
|
||||
const progressText = actionResultEl.querySelector('#channel-action-progress-text')
|
||||
const { listen } = await import('@tauri-apps/api/event')
|
||||
const listen = safeTauriListen
|
||||
let unlistenLog = null
|
||||
let unlistenProgress = null
|
||||
let unlistenDone = null
|
||||
@@ -2110,7 +2110,7 @@ async function openConfigDialog(pid, page, state, accountId) {
|
||||
const progressText = resultEl.querySelector('#plugin-progress-text')
|
||||
let unlistenLog, unlistenProgress
|
||||
try {
|
||||
const { listen } = await import('@tauri-apps/api/event')
|
||||
const listen = safeTauriListen
|
||||
unlistenLog = await listen('plugin-log', (e) => {
|
||||
logBox.textContent += e.payload + '\n'
|
||||
logBox.scrollTop = logBox.scrollHeight
|
||||
|
||||
Reference in New Issue
Block a user