为思源挂件块提供 api 访问的工具库,同时具有缓存 api 调用结果到块属性上以及在非思源笔记环境下使用缓存结果的功能
npm install siyuan_api_cache_lib@defaultValue "" 会在 api 请求路径的前面加上这个字段的值,便于开发调试
@defaultValue true 对 api 上方法的调用是否开启缓存,如果需要支持 OceanPress 请开启此选项
@defaultValue 10 * 1024 缓存结果的最大长度,超出此长度则不会缓存且在控制台打印警告
self.frameElement 而 frameElement 只能在同源的情况下才能访问到,
frameElement)
http://127.0.0.1/widgets/run-code/ (run-code 是我在开发的插件 github.com/run-code,建议查看这个项目里面对本库的使用方式)
js nginx conf
server {
listen 80;
server_name localhost 127.0.0.1;
location / {
#// 思源服务
proxy_pass http://127.0.0.1:6806;
proxy_set_header Host $host;
index index.html index.htm;
}
location /widgets/run-code/ {
#// run-code 所启动的服务, run-code 还配置了 base 路径为 /widgets/run-code/
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
index index.html index.htm;
}
}
`
对于 OceanPress 的调试可以采用如下配置
`js nginx conf
server {
listen 80;
server_name localhost 127.0.0.1;
location / {
#// oceanPress 生成的静态站点目录
alias 'D:/TEMP/思源test/';
}
location /widgets/run-code/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
index index.html index.htm;
}
}
``