Skip to content

Commit

Permalink
load user css
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jul 13, 2024
1 parent c34b7af commit a21813d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions page/customize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type STYLE_JSON = {
LabelTextGap: string
HorizontalDividerWidth: string
}
Advanced: {
UserCss: string
}
}

function lightToDark (light: string) {
Expand Down Expand Up @@ -166,6 +169,10 @@ function setFontFamily (o: {[key: string]: string}, f: FONT_FAMILY) {
}
}

function noCache (url: string): string {
return url + '?r=' + Math.random()
}

export function setStyle (style: string) {
const j = JSON.parse(style) as STYLE_JSON
const rules: {[key: string]: {[key: string]: string}} = {}
Expand Down Expand Up @@ -464,4 +471,6 @@ export function setStyle (style: string) {
`${selector} {` + Object.entries(block).map(([key, value]) =>
`${key}: ${value};`).join('\n') + '}').join('\n')
}

document.head.querySelector('#fcitx-user')?.setAttribute('href', noCache(j.Advanced.UserCss))
}
3 changes: 2 additions & 1 deletion page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<style id="fcitx-macos">
@import "./macos.scss";
</style>
<style id="fcitx-user">
<style>
@import "./user.scss";
</style>
<style id="fcitx-basic"></style>
<link id="fcitx-user" rel="stylesheet">
</head>
<body>
<div id="fcitx-theme" class="fcitx-macos fcitx-basic fcitx-blue">
Expand Down

0 comments on commit a21813d

Please sign in to comment.