This commit is contained in:
Vanessa
2026-05-07 12:16:05 +08:00
parent 2d27fb2728
commit e451bc3dab
12 changed files with 22 additions and 21 deletions
+1 -1
View File
@@ -431,7 +431,7 @@ const initMainWindow = () => {
}).then((response) => {
setProxy(`${response.data.proxy.scheme}://${response.data.proxy.host}:${response.data.proxy.port}`, currentWindow.webContents).then(() => {
// 加载主界面
currentWindow.loadURL(getServer() + "/stage/build/app/?v=" + new Date().getTime());
currentWindow.loadURL(getServer() + "/stage/build/app/?v=" + Date.now());
});
});
+3 -2
View File
@@ -127,7 +127,7 @@ export const initWindowEvent = (app: App) => {
let time = 0;
document.addEventListener("touchstart", (event) => {
time = new Date().getTime();
time = Date.now();
// https://github.com/siyuan-note/siyuan/issues/6328
const target = event.target as HTMLElement;
if (hasClosestByClassName(target, "protyle-icons") ||
@@ -147,7 +147,8 @@ export const initWindowEvent = (app: App) => {
return;
}
// pad 端长按事件
if (isIPad() && new Date().getTime() - time > 900) {
const currentTime = Date.now();
if (isIPad() && currentTime - time > 900 && currentTime - time < 2000) {
event.target.dispatchEvent(new MouseEvent("contextmenu", {
bubbles: true,
cancelable: true,
+2 -2
View File
@@ -104,7 +104,7 @@ ${genSVGBG()}
const renewHTML = `<div class="fn__hr--b"></div>
<div class="ft__on-surface ft__smaller">
${window.siyuan.languages.account6}
${Math.max(0, Math.floor((window.siyuan.user.userSiYuanProExpireTime - new Date().getTime()) / 1000 / 60 / 60 / 24))}
${Math.max(0, Math.floor((window.siyuan.user.userSiYuanProExpireTime - Date.now()) / 1000 / 60 / 60 / 24))}
${window.siyuan.languages.day}
${isIOS ? `<a href="javascript:void(0)" data-action="iOSPay" data-type="subscribe">${window.siyuan.languages.clickMeToRenew}</a>` : `<a href="${getCloudURL("subscribe/siyuan")}" target="_blank">${window.siyuan.languages.clickMeToRenew}</a>`}
</div>`;
@@ -392,7 +392,7 @@ ${renewHTML}<div class="fn__hr--b"></div>`;
let token: string;
let needCaptcha: string;
captchaImgElement.addEventListener("click", () => {
captchaImgElement.setAttribute("src", getCloudURL("captcha") + `/login?needCaptcha=${needCaptcha}&t=${new Date().getTime()}`);
captchaImgElement.setAttribute("src", getCloudURL("captcha") + `/login?needCaptcha=${needCaptcha}&t=${Date.now()}`);
});
const cloudRegionElement = element.querySelector("#cloudRegion") as HTMLSelectElement;
+1 -1
View File
@@ -90,7 +90,7 @@ export class Model {
if (!this.ws) { // Inbox 无 ws
return;
}
this.reqId = process ? 0 : new Date().getTime();
this.reqId = process ? 0 : Date.now();
this.ws.send(JSON.stringify({
cmd,
reqId: this.reqId,
+4 -4
View File
@@ -74,7 +74,7 @@ const editLayout = (layoutName?: string) => {
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
if (layoutItem.name === layoutName) {
layoutItem.name = value;
layoutItem.time = new Date().getTime();
layoutItem.time = Date.now();
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
return true;
}
@@ -91,7 +91,7 @@ const editLayout = (layoutName?: string) => {
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
if (layoutItem.name === layoutName) {
layoutItem.name = value;
layoutItem.time = new Date().getTime();
layoutItem.time = Date.now();
layoutItem.layout = getAllLayout();
layoutItem.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
@@ -104,7 +104,7 @@ const editLayout = (layoutName?: string) => {
if (item.name === value) {
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
item.layout = getAllLayout();
item.time = new Date().getTime();
item.time = Date.now();
item.filesPaths = window.siyuan.storage[Constants.LOCAL_FILESPATHS];
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
});
@@ -116,7 +116,7 @@ const editLayout = (layoutName?: string) => {
}
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
name: value,
time: new Date().getTime(),
time: Date.now(),
layout: getAllLayout(),
filesPaths: window.siyuan.storage[Constants.LOCAL_FILESPATHS]
});
+2 -2
View File
@@ -62,7 +62,7 @@ export const showAccountInfo = () => {
const renewHTML = `<div class="fn__hr--b"></div>
<div class="ft__on-surface ft__smaller">
${window.siyuan.languages.account6}
${Math.max(0, Math.floor((window.siyuan.user.userSiYuanProExpireTime - new Date().getTime()) / 1000 / 60 / 60 / 24))}
${Math.max(0, Math.floor((window.siyuan.user.userSiYuanProExpireTime - Date.now()) / 1000 / 60 / 60 / 24))}
${window.siyuan.languages.day}
${isIOS ? `<a href="javascript:void(0)" data-action="iOSPay" data-type="subscribe">${window.siyuan.languages.clickMeToRenew}</a>` : `<a href="${getCloudURL("subscribe/siyuan")}" target="_blank">${window.siyuan.languages.clickMeToRenew}</a>`}
</div>`;
@@ -310,7 +310,7 @@ const bindLoginEvent = (modelMainElement: HTMLElement, deactive = false) => {
});
}
captchaImgElement.addEventListener("click", () => {
captchaImgElement.setAttribute("src", getCloudURL("captcha") + `/login?needCaptcha=${needCaptcha}&t=${new Date().getTime()}`);
captchaImgElement.setAttribute("src", getCloudURL("captcha") + `/login?needCaptcha=${needCaptcha}&t=${Date.now()}`);
});
const cloudRegionElement = modelMainElement.querySelector("#cloudRegion") as HTMLSelectElement;
+1 -1
View File
@@ -405,7 +405,7 @@ export class Title {
this.element.querySelector(".protyle-attr").insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block">${response.data.refCount}</div>`);
}
// 存在设置新建文档名模板,不能使用 Untitled 进行判断,https://ld246.com/article/1649301009888
if (this.editElement && new Date().getTime() - dayjs(response.data.id.split("-")[0]).toDate().getTime() < 2000) {
if (this.editElement && Date.now() - dayjs(response.data.id.split("-")[0]).toDate().getTime() < 2000) {
const range = this.editElement.ownerDocument.createRange();
range.selectNodeContents(this.editElement);
focusByRange(range);
+1 -1
View File
@@ -72,7 +72,7 @@ export class Protyle {
this.protyle = {
getInstance: () => this,
app,
transactionTime: new Date().getTime(),
transactionTime: Date.now(),
id: genUUID(),
disabled: false,
updated: false,
+2 -2
View File
@@ -5,7 +5,7 @@ export const getDateHTML = (cellElements: HTMLElement[]) => {
const cellValue = genCellValueByElement("date", cellElements[0]).date;
const isNotTime = cellValue.isNotTime;
let value = "";
const currentDate = new Date().getTime();
const currentDate = Date.now();
if (cellValue.isNotEmpty) {
value = dayjs(cellValue.content).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
const year = value.split("-")[0];
@@ -84,7 +84,7 @@ export const bindDateEvent = (options: {
inputElements[2].addEventListener("change", () => {
if (inputElements[2].checked) {
if (!inputElements[1].dataset.value) {
const currentDate = new Date().getTime();
const currentDate = Date.now();
inputElements[1].dataset.value = dayjs(currentDate).format("YYYY-MM-DD HH:mm");
inputElements[1].value = dayjs(currentDate).format(inputElements[3].checked ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD");
}
+1 -1
View File
@@ -1380,7 +1380,7 @@ export const transaction = (protyle: IProtyle, doOperations: IOperation[], undoO
const lastTransaction = window.siyuan.transactions[window.siyuan.transactions.length - 1];
let needDebounce = false;
const time = new Date().getTime();
const time = Date.now();
if (lastTransaction && lastTransaction.doOperations.length === 1 && lastTransaction.doOperations[0].action === "update" &&
doOperations.length === 1 && doOperations[0].action === "update" &&
lastTransaction.doOperations[0].id === doOperations[0].id &&
+2 -2
View File
@@ -282,7 +282,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
}
}
let clickTimeout: number;
let lastClickTime = new Date().getTime();
let lastClickTime = Date.now();
searchInputElement.value = config.k || "";
replaceInputElement.value = config.r || "";
@@ -803,7 +803,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele
let isDblClick = event.detail === 2;
/// #if BROWSER
if (isIPad()) { // 需要进行 ipad 判断 https://github.com/siyuan-note/siyuan/issues/12704
const newDate = new Date().getTime();
const newDate = Date.now();
isClick = newDate - lastClickTime > Constants.TIMEOUT_DBLCLICK;
isDblClick = !isClick;
lastClickTime = newDate;
+2 -2
View File
@@ -17,7 +17,7 @@ export const fetchPost = (
if (data) {
if (["/api/search/searchRefBlock", "/api/graph/getGraph", "/api/graph/getLocalGraph",
"/api/block/getRecentUpdatedBlocks", "/api/search/fullTextSearchBlock"].includes(url)) {
window.siyuan.reqIds[url] = new Date().getTime();
window.siyuan.reqIds[url] = Date.now();
if (data.type === "local" && url === "/api/graph/getLocalGraph") {
// 当打开文档A的关系图、关系图、文档A后刷新,由于防止请求重复处理,文档A关系图无法渲染。
} else {
@@ -26,7 +26,7 @@ export const fetchPost = (
}
// 并发导出后端接受顺序不一致
if (url === "/api/transactions") {
data.reqId = new Date().getTime();
data.reqId = Date.now();
}
if (data instanceof FormData) {
init.body = data;