chore: add dark mask, remove clear button in audio and image
This commit is contained in:
@@ -16,6 +16,15 @@ const defaultSettings: UserSettings = {
|
|||||||
colorPrimary: colorPrimary
|
colorPrimary: colorPrimary
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getStorageUserSettings = () => {
|
||||||
|
if (typeof window === 'undefined') return defaultSettings;
|
||||||
|
try {
|
||||||
|
return JSON.parse(localStorage.getItem('userSettings') || '{}');
|
||||||
|
} catch {
|
||||||
|
return defaultSettings;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const userSettingsAtom = atomWithStorage<UserSettings>(
|
export const userSettingsAtom = atomWithStorage<UserSettings>(
|
||||||
'userSettings',
|
'userSettings',
|
||||||
defaultSettings
|
defaultSettings
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { getStorageUserSettings } from '@/atoms/settings';
|
||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import styled, { keyframes } from 'styled-components';
|
||||||
|
|
||||||
|
const duration = 1;
|
||||||
|
|
||||||
|
const fadeOut = keyframes`
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(1.05);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Mask = styled.div<{ isHiding: boolean }>`
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: rgba(59, 59, 59, 1);
|
||||||
|
z-index: 9999;
|
||||||
|
animation: ${({ isHiding }) => (isHiding ? fadeOut : 'none')} ${duration}s
|
||||||
|
ease forwards;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const DarkModeMask = () => {
|
||||||
|
const { theme: savedTheme } = getStorageUserSettings();
|
||||||
|
const [visible, setVisible] = useState(savedTheme === 'realDark');
|
||||||
|
const [isHiding, setIsHiding] = useState(false);
|
||||||
|
const maskRef = useRef<HTMLDivElement>(null);
|
||||||
|
const timerRef = useRef<any>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (savedTheme === 'realDark') {
|
||||||
|
setVisible(true);
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
setIsHiding(true);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setIsHiding(true);
|
||||||
|
}
|
||||||
|
}, [savedTheme]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const el = maskRef.current;
|
||||||
|
if (!el) return;
|
||||||
|
|
||||||
|
const handleAnimationEnd = () => {
|
||||||
|
clearTimeout(timerRef.current);
|
||||||
|
setVisible(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
el.addEventListener('animationend', handleAnimationEnd);
|
||||||
|
|
||||||
|
if (isHiding) {
|
||||||
|
timerRef.current = setTimeout(
|
||||||
|
() => {
|
||||||
|
setVisible(false);
|
||||||
|
},
|
||||||
|
duration * 1000 + 100
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return () => el.removeEventListener('animationend', handleAnimationEnd);
|
||||||
|
}, [visible]);
|
||||||
|
|
||||||
|
return visible ? <Mask ref={maskRef} isHiding={isHiding}></Mask> : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DarkModeMask;
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { routeCacheAtom, setRouteCache } from '@/atoms/route-cache';
|
import { routeCacheAtom, setRouteCache } from '@/atoms/route-cache';
|
||||||
import { GPUStackVersionAtom, UpdateCheckAtom, userAtom } from '@/atoms/user';
|
import { GPUStackVersionAtom, UpdateCheckAtom, userAtom } from '@/atoms/user';
|
||||||
|
import DarkMask from '@/components/dark-mask';
|
||||||
import ShortCuts, {
|
import ShortCuts, {
|
||||||
modalConfig as ShortCutsConfig
|
modalConfig as ShortCutsConfig
|
||||||
} from '@/components/short-cuts';
|
} from '@/components/short-cuts';
|
||||||
@@ -430,6 +431,7 @@ export default (props: any) => {
|
|||||||
...themeData
|
...themeData
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<DarkMask theme={userSettings.theme}></DarkMask>
|
||||||
<ProLayout
|
<ProLayout
|
||||||
route={route}
|
route={route}
|
||||||
location={location}
|
location={location}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Bg2 from '@/assets/images/bg-2.png';
|
import Bg2 from '@/assets/images/bg-2.png';
|
||||||
import { userAtom } from '@/atoms/user';
|
import { userAtom } from '@/atoms/user';
|
||||||
|
import DarkMask from '@/components/dark-mask';
|
||||||
import Footer from '@/components/footer';
|
import Footer from '@/components/footer';
|
||||||
import useUserSettings from '@/hooks/use-user-settings';
|
import useUserSettings from '@/hooks/use-user-settings';
|
||||||
import { useModel } from '@umijs/max';
|
import { useModel } from '@umijs/max';
|
||||||
@@ -93,6 +94,7 @@ const Login = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
<DarkMask></DarkMask>
|
||||||
<Wrapper $isDarkTheme={isDarkTheme}></Wrapper>
|
<Wrapper $isDarkTheme={isDarkTheme}></Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<FormWrapper>
|
<FormWrapper>
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
placeholer={intl.formatMessage({
|
placeholer={intl.formatMessage({
|
||||||
id: 'playground.input.prompt.holder'
|
id: 'playground.input.prompt.holder'
|
||||||
})}
|
})}
|
||||||
actions={['clear']}
|
actions={[]}
|
||||||
defaultSize={{
|
defaultSize={{
|
||||||
minRows: 5,
|
minRows: 5,
|
||||||
maxRows: 5
|
maxRows: 5
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ const GroundTTS: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
)}
|
)}
|
||||||
<div className="ground-left-footer">
|
<div className="ground-left-footer">
|
||||||
<MessageInput
|
<MessageInput
|
||||||
actions={['check', 'clear']}
|
actions={['check']}
|
||||||
checkLabel={intl.formatMessage({
|
checkLabel={intl.formatMessage({
|
||||||
id: 'playground.toolbar.autoplay'
|
id: 'playground.toolbar.autoplay'
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ const GroundImages: React.FC<MessageProps> = forwardRef((props, ref) => {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ width: 389 }}>
|
<div style={{ width: 389 }}>
|
||||||
<MessageInput
|
<MessageInput
|
||||||
actions={['clear']}
|
actions={[]}
|
||||||
defaultSize={{
|
defaultSize={{
|
||||||
minRows: 5,
|
minRows: 5,
|
||||||
maxRows: 5
|
maxRows: 5
|
||||||
|
|||||||
@@ -179,12 +179,12 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
|
|||||||
const handleClearAll = (e: any) => {
|
const handleClearAll = (e: any) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
clearAll();
|
clearAll();
|
||||||
handleInputChange({ target: { value: '' } });
|
// handleInputChange({ target: { value: '' } });
|
||||||
setMessage({
|
// setMessage({
|
||||||
role: Roles.User,
|
// role: Roles.User,
|
||||||
content: '',
|
// content: '',
|
||||||
imgs: []
|
// imgs: []
|
||||||
});
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddMessage = (e?: any) => {
|
const handleAddMessage = (e?: any) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user