Skip to content

Open bazaar resouce readme by siyuan://bazaar/{type}/{name}/readme URI - #17938

Merged
88250 merged 11 commits into
siyuan-note:devfrom
Zuoqiu-Yingyi:feat/url-open-bazaar-resource
Jul 1, 2026
Merged

Open bazaar resouce readme by siyuan://bazaar/{type}/{name}/readme URI#17938
88250 merged 11 commits into
siyuan-note:devfrom
Zuoqiu-Yingyi:feat/url-open-bazaar-resource

Conversation

@Zuoqiu-Yingyi

@Zuoqiu-Yingyi Zuoqiu-Yingyi commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description / 描述

English

Refactors SiYuan protocol URL handling across multiple files, introducing a unified URI processing architecture based on an application-level event bus.

New files:

  • app/src/util/uri.ts — Adds processSiYuanUri(app, uri) which validates and parses a siyuan: or web+siyuan: URL, then dispatches it to one of three handlers based on the hostname:
    • blocksprocessSiYuanUriBlocks: opens the target block (with focus/fullscreen support), notifies plugins via open-siyuan-url-block.
    • pluginsprocessSiYuanUriPlugins: emits open-siyuan-url-plugin to matching plugins, or opens a custom plugin tab.
    • bazaarprocessSiYuanUriBazaar: opens a bazaar resource's README page via the new siyuan://bazaar/{type}/{name}/readme protocol.

New utility functions:

  • renderReadme(bazaarType, isDownload, data) in app/src/config/bazaar.ts — a public wrapper that guards against a missing bazaar element before delegating to the internal _renderReadme method.
  • openBazaarReadme(app, bazaarType, itemName) in app/src/config/index.ts — fetches a bazaar resource by name via the appropriate /api/bazaar/getBazaar{Type} endpoint, opens the bazaar settings tab, and renders the resource's README.

Refactored / moved:

New protocol support:

  • siyuan://bazaar/{type}/{name}/readme — opens the README page for a bazaar resource (plugin, theme, icon, widget, or template) directly in the settings dialog.
    • type supports five values: plugins, themes, icons, widgets, templates.
中文

重构思源协议 URL 处理逻辑,引入统一的 URI 处理模块。

新增文件:

  • app/src/util/uri.ts — 新增 processSiYuanUri(app, uri),校验并解析 siyuan:web+siyuan: URL,按 hostname 分发到三个处理器:
    • blocksprocessSiYuanUriBlocks:打开目标块(支持 focus/fullscreen),通过 open-siyuan-url-block 通知插件。
    • pluginsprocessSiYuanUriPlugins:向匹配的插件发送 open-siyuan-url-plugin 事件,或打开自定义插件页签。
    • bazaarprocessSiYuanUriBazaar:通过新协议 siyuan://bazaar/{type}/{name}/readme 打开集市资源的 README 页面。

新增工具函数:

  • app/src/config/bazaar.ts 中的 renderReadme(bazaarType, isDownload, data) — 公开包装函数,在 bazaar 元素不存在时提前返回,否则调用内部 _renderReadme 方法。
  • app/src/config/index.ts 中的 openBazaarReadme(app, bazaarType, itemName) — 按名称通过对应的 /api/bazaar/getBazaar{Type} 接口获取集市资源,打开集市设置页签,并渲染该资源的 README。

重构 / 移动:

新增协议支持:

  • siyuan://bazaar/{type}/{name}/readme — 在设置对话框中直接打开集市资源(插件、主题、图标、挂件、模板)的 README 页面。
    • type 支持 pluginsthemesiconswidgetstemplates 五种类型。

Type of change / 变更类型

  • Bug fix
    缺陷修复
  • Refactoring
    代码重构
  • New feature
    新功能
  • Text edits or new language additions
    修改文案或增加新语言

Checklist / 检查清单

  • I have performed a self-review of my own code
    我对自己的代码进行了自我审查
  • I have full rights to the submitted code and agree to license it under this project's AGPL-3.0 license
    我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
  • PR is submitted to the dev branch and has no merge conflicts
    PR 提交到 dev 分支,并且没有合并冲突

@Zuoqiu-Yingyi
Zuoqiu-Yingyi marked this pull request as ready for review June 25, 2026 08:05
@Zuoqiu-Yingyi Zuoqiu-Yingyi changed the title Open bazaar resouce readme by siyuan:// URI Open bazaar resouce readme by siyuan://bazaar/<type>/<name>/readme URI Jun 25, 2026
@88250
88250 requested a review from Copilot June 28, 2026 01:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors SiYuan protocol (siyuan: / web+siyuan:) URL handling into a reusable utility module and adds support for opening a bazaar resource README via siyuan://bazaar/{type}/{name}/readme, so different UI entry points (boot, agent messages, etc.) can route these URIs consistently.

Changes:

  • Added app/src/util/uri.ts with centralized processSiYuanUri(app, uri) routing for blocks, plugins, and new bazaar hostnames.
  • Added openBazaarReadme() and a public README-render wrapper to open a bazaar item README by {type, name}.
  • Updated import sites to use the new URI utility and simplified parseUriInfo() URL parameter handling.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
app/src/util/uri.ts New centralized SiYuan URI processor, including bazaar README protocol routing.
app/src/util/pathName.ts Simplifies url query parsing before calling parseSiYuanUriInfo.
app/src/layout/dock/agent/AgentMessageRenderer.ts Switches to the new URI processor for agent-rendered links.
app/src/editor/openLink.ts Removes exported URI processing code from this module (now centralized elsewhere).
app/src/config/index.ts Adds openBazaarReadme() to open settings → bazaar and render README for a named resource.
app/src/config/bazaar.ts Exposes a public renderReadme() wrapper around the internal README renderer.
app/src/boot/onGetConfig.ts Switches to the new URI processor import path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/util/uri.ts Outdated
Comment thread app/src/util/uri.ts Outdated
Comment thread app/src/config/index.ts
Comment thread app/src/config/bazaar.ts Outdated
Comment thread app/src/config/index.ts Outdated
…#17969)

* Initial plan

* fix: upgrade Node.js base image from 21 to 22 in Dockerfile to fix corepack ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@88250 88250 added this to the 3.7.1 milestone Jun 29, 2026
@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

@88250
Issues with feedback have been fixed

@Zuoqiu-Yingyi Zuoqiu-Yingyi changed the title Open bazaar resouce readme by siyuan://bazaar/<type>/<name>/readme URI Open bazaar resouce readme by siyuan://bazaar/{type}/{name}/readme URI Jul 1, 2026
@88250

88250 commented Jul 1, 2026

Copy link
Copy Markdown
Member

AI 建议请参考:

🔴 需要处理的问题

1. PR 混入了无关的构建脚本改动

kernel/harmony/build-win.shbuild.shscripts/darwin-build.shscripts/linux-build.shscripts/win-build.bat 等文件包含 GOPROXY 镜像变更与 Node 基础镜像升级,与本 PR 的功能无关(来自 merge master 的 commit)。

建议:rebase 掉这些 commit,保持 PR diff 只包含功能改动,减少评审与回溯负担。


🟡 建议改进的问题

2. setTimeout 的时序依赖略显脆弱

openSettingDialog(app, "bazaar");
setTimeout(() => {
    renderReadme(bazaarType, "bazaar", resource);
});

经核查,openSettingDialog → switchSettingTab → mountBazaarTab同步执行的,mountBazaarTabroot.innerHTML = bazaar.genHTML() 立即完成,#configBazaarReadme 容器在 openSettingDialog 返回时就已存在。因此这里的 setTimeout(0) 并非必需,且「魔法延迟」可读性较差。

建议:改为直接同步调用,或使用 requestAnimationFrame 来明确表达「等待下一帧绘制」的意图:

openSettingDialog(app, "bazaar");
renderReadme(bazaarType, "bazaar", resource);

3. README 面板与底层子页签可能不一致

openBazaarReadme 打开 bazaar 设置页时只传了 "bazaar",不会自动切换到与 bazaarType 对应的子页签(plugins / themes / icons / widgets / templates)。由于 README 是以 overlay 形式叠加在卡片网格上,功能本身没问题;但用户关闭 README 后,看到的底层网格可能是别的分类,体验上略显突兀。

建议:打开设置页后,利用 mountBazaarTabkeywords 参数或 switchSettingPanelSubTab 切换到对应类型的子页签,保持上下文一致。

4. 移动端静默无反应

processSiYuanUriBazaaropenBazaarReadme 整段包在 /// #if !MOBILE 内。移动端点击 siyuan://bazaar/... 链接会返回 false,既无反应也无提示。

这与移动端无 bazaar 设置 UI(走 popMenu())的现状一致,属于可接受的限制。但建议在 PR 描述中明确说明这一限制,便于后续维护者知晓是有意为之。


@TCOTC

TCOTC commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

打开设置页后,利用 mountBazaarTab 的 keywords 参数或 switchSettingPanelSubTab 切换到对应类型的子页签,保持上下文一致

这个应该没有必要

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

@88250
问题 1, 2 已修复
问题 3, 4 可忽略

@88250

88250 commented Jul 1, 2026

Copy link
Copy Markdown
Member

goproxy 环境变量不能动,还是要用 https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

goproxy 环境变量不能动,还是要用 https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct

@88250
已恢复为 https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct

@88250
88250 merged commit 24c9c5f into siyuan-note:dev Jul 1, 2026
@Zuoqiu-Yingyi
Zuoqiu-Yingyi deleted the feat/url-open-bazaar-resource branch July 1, 2026 09:48
@TCOTC

TCOTC commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

应该还需要区分 readme-online 和 readme-local

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

应该还需要区分 readme-online 和 readme-local

类比于 VSCode 的 vscode:extension/openai.chatgpt, 跳转到的是插件详情, 不用区分本地还是在线

@TCOTC

TCOTC commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

思源里必须要区分

@TCOTC

TCOTC commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

这个 PR 是不是没有测试过,好多 BUG 啊,我修一下 #18068

88250 added a commit that referenced this pull request Jul 4, 2026
…` URI (#17938)

* 🎨 Implement bazaar readme rendering and update URI processing for bazaar resources

* 🎨 Refactor URI processing by moving functions to a new utility module

* 👷 upgrade Node.js base image from 21 to 22 in Dockerfile (#17969)

* Initial plan

* fix: upgrade Node.js base image from 21 to 22 in Dockerfile to fix corepack ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* 👷 Update GOPROXY

Signed-off-by: Daniel <845765@qq.com>

* 🎨 Update renderReadme function to use more descriptive parameter and adjust calls accordingly

* 🎨 Simplify GOPROXY configuration across build scripts

* 🎨 Optimize openBazaarReadme by removing unnecessary setTimeout for renderReadme

* Revert "🎨 Simplify GOPROXY configuration across build scripts"

This reverts commit 5b5f513.

---------

Signed-off-by: Daniel <845765@qq.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Daniel <845765@qq.com>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants