chore: reset the primary color after logout
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { colorPrimary } from '@/config/theme';
|
import { COLOR_PRIMARY } from '@/config/theme';
|
||||||
import { atom } from 'jotai';
|
import { atom } from 'jotai';
|
||||||
import { atomWithStorage } from 'jotai/utils';
|
import { atomWithStorage } from 'jotai/utils';
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ const defaultSettings: UserSettings = {
|
|||||||
theme: 'light',
|
theme: 'light',
|
||||||
mode: 'auto',
|
mode: 'auto',
|
||||||
isDarkTheme: false,
|
isDarkTheme: false,
|
||||||
colorPrimary: colorPrimary,
|
colorPrimary: COLOR_PRIMARY,
|
||||||
collapsed: false
|
collapsed: false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ export const userSettingsHelperAtom = atom(
|
|||||||
};
|
};
|
||||||
set(userSettingsAtom, {
|
set(userSettingsAtom, {
|
||||||
...newSettings,
|
...newSettings,
|
||||||
colorPrimary: newSettings.colorPrimary || colorPrimary,
|
colorPrimary: newSettings.colorPrimary || COLOR_PRIMARY,
|
||||||
isDarkTheme: newSettings.theme === 'realDark'
|
isDarkTheme: newSettings.theme === 'realDark'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
import { getDefaultStore } from 'jotai';
|
import { getDefaultStore } from 'jotai';
|
||||||
|
|
||||||
|
export const clearStorageUserSettings = () => {
|
||||||
|
const savedSettings = JSON.parse(
|
||||||
|
localStorage.getItem('userSettings') || '{}'
|
||||||
|
);
|
||||||
|
localStorage.setItem(
|
||||||
|
'userSettings',
|
||||||
|
JSON.stringify({
|
||||||
|
...savedSettings,
|
||||||
|
colorPrimary: undefined
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const clearAtomStorage = (atom: any) => {
|
export const clearAtomStorage = (atom: any) => {
|
||||||
if (!atom) {
|
if (!atom) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const Chart: React.FC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setOption = (options: ECOption) => {
|
const setOption = (options: ECOption) => {
|
||||||
console.log('setOption', options);
|
if (!chart.current) return;
|
||||||
chart.current?.clear();
|
chart.current?.clear();
|
||||||
chart.current?.setOption(options, {
|
chart.current?.setOption(options, {
|
||||||
notMerge: true,
|
notMerge: true,
|
||||||
@@ -107,8 +107,8 @@ const Chart: React.FC<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
chart.current?.dispose();
|
|
||||||
chart.current?.off('finished', handleOnFinished);
|
chart.current?.off('finished', handleOnFinished);
|
||||||
|
chart.current?.dispose();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -128,13 +128,11 @@ const Chart: React.FC<{
|
|||||||
|
|
||||||
if (container.current) {
|
if (container.current) {
|
||||||
resizeObserver.current = new ResizeObserver(handleResize);
|
resizeObserver.current = new ResizeObserver(handleResize);
|
||||||
|
|
||||||
resizeObserver.current.observe(container.current);
|
resizeObserver.current.observe(container.current);
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
if (container.current) {
|
resizeObserver.current?.disconnect();
|
||||||
resizeObserver.current?.unobserve(container.current);
|
resizeObserver.current = undefined;
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ export default function useChartConfig() {
|
|||||||
const { useToken } = theme;
|
const { useToken } = theme;
|
||||||
const { token } = useToken();
|
const { token } = useToken();
|
||||||
|
|
||||||
console.log('token:', token);
|
|
||||||
|
|
||||||
const chartColorMap = useMemo(() => {
|
const chartColorMap = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
titleColor: token.colorText,
|
titleColor: token.colorText,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { COLOR_PRIMARY } from './index';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'root-entry-name': 'variable',
|
'root-entry-name': 'variable',
|
||||||
cssVar: true,
|
cssVar: true,
|
||||||
@@ -36,7 +38,7 @@ export default {
|
|||||||
iconMarginInlineEnd: 12,
|
iconMarginInlineEnd: 12,
|
||||||
itemBorderRadius: 4,
|
itemBorderRadius: 4,
|
||||||
itemHeight: 32,
|
itemHeight: 32,
|
||||||
itemSelectedColor: '#007BFF',
|
itemSelectedColor: COLOR_PRIMARY,
|
||||||
darkItemSelectedBg: '#141414',
|
darkItemSelectedBg: '#141414',
|
||||||
darkItemHoverBg: 'rgba(255, 255, 255, 0.03)',
|
darkItemHoverBg: 'rgba(255, 255, 255, 0.03)',
|
||||||
groupTitleColor: 'rgba(0,0,0,1)',
|
groupTitleColor: 'rgba(0,0,0,1)',
|
||||||
@@ -78,7 +80,7 @@ export default {
|
|||||||
fontFamily:
|
fontFamily:
|
||||||
"Helvetica Neue, -apple-system, BlinkMacSystemFont, Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
|
"Helvetica Neue, -apple-system, BlinkMacSystemFont, Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
|
||||||
colorText: '#ccc',
|
colorText: '#ccc',
|
||||||
colorPrimary: '#007BFF',
|
colorPrimary: COLOR_PRIMARY,
|
||||||
colorSuccess: '#48A77E',
|
colorSuccess: '#48A77E',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
borderRadiusSM: 2,
|
borderRadiusSM: 2,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import dark from './dark';
|
import dark from './dark';
|
||||||
import light from './light';
|
import light from './light';
|
||||||
|
|
||||||
export const colorPrimary = '#007BFF';
|
export const COLOR_PRIMARY = '#007BFF';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
light,
|
light,
|
||||||
dark,
|
dark,
|
||||||
colorPrimary: colorPrimary
|
colorPrimary: COLOR_PRIMARY
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { COLOR_PRIMARY } from './index';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'root-entry-name': 'variable',
|
'root-entry-name': 'variable',
|
||||||
cssVar: true,
|
cssVar: true,
|
||||||
@@ -35,7 +37,7 @@ export default {
|
|||||||
iconSize: 16,
|
iconSize: 16,
|
||||||
iconMarginInlineEnd: 12,
|
iconMarginInlineEnd: 12,
|
||||||
itemBorderRadius: 4,
|
itemBorderRadius: 4,
|
||||||
itemSelectedColor: '#007BFF',
|
itemSelectedColor: COLOR_PRIMARY,
|
||||||
itemHeight: 32,
|
itemHeight: 32,
|
||||||
groupTitleColor: 'rgba(0,0,0,1)',
|
groupTitleColor: 'rgba(0,0,0,1)',
|
||||||
itemHoverColor: 'rgba(0,0,0,1)',
|
itemHoverColor: 'rgba(0,0,0,1)',
|
||||||
@@ -76,7 +78,7 @@ export default {
|
|||||||
fontFamily:
|
fontFamily:
|
||||||
"Helvetica Neue, -apple-system, BlinkMacSystemFont, Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
|
"Helvetica Neue, -apple-system, BlinkMacSystemFont, Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",
|
||||||
colorText: 'rgba(0,0,0,1)',
|
colorText: 'rgba(0,0,0,1)',
|
||||||
colorPrimary: '#007BFF',
|
colorPrimary: COLOR_PRIMARY,
|
||||||
colorSuccess: '#54cc98',
|
colorSuccess: '#54cc98',
|
||||||
colorBorder: '#d3d0d9',
|
colorBorder: '#d3d0d9',
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export default function useBodyScroll() {
|
|||||||
window.__GPUSTACK_BODY_SCROLLER__?.elements()?.scrollEventElement;
|
window.__GPUSTACK_BODY_SCROLLER__?.elements()?.scrollEventElement;
|
||||||
|
|
||||||
instanceRef.current = window.__GPUSTACK_BODY_SCROLLER__;
|
instanceRef.current = window.__GPUSTACK_BODY_SCROLLER__;
|
||||||
console.log('bodyScroller', bodyScroller.current, instanceRef.current);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveScrollHeight = React.useCallback(() => {
|
const saveScrollHeight = React.useCallback(() => {
|
||||||
|
|||||||
@@ -193,6 +193,22 @@ const options: BackendParameter[] = [
|
|||||||
{
|
{
|
||||||
label: '--multi-token-prediction-tokens',
|
label: '--multi-token-prediction-tokens',
|
||||||
value: '--multi-token-prediction-tokens'
|
value: '--multi-token-prediction-tokens'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--context-parallel-size',
|
||||||
|
value: '--context-parallel-size'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--models',
|
||||||
|
value: '--models'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--max-prefill-tokens',
|
||||||
|
value: '--max-prefill-tokens'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '--max-iter-times',
|
||||||
|
value: '--max-iter-times'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { userAtom } from '@/atoms/user';
|
import { userAtom } from '@/atoms/user';
|
||||||
import { clearAtomStorage } from '@/atoms/utils';
|
import { clearAtomStorage, clearStorageUserSettings } from '@/atoms/utils';
|
||||||
import { request } from '@umijs/max';
|
import { request } from '@umijs/max';
|
||||||
import qs from 'query-string';
|
import qs from 'query-string';
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ export const logout = async (userInfo?: any) => {
|
|||||||
await request(`${AUTH_API}/logout`, {
|
await request(`${AUTH_API}/logout`, {
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
});
|
});
|
||||||
|
clearStorageUserSettings();
|
||||||
clearAtomStorage(userAtom);
|
clearAtomStorage(userAtom);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ const SettingsItem = styled.div`
|
|||||||
const Appearance: React.FC = () => {
|
const Appearance: React.FC = () => {
|
||||||
const { setTheme, userSettings } = useUserSettings();
|
const { setTheme, userSettings } = useUserSettings();
|
||||||
|
|
||||||
console.log('userSettings', userSettings);
|
|
||||||
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const allLocals = getAllLocales();
|
const allLocals = getAllLocales();
|
||||||
|
|
||||||
@@ -57,8 +55,6 @@ const Appearance: React.FC = () => {
|
|||||||
setTheme(value);
|
setTheme(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('allLocals', allLocals);
|
|
||||||
|
|
||||||
const languageOptions = allLocals.map((locale) => ({
|
const languageOptions = allLocals.map((locale) => ({
|
||||||
value: locale,
|
value: locale,
|
||||||
label: _.get(langConfigMap, [locale, 'label'])
|
label: _.get(langConfigMap, [locale, 'label'])
|
||||||
@@ -71,6 +67,7 @@ const Appearance: React.FC = () => {
|
|||||||
<span>{intl.formatMessage({ id: 'common.appearance.theme' })}</span>
|
<span>{intl.formatMessage({ id: 'common.appearance.theme' })}</span>
|
||||||
</span>
|
</span>
|
||||||
<BaseSelect
|
<BaseSelect
|
||||||
|
defaultValue={'light'}
|
||||||
value={userSettings.mode}
|
value={userSettings.mode}
|
||||||
options={ThemeOptions}
|
options={ThemeOptions}
|
||||||
onChange={handleOnChange}
|
onChange={handleOnChange}
|
||||||
|
|||||||
Reference in New Issue
Block a user