Skip to content

Commit d5d692e

Browse files
committed
feat: 我的页面 刷新按钮 重置 PWA 缓存 / 修改 cmView ▲ ▼
1 parent 5fde99c commit d5d692e

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.15.7",
3+
"version": "2.15.8",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/components/NavBar.vue

+21-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ import { storeToRefs } from "pinia";
101101
import { Toast } from "@nutui/nutui";
102102
import { initStores } from "@/utils/initApp";
103103
import { useMethodStore } from '@/store/methodStore';
104+
import { useAppNotifyStore } from "@/store/appNotify";
105+
import i18n from "@/locales";
104106
107+
const { t:i18n_global } = i18n.global;
108+
const { showNotify } = useAppNotifyStore();
105109
const { t, locale } = useI18n();
106110
const router = useRouter();
107111
const route = useRoute();
@@ -218,11 +222,26 @@ const setSimpleMode = (isSimpleMode: boolean) => {
218222
changeAppearanceSetting({ appearanceSetting: data })
219223
};
220224
221-
const refresh = () => {
225+
const refresh = async () => {
222226
if (["/subs", "/sync", "/files"].includes(route.path)) {
223227
initStores(true, true, true);
224228
} else {
225-
window.location.reload();
229+
if ("serviceWorker" in navigator) {
230+
const registrations = await navigator.serviceWorker.getRegistrations();
231+
for (let registration of registrations) {
232+
await registration.unregister();
233+
}
234+
}
235+
if ("caches" in window) {
236+
const cacheNames = await caches.keys();
237+
for (let cacheName of cacheNames) {
238+
await caches.delete(cacheName);
239+
}
240+
}
241+
showNotify({ title: i18n_global("globalNotify.refresh.rePwa"), type: "primary" });
242+
setTimeout(() => {
243+
window.location.reload();
244+
}, 1000);
226245
}
227246
};
228247
watchEffect(() => {

src/locales/en.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default {
1919
flowFailed: "Refresh of {name} failed!",
2020
failed: "Refresh Failed\n",
2121
loading: "Refreshing Data...",
22+
rePwa: 'PWA cache reset successfully. The page will refresh soon...',
2223
},
2324
},
2425
// Title Bar

src/locales/zh.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default {
1919
flowFailed: '刷新 {name} 失败!',
2020
failed: '数据刷新失败\n',
2121
loading: '刷新数据中...',
22+
rePwa: '重置 PWA 缓存成功,即将刷新页面...',
2223
},
2324
share: {
2425
title: '分享',

src/views/editCode/cmView.vue

+6
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ const pasteNav = async () => {
371371
border-radius: 16px;
372372
}
373373
374+
1 .cm-button {
375+
margin: .6em 0.2em .6em .6em !important;
376+
padding: .2em 1em;
377+
white-space: pre;
378+
}
379+
374380
.cm-img-button {
375381
display: flex;
376382
padding-top: 9px;

src/views/editCode/search/dists/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1092,14 +1092,14 @@ class SearchPanel {
10921092
this.dom = elt("div", { onkeydown: (e) => this.keydown(e), class: "cm-search" }, [
10931093
this.searchField,
10941094
// ⇧⇩
1095-
button("prev", () => findPrevious(view), [phrase(view, "")]),
1095+
button("prev", () => findPrevious(view), [phrase(view, "")]),
10961096
elt("label", null, [this.caseField, phrase(view, "Aa")]),
10971097
elt("label", null, [this.wordField, phrase(view, "ab")]),
10981098
elt("label", null, [this.reField, phrase(view, " .*")]),
10991099
...view.state.readOnly ? [] : [
11001100
elt("br"),
11011101
this.replaceField,
1102-
button("next", () => findNext(view), [phrase(view, "")]),
1102+
button("next", () => findNext(view), [phrase(view, "")]),
11031103
button("replace", () => replaceNext(view), [phrase(view, "Replace")]),
11041104
button("replaceAll", () => replaceAll(view), [phrase(view, "Rep All")])
11051105
],

0 commit comments

Comments
 (0)