Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Vanessa40945fc22167
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index b4d409a940..62bf81b35f 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -1,4 +1,5 @@
{
+ "needLogin": "This feature requires login",
"calcResultCountAll": "COUNT",
"calcResultCountValues": "VALUES",
"calcResultCountUniqueValues": "UNIQUE",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 5fd5fb9265..385c510988 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -1,4 +1,5 @@
{
+ "needLogin": "Esta función requiere iniciar sesión",
"calcResultCountAll": "CONTAR",
"calcResultCountValues": "VALORES",
"calcResultCountUniqueValues": "ÚNICO",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index b3c33e7ef4..6eceb3b285 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -1,4 +1,5 @@
{
+ "needLogin": "Cette fonctionnalité nécessite une connexion",
"calcResultCountAll": "COUNT",
"calcResultCountValues": "VALEURS",
"calcResultCountUniqueValues": "UNIQUE",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 83e5acfc5e..407337b320 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -1,4 +1,5 @@
{
+ "needLogin": "該功能需要登錄",
"calcResultCountAll": "行計數",
"calcResultCountValues": "值計數",
"calcResultCountUniqueValues": "唯一值計數",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 8cc5cdaf91..98865aacad 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "needLogin": "该功能需要登录",
"calcResultCountAll": "行计数",
"calcResultCountValues": "值计数",
"calcResultCountUniqueValues": "唯一值计数",
diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml
index 660ae09f41..415cfe3b2c 100644
--- a/app/pnpm-lock.yaml
+++ b/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
diff --git a/app/src/assets/scss/component/_menu.scss b/app/src/assets/scss/component/_menu.scss
index dd4668a6f5..e7d3ece09a 100644
--- a/app/src/assets/scss/component/_menu.scss
+++ b/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;
diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts
index 889eaf96c4..1427ea4ce6 100644
--- a/app/src/card/openCard.ts
+++ b/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");
}
diff --git a/app/src/config/account.ts b/app/src/config/account.ts
index 7ebb3b7949..a6c777fb57 100644
--- a/app/src/config/account.ts
+++ b/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"));
diff --git a/app/src/config/repos.ts b/app/src/config/repos.ts
index 4a39db84b9..2b1d8884c1 100644
--- a/app/src/config/repos.ts
+++ b/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");
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 31a4aa0040..b121e08a09 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/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");
}
diff --git a/app/src/sync/syncGuide.ts b/app/src/sync/syncGuide.ts
index 07f444160e..980b511d7d 100644
--- a/app/src/sync/syncGuide.ts
+++ b/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);
diff --git a/app/src/util/needSubscribe.ts b/app/src/util/needSubscribe.ts
index 2731364c3a..a7ff60f55b 100644
--- a/app/src/util/needSubscribe.ts
+++ b/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;