@@ -8,11 +8,12 @@ import {
88 createStyles ,
99} from "@mantine/core" ;
1010import BalanceTip from "@/views/components/BalanceTip" ;
11- import { IconSettings , IconLanguage } from "@tabler/icons-react" ;
11+ import { IconSettings , IconLanguage , IconMessages } from "@tabler/icons-react" ;
1212import { useTranslation } from "react-i18next" ;
1313// @ts -ignore
1414import SvgAvatarDevChat from "../MessageAvatar/avatar_devchat.svg" ;
1515import messageUtil from "@/util/MessageUtil" ;
16+ import { useRouter } from "@/views/router" ;
1617
1718const useStyles = createStyles ( ( theme ) => ( {
1819 logoName : {
@@ -21,6 +22,7 @@ const useStyles = createStyles((theme) => ({
2122} ) ) ;
2223
2324export default function Head ( ) {
25+ const router = useRouter ( ) ;
2426 const { classes } = useStyles ( ) ;
2527 const { i18n } = useTranslation ( ) ;
2628
@@ -46,10 +48,21 @@ export default function Head() {
4648 } , [ ] ) ;
4749
4850 const openSetting = ( ) => {
49- messageUtil . sendMessage ( {
50- command : "doCommand" ,
51- content : [ "workbench.action.openSettings" , "@ext:merico.devchat" ] ,
52- } ) ;
51+ if ( router . currentRoute === "config" ) return ;
52+ router . updateRoute ( "config" ) ;
53+ // messageUtil.sendMessage({
54+ // command: "doCommand",
55+ // content: ["workbench.action.openSettings", "@ext:merico.devchat"],
56+ // });
57+ } ;
58+
59+ const openChat = ( ) => {
60+ if ( router . currentRoute === "chat" ) return ;
61+ router . updateRoute ( "chat" ) ;
62+ // messageUtil.sendMessage({
63+ // command: "doCommand",
64+ // content: ["workbench.action.openSettings", "@ext:merico.devchat"],
65+ // });
5366 } ;
5467
5568 const switchLang = ( ) => {
@@ -89,10 +102,22 @@ export default function Head() {
89102 </ Flex >
90103 < Flex align = "center" gap = "xs" sx = { { paddingRight : 10 } } >
91104 < div >
92- < BalanceTip />
105+ < ActionIcon
106+ size = "sm"
107+ onClick = { openChat }
108+ color = { router . currentRoute === "chat" ? "merico" : "gray" }
109+ variant = { router . currentRoute === "chat" ? "filled" : "subtle" }
110+ >
111+ < IconMessages size = "1.125rem" />
112+ </ ActionIcon >
93113 </ div >
94114 < div >
95- < ActionIcon size = "sm" onClick = { openSetting } >
115+ < ActionIcon
116+ size = "sm"
117+ onClick = { openSetting }
118+ color = { router . currentRoute === "config" ? "merico" : "gray" }
119+ variant = { router . currentRoute === "config" ? "filled" : "subtle" }
120+ >
96121 < IconSettings size = "1.125rem" />
97122 </ ActionIcon >
98123 </ div >
@@ -101,6 +126,9 @@ export default function Head() {
101126 < IconLanguage size = "1.125rem" />
102127 </ ActionIcon >
103128 </ div >
129+ < div >
130+ < BalanceTip />
131+ </ div >
104132 </ Flex >
105133 </ Flex >
106134 </ Header >
0 commit comments