Explorar o código

:art: https://github.com/siyuan-note/siyuan/issues/8780

Vanessa hai 1 ano
pai
achega
2ca0cfadde

+ 2 - 2
app/src/card/openCard.ts

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

+ 4 - 4
app/src/config/repos.ts

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

+ 2 - 2
app/src/protyle/wysiwyg/transaction.ts

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

+ 6 - 0
app/src/search/assets.ts

@@ -190,6 +190,12 @@ export const assetInputEvent = (element: Element, localSearch?: ISearchAssetOpti
             orderBy: localSearch.sort
         }, (response) => {
             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"]');
             if (page < response.data.pageCount) {
                 nextElement.removeAttribute("disabled");

+ 5 - 6
app/src/sync/syncGuide.ts

@@ -1,4 +1,4 @@
-import {needLogin, needSubscribe} from "../util/needSubscribe";
+import {isPaidUser, needSubscribe} from "../util/needSubscribe";
 import {showMessage} from "../dialog/message";
 import {fetchPost} from "../util/fetch";
 import {Dialog} from "../dialog";
@@ -147,7 +147,8 @@ export const syncGuide = (app?: App) => {
     }
     /// #if MOBILE
     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;
     }
     /// #else
@@ -164,10 +165,8 @@ export const syncGuide = (app?: App) => {
         }
         return;
     }
-    if (0 !== window.siyuan.config.sync.provider && needLogin("") && app) {
-        const dialogSetting = openSetting(app);
-        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");
+    if (0 !== window.siyuan.config.sync.provider && !isPaidUser() && app) {
+        showMessage(window.siyuan.languages["_kernel"][214]);
         return;
     }
     /// #endif

+ 0 - 10
app/src/util/needSubscribe.ts

@@ -1,16 +1,6 @@
 import {showMessage} from "../dialog/message";
 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]) => {
     if (window.siyuan.user && (window.siyuan.user.userSiYuanProExpireTime === -1 || window.siyuan.user.userSiYuanProExpireTime > 0)) {
         return false;