Skip to content

Commit

Permalink
feat: #132 集成PicGO以及图床-修复Windows路径问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Dec 28, 2022
1 parent 0f7d9aa commit b81dd85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import("/widgets/sy-post-publisher/lib/siyuanhook.js")

点击按钮开始体验

![](https://img1.terwer.space/api/public/202212182033394.png)
![](https://img1.terwer.space/api/public/20221228-175950.jpeg)

详情请参考: [挂件模式用挂载菜单的方式使用](https://www.terwer.space/post/the-pendant-mode-is-used-in-the-method-of-mounting-menu-169wrw.html#%E6%95%88%E6%9E%9C%E6%BC%94%E7%A4%BA)<sup>
强烈推荐</sup> <sup>0.4.2+</sup>
Expand Down Expand Up @@ -157,6 +157,18 @@ https://terwer.space/post/start-to-get-started-zi0eyk.html
- [x] 支持自定义设置 API 地址,支持本地、局域网、远程 <sup>0.1.0+</sup>
- [x] 支持配置导入导出 <sup>0.2.0+</sup>
- [x] 通用设置支持标题序号开关、正文 H1 开关、新窗口开关、自动标签开关 <sup>0.2.0+</sup>
- [x] 支持设置 Anki 牌组标记 <sup>0.6.0+</sup>

- anki 使用入门请参考:https://ld246.com/article/1670312056742

- [x] 支持通过 PicGO 管理图床 <sup>
0.6.0+ [挂件版已经完美集成 PicGO,可直接使用;浏览器插件只能通过 HTTP 调用本地的 PicGO,需手动下载和配置]</sup>

- PicGO 使用注意事项:

1. 如果你使用的是浏览器插件可以从这里下载配置 PicGO 客户端:https://github.com/Molunerfinn/PicGo/releases

2. 挂件版无需此操作

## 最近更新

Expand Down
9 changes: 7 additions & 2 deletions public/lib/siyuanhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,13 @@ window.terwer.renderPublishHelper = (pageId, pageUrl) => {
if (err) {
console.log(err)
}
var dataDir = `${window.siyuan.config.system.dataDir}`
let dataDir = `${window.siyuan.config.system.dataDir}`
// 修复Windows路径问题
dataDir = dataDir.replace(/\\/g, "/")
const newWinPageId = pageId ?? ""
console.log("dataDir=>", dataDir)
console.log("newWinPageId=>", newWinPageId)

var txt = data.toString().replace(/<!--.*-->/gs, "")
txt += `<script>window.terwer={};window.terwer.pageId="${newWinPageId}";window.terwer.dataDir="${dataDir}";
window.terwer.picgoExtension = require("${dataDir}/widgets/sy-post-publisher/lib/picgo/picgo.js").default;
Expand Down Expand Up @@ -230,7 +235,7 @@ window.terwer.renderPublishHelper = (pageId, pageUrl) => {
(response) => {
window.siyuan.printWin.loadURL(response.data.url)
// 打开开发者工具
// window.siyuan.printWin.webContents.openDevTools()
window.siyuan.printWin.webContents.openDevTools()
}
)
})
Expand Down

0 comments on commit b81dd85

Please sign in to comment.