-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
增加公共代码 js/css 片段 #6143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
公共主题为 stage/build/app/base.css,所有主题都会进行加载。公共 js 里面主要的是前端 API 之类的么? |
是指不与特定主题耦合的自定义主题片段, 优先级比用户所当前所使用的主题( |
哦哦哦,想起来了,抱歉抱歉。 |
这是不是类似ob的代码片段? |
@mozhux 这个就不区分功能了,所有功能都塞到一个 js/css 中,区分功能的话还是通过插件机制比较好。 |
额,我意思是说有一个大的公共文件,其他的css和js就放在里面,通过设置打开对应需要的片段,类似ob那样呢,毕竟不是所有主题都可以通用的
从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送
发件人: ***@***.***>
发送时间: 2022年10月11日 22:15
收件人: ***@***.***>
抄送: ***@***.***>; ***@***.***>
主题: Re: [siyuan-note/siyuan] 增加公共主题 css 与 js 文件 (Issue #6143)
@mozhux<https://github.com/mozhux> 这个就不区分功能了,所有功能都塞到一个 js/css 中,区分功能的话还是通过插件机制比较好。
―
Reply to this email directly, view it on GitHub<#6143 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALGHHG7WWTXELZ6K3HSJKLTWCVY7DANCNFSM6AAAAAARBJJYNQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
我不太清楚如何区分一个文件中的不同片段 😂 |
应该是每个片段都独立,通过勾选让其生效。
从 Windows 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>发送
发件人: ***@***.***>
发送时间: 2022年10月11日 22:18
收件人: ***@***.***>
抄送: ***@***.***>; ***@***.***>
主题: Re: [siyuan-note/siyuan] 增加公共主题 css 与 js 文件 (Issue #6143)
我不太清楚如何区分一个文件中的不同片段 😂
—
Reply to this email directly, view it on GitHub<#6143 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALGHHG2IDVQQ2522EGEEGK3WCVZL7ANCNFSM6AAAAAARBJJYNQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
简单点可以使用不同文件吧 这个应该比较好实现 我之前试了就是片段的加载顺序不知道怎么交互比较好 |
那有可能是 JSON 存储,按 Key 来区分功能吧。这个得再考虑看下是否有必要,因为扩展性后面可能更多是通过插件机制来实现,共享依赖库这样的场景恐怕比较少。 目前我们可以考虑支持区分功能代码片段的扩展性,即实现上按照 JSON 保存: [
{
"name": "common",
"type": "js",
"enabled": true,
"content": "js code"
}
] 后面如果要区分功能再扩展这个数组,让用户可以添加类似 common 的多个 snippet 对象。 物理存放路径:工作空间/data/snippets/conf.json 前端从 /api/snippet/getSnippet 加载。 |
问一下 公共代码 js/css 片段 怎么操作? |
|
参照D大的示例,css直接改type即可,提供给有需要的参考: [
{
"name": "common",
"type": "js",
"enabled": true,
"content": "console.log('这是自定义js片段');"
},
{
"name": "common",
"type": "css",
"enabled": true,
"content": ".protyle-background:has(.protyle-background__icon.fn__none) {min-height: 57px !important;}.protyle-title{margin-left:16px !important;margin-right:16px !important;}.protyle-wysiwyg{padding-left:16px !important;padding-right:16px !important;}"
}
] |
引用第三方文件的方案: [
{
"name": "-js-test-1",
"type": "js",
"enabled": false,
"content": "document.currentScript.type='module';document.currentScript.src='/widgets/custom.js';"
},
{
"name": "-js-test-2",
"type": "js",
"enabled": false,
"content": "import('/widgets/custom.js');"
},
{
"name": "-css-test-1",
"type": "css",
"enabled": false,
"content": "@import url('/widgets/custom.css');"
}
]
|
@88250 能不能将 |
在什么情况下你需要该特性?In what scenarios do you need this feature?
关联: [提议] 增加公共主题 css 文件, 无论使用哪个主题, 该 css 都会生效 - 链滴
描述可能的最优解决方案 Describe the optimal solution
将公共主题
theme.css
文件与theme.js
文件塞到某个 data 目录下某个现有的静态 Web 文件服务的目录描述候选的解决方案 Describe the candidate solution
在 data 目录下设置一个新的提供静态 Web 文件服务的目录, 用于存放公共主题的
theme.css
文件与theme.js
文件其他信息 Other information
不急~
The text was updated successfully, but these errors were encountered: