An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support themes in the mobile marketplace https://github.com/siyuan-note/siyuan/issues/17151
Daniel0b7b4950acac
diff --git a/app/appearance/themes/daylight/theme.json b/app/appearance/themes/daylight/theme.jsonindex 47166fa3ca..72c813d3f9 100644--- a/app/appearance/themes/daylight/theme.json+++ b/app/appearance/themes/daylight/theme.json@@ -3,6 +3,9 @@"author": "Vanessa","url": "https://github.com/Vanessa219","version": "1.1.2",+ "frontends": [+ "all"+ ],"modes": ["light"]diff --git a/app/appearance/themes/midnight/theme.json b/app/appearance/themes/midnight/theme.jsonindex 970b29260b..8fec678bd4 100644--- a/app/appearance/themes/midnight/theme.json+++ b/app/appearance/themes/midnight/theme.json@@ -3,6 +3,9 @@"author": "Vanessa","url": "https://github.com/Vanessa219","version": "1.1.2",+ "frontends": [+ "all"+ ],"modes": ["dark"]diff --git a/app/guide/20210808180117-6v0mkxr/20240113110040-7sgw8kl.sy b/app/guide/20210808180117-6v0mkxr/20240113110040-7sgw8kl.syindex b1602ea6b3..9bef8dc1d4 100644--- a/app/guide/20210808180117-6v0mkxr/20240113110040-7sgw8kl.sy+++ b/app/guide/20210808180117-6v0mkxr/20240113110040-7sgw8kl.sy@@ -7,7 +7,7 @@"id": "20240113110040-7sgw8kl","title": "Mobile App","type": "doc",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{@@ -361,12 +361,12 @@"Type": "NodeParagraph","Properties": {"id": "20240113110114-54bc1f8",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{"Type": "NodeText",- "Data": "Some app store versions may not provide the marketplace in the app due to review requirements. Themes are not available in the initial in-app mobile marketplace release."+ "Data": "Some app store versions may not provide the marketplace in the app due to review requirements."}]},diff --git a/app/guide/20210808180117-czj9bvb/20240113102857-c63dmo5.sy b/app/guide/20210808180117-czj9bvb/20240113102857-c63dmo5.syindex a692a887bd..d1c52b2cd8 100644--- a/app/guide/20210808180117-czj9bvb/20240113102857-c63dmo5.sy+++ b/app/guide/20210808180117-czj9bvb/20240113102857-c63dmo5.sy@@ -7,7 +7,7 @@"id": "20240113102857-c63dmo5","title": "移动端 App","type": "doc",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{@@ -361,12 +361,12 @@"Type": "NodeParagraph","Properties": {"id": "20240113104141-5jvccmj",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{"Type": "NodeText",- "Data": "部分应用商店版本可能因审核要求不在 App 内提供集市;App 内移动端集市首版暂不提供主题。"+ "Data": "部分应用商店版本可能因审核要求不在 App 内提供集市。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20240113110500-dz2ae4n.sy b/app/guide/20211226090932-5lcq56f/20240113110500-dz2ae4n.syindex 229923634b..518c1e21cf 100644--- a/app/guide/20211226090932-5lcq56f/20240113110500-dz2ae4n.sy+++ b/app/guide/20211226090932-5lcq56f/20240113110500-dz2ae4n.sy@@ -7,7 +7,7 @@"id": "20240113110500-dz2ae4n","title": "行動端 App","type": "doc",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{@@ -361,12 +361,12 @@"Type": "NodeParagraph","Properties": {"id": "20240113110513-1zlx78j",- "updated": "20260819122705"+ "updated": "20260819224004"},"Children": [{"Type": "NodeText",- "Data": "部分應用程式商店版本可能因審核要求不在 App 內提供集市;App 內行動端集市首版暫不提供主題。"+ "Data": "部分應用程式商店版本可能因審核要求不在 App 內提供集市。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-e6z5okf.sy b/app/guide/20240530133126-axarxgx/20240530101000-e6z5okf.syindex 4288515581..9f772ef6c4 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-e6z5okf.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-e6z5okf.sy@@ -8,7 +8,7 @@"id": "20240530101000-e6z5okf","title": "モバイルアプリ","type": "doc",- "updated": "20260819132654"+ "updated": "20260819224004"},"Children": [{@@ -63,12 +63,12 @@"Properties": {"ID": "20240530101000-stdxnih","id": "20240530101000-vma8ggh",- "updated": "20260819132654"+ "updated": "20260819224004"},"Children": [{"Type": "NodeText",- "Data": "一部のアプリストア版では、審査要件によりアプリ内でマーケットプレイスを提供しない場合があります。アプリ内モバイルマーケットプレイスの初期リリースでは、テーマは利用できません。"+ "Data": "一部のアプリストア版では、審査要件によりアプリ内でマーケットプレイスを提供しない場合があります。"}]},diff --git a/app/src/assets/scss/business/_config.scss b/app/src/assets/scss/business/_config.scssindex 6f67a559ad..d4d34a2918 100644--- a/app/src/assets/scss/business/_config.scss+++ b/app/src/assets/scss/business/_config.scss@@ -416,12 +416,13 @@> .b3-text-field {flex: 1;+ max-width: 240px;min-width: 0;}> .counter {flex-shrink: 0;- margin-left: 0;+ margin-left: auto;}}diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scssindex ccc6d7288d..66da4981f6 100644--- a/app/src/assets/scss/main/_mobile.scss+++ b/app/src/assets/scss/main/_mobile.scss@@ -518,6 +518,14 @@> .config-bazaar__filter-row {flex-basis: 100%;order: 2;++ > .b3-text-field {+ max-width: none;+ }++ > .counter {+ margin-left: 0;+ }}}@@ -557,6 +565,34 @@}}+ &__panel[data-type="downloaded"] .config-bazaar__content .b3-card {+ display: grid;+ grid-template-columns: auto minmax(0, 1fr);++ > .b3-card__img {+ grid-column: 1;+ grid-row: 1;+ }++ > .fn__flex-1 {+ grid-column: 2;+ grid-row: 1;+ }++ > .b3-card__actions--right {+ grid-column: 1 / -1;+ grid-row: 2;+ max-width: none;+ min-height: 36px;+ padding: 4px 8px 8px 12px;+ width: 100%;++ > .config-bazaar__publish-switch {+ margin-right: auto;+ }+ }+ }+&__readme {border-radius: 0;flex-direction: column;diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.tsindex a1048f514b..ce64a54e38 100644--- a/app/src/config/bazaar.ts+++ b/app/src/config/bazaar.ts@@ -48,7 +48,6 @@ import {sortBazaarPackagesByRating,} from "../util/bazaarPackage";import {Dialog} from "../dialog";-import {isBazaarPackageTypeAvailable} from "../util/bazaarAvailability";interface IBazaarMountSnapshot {element: HTMLElement;@@ -76,8 +75,7 @@ export const mountBazaarTab = (root: HTMLElement, keywords?: string, app?: App)switchSettingPanelSubTab(root, keywords, [{type: "downloaded", label: window.siyuan.languages.downloaded},{type: "plugin", label: window.siyuan.languages.plugin},- ...(isBazaarPackageTypeAvailable("themes") ?- [{type: "theme", label: window.siyuan.languages.theme}] : []),+ {type: "theme", label: window.siyuan.languages.theme},{type: "icon", label: window.siyuan.languages.icon},{type: "template", label: window.siyuan.languages.template},{type: "widget", label: window.siyuan.languages.widget},@@ -197,7 +195,6 @@ export const bazaar = {</div>`;}const localSort = window.siyuan.storage[Constants.LOCAL_BAZAAR];- const themeAvailable = isBazaarPackageTypeAvailable("themes");const localPackageAvailable = getFrontend() !== "mobile";const loadingHTML = `<div style="height: ${bazaar.element.clientHeight - 160}px;display: flex;align-items: center;justify-content: center;"><img src="/stage/loading-pure.svg"></div>`;return `<div class="config-bazaar fn__flex-column" style="height: 100%">@@ -209,7 +206,7 @@ export const bazaar = {<div class="layout-tab-bar fn__flex"><div data-type="downloaded" class="item item--full item--focus"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.downloaded}</span><span class="fn__flex-1"></span></div><div data-type="plugin" class="item item--full"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.plugin}</span><span class="fn__flex-1"></span></div>- <div data-type="theme" class="item item--full${themeAvailable ? "" : " fn__none"}"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.theme}</span><span class="fn__flex-1"></span></div>+ <div data-type="theme" class="item item--full"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.theme}</span><span class="fn__flex-1"></span></div><div data-type="icon" class="item item--full"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.icon}</span><span class="fn__flex-1"></span></div><div data-type="template" class="item item--full"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.template}</span><span class="fn__flex-1"></span></div><div data-type="widget" class="item item--full"><span class="fn__flex-1"></span><span class="item__text">${window.siyuan.languages.widget}</span><span class="fn__flex-1"></span></div>@@ -220,7 +217,7 @@ export const bazaar = {<div class="fn__flex config-bazaar__tabs"><button data-type="myUpdate" class="b3-button b3-button--outline config-bazaar__update-tab">${window.siyuan.languages.update}<span data-type="update-tab-count" class="config-bazaar__update-count fn__none"></span></button><button data-type="myPlugin" class="b3-button">${window.siyuan.languages.plugin}</button>- <button data-type="myTheme" class="b3-button b3-button--outline${themeAvailable ? "" : " fn__none"}">${window.siyuan.languages.theme}</button>+ <button data-type="myTheme" class="b3-button b3-button--outline">${window.siyuan.languages.theme}</button><button data-type="myIcon" class="b3-button b3-button--outline">${window.siyuan.languages.icon}</button><button data-type="myTemplate" class="b3-button b3-button--outline">${window.siyuan.languages.template}</button><button data-type="myWidget" class="b3-button b3-button--outline">${window.siyuan.languages.widget}</button>@@ -486,8 +483,12 @@ export const bazaar = {}return `${chips}<button type="button" data-type="keywords-expand" data-position="north" aria-label="${escapeAttr(window.siyuan.languages.showMore)}" class="item__keywords-more b3-chip b3-chip--small b3-chip--hover ariaLabel">...</button>`;},- _getFrontendLabels(frontends: string[]) {- if (!frontends?.length || frontends.includes("all")) {+ _getFrontendLabels(frontends: string[], requireMobileDeclaration = false) {+ if (!frontends?.length) {+ return requireMobileDeclaration && ["mobile", "browser-mobile"].includes(getFrontend()) ?+ [] : [window.siyuan.languages.all];+ }+ if (frontends.includes("all")) {return [window.siyuan.languages.all];}const labels = new Set<string>();@@ -790,9 +791,6 @@ ${primaryAction ? '<div class="fn__hr"></div>' : ""}_getUpdatedItems(): Array<{type: TBazaarType, item: IUpdatedBazaarItem}> {const items: Array<{type: TBazaarType, item: IUpdatedBazaarItem}> = [];(["plugins", "themes", "icons", "templates", "widgets"] as TBazaarType[]).forEach((type) => {- if (!isBazaarPackageTypeAvailable(type)) {- return;- }bazaar._data.update[type].forEach((item) => items.push({type, item}));});return items;@@ -900,9 +898,6 @@ ${primaryAction ? '<div class="fn__hr"></div>' : ""}}},_genMyHTML(bazaarType: TBazaarType, app: App, preserveOrder = false) {- if (!isBazaarPackageTypeAvailable(bazaarType)) {- return false;- }const contentElement = bazaar.element.querySelector("#configBazaarDownloaded");const myType = bazaar._type2myType(bazaarType);const typeBtn = contentElement.previousElementSibling.querySelector(`[data-type="${myType}"]`) as HTMLElement;@@ -963,6 +958,11 @@ ${primaryAction ? '<div class="fn__hr"></div>' : ""}}const showPublishSwitch = bazaarType === "plugins" && window.siyuan.config.publish.enable;const publishEnabled = isBazaarPluginEnabledInPublish(bazaarItem);+ const publishSwitchHTML = showPublishSwitch ? `<label data-type="plugin-publish-enable-label" class="config-bazaar__publish-switch" title="${escapeAttr(bazaarItem.disabledInPublish ? window.siyuan.languages.pluginDisabledInPublishTip : window.siyuan.languages.publishService)}">+ <input data-type="plugin-publish-enable" data-position="north" class="b3-switch fn__flex-center" type="checkbox"${publishEnabled ? " checked" : ""}${bazaarItem.disabledInPublish ? " disabled" : ""}>+ <span class="fn__space--small"></span>+ <span class="fn__flex-center ft__on-surface">${window.siyuan.languages.publishService}</span>+ </label>` : "";const available = bazaar._getUpdatedItem(bazaarType, bazaarItem.name)?.available;const ratingKey = bazaar._getRatingKey(bazaarType, bazaarItem.name);return `<div data-name="${escapeAttr(bazaarItem.name)}" data-package-type="${bazaarType}" data-package-source="downloaded" class="b3-card${bazaarItem.current ? " b3-card--current" : ""}">@@ -971,15 +971,11 @@ ${primaryAction ? '<div class="fn__hr"></div>' : ""}<div class="b3-card__info b3-card__info--left fn__flex-1">${escapeHtml(bazaarItem.preferredName)}<div class="b3-card__desc" title="${escapeAttr(bazaarItem.preferredDesc)}">${escapeHtml(bazaarItem.preferredDesc)}</div>- ${showPublishSwitch ? `<div class="fn__hr--b"></div>- <label data-type="plugin-publish-enable-label" class="config-bazaar__publish-switch" title="${escapeAttr(bazaarItem.disabledInPublish ? window.siyuan.languages.pluginDisabledInPublishTip : window.siyuan.languages.publishService)}">- <input data-type="plugin-publish-enable" data-position="north" class="b3-switch fn__flex-center" type="checkbox"${publishEnabled ? " checked" : ""}${bazaarItem.disabledInPublish ? " disabled" : ""}>- <span class="fn__space--small"></span>- <span class="fn__flex-center ft__on-surface">${window.siyuan.languages.publishService}</span>- </label>` : ""}+ ${showPublishSwitch && !isMobile() ? `<div class="fn__hr--b"></div>${publishSwitchHTML}` : ""}</div></div><div class="b3-card__actions b3-card__actions--right">+ ${isMobile() ? publishSwitchHTML : ""}${bazaar._genUpdateButtonHTML(available, bazaarType, true)}${bazaar._genRatePackageActionHTML(bazaar._data.downloadedRatingKeys.has(ratingKey), bazaar._data.userRatings.get(ratingKey))}${bazaar._genIncompatibleChipHTML(bazaarItem, "installed", bazaarType)}@@ -1085,9 +1081,6 @@ type="checkbox">}},_renderReadme(bazaarType: TBazaarType, from: "downloaded" | "updated" | "bazaar", data: IBazaarItem, detail?: IBazaarPackageDetail) {- if (!isBazaarPackageTypeAvailable(bazaarType)) {- return;- }const mount = bazaar._captureMount();const readmeElement = bazaar.element.querySelector("#configBazaarReadme") as HTMLElement;const navTitles: Record<TBazaarType, string> = {@@ -1124,7 +1117,7 @@ type="checkbox">urls.pop();const compatibilityFieldVisibility = getBazaarCompatibilityFieldVisibility(bazaarType);const frontendLabels = compatibilityFieldVisibility.frontends ?- bazaar._getFrontendLabels(compatibilityData.frontends) : [];+ bazaar._getFrontendLabels(compatibilityData.frontends, bazaarType === "themes") : [];const systemLabels = compatibilityFieldVisibility.systems ?getBazaarBackendSystemLabels(compatibilityData.backends, window.siyuan.languages.all) : [];const kernelSystemLabels = compatibilityFieldVisibility.kernelSystems ?@@ -1143,7 +1136,7 @@ type="checkbox">const compatibilitySection = `<section class="item__meta-section"><div class="item__meta-title">${window.siyuan.languages.bazaarCompatibility}</div>${bazaar._genReadmeMetaRow(window.siyuan.languages.bazaarMinAppVersion, compatibilityData.minAppVersion ? `v${compatibilityData.minAppVersion}` : "-")}- ${compatibilityFieldVisibility.frontends ? bazaar._genReadmeMetaRow(window.siyuan.languages.bazaarPlatforms, bazaar._genReadmeChips(frontendLabels, true), true) : ""}+ ${compatibilityFieldVisibility.frontends ? bazaar._genReadmeMetaRow(window.siyuan.languages.bazaarPlatforms, frontendLabels.length ? bazaar._genReadmeChips(frontendLabels, true) : "-", true) : ""}${compatibilityFieldVisibility.systems ? bazaar._genReadmeMetaRow(window.siyuan.languages.bazaarSystems, bazaar._genReadmeChips(systemLabels, true), true) : ""}${kernelSystemLabels.length ? bazaar._genReadmeMetaRow(window.siyuan.languages.bazaarKernelPlugin, bazaar._genReadmeChips(kernelSystemLabels, true), true) : ""}${compatibilityFieldVisibility.disabledInPublish ? bazaar._genReadmeMetaRow(window.siyuan.languages.publishService, compatibilityData.disabledInPublish ? window.siyuan.languages.disable : window.siyuan.languages.enable) : ""}@@ -1610,9 +1603,6 @@ type="checkbox">},_loadUpdatedRatings() {(["plugins", "themes", "icons", "templates", "widgets"] as TBazaarType[]).forEach((bazaarType) => {- if (!isBazaarPackageTypeAvailable(bazaarType)) {- return;- }const items = bazaar._data.update[bazaarType];const installed = items.map((item) => item.installed);if (items.length && !items.every((item) => bazaar._data.downloadedRatingKeys.has(@@ -1935,9 +1925,6 @@ type="checkbox">});},_reloadBazaarType(bazaarType: TBazaarType) {- if (!isBazaarPackageTypeAvailable(bazaarType)) {- return;- }const bazaarAPI: Record<TBazaarType, string> = {plugins: "/api/bazaar/getBazaarPlugin",themes: "/api/bazaar/getBazaarTheme",@@ -2058,7 +2045,7 @@ type="checkbox">});},_initBazaarPanel(app: App, bazaarType: TBazaarType, panel: HTMLElement) {- if (!isBazaarPackageTypeAvailable(bazaarType) || panel.getAttribute("data-init")) {+ if (panel.getAttribute("data-init")) {return;}const mount = bazaar._beginBazaarRequest(bazaarType);@@ -2095,7 +2082,7 @@ type="checkbox">},/** 切换集市顶部 Tab */switchBazaarTab(app: App, bazaarType: TBazaarType, from: "downloaded" | "updated" | "bazaar") {- if (!bazaar.element || !isBazaarPackageTypeAvailable(bazaarType)) {+ if (!bazaar.element) {return;}const layoutTabType = from === "bazaar" ? bazaar._type2tabType(bazaarType) : "downloaded";@@ -2335,11 +2322,6 @@ type="checkbox">(packageSource === "downloaded" ? pkgItem : undefined);const availableItem = packageDetail?.available || updatedItem?.available ||(packageSource === "bazaar" ? pkgItem : undefined);- if (pkgType && !isBazaarPackageTypeAvailable(pkgType)) {- event.preventDefault();- event.stopPropagation();- return;- }while (target && !target.isEqualNode(bazaar.element)) {const type = target.getAttribute("data-type");if (target.tagName === "A") {@@ -2736,7 +2718,7 @@ type="checkbox">fetchPost("/api/bazaar/getBazaarWidget", {keyword}, response => {bazaar._onBazaar(response, "widgets", request);});- } else if (type === "theme" && isBazaarPackageTypeAvailable("themes")) {+ } else if (type === "theme") {const request = bazaar._beginBazaarRequest("themes", mount);fetchPost("/api/bazaar/getBazaarTheme", {frontend: getFrontend(), keyword}, response => {bazaar._onBazaar(response, "themes", request);@@ -2841,7 +2823,7 @@ type="checkbox">container.parentElement.querySelector(".counter").textContent = htmlParts.length.toString();},_onBazaar(response: IWebSocketData, bazaarType: TBazaarType, mount: IBazaarMountSnapshot) {- if (!isBazaarPackageTypeAvailable(bazaarType) || !bazaar._isBazaarRequestCurrent(bazaarType, mount)) {+ if (!bazaar._isBazaarRequestCurrent(bazaarType, mount)) {return;}const panelSelector: Record<TBazaarType, string> = {diff --git a/app/src/config/bazaarTab.ts b/app/src/config/bazaarTab.tsindex a592a44cb9..cdb70b4bbc 100644--- a/app/src/config/bazaarTab.ts+++ b/app/src/config/bazaarTab.ts@@ -1,5 +1,4 @@import type {App} from "../index";-import {isBazaarPackageTypeAvailable} from "../util/bazaarAvailability";type BazaarModule = typeof import("./bazaar");@@ -20,7 +19,7 @@ export const collectBazaarTabSearchStrings = (): string[] => [window.siyuan.languages.downloaded,window.siyuan.languages.update,window.siyuan.languages.plugin,- ...(isBazaarPackageTypeAvailable("themes") ? [window.siyuan.languages.theme] : []),+ window.siyuan.languages.theme,window.siyuan.languages.icon,window.siyuan.languages.template,window.siyuan.languages.widget,diff --git a/app/src/config/index.ts b/app/src/config/index.tsindex f7ea948dc3..6b55696018 100644--- a/app/src/config/index.ts+++ b/app/src/config/index.ts@@ -12,7 +12,7 @@ import {fetchSyncPost} from "../util/fetch";import {getFrontend} from "../util/functions";import {showMessage} from "../dialog/message";import {escapeHtml} from "../util/escape";-import {isBazaarAvailable, isBazaarPackageTypeAvailable} from "../util/bazaarAvailability";+import {isBazaarAvailable} from "../util/bazaarAvailability";import {getSettingTabDefs} from "./setting/tabs";import {clearAccessTabElement} from "./tabs/accessRuntime";import {clearSyncTabElement} from "./tabs/syncRuntime";@@ -97,7 +97,7 @@ export const openSetting = (app: App, tab?: TSettingTab) => {};export const openBazaarReadme = async (app: App, bazaarType: TBazaarType, itemName: string, from: "bazaar" | "downloaded") => {- if (!isBazaarAvailable() || !isBazaarPackageTypeAvailable(bazaarType)) {+ if (!isBazaarAvailable()) {return;}if (!window.siyuan.config.bazaar.trust) {diff --git a/app/src/config/tabs/appearanceTab.ts b/app/src/config/tabs/appearanceTab.tsindex 61a8867f41..df9044430d 100644--- a/app/src/config/tabs/appearanceTab.ts+++ b/app/src/config/tabs/appearanceTab.ts@@ -9,7 +9,7 @@ import {resetLayout} from "../../layout/util";import {updateHotkeyTip} from "../../protyle/util/compatibility";/// #endifimport {desktopModeCookie} from "../../util/cookie";-import {isBrowser, isMobile, objEquals} from "../../util/functions";+import {getFrontend, isBrowser, isMobile, objEquals} from "../../util/functions";import {exitSiYuan} from "../../dialog/processSystem";import {isInMobileApp} from "../../protyle/util/compatibility";import {fetchPost, fetchSyncPost} from "../../util/fetch";@@ -25,6 +25,7 @@ import {controlBoolean} from "../setting/control";import {editorConfigApi} from "./editorRuntime";import {appearanceThemeModeValue, saveThemeMode} from "./appearanceRuntime";import {upDownHint} from "../../util/upDownHint";+import {isThemeFrontendSupported} from "../../util/themeCompatibility";import {ICustomFont,invalidateCustomFonts,@@ -393,14 +394,16 @@ const registerAppearanceInterfaceGroup = (tab: SettingTabBuilder) => {/// #endifstack.select("appearance.themeLight", {desc: window.siyuan.languages.theme11,- options: window.siyuan.config.appearance.lightThemes.map((item) => ({+ options: window.siyuan.config.appearance.lightThemes.filter((item) =>+ isThemeFrontendSupported(item.frontends, getFrontend())).map((item) => ({value: item.name,label: item.label,})),});stack.select("appearance.themeDark", {desc: window.siyuan.languages.theme12,- options: window.siyuan.config.appearance.darkThemes.map((item) => ({+ options: window.siyuan.config.appearance.darkThemes.filter((item) =>+ isThemeFrontendSupported(item.frontends, getFrontend())).map((item) => ({value: item.name,label: item.label,})),diff --git a/app/src/util/bazaarAvailability.test.ts b/app/src/util/bazaarAvailability.test.tsindex a883d953af..1a6575650e 100644--- a/app/src/util/bazaarAvailability.test.ts+++ b/app/src/util/bazaarAvailability.test.ts@@ -1,9 +1,6 @@import {describe, it} from "node:test";import * as assert from "node:assert/strict";-import {- isBazaarAvailableForFrontend,- isBazaarPackageTypeAvailableForFrontend,-} from "./bazaarAvailability";+import {isBazaarAvailableForFrontend} from "./bazaarAvailability";describe("bazaar frontend availability", () => {it("disables the marketplace only for disabled native mobile builds", () => {@@ -23,18 +20,4 @@ describe("bazaar frontend availability", () => {assert.equal(isBazaarAvailableForFrontend("desktop", ["bazaar"]), true);assert.equal(isBazaarAvailableForFrontend("desktop-window", ["bazaar"]), true);});-- it("keeps themes out of the first native mobile release", () => {- assert.equal(isBazaarPackageTypeAvailableForFrontend("themes", "mobile"), false);- assert.equal(isBazaarPackageTypeAvailableForFrontend("plugins", "mobile"), true);- assert.equal(isBazaarPackageTypeAvailableForFrontend("icons", "mobile"), true);- assert.equal(isBazaarPackageTypeAvailableForFrontend("templates", "mobile"), true);- assert.equal(isBazaarPackageTypeAvailableForFrontend("widgets", "mobile"), true);- });-- it("keeps themes available through browser and desktop frontends", () => {- assert.equal(isBazaarPackageTypeAvailableForFrontend("themes", "browser-mobile"), true);- assert.equal(isBazaarPackageTypeAvailableForFrontend("themes", "browser-desktop"), true);- assert.equal(isBazaarPackageTypeAvailableForFrontend("themes", "desktop"), true);- });});diff --git a/app/src/util/bazaarAvailability.ts b/app/src/util/bazaarAvailability.tsindex 7bce6f1d01..53ca22a8d5 100644--- a/app/src/util/bazaarAvailability.ts+++ b/app/src/util/bazaarAvailability.ts@@ -5,15 +5,7 @@ export const isBazaarAvailableForFrontend = (disabledFeatures: readonly string[] | undefined,): boolean => frontend !== "mobile" || !disabledFeatures?.includes("bazaar");-export const isBazaarPackageTypeAvailableForFrontend = (- bazaarType: TBazaarType,- frontend: string,-): boolean => frontend !== "mobile" || bazaarType !== "themes";-export const isBazaarAvailable = (): boolean => isBazaarAvailableForFrontend(getFrontend(),window.siyuan.config.system.disabledFeatures,);--export const isBazaarPackageTypeAvailable = (bazaarType: TBazaarType): boolean =>- isBazaarPackageTypeAvailableForFrontend(bazaarType, getFrontend());diff --git a/app/src/util/themeCompatibility.test.ts b/app/src/util/themeCompatibility.test.tsindex ae95da5eed..d215679783 100644--- a/app/src/util/themeCompatibility.test.ts+++ b/app/src/util/themeCompatibility.test.ts@@ -19,11 +19,12 @@ const appearance = (overrides: Partial<Config.IAppearance> = {}) => ({} as Config.IAppearance);describe("theme frontend compatibility", () => {- it("treats missing, empty, and all frontends as supported", () => {- assert.equal(isThemeFrontendSupported(undefined, "mobile"), true);- assert.equal(isThemeFrontendSupported(null, "mobile"), true);- assert.equal(isThemeFrontendSupported([], "mobile"), true);+ it("requires mobile themes to declare compatible frontends", () => {+ assert.equal(isThemeFrontendSupported(undefined, "mobile"), false);+ assert.equal(isThemeFrontendSupported(null, "browser-mobile"), false);+ assert.equal(isThemeFrontendSupported([], "mobile"), false);assert.equal(isThemeFrontendSupported(["all"], "mobile"), true);+ assert.equal(isThemeFrontendSupported(undefined, "desktop"), true);});it("matches frontends exactly", () => {@@ -37,8 +38,9 @@ describe("theme frontend compatibility", () => {assert.equal(getCurrentAppearanceTheme(appearance({mode: 1}))?.name, "dark-theme");});- it("falls back to supported when theme metadata is unavailable", () => {- assert.equal(isCurrentThemeSupported(appearance({lightThemes: []}), "mobile"), true);+ it("falls back according to the current frontend when theme metadata is unavailable", () => {+ assert.equal(isCurrentThemeSupported(appearance({lightThemes: []}), "mobile"), false);+ assert.equal(isCurrentThemeSupported(appearance({lightThemes: []}), "desktop"), true);});it("uses each mode's frontend declaration", () => {diff --git a/app/src/util/themeCompatibility.ts b/app/src/util/themeCompatibility.tsindex 267171ebf2..d95bcce27e 100644--- a/app/src/util/themeCompatibility.ts+++ b/app/src/util/themeCompatibility.ts@@ -2,7 +2,10 @@ export const isThemeFrontendSupported = (frontends: string[] | null | undefined,frontend: string,) => {- if (!frontends?.length || frontends.includes("all")) {+ if (!frontends?.length) {+ return !["mobile", "browser-mobile"].includes(frontend);+ }+ if (frontends.includes("all")) {return true;}return frontends.includes(frontend);diff --git a/app/src/util/uri.ts b/app/src/util/uri.tsindex 2fd60c7d30..dd7401f422 100644--- a/app/src/util/uri.ts+++ b/app/src/util/uri.ts@@ -10,7 +10,7 @@ import {fetchPost} from "./fetch";import {checkFold} from "./noRelyPCFunction";import {openMobileFileById} from "../mobile/editor";import {isValidBazaarPackageName} from "./bazaarPackage";-import {isBazaarAvailable, isBazaarPackageTypeAvailable} from "./bazaarAvailability";+import {isBazaarAvailable} from "./bazaarAvailability";import type {App} from "../index";import {openDatabaseItem} from "../protyle/render/av/openDatabaseItem";@@ -129,9 +129,6 @@ const processSiYuanUriBazaar = (app: App, uriObj: URL): boolean => {return false;}const resourceType = _type as TBazaarType;- if (!isBazaarPackageTypeAvailable(resourceType)) {- return false;- }let resourceName: string;try {resourceName = decodeURIComponent(_name);diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.goindex 2643e81401..5d22c84345 100644--- a/kernel/bazaar/theme.go+++ b/kernel/bazaar/theme.go@@ -22,6 +22,10 @@ func IsIncompatibleTheme(theme *Package, frontend string) bool {if "" == frontend {return false}+ // 移动端主题需要显式声明兼容性,避免旧主题破坏移动端界面+ if len(theme.Frontends) == 0 && ("mobile" == frontend || "browser-mobile" == frontend) {+ return true+ }return !IsTargetSupported(theme.Frontends, frontend)}diff --git a/kernel/bazaar/theme_test.go b/kernel/bazaar/theme_test.goindex 49d057d0a9..cfce1d8d2e 100644--- a/kernel/bazaar/theme_test.go+++ b/kernel/bazaar/theme_test.go@@ -26,7 +26,9 @@ func TestBuildBazaarThemeCompatibility(t *testing.T) {wantIncompatible boolwantDisallowAction bool}{- {name: "missing field", frontend: "mobile"},+ {name: "missing field on mobile", frontend: "mobile", wantIncompatible: true, wantDisallowAction: true},+ {name: "missing field on browser mobile", frontend: "browser-mobile", wantIncompatible: true, wantDisallowAction: true},+ {name: "missing field on desktop", frontend: "desktop"},{name: "all frontends", frontends: []string{"all"}, frontend: "mobile"},{name: "supported frontend", frontends: []string{"desktop", "mobile"}, frontend: "mobile"},{name: "unsupported frontend", frontends: []string{"desktop"}, frontend: "mobile", wantIncompatible: true, wantDisallowAction: true},