Open bazaar resouce readme by siyuan://bazaar/{type}/{name}/readme URI - #17938
Conversation
siyuan://bazaar/<type>/<name>/readme URI
There was a problem hiding this comment.
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.tswith centralizedprocessSiYuanUri(app, uri)routing forblocks,plugins, and newbazaarhostnames. - 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.
…#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>
Signed-off-by: Daniel <845765@qq.com>
…adjust calls accordingly
|
@88250 |
siyuan://bazaar/<type>/<name>/readme URIsiyuan://bazaar/{type}/{name}/readme URI
|
AI 建议请参考: 🔴 需要处理的问题1. PR 混入了无关的构建脚本改动
建议:rebase 掉这些 commit,保持 PR diff 只包含功能改动,减少评审与回溯负担。 🟡 建议改进的问题2.
|
这个应该没有必要 |
|
@88250 |
|
goproxy 环境变量不能动,还是要用 https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct |
This reverts commit 5b5f513.
@88250 |
|
应该还需要区分 readme-online 和 readme-local |
类比于 VSCode 的 |
|
思源里必须要区分 |
|
这个 PR 是不是没有测试过,好多 BUG 啊,我修一下 #18068 |
…` 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>
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:
processSiYuanUri(app, uri)which validates and parses asiyuan:orweb+siyuan:URL, then dispatches it to one of three handlers based on the hostname:blocks→processSiYuanUriBlocks: opens the target block (with focus/fullscreen support), notifies plugins viaopen-siyuan-url-block.plugins→processSiYuanUriPlugins: emitsopen-siyuan-url-pluginto matching plugins, or opens a custom plugin tab.bazaar→processSiYuanUriBazaar: opens a bazaar resource's README page via the newsiyuan://bazaar/{type}/{name}/readmeprotocol.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_renderReadmemethod.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:
processSiYuanUrifunction and its three route handlers have been moved from app/src/editor/openLink.ts into the new app/src/util/uri.ts module, making them reusable outside the editor context.../util/uriinstead of../editor/openLink.parseUriInfoin app/src/util/pathName.ts now usessearchParams.has("url")before parsing, simplifying theweb+siyuan:detection logic.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.typesupports five values:plugins,themes,icons,widgets,templates.中文
重构思源协议 URL 处理逻辑,引入统一的 URI 处理模块。
新增文件:
processSiYuanUri(app, uri),校验并解析siyuan:或web+siyuan:URL,按 hostname 分发到三个处理器:blocks→processSiYuanUriBlocks:打开目标块(支持 focus/fullscreen),通过open-siyuan-url-block通知插件。plugins→processSiYuanUriPlugins:向匹配的插件发送open-siyuan-url-plugin事件,或打开自定义插件页签。bazaar→processSiYuanUriBazaar:通过新协议siyuan://bazaar/{type}/{name}/readme打开集市资源的 README 页面。新增工具函数:
renderReadme(bazaarType, isDownload, data)— 公开包装函数,在 bazaar 元素不存在时提前返回,否则调用内部_renderReadme方法。openBazaarReadme(app, bazaarType, itemName)— 按名称通过对应的/api/bazaar/getBazaar{Type}接口获取集市资源,打开集市设置页签,并渲染该资源的 README。重构 / 移动:
processSiYuanUri函数及其三个路由处理器从 app/src/editor/openLink.ts 移至新的 app/src/util/uri.ts 模块,使其可在编辑器上下文之外复用。../editor/openLink改为../util/uri。parseUriInfo现在先通过searchParams.has("url")判断再解析,简化了web+siyuan:的检测逻辑。新增协议支持:
siyuan://bazaar/{type}/{name}/readme— 在设置对话框中直接打开集市资源(插件、主题、图标、挂件、模板)的 README 页面。type支持plugins、themes、icons、widgets、templates五种类型。Type of change / 变更类型
缺陷修复
代码重构
新功能
修改文案或增加新语言
Checklist / 检查清单
我对自己的代码进行了自我审查
我拥有所提交代码的完整权利,并同意其以本项目的 AGPL-3.0 许可证授权
devbranch and has no merge conflictsPR 提交到
dev分支,并且没有合并冲突