Vanessa 2023-07-21 17:20:34 +08:00
parent 4f812bcf0c
commit 40945fc221
13 changed files with 50 additions and 21 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

8
app/pnpm-lock.yaml generated
View file

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

View file

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

View file

@ -6,7 +6,7 @@ import {Constants} from "../constants";
import {disabledProtyle, onGet} from "../protyle/util/onGet"; import {disabledProtyle, 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 {needSubscribe} from "../util/needSubscribe"; import {needLogin, 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";
@ -358,7 +358,8 @@ export const bindCardEvent = (options: {
}, () => { }, () => {
/// #if MOBILE /// #if MOBILE
if (type !== "-3" && 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) { 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

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

View file

@ -1,4 +1,4 @@
import {needSubscribe} from "../util/needSubscribe"; import {needLogin, 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";
@ -37,15 +37,18 @@ const renderProvider = (provider: number) => {
return `<div class="b3-label b3-label--inner"> return `<div class="b3-label b3-label--inner">
${window.siyuan.languages.syncOfficialProviderIntro} ${window.siyuan.languages.syncOfficialProviderIntro}
</div>`; </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} ${window.siyuan.languages.syncThirdPartyProviderS3Intro}
<div class="fn__hr"></div> <div class="fn__hr"></div>
<em>${window.siyuan.languages.featureBetaStage}</em> <em>${window.siyuan.languages.featureBetaStage}</em>
<div class="fn__hr"></div> <div class="fn__hr"></div>
${window.siyuan.languages.syncThirdPartyProviderTip} ${window.siyuan.languages.syncThirdPartyProviderTip}
</div>`; </div>
return `${tip}
<label class="b3-label b3-label--noborder fn__flex config__item"> <label class="b3-label b3-label--noborder fn__flex config__item">
<div class="fn__flex-center fn__size200">Endpoint</div> <div class="fn__flex-center fn__size200">Endpoint</div>
<div class="fn__space"></div> <div class="fn__space"></div>
@ -96,14 +99,13 @@ const renderProvider = (provider: number) => {
</select> </select>
</label>`; </label>`;
} else if (provider === 3) { } 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} ${window.siyuan.languages.syncThirdPartyProviderWebDAVIntro}
<div class="fn__hr"></div> <div class="fn__hr"></div>
<em>${window.siyuan.languages.featureBetaStage}</em> <em>${window.siyuan.languages.featureBetaStage}</em>
<div class="fn__hr"></div> <div class="fn__hr"></div>
${window.siyuan.languages.syncThirdPartyProviderTip} ${window.siyuan.languages.syncThirdPartyProviderTip}
</div>`; </div>
return `${tip}
<label class="b3-label b3-label--noborder fn__flex config__item"> <label class="b3-label b3-label--noborder fn__flex config__item">
<div class="fn__flex-center fn__size200">Endpoint</div> <div class="fn__flex-center fn__size200">Endpoint</div>
<div class="fn__space"></div> <div class="fn__space"></div>
@ -191,7 +193,11 @@ 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("")) {
nextElement.classList.remove("fn__none"); nextElement.classList.remove("fn__none");
} else {
nextElement.classList.add("fn__none");
}
nextElement = nextElement.nextElementSibling; nextElement = nextElement.nextElementSibling;
} }
reposDataElement.classList.add("fn__none"); reposDataElement.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 {needSubscribe} from "../../util/needSubscribe"; import {needLogin, needSubscribe} from "../../util/needSubscribe";
const removeTopElement = (updateElement: Element, protyle: IProtyle) => { const removeTopElement = (updateElement: Element, protyle: IProtyle) => {
// 移动到其他文档中,该块需移除 // 移动到其他文档中,该块需移除
@ -73,7 +73,8 @@ const promiseTransaction = () => {
promiseTransaction(); promiseTransaction();
} }
/// #if MOBILE /// #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) { 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 {needSubscribe} from "../util/needSubscribe"; import {needLogin, 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) => {
return; return;
} }
/// #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())) {
return; return;
} }
/// #else /// #else
@ -164,6 +165,12 @@ export const syncGuide = (app?: App) => {
} }
return; 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 /// #endif
if (!window.siyuan.config.repo.key) { if (!window.siyuan.config.repo.key) {
setKey(true); setKey(true);

View file

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