Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0e3abc2b
authored
Mar 31, 2025
by
Joeshu
Committed by
GitHub
Mar 31, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
docs: add third-party libraries to check update methods (#5819)
1 parent
a96be3db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
docs/src/guide/in-depth/check-updates.md
docs/src/guide/in-depth/check-updates.md
View file @
0e3abc2
...
@@ -46,3 +46,47 @@ async function getVersionTag() {
...
@@ -46,3 +46,47 @@ async function getVersionTag() {
}
}
}
}
```
```
## 替换为第三方库检查更新方式
如果需要通过其他方式检查更新,例如使用其他版本控制方式(chunkHash、version.json)、使用
`Web Worker`
在后台轮询更新、自定义检查更新时机(不使用轮询),你可以通过JS库
`version-polling`
来实现。
```
bash
pnpm add version-polling
```
以
`apps/web-antd`
项目为例,在项目入口文件
`main.ts`
或者
`app.vue`
添加以下代码
```
ts
import
{
h
}
from
'vue'
;
import
{
Button
,
notification
}
from
'ant-design-vue'
;
import
{
createVersionPolling
}
from
'version-polling'
;
createVersionPolling
({
silent
:
import
.
meta
.
env
.
MODE
===
'development'
,
// 开发环境下不检测
onUpdate
:
(
self
)
=>
{
const
key
=
`open
${
Date
.
now
()}
`
;
notification
.
info
({
message
:
'提示'
,
description
:
'检测到网页有更新, 是否刷新页面加载最新版本?'
,
btn
:
()
=>
h
(
Button
,
{
type
:
'primary'
,
size
:
'small'
,
onClick
:
()
=>
{
notification
.
close
(
key
);
self
.
onRefresh
();
},
},
{
default
:
()
=>
'刷新'
},
),
key
,
duration
:
null
,
placement
:
'bottomRight'
,
});
},
});
```
Write
Preview
Markdown
is supported
Attach a file
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 post a comment