11import React from "react" ;
2- import { Header , Avatar , Flex , Text , ActionIcon , createStyles } from "@mantine/core" ;
2+ import {
3+ Header ,
4+ Avatar ,
5+ Flex ,
6+ Text ,
7+ ActionIcon ,
8+ createStyles ,
9+ } from "@mantine/core" ;
310import BalanceTip from "@/views/components/BalanceTip" ;
4- import { IconSettings } from "@tabler/icons-react" ;
11+ import { IconSettings , IconLanguage } from "@tabler/icons-react" ;
12+ import { useTranslation } from "react-i18next" ;
513// @ts -ignore
614import SvgAvatarDevChat from "../MessageAvatar/avatar_devchat.svg" ;
715import messageUtil from "@/util/MessageUtil" ;
816
917const useStyles = createStyles ( ( theme ) => ( {
10- logoName :{
11- color : ' var(--vscode-foreground)'
12- }
18+ logoName : {
19+ color : " var(--vscode-foreground)" ,
20+ } ,
1321} ) ) ;
1422
1523export default function Head ( ) {
16- const { classes} = useStyles ( ) ;
24+ const { classes } = useStyles ( ) ;
25+ const { t, i18n } = useTranslation ( ) ;
26+
1727 const openSetting = ( ) => {
1828 messageUtil . sendMessage ( {
1929 command : "doCommand" ,
2030 content : [ "workbench.action.openSettings" , "DevChat" ] ,
2131 } ) ;
2232 } ;
33+
34+ const switchLang = ( ) => {
35+ const currentLang = i18n . language ;
36+ const newLang = currentLang === "en" ? "zh" : "en" ;
37+ i18n . changeLanguage ( newLang ) ;
38+ } ;
39+
2340 return (
2441 < Header
2542 height = { 40 }
2643 style = { {
2744 backgroundColor : "var(--vscode-sideBar-background)" ,
28- borderBottom : ' 1px solid #ced4da' ,
45+ borderBottom : " 1px solid #ced4da" ,
2946 } }
3047 >
3148 < Flex justify = "space-between" align = "center" sx = { { padding : "0 10px" } } >
@@ -38,17 +55,24 @@ export default function Head() {
3855 } }
3956 >
4057 < Avatar color = "indigo" size = { 25 } radius = "xl" src = { SvgAvatarDevChat } />
41- < Text weight = "bold" className = { classes . logoName } > DevChat</ Text >
58+ < Text weight = "bold" className = { classes . logoName } >
59+ DevChat
60+ </ Text >
4261 </ Flex >
43- < Flex align = "center" gap = "xs" sx = { { paddingRight :10 } } >
62+ < Flex align = "center" gap = "xs" sx = { { paddingRight : 10 } } >
4463 < div >
4564 < BalanceTip />
4665 </ div >
4766 < div >
48- < ActionIcon size = 'sm' onClick = { openSetting } >
67+ < ActionIcon size = "sm" onClick = { openSetting } >
4968 < IconSettings size = "1.125rem" />
5069 </ ActionIcon >
5170 </ div >
71+ < div >
72+ < ActionIcon size = "sm" onClick = { switchLang } >
73+ < IconLanguage size = "1.125rem" />
74+ </ ActionIcon >
75+ </ div >
5276 </ Flex >
5377 </ Flex >
5478 </ Header >
0 commit comments