88 Text ,
99 Tooltip ,
1010} from "@chakra-ui/react" ;
11+ import { appCacheDir , join } from "@tauri-apps/api/path" ;
1112import { getCurrentWebview } from "@tauri-apps/api/webview" ;
13+ import { revealItemInDir } from "@tauri-apps/plugin-opener" ;
1214import { useEffect , useRef , useState } from "react" ;
1315import { useTranslation } from "react-i18next" ;
1416import { LuChevronsDown , LuFileInput , LuTrash } from "react-icons/lu" ;
@@ -35,13 +37,17 @@ const GameLogPage: React.FC = () => {
3537 const [ isScrolledToBottom , setIsScrolledToBottom ] = useState ( true ) ;
3638
3739 const logContainerRef = useRef < HTMLDivElement > ( null ) ;
40+ const launchingIdRef = useRef < number | null > ( null ) ;
3841
3942 const clearLogs = ( ) => setLogs ( [ ] ) ;
4043
4144 // invoke retrieve on first load
4245 useEffect ( ( ) => {
4346 ( async ( ) => {
44- let launchingId = parseIdFromWindowLabel ( getCurrentWebview ( ) . label ) ;
47+ launchingIdRef . current = parseIdFromWindowLabel (
48+ getCurrentWebview ( ) . label
49+ ) ;
50+ const launchingId = launchingIdRef . current ;
4551 if ( launchingId ) {
4652 const res = await LaunchService . retrieveGameLog ( launchingId ) ;
4753 if ( res . status === "success" && Array . isArray ( res . data ) ) {
@@ -59,6 +65,24 @@ const GameLogPage: React.FC = () => {
5965 return ( ) => unlisten ( ) ;
6066 } , [ ] ) ;
6167
68+ const revealRawLogFile = async ( ) => {
69+ try {
70+ const launchingId = launchingIdRef . current ;
71+ if ( launchingId == null ) return ;
72+
73+ const baseDir = await appCacheDir ( ) ;
74+ const logFilePath = await join (
75+ baseDir ,
76+ "GameLogs" ,
77+ `game_log_${ launchingId } .log`
78+ ) ;
79+
80+ await revealItemInDir ( logFilePath ) ;
81+ } catch ( err ) {
82+ logger . error ( "Failed to open raw log file:" , err ) ;
83+ }
84+ } ;
85+
6286 let lastLevel : string = "INFO" ;
6387
6488 const getLogLevel = ( log : string ) : string => {
@@ -167,14 +191,14 @@ const GameLogPage: React.FC = () => {
167191 { level } ({ logCounts [ level ] || 0 } )
168192 </ Button >
169193 ) ) }
170- < Tooltip label = { t ( "GameLogPage.exportLogs " ) } placement = "bottom" >
194+ < Tooltip label = { t ( "GameLogPage.revealRawLog " ) } placement = "bottom" >
171195 < IconButton
172196 icon = { < LuFileInput /> }
173- aria-label = { t ( "GameLogPage.exportLogs " ) }
197+ aria-label = { t ( "GameLogPage.revealRawLog " ) }
174198 variant = "ghost"
175199 size = "sm"
176200 colorScheme = "gray"
177- isDisabled
201+ onClick = { revealRawLogFile }
178202 />
179203 </ Tooltip >
180204 < Tooltip label = { t ( "GameLogPage.clearLogs" ) } placement = "bottom" >
0 commit comments