Przeglądaj źródła

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

Vanessa 2 lat temu
rodzic
commit
40945fc221

+ 1 - 0
app/appearance/langs/en_US.json

@@ -1,4 +1,5 @@
 {
+  "needLogin": "This feature requires login",
   "calcResultCountAll": "COUNT",
   "calcResultCountValues": "VALUES",
   "calcResultCountUniqueValues": "UNIQUE",

+ 1 - 0
app/appearance/langs/es_ES.json

@@ -1,4 +1,5 @@
 {
+  "needLogin": "Esta función requiere iniciar sesión",
   "calcResultCountAll": "CONTAR",
   "calcResultCountValues": "VALORES",
   "calcResultCountUniqueValues": "ÚNICO",

+ 1 - 0
app/appearance/langs/fr_FR.json

@@ -1,4 +1,5 @@
 {
+  "needLogin": "Cette fonctionnalité nécessite une connexion",
   "calcResultCountAll": "COUNT",
   "calcResultCountValues": "VALEURS",
   "calcResultCountUniqueValues": "UNIQUE",

+ 1 - 0
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,5 @@
 {
+  "needLogin": "該功能需要登錄",
   "calcResultCountAll": "行計數",
   "calcResultCountValues": "值計數",
   "calcResultCountUniqueValues": "唯一值計數",

+ 1 - 0
app/appearance/langs/zh_CN.json

@@ -1,4 +1,5 @@
 {
+  "needLogin": "该功能需要登录",
   "calcResultCountAll": "行计数",
   "calcResultCountValues": "值计数",
   "calcResultCountUniqueValues": "唯一值计数",

+ 4 - 4
app/pnpm-lock.yaml

@@ -1,5 +1,9 @@
 lockfileVersion: '6.0'
 
+settings:
+  autoInstallPeers: true
+  excludeLinksFromLockfile: false
+
 dependencies:
   '@electron/remote':
     specifier: ^2.0.9
@@ -4463,7 +4467,3 @@ packages:
     dependencies:
       buffer-crc32: 0.2.13
       fd-slicer: 1.1.0
-
-settings:
-  autoInstallPeers: true
-  excludeLinksFromLockfile: false

+ 0 - 1
app/src/assets/scss/component/_menu.scss

@@ -116,7 +116,6 @@
         height: 17px;
         width: 17px;
         margin: 0 16px 0 8px;
-        border-radius: var(--b3-border-radius);
 
         &--arrow {
           width: 12px;

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

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

+ 1 - 1
app/src/config/account.ts

@@ -384,7 +384,7 @@ ${renewHTML}
         account.bindEvent(element);
         account.onSetaccount();
         if (element.getAttribute("data-action") === "go-repos") {
-            if (needSubscribe()) {
+            if (needSubscribe("") && 0 === window.siyuan.config.sync.provider) {
                 const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
                 if (dialogElement) {
                     dialogElement.querySelector('.b3-tab-bar [data-name="repos"]').dispatchEvent(new CustomEvent("click"));

+ 15 - 9
app/src/config/repos.ts

@@ -1,4 +1,4 @@
-import {needSubscribe} from "../util/needSubscribe";
+import {needLogin, needSubscribe} from "../util/needSubscribe";
 import {fetchPost} from "../util/fetch";
 import {showMessage} from "../dialog/message";
 import {bindSyncCloudListEvent, getSyncCloudList} from "../sync/syncGuide";
@@ -37,15 +37,18 @@ const renderProvider = (provider: number) => {
         return `<div class="b3-label b3-label--inner">
     ${window.siyuan.languages.syncOfficialProviderIntro}
 </div>`;
-    } else if (provider === 2) {
-        const tip = `<div class="b3-label b3-label--inner">
+    }
+    if (needLogin("")) {
+        return `<div class="b3-label b3-label--inner">${window.siyuan.languages.needLogin}</div>`;
+    }
+    if (provider === 2) {
+        return `<div class="b3-label b3-label--inner">
     ${window.siyuan.languages.syncThirdPartyProviderS3Intro}
     <div class="fn__hr"></div>
     <em>${window.siyuan.languages.featureBetaStage}</em>
     <div class="fn__hr"></div>
     ${window.siyuan.languages.syncThirdPartyProviderTip}
-</div>`;
-        return `${tip}
+</div>
 <label class="b3-label b3-label--noborder fn__flex config__item">
     <div class="fn__flex-center fn__size200">Endpoint</div>
     <div class="fn__space"></div>
@@ -96,14 +99,13 @@ const renderProvider = (provider: number) => {
     </select>
 </label>`;
     } else if (provider === 3) {
-        const tip = `<div class="b3-label b3-label--inner">
+        return `<div class="b3-label b3-label--inner">
     ${window.siyuan.languages.syncThirdPartyProviderWebDAVIntro}
     <div class="fn__hr"></div>
     <em>${window.siyuan.languages.featureBetaStage}</em>
     <div class="fn__hr"></div>    
     ${window.siyuan.languages.syncThirdPartyProviderTip}
-</div>`;
-        return `${tip}
+</div>
 <label class="b3-label b3-label--noborder fn__flex config__item">
     <div class="fn__flex-center fn__size200">Endpoint</div>
     <div class="fn__space"></div>
@@ -191,7 +193,11 @@ const bindProviderEvent = () => {
     loadingElement.classList.add("fn__none");
     let nextElement = reposDataElement.nextElementSibling;
     while (nextElement) {
-        nextElement.classList.remove("fn__none");
+        if (!needLogin("")) {
+            nextElement.classList.remove("fn__none");
+        } else {
+            nextElement.classList.add("fn__none");
+        }
         nextElement = nextElement.nextElementSibling;
     }
     reposDataElement.classList.add("fn__none");

+ 3 - 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 {needSubscribe} from "../../util/needSubscribe";
+import {needLogin, needSubscribe} from "../../util/needSubscribe";
 
 const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
     // 移动到其他文档中,该块需移除
@@ -73,7 +73,8 @@ const promiseTransaction = () => {
             promiseTransaction();
         }
         /// #if MOBILE
-        if ((0 !== window.siyuan.config.sync.provider || (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
+        if (((0 !== window.siyuan.config.sync.provider && !needLogin("")) ||
+                (0 === window.siyuan.config.sync.provider && !needSubscribe(""))) &&
             window.siyuan.config.repo.key && window.siyuan.config.sync.enabled) {
             document.getElementById("toolbarSync").classList.remove("fn__none");
         }

+ 9 - 2
app/src/sync/syncGuide.ts

@@ -1,4 +1,4 @@
-import {needSubscribe} from "../util/needSubscribe";
+import {needLogin, 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) => {
         return;
     }
     /// #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())) {
         return;
     }
     /// #else
@@ -164,6 +165,12 @@ 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");
+        return;
+    }
     /// #endif
     if (!window.siyuan.config.repo.key) {
         setKey(true);

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

@@ -1,6 +1,16 @@
 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;