ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
769 B

  1. import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants.js'
  2. import { PluginManager } from './plugin-manager.js'
  3. import { CONFIG } from '../../initializers/config.js'
  4. function getThemeOrDefault (name: string, defaultTheme: string) {
  5. if (isThemeRegistered(name)) return name
  6. // Fallback to admin default theme
  7. if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
  8. return defaultTheme
  9. }
  10. function isThemeRegistered (name: string) {
  11. if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) return true
  12. return !!PluginManager.Instance.getRegisteredThemes()
  13. .find(r => r.name === name)
  14. }
  15. export {
  16. getThemeOrDefault,
  17. isThemeRegistered
  18. }