chore: clean up logs opening

This commit is contained in:
Louis 2025-03-26 13:10:25 +07:00
parent 85389aec68
commit 520a0d04ea
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
7 changed files with 8 additions and 39 deletions

View File

@ -177,7 +177,7 @@ pub fn open_app_directory(app: AppHandle) {
} }
#[tauri::command] #[tauri::command]
pub fn open_file_explorer(app: AppHandle, path: String) { pub fn open_file_explorer(path: String) {
let path = PathBuf::from(path); let path = PathBuf::from(path);
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
std::process::Command::new("explorer") std::process::Command::new("explorer")

View File

@ -91,7 +91,7 @@ const SystemMonitor = () => {
<div className="unset-drag flex cursor-pointer items-center gap-x-2"> <div className="unset-drag flex cursor-pointer items-center gap-x-2">
<div <div
className="flex cursor-pointer items-center gap-x-1 rounded px-1 py-0.5 hover:bg-[hsla(var(--secondary-bg))]" className="flex cursor-pointer items-center gap-x-1 rounded px-1 py-0.5 hover:bg-[hsla(var(--secondary-bg))]"
onClick={() => onRevealInFinder('Logs')} onClick={() => onRevealInFinder('logs')}
> >
<FolderOpenIcon size={12} /> App Log <FolderOpenIcon size={12} /> App Log
</div> </div>

View File

@ -41,7 +41,7 @@ const AppLogs = () => {
<Button <Button
theme="ghost" theme="ghost"
variant="outline" variant="outline"
onClick={() => onRevealInFinder('Logs')} onClick={() => onRevealInFinder('logs')}
> >
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<> <>

View File

@ -41,7 +41,7 @@ const CortexLogs = () => {
<Button <Button
theme="ghost" theme="ghost"
variant="outline" variant="outline"
onClick={() => onRevealInFinder('Logs')} onClick={() => onRevealInFinder('logs')}
> >
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<> <>

View File

@ -103,7 +103,7 @@ const ServerLogs = (props: ServerLogsProps) => {
<Button <Button
theme="ghost" theme="ghost"
variant="outline" variant="outline"
onClick={() => onRevealInFinder('Logs')} onClick={() => onRevealInFinder('logs')}
> >
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<> <>

View File

@ -4,45 +4,14 @@ import { useAtomValue } from 'jotai'
import { getFileInfo } from '@/utils/file' import { getFileInfo } from '@/utils/file'
import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom' import { janDataFolderPathAtom } from '@/helpers/atoms/AppConfig.atom'
import { activeAssistantAtom } from '@/helpers/atoms/Assistant.atom'
import { selectedModelAtom } from '@/helpers/atoms/Model.atom'
import { activeThreadAtom } from '@/helpers/atoms/Thread.atom' import { activeThreadAtom } from '@/helpers/atoms/Thread.atom'
export const usePath = () => { export const usePath = () => {
const janDataFolderPath = useAtomValue(janDataFolderPathAtom) const janDataFolderPath = useAtomValue(janDataFolderPathAtom)
const activeThread = useAtomValue(activeThreadAtom) const activeThread = useAtomValue(activeThreadAtom)
const selectedModel = useAtomValue(selectedModelAtom)
const activeAssistant = useAtomValue(activeAssistantAtom)
const onRevealInFinder = async (type: string) => { const onRevealInFinder = async (path: string) => {
// TODO: this logic should be refactored. const fullPath = await joinPath([janDataFolderPath, path])
if (type !== 'Model' && !activeThread) return
let filePath = undefined
const assistantId = activeAssistant?.assistant_id
switch (type) {
case 'Engine':
case 'Thread':
filePath = await joinPath(['threads', activeThread?.id ?? ''])
break
case 'Model':
if (!selectedModel) return
filePath = await joinPath(['models', selectedModel.id])
break
case 'Tools':
case 'Assistant':
if (!assistantId) return
filePath = await joinPath(['assistants', assistantId])
break
case 'Logs':
filePath = 'logs'
break
default:
break
}
if (!filePath) return
const fullPath = await joinPath([janDataFolderPath, filePath])
openFileExplorer(fullPath) openFileExplorer(fullPath)
} }

View File

@ -125,7 +125,7 @@ const Privacy = () => {
<FolderOpenIcon <FolderOpenIcon
size={16} size={16}
className="absolute right-2 top-1/2 z-10 -translate-y-1/2 cursor-pointer" className="absolute right-2 top-1/2 z-10 -translate-y-1/2 cursor-pointer"
onClick={() => onRevealInFinder('Logs')} onClick={() => onRevealInFinder('logs')}
/> />
</div> </div>
</div> </div>