Vanessa 2024-01-01 23:07:40 +08:00
parent f3869593f0
commit 2ca0cfadde
6 changed files with 19 additions and 24 deletions

View File

@ -6,7 +6,7 @@ import {Constants} from "../constants";
import {onGet} from "../protyle/util/onGet"; import {onGet} from "../protyle/util/onGet";
import {hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest"; import {hasClosestByAttribute, hasClosestByClassName} from "../protyle/util/hasClosest";
import {hideElements} from "../protyle/ui/hideElements"; import {hideElements} from "../protyle/ui/hideElements";
import {needLogin, needSubscribe} from "../util/needSubscribe"; import {isPaidUser, needSubscribe} from "../util/needSubscribe";
import {fullscreen} from "../protyle/breadcrumb/action"; import {fullscreen} from "../protyle/breadcrumb/action";
import {MenuItem} from "../menus/Menu"; import {MenuItem} from "../menus/Menu";
import {escapeHtml} from "../util/escape"; import {escapeHtml} from "../util/escape";
@ -394,7 +394,7 @@ export const bindCardEvent = (options: {
}, () => { }, () => {
/// #if MOBILE /// #if MOBILE
if (type !== "-3" && if (type !== "-3" &&
((0 !== window.siyuan.config.sync.provider && !needLogin("")) || ((0 !== window.siyuan.config.sync.provider && isPaidUser()) ||
(0 === window.siyuan.config.sync.provider && !needSubscribe(""))) && (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) { window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
document.getElementById("toolbarSync").classList.remove("fn__none"); document.getElementById("toolbarSync").classList.remove("fn__none");

View File

@ -1,4 +1,4 @@
import {needLogin, needSubscribe} from "../util/needSubscribe"; import {isPaidUser, needSubscribe} from "../util/needSubscribe";
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";
import {showMessage} from "../dialog/message"; import {showMessage} from "../dialog/message";
import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide"; import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide";
@ -38,8 +38,8 @@ const renderProvider = (provider: number) => {
${window.siyuan.languages.syncOfficialProviderIntro} ${window.siyuan.languages.syncOfficialProviderIntro}
</div>`; </div>`;
} }
if (needLogin("")) { if (!isPaidUser()) {
return `<div class="b3-label b3-label--inner">${window.siyuan.languages.needLogin}</div>`; return `<div class="b3-label b3-label--inner">${window.siyuan.languages["_kernel"][214]}</div>`;
} }
if (provider === 2) { if (provider === 2) {
return `<div class="b3-label b3-label--inner"> return `<div class="b3-label b3-label--inner">
@ -235,7 +235,7 @@ const bindProviderEvent = () => {
loadingElement.classList.add("fn__none"); loadingElement.classList.add("fn__none");
let nextElement = reposDataElement.nextElementSibling; let nextElement = reposDataElement.nextElementSibling;
while (nextElement) { while (nextElement) {
if (!needLogin("")) { if (isPaidUser()) {
nextElement.classList.remove("fn__none"); nextElement.classList.remove("fn__none");
} else { } else {
nextElement.classList.add("fn__none"); nextElement.classList.add("fn__none");

View File

@ -17,7 +17,7 @@ import {genEmptyElement, genSBElement} from "../../block/util";
import {hideElements} from "../ui/hideElements"; import {hideElements} from "../ui/hideElements";
import {reloadProtyle} from "../util/reload"; import {reloadProtyle} from "../util/reload";
import {countBlockWord} from "../../layout/status"; import {countBlockWord} from "../../layout/status";
import {needLogin, needSubscribe} from "../../util/needSubscribe"; import {isPaidUser, needSubscribe} from "../../util/needSubscribe";
import {resize} from "../util/resize"; import {resize} from "../util/resize";
const removeTopElement = (updateElement: Element, protyle: IProtyle) => { const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
@ -74,7 +74,7 @@ const promiseTransaction = () => {
promiseTransaction(); promiseTransaction();
} }
/// #if MOBILE /// #if MOBILE
if (((0 !== window.siyuan.config.sync.provider && !needLogin("")) || if (((0 !== window.siyuan.config.sync.provider && isPaidUser()) ||
(0 === window.siyuan.config.sync.provider && !needSubscribe(""))) && (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) { window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
document.getElementById("toolbarSync").classList.remove("fn__none"); document.getElementById("toolbarSync").classList.remove("fn__none");

View File

@ -190,6 +190,12 @@ export const assetInputEvent = (element: Element, localSearch?: ISearchAssetOpti
orderBy: localSearch.sort orderBy: localSearch.sort
}, (response) => { }, (response) => {
element.nextElementSibling.classList.add("fn__none"); element.nextElementSibling.classList.add("fn__none");
if (response.code === 1) {
element.querySelector("#searchAssetList").innerHTML = `<div class="search__empty">
${window.siyuan.languages["_kernel"][214]}
</div>`;
return;
}
const nextElement = element.querySelector('[data-type="assetNext"]'); const nextElement = element.querySelector('[data-type="assetNext"]');
if (page < response.data.pageCount) { if (page < response.data.pageCount) {
nextElement.removeAttribute("disabled"); nextElement.removeAttribute("disabled");

View File

@ -1,4 +1,4 @@
import {needLogin, needSubscribe} from "../util/needSubscribe"; import {isPaidUser, needSubscribe} from "../util/needSubscribe";
import {showMessage} from "../dialog/message"; import {showMessage} from "../dialog/message";
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";
import {Dialog} from "../dialog"; import {Dialog} from "../dialog";
@ -147,7 +147,8 @@ export const syncGuide = (app?: App) => {
} }
/// #if MOBILE /// #if MOBILE
if ((0 === window.siyuan.config.sync.provider && needSubscribe()) || if ((0 === window.siyuan.config.sync.provider && needSubscribe()) ||
(0 !== window.siyuan.config.sync.provider && needLogin())) { (0 !== window.siyuan.config.sync.provider && !isPaidUser())) {
showMessage(window.siyuan.languages["_kernel"][214]);
return; return;
} }
/// #else /// #else
@ -164,10 +165,8 @@ export const syncGuide = (app?: App) => {
} }
return; return;
} }
if (0 !== window.siyuan.config.sync.provider && needLogin("") && app) { if (0 !== window.siyuan.config.sync.provider && !isPaidUser() && app) {
const dialogSetting = openSetting(app); showMessage(window.siyuan.languages["_kernel"][214]);
dialogSetting.element.querySelector('.b3-tab-bar [data-name="account"]').dispatchEvent(new CustomEvent("click"));
dialogSetting.element.querySelector('.config__tab-container[data-name="account"]').setAttribute("data-action", "go-repos");
return; return;
} }
/// #endif /// #endif

View File

@ -1,16 +1,6 @@
import {showMessage} from "../dialog/message"; import {showMessage} from "../dialog/message";
import {getCloudURL} from "../config/util/about"; import {getCloudURL} from "../config/util/about";
export const needLogin = (tip = window.siyuan.languages.needLogin) => {
if (window.siyuan.user) {
return false;
}
if (tip) {
showMessage(tip);
}
return true;
};
export const needSubscribe = (tip = window.siyuan.languages._kernel[29]) => { export const needSubscribe = (tip = window.siyuan.languages._kernel[29]) => {
if (window.siyuan.user && (window.siyuan.user.userSiYuanProExpireTime === -1 || window.siyuan.user.userSiYuanProExpireTime > 0)) { if (window.siyuan.user && (window.siyuan.user.userSiYuanProExpireTime === -1 || window.siyuan.user.userSiYuanProExpireTime > 0)) {
return false; return false;