Skip to content

Commit

Permalink
🎨 #8780
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 1, 2024
1 parent f386959 commit 2ca0cfa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
4 changes: 2 additions & 2 deletions app/src/card/openCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions app/src/config/repos.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions app/src/protyle/wysiwyg/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions app/src/search/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 5 additions & 6 deletions app/src/sync/syncGuide.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 0 additions & 10 deletions app/src/util/needSubscribe.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 2ca0cfa

Please sign in to comment.