PWA support (desktop & mobile) (#8012)

* 🎨 Improve return to feature of the auth page

* 🎨 PWA support

* Update manifest.webmanifest

* 🎨 add `service-worker.js`

* Update service-worker.js

* Update service-worker.js

* Update service-worker.js
This commit is contained in:
颖逸 2023-04-18 19:07:58 +08:00 committed by GitHub
parent e1d3789ced
commit 93e4bb1adf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 816 additions and 30 deletions

View file

@ -46,3 +46,27 @@ export const isFileAnnotation = (text: string) => {
export const looseJsonParse = (text: string) => {
return Function(`"use strict";return (${text})`)();
};
/* redirect to auth page */
export const redirectToCheckAuth = (to: string = window.location.href) => {
const url = new URL(window.location.origin);
url.pathname = '/check-auth';
url.searchParams.set('to', to);
window.location.href = url.href;
}
export const isSiyuanUrl = (url: string) => {
return /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
}
export const isWebSiyuanUrl = (url: string) => {
return /^web\+siyuan:\/\/blocks\/\d{14}-\w{7}/.test(url);
}
export const getIdFromSiyuanUrl = (url: string) => {
return url.substring(16, 16 + 22);
}
export const getIdFromWebSiyuanUrl = (url: string) => {
return url.substring(20, 20 + 22);
}