-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: add global theme switching config #2
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢贡献,功能我测试没有问题,以下是一些改进建议。
@@ -111,6 +105,16 @@ export function ShikiPlugin({ | |||
// Initialize shiki async, and then highlight initial document | |||
async initDecorations() { | |||
const doc = view.state.doc; | |||
|
|||
let defaultTheme:BundledTheme = "github-light"; | |||
const configmap = await coreApiClient.configMap.getConfigMap({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里推荐使用 consoleApiClient.plugin.plugin.fetchPluginJsonConfig()
此外,这里需要考虑权限问题,不是所有用户都能访问这个接口,个人中心的编辑器也需要使用。
我的建议是将这个接口附加给 role-template-view-posts(Console 文章查看权限)和 role-template-post-contributor(允许在个人中心投稿)。
可以参考:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchPluginJsonConfig
用不了,报错Uncaught (in promise) TypeError: i.consoleApiClient.plugin.plugin.fetchPluginJsonConfig is not a function
。这可能是一个bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我改用fetchPluginConfig
之后没问题了,但是参考示例写了角色模板后没用,能看看有啥地方出问题了吗
apiVersion: v1alpha1
kind: Role
metadata:
name: role-template-shiki
labels:
halo.run/role-template: "true"
halo.run/hidden: "true"
rbac.authorization.halo.run/aggregate-to-role-template-view-posts: "true"
rbac.authorization.halo.run/aggregate-to-role-template-post-contributor: "true"
annotations:
rbac.authorization.halo.run/module: "Shiki"
rbac.authorization.halo.run/display-name: "Shiki"
rules:
- apiGroups: [ "" ]
resources: [ "configmaps" ]
resourceNames: [ "shiki-configmap" ]
verbs: [ "get" ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetchPluginJsonConfig
用不了,报错Uncaught (in promise) TypeError: i.consoleApiClient.plugin.plugin.fetchPluginJsonConfig is not a function
。这可能是一个bug
提升依赖(plugin.yaml#spec.requires)以及开发环境运行的 Halo 版本,fetchPluginJsonConfig 应该是在 2.20 才有
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我改用
fetchPluginConfig
之后没问题了,但是参考示例写了角色模板后没用,能看看有啥地方出问题了吗apiVersion: v1alpha1 kind: Role metadata: name: role-template-shiki labels: halo.run/role-template: "true" halo.run/hidden: "true" rbac.authorization.halo.run/aggregate-to-role-template-view-posts: "true" rbac.authorization.halo.run/aggregate-to-role-template-post-contributor: "true" annotations: rbac.authorization.halo.run/module: "Shiki" rbac.authorization.halo.run/display-name: "Shiki" rules: - apiGroups: [ "" ] resources: [ "configmaps" ] resourceNames: [ "shiki-configmap" ] verbs: [ "get" ]
ping @guqing
label: 配置 | ||
formSchema: | ||
- $formkit: select | ||
name: themeLight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以考虑加上 searchable,支持搜索。
label: 亮色主题 | ||
value: "vitesse-light" | ||
<<: *theme-options | ||
- $formkit: select |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
.shiki > code { | ||
display: block; | ||
overflow-x: auto; | ||
padding: 1em; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议为 .shiki 添加内边距,观察到不少主题为 pre 添加了边距样式,建议直接覆盖,否则可能造成 code 和 pre 都有内边距。
name: themeDark | ||
label: 暗色主题 | ||
value: "vitesse-dark" | ||
<<: *theme-options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
学习了
去除原先的代码块单独配置主题,添加了全局深浅色主题切换配置功能