Files
FixIt/assets/js/core/tokens.ts
T
Cell 17d7bc1781 refactor(assets): SCSS variables with hugo:vars and module setup standardization (#788)
* feat(assets): refactor SCSS variables with Hugo config via hugo:vars

Use Hugo's hugo:vars mechanism (v0.161.0+) to configure SCSS variables
via [params.appearance] in hugo.toml, replacing the override.scss file.

- Add [params.appearance] config section in hugo.toml
- Create scss-vars.html partial for SCSS default values
- Pass vars to toCSS via head/index.html
- Rewrite _variables.scss to use @use "hugo:vars" as h with !default
- Update all 20 consumer files from @use "override" to @use "variables"
- Delete override.scss
- Add admonition mixin in core/mixins/_admonition.scss
- Update deprecation detection to use fileExists

* refactor(assets): standardize module setup() and simplify main.ts init

- Add setup() method to all modules (menu, theme, search, enc, misc, events)
- Rename initMenu to setup, initMenuDesktop/initMenuMobile to initDesktop/initMobile
- Rename initSearch, initFixItDecryptor to setup
- Standardize setup() position at end of each module class and interface
- Simplify main.ts init sequence to uniform setup() calls

* refactor(assets): replace config.template.scss with hugo:vars/internal

- Delete config.template.scss and its ExecuteAsTemplate pipeline
- Pass internal config (base URL, logo, loading) via hugo:vars/internal namespace
- Move CSS custom properties to _root.scss using set-fi-vars mixin
- Simplify _variables.scss by removing config namespace dependency
- Update CLAUDE.md to reflect new SCSS architecture

* style(i18n): fix spacing in Korean translation strings

* fix(assets): resolve dead SCSS config keys and deduplicate defaults

- Wire up 5 config keys with v.$ references: menu-active-color,
  tag-cloud-start, tag-cloud-end, tag-cloud-end-dark,
  pagination-link-color-dark (were reading from SCSS vars, ignoring
  hugo:vars overrides)
- Remove dead !default flags from all v.$ references (hugo:vars
  always provides values, making !default unreachable)
- Compute derived defaults in scss-vars.html from base values instead
  of hardcoding duplicates
- Extract admonition mixin set-fi-vars map to shared $vars variable
2026-06-22 02:43:35 +08:00

108 lines
2.7 KiB
TypeScript

/** Service interfaces for all FixIt modules. */
import type { FixItConfig, MaskOverlayHandler } from '../types'
import type { TypedEventBus } from './event-bus'
// ─── CoreService ───
export interface CoreService {
readonly config: FixItConfig
readonly version: string
isDark: boolean
themeMode: string
registerMaskOverlay: (name: string, handlers: MaskOverlayHandler) => void
openMaskOverlay: (name: string) => void
closeMaskOverlay: (name: string, skipSync?: boolean) => void
toggleMaskOverlay: (name: string) => void
closeActiveMaskOverlay: () => void
syncMaskState: () => void
}
// ─── ThemeService ───
export interface ThemeService {
setThemeMode: (mode: string, persist?: boolean) => void
initThemeColor: () => void
initSwitchTheme: () => void
setup: () => void
}
// ─── MenuService ───
export interface MenuService {
initDesktop: () => void
initMobile: () => void
setup: () => void
}
// ─── SearchService ───
export interface SearchService {
setup: () => void
}
// ─── CodeService ───
export interface CodeService {
initCodeWrapper: () => void
initCodeTabs: () => void
initDiagramCopyBtn: () => void
}
// ─── TocService ───
export interface TocService {
syncTocHeight: () => void
syncTocActiveState: () => void
initToc: () => void
setup: () => void
}
// ─── EncryptionService ───
export interface EncryptionService {
setup: () => void
}
// ─── ContentService ───
export interface ContentService {
initSVGIcon: () => void
initLinkGuardDialog: (target?: Element | Document) => void
initContent: (target?: Element | Document) => void
setup: () => void
}
// ─── MiscService ───
export interface MiscService {
initSiteTime: () => void
initServiceWorker: () => void
initAutoMark: () => void
initReward: () => void
initPostChatUser: () => void
initComment: () => void
setup: () => void
}
// ─── EventsService ───
export interface EventsService {
onScroll: () => void
onResize: () => void
onClickMask: () => void
initPrint: () => void
setup: () => void
}
// ─── FixItPublicAPI ───
export interface FixItPublicAPI {
readonly config: FixItConfig
readonly version: string
readonly themeMode: string
readonly isDark: boolean
// Modules
readonly core: CoreService
readonly theme: ThemeService
readonly code: CodeService
readonly toc: TocService
readonly menu: MenuService
readonly search: SearchService
readonly enc: EncryptionService
readonly misc: MiscService
readonly content: ContentService
readonly events: EventsService
readonly eventBus: TypedEventBus
// Methods
setThemeMode: (mode: string, persist?: boolean) => void
}