11<script lang="ts">
22/* eslint-disable vue/valid-template-root */
33import { h , onMounted } from ' vue' ;
4- import { VERSION } from ' ../const' ;
4+ import { STORAGE_UPDATE_IGNORE , VERSION } from ' ../const' ;
55import { useNotification , NButton } from ' naive-ui' ;
66import { getRecorderLatestVersion } from ' ../utils/version' ;
77import { compare as compareVersion } from ' semver' ;
@@ -16,11 +16,20 @@ onMounted(() => {
1616 getRecorderLatestVersion ().then ((version ) => {
1717 try {
1818 if (compareVersion (version .webui .version , VERSION ) > 0 ) {
19+ const store = JSON .parse (localStorage .getItem (STORAGE_UPDATE_IGNORE ) || ' {}' );
20+ if (store .webui && store .webui === version .webui .version ) {
21+ return ;
22+ }
1923 const n = notification .warning ({
2024 title: ' 更新提醒' ,
2125 content: ` 检测到新版本WebUI:${version .webui .version },请及时更新! ` ,
2226 duration: 0 ,
23- action : () =>
27+ action : () => h (' div' , {
28+ style: {
29+ display: ' flex' ,
30+ gap: ' 1rem' ,
31+ },
32+ }, [
2433 h (NButton , {
2534 type: ' primary' ,
2635 text: true ,
@@ -29,6 +38,28 @@ onMounted(() => {
2938 window .open (version .webui .url );
3039 },
3140 }, () => ' 立即更新' ),
41+ h (NButton , {
42+ type: ' default' ,
43+ text: true ,
44+ onClick : () => {
45+ n .destroy ();
46+ },
47+ }, () => ' 忽略' ),
48+ h (NButton , {
49+ type: ' default' ,
50+ text: true ,
51+ onClick : () => {
52+ n .destroy ();
53+ try {
54+ const store = JSON .parse (localStorage .getItem (STORAGE_UPDATE_IGNORE ) || ' {}' );
55+ store .webui = version .webui .version ;
56+ localStorage .setItem (STORAGE_UPDATE_IGNORE , JSON .stringify (store ));
57+ } catch (error ) {
58+ // ignore
59+ }
60+ },
61+ }, () => ' 忽略此版本' ),
62+ ]),
3263 });
3364 }
3465 } catch (e ) {
@@ -41,15 +72,21 @@ const notified: { [key: string]: boolean } = {};
4172
4273function onRecorderChange() {
4374 if (recorderController .recorder !== null ) {
44- if (notified [recorderController .recorder .meta .id ]) {
75+ const recorderMeta = recorderController .recorder .meta ;
76+
77+ if (notified [recorderMeta .id ]) {
4578 return ;
4679 }
47- const recorderMeta = recorderController . recorder . meta ;
80+
4881 recorderController .recorder .getVersion ().then ((v ) => {
4982 const serverVersion = v .fullSemVer ;
5083 getRecorderLatestVersion ().then ((version ) => {
5184 try {
5285 if (compareVersion (version .recorder .version , serverVersion ) > 0 ) {
86+ const store = JSON .parse (localStorage .getItem (STORAGE_UPDATE_IGNORE ) || ' {}' );
87+ if (store [recorderMeta .id ] && store [recorderMeta .id ] === version .webui .version ) {
88+ return ;
89+ }
5390 notified [recorderMeta .id ] = true ;
5491 const n = notification .warning ({
5592 title: ' 更新提醒' ,
@@ -65,7 +102,12 @@ function onRecorderChange() {
65102 ];
66103 },
67104 duration: 0 ,
68- action : () =>
105+ action : () => h (' div' , {
106+ style: {
107+ display: ' flex' ,
108+ gap: ' 1rem' ,
109+ },
110+ }, [
69111 h (NButton , {
70112 type: ' primary' ,
71113 text: true ,
@@ -74,6 +116,28 @@ function onRecorderChange() {
74116 window .open (version .recorder .url );
75117 },
76118 }, () => ' 立即更新' ),
119+ h (NButton , {
120+ type: ' default' ,
121+ text: true ,
122+ onClick : () => {
123+ n .destroy ();
124+ },
125+ }, () => ' 忽略' ),
126+ h (NButton , {
127+ type: ' default' ,
128+ text: true ,
129+ onClick : () => {
130+ n .destroy ();
131+ try {
132+ const store = JSON .parse (localStorage .getItem (STORAGE_UPDATE_IGNORE ) || ' {}' );
133+ store [recorderMeta .id ] = version .webui .version ;
134+ localStorage .setItem (STORAGE_UPDATE_IGNORE , JSON .stringify (store ));
135+ } catch (error ) {
136+ // ignore
137+ }
138+ },
139+ }, () => ' 忽略此版本' ),
140+ ]),
77141 });
78142 }
79143 } catch (e ) {
0 commit comments