You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.en-US.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,17 @@
6
6
7
7
---
8
8
9
+
## 1.7.0
10
+
11
+
`2023-06-25`
12
+
13
+
- 🆕 Another method for real-time detection of web application version: By leveraging the browser's cache negotiation mechanism, it checks whether the content of the specified file address has been updated to determine if a new version is available.
14
+
- Added `checkOriginSpecifiedFilesUrl` configuration option: After setting this property, the version will be monitored by "checking whether the specified file has been updated" instead of "managing the version number". Pass in a list of file addresses to be monitored, usually the index.html file under a domain name (string array type).
15
+
- Added `checkOriginSpecifiedFilesUrlMode` configuration option: Supports two modes: 'one' / 'all'. 'one' means that if the content of one of the file addresses in the list changes, it will prompt for an update; 'all' means that it will prompt for an update only when the content of all file addresses in the list changes. (Only effective when checkOriginSpecifiedFilesUrl is configured)
16
+
- Added `enable` configuration option: Whether to enable version monitoring. With this configuration option, version monitoring can be enabled only in specified environments (default is true).
17
+
- Added `clearIntervalOnDialog` configuration option: Whether to clear the timer when the new version prompt dialog appears.
Copy file name to clipboardExpand all lines: README.md
+41-7Lines changed: 41 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,9 @@ When is it suitable to use **to automatically send deployment messages to Lark o
54
54
## Features
55
55
56
56
- Support all modern browsers
57
-
- Available version real-time monitoring, support any version format, such as: 1.1.0, 1.1.1.0, 1.1.0-beta, etc.
57
+
- Real-time detection of available versions is provided in two ways: 1. through managing version numbers; 2. by detecting updates in specified file contents
58
+
- Managing version numbers supports any version format, such as 1.1.0, 1.1.1.0, 1.1.0-beta, etc.
59
+
- Detecting updates in specified file contents supports any file on a remote server `v1.7.0`
58
60
- Support personalized version popup text and theme, also support custom UI
59
61
- Sync deployment message to Lark or WeCom group chat after successful deploy
60
62
- Card text and templates for deployment messages support customization, and support the dynamically generated fields.
@@ -64,7 +66,9 @@ When is it suitable to use **to automatically send deployment messages to Lark o
64
66
65
67
## Implementation Principle
66
68
67
-
-**Web application version real-time detection:****version-rocket** compares the version of the user's current browser with the version files in the remote server. We use JavaScript's `Web Worker API` to make monitoring rotation, which will not affect the browser rendering process.
69
+
-**Web application version real-time detection:**
70
+
1. Through version number management: **version-rocket** compares the version in the user's current browser with the version file on the remote server. We use the `Web Worker API` based on JavaScript to perform monitoring polling, which does not affect the browser rendering process.
71
+
2. By detecting updates in specified file contents: **version-rocket** uses the browser's conditional cache mechanism to determine whether the specified file content has changed. We use the `Web Worker API` based on JavaScript to perform monitoring polling, which does not affect the browser rendering process. `v1.7.0`
68
72
69
73
-**Automatically send deployment messages to Lark or WeCom group chat:****version-rocket** call the webhook method provided by collaborative office software to trigger group chat robots send messages.
70
74
@@ -75,10 +79,10 @@ When is it suitable to use **to automatically send deployment messages to Lark o
75
79
```bash
76
80
# Choose a package manager you prefer
77
81
78
-
// npm
82
+
# npm
79
83
npm install version-rocket --save
80
84
81
-
// yarn
85
+
# yarn
82
86
yarn add version-rocket
83
87
84
88
# pnpm
@@ -88,7 +92,7 @@ pnpm install version-rocket
88
92
89
93
### Quick Start
90
94
91
-
### Web application version real-time detection
95
+
### Web application version real-time detection: Through version number management
92
96
93
97
Step 1: Import `checkVersion()`, and use it
94
98
@@ -211,14 +215,40 @@ server {
211
215
```
212
216
</details>
213
217
214
-
*Complete the above two steps, the version monitoring functioncan be used normally 🎉🎉*
218
+
*Complete the above two steps, the version monitoring function(through version number management) can be used normally 🎉🎉*
219
+
220
+
### Web application version real-time detection: By detecting updates in specified file contents `v1.7.0`
221
+
222
+
> ⚠️ Friendly reminder: This method does not support displaying "current version changes or other information that needs to be shown in the prompt window". If you have such a requirement, please use the "version management" method.
223
+
224
+
import `checkVersion()`, and use it
225
+
226
+
```javascript
227
+
// Entry file: such as App.vue or App.jsx, etc
228
+
import { checkVersion } from 'version-rocket'
229
+
230
+
// Call checkVersion in the lifecycle hook
231
+
checkVersion({
232
+
// The list of files to be monitored usually includes the index.html file under a certain domain
// The validation mode for the list of monitored files: 'one' (default) or 'all'
235
+
checkOriginSpecifiedFilesUrlMode: 'one',
236
+
// Whether to enable version monitoring (default true)
237
+
enable: process.env.NODE_ENV !== 'development'
238
+
})
239
+
240
+
// If you need to terminate version checking, call the unCheckVersion method in the destroy lifecycle. For more details, see the API documentation
241
+
unCheckVersion({closeDialog: false})
242
+
243
+
```
244
+
245
+
*After completing the above steps, the version monitoring feature (by detecting updates in specified file contents) can be used normally 🎉🎉*
215
246
216
247
#### Personalize the theme
217
248
218
249
```javascript
219
250
220
251
// Entry file: such as App.vue or App.jsx, etc
221
-
222
252
import { checkVersion } from 'version-rocket'
223
253
// It is recommended to use the version field in package.json, or you can customize versions
224
254
import { version } from '../package.json'
@@ -592,6 +622,10 @@ sh "export messageJSON='{\"title\": \"This is a title\"}'"
592
622
| config.localPackageVersion | string | The version of the current application usually takes the version field of package.json for comparison with the version.json file of the remote server || Yes |
593
623
| config.pollingTime | number | Time interval forpolling monitoring,in ms | 5000 | No |
594
624
| config.immediate | boolean | On the first visit, version monitoring will be triggered immediately, and then polling will be conducted at a customized time interval **`v1.5.0`**|false| No |
625
+
| config.checkOriginSpecifiedFilesUrl | array | Setting this property will use 'detecting updates in specified file contents' instead of 'version number management' to monitor versions. Pass in the list of file addresses to be monitored, usually the index.html file under a certain domain **`v1.7.0`**||false|
626
+
| config.checkOriginSpecifiedFilesUrlMode |'one' / 'all'|'one' means that if the content of any file address in the list changes, a prompt foran update will be displayed; 'all' means that a prompt for an update will only be displayed when the content of all file addressesin the list changes. (This only takes effect when checkOriginSpecifiedFilesUrl is configured) **`v1.7.0`**|'one'|false|
627
+
| config.enable | boolean | Whether to enable version monitoring. This configuration item can be used to enable version monitoring only in specified environments **`v1.7.0`**|true| 否 |
628
+
| config.clearIntervalOnDialog | boolean | When the prompt dialog for a new version appears, clear the timer **`v1.7.0`**|false| 否 |
595
629
| config.onVersionUpdate | function(data) | Callback functionfor custom version hint UI (if you want to customize the popup UI, you can get the return value through the callback functionto control the appearance of the popup) || No |
596
630
| config.onRefresh | function(data) | Confirm update: the callback functionof the custom refresh event, where data is the latest version **`v1.5.0`**|| No |
597
631
| config.onCancel | function(data) | Cancel update: the callback functionof the custom cancel event, where data is the latest version **`v1.5.0`**|| No |
0 commit comments