mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
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:
parent
e1d3789ced
commit
93e4bb1adf
17 changed files with 816 additions and 30 deletions
|
|
@ -9,6 +9,7 @@ import {addScript, addScriptSync} from "./protyle/util/addScript";
|
|||
import {genUUID} from "./util/genID";
|
||||
import {fetchGet, fetchPost} from "./util/fetch";
|
||||
import {addBaseURL, setNoteBook} from "./util/pathName";
|
||||
import {registerServiceWorker} from "./util/serviceWorker";
|
||||
import {openFileById} from "./editor/util";
|
||||
import {
|
||||
bootSync,
|
||||
|
|
@ -25,11 +26,18 @@ import {resizeDrag} from "./layout/util";
|
|||
import {getAllTabs} from "./layout/getAll";
|
||||
import {getLocalStorage} from "./protyle/util/compatibility";
|
||||
import {updateEditModeElement} from "./layout/topBar";
|
||||
import {getSearch} from "./util/functions";
|
||||
import {getSearch, isSiyuanUrl, getIdFromSiyuanUrl} from "./util/functions";
|
||||
import {hideAllElements} from "./protyle/ui/hideElements";
|
||||
|
||||
class App {
|
||||
constructor() {
|
||||
/// #if BROWSER
|
||||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
||||
/// #endif
|
||||
/// #if MOBILE
|
||||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`);
|
||||
/// #endif
|
||||
|
||||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript");
|
||||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript");
|
||||
addBaseURL();
|
||||
|
|
@ -172,9 +180,9 @@ class App {
|
|||
|
||||
new App();
|
||||
window.openFileByURL = (openURL) => {
|
||||
if (openURL && /^siyuan:\/\/blocks\/\d{14}-\w{7}/.test(openURL)) {
|
||||
if (openURL && isSiyuanUrl(openURL)) {
|
||||
openFileById({
|
||||
id: openURL.substr(16, 22),
|
||||
id: getIdFromSiyuanUrl(openURL),
|
||||
action:getSearch("focus", openURL) === "1" ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
|
||||
});
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue