@choerodon/master
Version:
A package of Master for Choerodon platform.
29 lines (24 loc) • 763 B
JavaScript
import { useLayoutEffect, useCallback } from 'react';
import { initTheme } from '@hzero-front-ui/core';
import { useUpdateEffect } from 'ahooks';
import { theme4Configs } from "./config";
/**
* hook
* 初始化新UI hook
*/
function useC7NThemeInit() {
var handleInitTheme = useCallback(function () {
initTheme(theme4Configs);
}, []);
function syncBodyThemeAttribute() {
var _localStorage$getItem;
document.body.setAttribute('data-theme', (_localStorage$getItem = localStorage.getItem('theme')) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '');
}
useUpdateEffect(function () {
syncBodyThemeAttribute();
});
useLayoutEffect(function () {
handleInitTheme();
}, []);
}
export { useC7NThemeInit };