Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinjianhui
factory_front
Commits
60fe5a89
Commit
60fe5a89
authored
Dec 08, 2025
by
qinjianhui
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Revert "fix: 修改 CLODOP 打不开问题" See merge request
!121
parents
38650fb5
28c24885
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
68 deletions
+7
-68
src/utils/hooks/useLodop.ts
+7
-68
No files found.
src/utils/hooks/useLodop.ts
View file @
60fe5a89
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment