mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
fe846b4f59
commit
6ee275195e
8 changed files with 55 additions and 45 deletions
|
|
@ -247,10 +247,6 @@ export const about = {
|
|||
searchData.idPath = "";
|
||||
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(searchData));
|
||||
}
|
||||
localStorage.removeItem(Constants.LOCAL_DAILYNOTEID);
|
||||
localStorage.removeItem(Constants.LOCAL_DOCINFO);
|
||||
localStorage.removeItem(Constants.LOCAL_HISTORYNOTEID);
|
||||
localStorage.removeItem("pdfjs.history");
|
||||
exportLayout(false, () => {
|
||||
exitSiYuan();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {ipcRenderer, shell} from "electron";
|
|||
import * as path from "path";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {exportLayout} from "../layout/util";
|
||||
import {exportLayout, resetLayout} from "../layout/util";
|
||||
import {isBrowser} from "../util/functions";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {loadAssets} from "../util/assets";
|
||||
|
|
@ -217,9 +217,7 @@ export const appearance = {
|
|||
openColorPicker();
|
||||
});
|
||||
appearance.element.querySelector("#resetLayout").addEventListener("click", () => {
|
||||
fetchPost("/api/system/setUILayout", {layout: {}}, () => {
|
||||
window.location.reload();
|
||||
});
|
||||
resetLayout()
|
||||
});
|
||||
/// #if !BROWSER
|
||||
appearance.element.querySelector("#appearanceOpenIcon").addEventListener("click", () => {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ export abstract class Constants {
|
|||
// localstorage
|
||||
public static readonly LOCAL_SEARCHEDATA = "local-searchedata";
|
||||
public static readonly LOCAL_SEARCHETABDATA = "local-searchetabdata";
|
||||
public static readonly LOCAL_DOCINFO = "local-docinfo";
|
||||
public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile
|
||||
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid";
|
||||
public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid";
|
||||
public static readonly LOCAL_CODELANG = "local-codelang";
|
||||
|
|
|
|||
|
|
@ -136,6 +136,12 @@ const dockToJSON = (dock: Dock) => {
|
|||
return json;
|
||||
};
|
||||
|
||||
export const resetLayout = () => {
|
||||
fetchPost("/api/system/setUILayout", {layout: {}}, () => {
|
||||
window.location.reload();
|
||||
});
|
||||
};
|
||||
|
||||
export const exportLayout = (reload: boolean, cb?: () => void) => {
|
||||
const useElement = document.querySelector("#barDock use");
|
||||
if (!useElement) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {addBaseURL, setNoteBook} from "../util/pathName";
|
|||
import {handleTouchEnd, handleTouchMove, handleTouchStart} from "./util/touch";
|
||||
import {fetchGet, fetchPost} from "../util/fetch";
|
||||
import {initFramework} from "./util/initFramework";
|
||||
import {initAssets, loadAssets} from "../util/assets";
|
||||
import {addGA, initAssets, loadAssets} from "../util/assets";
|
||||
import {promiseTransactions} from "../protyle/wysiwyg/transaction";
|
||||
import {bootSync} from "../dialog/processSystem";
|
||||
import {initMessage} from "../dialog/message";
|
||||
|
|
@ -62,6 +62,7 @@ class App {
|
|||
}
|
||||
initMessage();
|
||||
});
|
||||
addGA();
|
||||
});
|
||||
if (navigator.userAgent.indexOf("iPhone") > -1) {
|
||||
document.addEventListener("touchstart", handleTouchStart, false);
|
||||
|
|
|
|||
|
|
@ -131,3 +131,11 @@ export const hotKey2Electron = (key: string) => {
|
|||
}
|
||||
return electronKey + key.substr(key.length - 1);
|
||||
};
|
||||
|
||||
export const setLocalStorage = () => {
|
||||
|
||||
}
|
||||
|
||||
export const exportLocalStorage = () => {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,38 @@ export const initAssets = () => {
|
|||
}
|
||||
};
|
||||
|
||||
export const addGA = () => {
|
||||
if (!window.siyuan.config.system.disableGoogleAnalytics) {
|
||||
addScript("https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9", "gaScript").then(() => {
|
||||
try {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.gtag = function (...args) {
|
||||
window.dataLayer.push(args);
|
||||
};
|
||||
window.gtag("js", new Date());
|
||||
window.gtag("config", "G-L7WEXVQCR9");
|
||||
const para = {
|
||||
"version": Constants.SIYUAN_VERSION,
|
||||
"container": window.siyuan.config.system.container,
|
||||
"isLoggedIn": "false",
|
||||
"subscriptionStatus": "-1",
|
||||
"subscriptionPlan": "-1",
|
||||
"subscriptionType": "-1",
|
||||
};
|
||||
if (window.siyuan.user) {
|
||||
para.isLoggedIn = "true";
|
||||
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
|
||||
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
|
||||
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();
|
||||
}
|
||||
window.gtag("event", Constants.ANALYTICS_EVT_ON_GET_CONFIG, para);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const setInlineStyle = (set = true) => {
|
||||
const height = Math.floor(window.siyuan.config.editor.fontSize * 1.625);
|
||||
let style = `.b3-typography, .protyle-wysiwyg, .protyle-title {font-size:${window.siyuan.config.editor.fontSize}px !important}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {openSearch} from "../search/spread";
|
||||
import {exportLayout, JSONToLayout, resizeDrag, resizeTabs} from "../layout/util";
|
||||
import {exportLayout, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from "../layout/util";
|
||||
import {hotKey2Electron, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
/// #if !BROWSER
|
||||
import {dialog, getCurrentWindow} from "@electron/remote";
|
||||
|
|
@ -15,7 +15,7 @@ import {globalShortcut} from "./globalShortcut";
|
|||
import {fetchPost} from "./fetch";
|
||||
import {mountHelp, newDailyNote} from "./mount";
|
||||
import {MenuItem} from "../menus/Menu";
|
||||
import {initAssets, loadAssets, setInlineStyle, setMode} from "./assets";
|
||||
import {addGA, initAssets, loadAssets, setInlineStyle, setMode} from "./assets";
|
||||
import {renderSnippet} from "../config/util/snippets";
|
||||
import {getOpenNotebookCount} from "./pathName";
|
||||
import {openFileById} from "../editor/util";
|
||||
|
|
@ -138,9 +138,7 @@ export const onGetConfig = (isStart: boolean) => {
|
|||
try {
|
||||
JSONToLayout(isStart);
|
||||
} catch (e) {
|
||||
fetchPost("/api/system/setUILayout", {layout: {}}, () => {
|
||||
window.location.reload();
|
||||
});
|
||||
resetLayout();
|
||||
}
|
||||
});
|
||||
initBar();
|
||||
|
|
@ -161,36 +159,7 @@ export const onGetConfig = (isStart: boolean) => {
|
|||
if (window.siyuan.config.newbie) {
|
||||
mountHelp();
|
||||
}
|
||||
|
||||
if (!window.siyuan.config.system.disableGoogleAnalytics) {
|
||||
addScript("https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9", "gaScript").then(() => {
|
||||
try {
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.gtag = function (...args) {
|
||||
window.dataLayer.push(args);
|
||||
};
|
||||
window.gtag("js", new Date());
|
||||
window.gtag("config", "G-L7WEXVQCR9");
|
||||
const para = {
|
||||
"version": Constants.SIYUAN_VERSION,
|
||||
"container": window.siyuan.config.system.container,
|
||||
"isLoggedIn": "false",
|
||||
"subscriptionStatus": "-1",
|
||||
"subscriptionPlan": "-1",
|
||||
"subscriptionType": "-1",
|
||||
};
|
||||
if (window.siyuan.user) {
|
||||
para.isLoggedIn = "true";
|
||||
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
|
||||
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
|
||||
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();
|
||||
}
|
||||
window.gtag("event", Constants.ANALYTICS_EVT_ON_GET_CONFIG, para);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
addGA();
|
||||
};
|
||||
|
||||
const initBar = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue