Commit 28c24885 by qinjianhui

Revert "fix: 修改 CLODOP 打不开问题"

This reverts commit 11caae4f.
parent 11caae4f
......@@ -30,7 +30,7 @@ declare global {
interface Window {
LODOP: new () => LODOPObject;
_lodop:LODOPObject | null;
_lodopCallback:{ [key: string]: (value: string) => void };
_lodopCallback:{ [key: string]: Function };
CLODOP: CLodopObject;
getCLodop: () => LODOPObject;
}
......@@ -99,43 +99,12 @@ export default function useLodop() {
JS1.src = 'http://localhost:8000/CLodopfuncs.js'
JS2.src = 'http://localhost:18000/CLodopfuncs.js'
}
let loadedCount = 0
let errorCount = 0
const totalScripts = 2
const checkComplete = () => {
if (loadedCount + errorCount >= totalScripts) {
CLodopJsState = 'complete'
// 检查是否成功加载了 getCLodop 函数
if (typeof window.getCLodop !== 'function') {
console.warn('Lodop JS文件加载完成,但 window.getCLodop 未定义')
} else {
console.log('Lodop JS文件加载成功')
}
}
}
JS1.onload = function () {
loadedCount++
checkComplete()
}
JS1.onerror = function () {
errorCount++
console.warn('加载 CLodop JS1 失败:', JS1.src)
checkComplete()
JS1.onload = JS2.onload = function () {
CLodopJsState = 'complete'
}
JS2.onload = function () {
loadedCount++
checkComplete()
JS1.onerror = JS2.onerror = function () {
CLodopJsState = 'complete'
}
JS2.onerror = function () {
errorCount++
console.warn('加载 CLodop JS2 失败:', JS2.src)
checkComplete()
}
head.insertBefore(JS1, head.firstChild)
head.insertBefore(JS2, head.firstChild)
CLodopIsLocal = !!(JS1.src + JS2.src).match(/\/\/localho|\/\/127.0.0./i)
......@@ -193,41 +162,11 @@ export default function useLodop() {
/Linux/i.test(navigator.userAgent) && /aarch64/i.test(navigator.userAgent)
if (needCLodop || isLinuxX86 || isLinuxARM) {
// 检查 window.getCLodop 是否存在
if (typeof window.getCLodop !== 'function') {
// 如果 JS 文件还在加载中,等待一段时间后重试
if (CLodopJsState === 'loading') {
console.log('Lodop JS文件正在加载中,请稍候...')
return null
}
// 如果 JS 文件加载完成但 getCLodop 不存在,可能是加载失败
if (CLodopJsState === 'complete') {
console.warn('Lodop JS文件加载完成,但 window.getCLodop 未定义,可能是加载失败')
// 尝试重新初始化(最多重试一次,避免无限循环)
const retryKey = '__lodop_retry_count__'
const retryCount = (window as unknown as Record<string, number>)[retryKey] || 0
if (retryCount < 1) {
(window as unknown as Record<string, number>)[retryKey] = retryCount + 1
CLodopJsState = null
initLodop()
} else {
console.error('Lodop JS文件加载失败,已重试一次,请检查CLodop服务是否正常运行')
}
return null
}
// 如果从未加载过,先初始化
if (CLodopJsState === null) {
initLodop()
return null
}
}
try {
LODOP = window.getCLodop()
} catch (err) {
console.error('调用 window.getCLodop() 出错:', err)
console.error(err)
}
if (!LODOP && CLodopJsState !== 'complete') {
if (CLodopJsState == 'loading'){
console.log('网页还没下载完毕,请稍等一下再操作.')
......@@ -250,7 +189,7 @@ export default function useLodop() {
strAlertMessage = strLodop7Update_X86
else if (isLinuxARM && LODOP.CVERSION < '7.0.4.3')
strAlertMessage = strLodop7Update_ARM
else if (window.CLODOP && window.CLODOP.CVERSION < '4.1.6.1')
else if (window.CLODOP.CVERSION < '4.1.6.1')
strAlertMessage = strCLodopUpdate
if (strAlertMessage) showMsg(strAlertMessage + strInstallOK)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment