Skip to content

Commit 03eafa1

Browse files
committed
style
1 parent c370871 commit 03eafa1

7 files changed

Lines changed: 78 additions & 36 deletions

File tree

chat2db-client/src/blocks/Setting/index.tsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,24 @@ interface IProps {
1818
aiConfig: IAiConfig;
1919
className?: string;
2020
render?: ReactNode;
21-
// text?: string;
2221
dispatch: (params: any) => void;
22+
noLogin?: boolean; // 用于在没有登录的页面使用,不显示ai设置等需要登录的功能
2323
}
2424

2525
function Setting(props: IProps) {
26-
const { className, dispatch } = props;
26+
const { className, dispatch, noLogin = false } = props;
2727
const [isModalVisible, setIsModalVisible] = useState(false);
2828

2929
const [currentMenu, setCurrentMenu] = useState(0);
3030

31-
// 判断当前页面是否为登录页
32-
const loginPage = window.location.pathname === '/login';
33-
3431
useEffect(() => {
35-
if (isModalVisible && !loginPage) {
32+
if (isModalVisible && !noLogin) {
3633
getAiSystemConfig();
3734
}
3835
}, [isModalVisible]);
3936

4037
useEffect(() => {
41-
if (!loginPage) {
38+
if (!noLogin) {
4239
getAiSystemConfig();
4340
}
4441
}, []);
@@ -100,11 +97,6 @@ function Setting(props: IProps) {
10097
<>
10198
<div className={classnames(className, styles.box)} onClick={showModal}>
10299
{props.render ? props.render : <Iconfont className={styles.settingIcon} code="&#xe630;" />}
103-
{/* {text ? (
104-
<span className={styles.setText}>{text}</span>
105-
) : (
106-
<Iconfont className={styles.settingIcon} code="&#xe630;"></Iconfont>
107-
)} */}
108100
</div>
109101
<TestVersion />
110102
<Modal
@@ -119,7 +111,8 @@ function Setting(props: IProps) {
119111
<div className={styles.menus}>
120112
<div className={classnames(styles.menusTitle)}>{i18n('setting.title.setting')}</div>
121113
{menusList.map((t, index) => {
122-
if (loginPage && index === 1) {
114+
// 如果是没有登录的页面,不显示ai设置等需要登录的功能
115+
if (noLogin && index === 1) {
123116
return false;
124117
}
125118
return (

chat2db-client/src/components/Iconfont/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ if (__ENV__ === 'local') {
99
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
1010
@font-face {
1111
font-family: 'iconfont'; /* Project id 3633546 */
12-
src: url('//at.alicdn.com/t/c/font_3633546_rr2udfcdk5.woff2?t=1697021469012') format('woff2'),
13-
url('//at.alicdn.com/t/c/font_3633546_rr2udfcdk5.woff?t=1697021469012') format('woff'),
14-
url('//at.alicdn.com/t/c/font_3633546_rr2udfcdk5.ttf?t=1697021469012') format('truetype');
12+
src: url('//at.alicdn.com/t/c/font_3633546_vrz0j0emjjs.woff2?t=1697347643380') format('woff2'),
13+
url('//at.alicdn.com/t/c/font_3633546_vrz0j0emjjs.woff?t=1697347643380') format('woff'),
14+
url('//at.alicdn.com/t/c/font_3633546_vrz0j0emjjs.ttf?t=1697347643380') format('truetype');
1515
}
1616
`;
1717
const style = document.createElement('style');

chat2db-client/src/layouts/index.less

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,22 @@
6161
.hint {
6262
transform: translateY(120px);
6363
}
64+
65+
.settingBox {
66+
position: absolute;
67+
top: 20px;
68+
right: 30px;
69+
height: 32px;
70+
width: 32px;
71+
display: flex;
72+
justify-content: center;
73+
align-items: center;
74+
&:hover {
75+
i {
76+
color: var(--color-primary);
77+
}
78+
}
79+
i {
80+
font-size: 16px;
81+
}
82+
}

chat2db-client/src/layouts/index.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import { useTheme } from '@/hooks';
1313
import { ThemeType, LangType } from '@/constants/';
1414
import styles from './index.less';
1515
import { getLang, setLang } from '@/utils/localStorage';
16-
import { clearOlderLocalStorage, getCookie } from '@/utils';
16+
import { clearOlderLocalStorage } from '@/utils';
1717
import registerMessage from './init/registerMessage';
1818
import registerNotification from './init/registerNotification';
1919
import MyNotification from '@/components/MyNotification';
20+
import Iconfont from '@/components/Iconfont';
21+
import Setting from '@/blocks/Setting';
2022
import indexedDB from '@/indexedDB';
2123

2224
declare global {
@@ -79,7 +81,7 @@ function AppContainer() {
7981
const { token } = useToken();
8082
const [initEnd, setInitEnd] = useState(false);
8183
const [appTheme, setAppTheme] = useTheme();
82-
const [startSchedule, setStartSchedule] = useState(1); // 0 初始状态 1 服务启动中 2 启动成功
84+
const [startSchedule, setStartSchedule] = useState(0); // 0 初始状态 1 服务启动中 2 启动成功
8385
const [serviceFail, setServiceFail] = useState(false);
8486
const [isLogin, setIsLogin] = useState<boolean | null>(null);
8587

@@ -152,9 +154,6 @@ function AppContainer() {
152154
.testService()
153155
.then(() => {
154156
clearInterval(time);
155-
// if (__ENV__ === 'desktop') {
156-
// window.location.href = 'http://127.0.0.1:10824/'
157-
// }
158157
setStartSchedule(2);
159158
flag++;
160159
})
@@ -174,12 +173,20 @@ function AppContainer() {
174173
{initEnd && (
175174
<div className={styles.app}>
176175
{/* 服务启动中 */}
177-
{(startSchedule === 1 || isLogin === null) && (
176+
{(startSchedule < 2 || isLogin === null) && (
178177
<div className={styles.loadingBox}>
179178
<Spin spinning={!serviceFail} size="large" />
180-
{/* <div className={styles.hint}>
181-
<Setting />
182-
</div> */}
179+
{/* 状态等于1时,说明没服务起来需要轮训接口,这时可能服务配置又问题,需要设置来修改 */}
180+
{startSchedule === 1 && (
181+
<Setting
182+
render={
183+
<div className={styles.settingBox}>
184+
<Iconfont code="&#xe630;" />
185+
</div>
186+
}
187+
noLogin
188+
/>
189+
)}
183190
{serviceFail && (
184191
<>
185192
<div className={styles.github}>

chat2db-client/src/pages/login/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const Login: React.FC = () => {
7272

7373
<Setting
7474
className={styles.setting}
75+
noLogin
7576
render={
7677
<Button
7778
type="text"

chat2db-client/src/pages/main/index.less

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,31 @@
9191
flex-direction: column;
9292
align-items: center;
9393
margin-bottom: 20px;
94+
.userBox {
95+
width: 32px;
96+
height: 32px;
97+
display: flex;
98+
align-items: center;
99+
justify-content: center;
100+
margin-bottom: 6px;
101+
102+
.questionIcon {
103+
font-size: 20px;
104+
cursor: pointer;
105+
transform: translateX(1px);
106+
color: var(--custom-color-icon);
107+
}
108+
&:hover .questionIcon {
109+
color: var(--color-primary);
110+
}
111+
}
94112
}
95113

96-
.questionIcon {
97-
font-size: 20px;
98-
margin-bottom: 16px;
99-
cursor: pointer;
100-
color: var(--custom-color-icon);
101-
&:hover {
102-
background-color: var(--color-hover-bg);
103-
color: var(--color-primary);
114+
.userDropdown {
115+
display: flex;
116+
align-items: center;
117+
i {
118+
margin-right: 4px;
104119
}
105120
}
106121

chat2db-client/src/pages/main/index.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,20 @@ function MainPage(props: IProps) {
167167
items: [
168168
{
169169
key: '1',
170-
label: <div onClick={handleLogout}>{i18n('login.text.logout')}</div>,
170+
label: (
171+
<div className={styles.userDropdown} onClick={handleLogout}>
172+
<Iconfont code="&#xe6b2;" />
173+
{i18n('login.text.logout')}
174+
</div>
175+
),
171176
},
172177
],
173178
}}
174179
placement="bottomRight"
175-
arrow={{ pointAtCenter: true }}
176180
>
177-
<Iconfont code="&#xe64c;" className={styles.questionIcon} />
181+
<div className={styles.userBox}>
182+
<Iconfont code="&#xe64c;" className={styles.questionIcon} />
183+
</div>
178184
</Dropdown>
179185
);
180186
};
@@ -206,6 +212,7 @@ function MainPage(props: IProps) {
206212
window.open('https://github.com/chat2db/chat2db/wiki');
207213
}}
208214
/> */}
215+
209216
{userInfo ? renderUser() : null}
210217
<Setting className={styles.setIcon} />
211218
</div>

0 commit comments

Comments
 (0)