chore: clean up logs opening
This commit is contained in:
parent
85389aec68
commit
520a0d04ea
@ -177,7 +177,7 @@ pub fn open_app_directory(app: AppHandle) {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn open_file_explorer(app: AppHandle, path: String) {
|
||||
pub fn open_file_explorer(path: String) {
|
||||
let path = PathBuf::from(path);
|
||||
if cfg!(target_os = "windows") {
|
||||
std::process::Command::new("explorer")
|
||||
|
||||
@ -91,7 +91,7 @@ const SystemMonitor = () => {
|
||||
<div className="unset-drag flex cursor-pointer items-center gap-x-2">
|
||||
<div
|
||||
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
|
||||
</div>
|
||||
|
||||
@ -41,7 +41,7 @@ const AppLogs = () => {
|
||||
<Button
|
||||
theme="ghost"
|
||||
variant="outline"
|
||||
onClick={() => onRevealInFinder('Logs')}
|
||||
onClick={() => onRevealInFinder('logs')}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<>
|
||||
|
||||
@ -41,7 +41,7 @@ const CortexLogs = () => {
|
||||
<Button
|
||||
theme="ghost"
|
||||
variant="outline"
|
||||
onClick={() => onRevealInFinder('Logs')}
|
||||
onClick={() => onRevealInFinder('logs')}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<>
|
||||
|
||||
@ -103,7 +103,7 @@ const ServerLogs = (props: ServerLogsProps) => {
|
||||
<Button
|
||||
theme="ghost"
|
||||
variant="outline"
|
||||
onClick={() => onRevealInFinder('Logs')}
|
||||
onClick={() => onRevealInFinder('logs')}
|
||||
>
|
||||
<div className="flex items-center space-x-2">
|
||||
<>
|
||||
|
||||
@ -4,45 +4,14 @@ import { useAtomValue } from 'jotai'
|
||||
import { getFileInfo } from '@/utils/file'
|
||||
|
||||
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'
|
||||
|
||||
export const usePath = () => {
|
||||
const janDataFolderPath = useAtomValue(janDataFolderPathAtom)
|
||||
const activeThread = useAtomValue(activeThreadAtom)
|
||||
const selectedModel = useAtomValue(selectedModelAtom)
|
||||
const activeAssistant = useAtomValue(activeAssistantAtom)
|
||||
|
||||
const onRevealInFinder = async (type: string) => {
|
||||
// TODO: this logic should be refactored.
|
||||
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])
|
||||
const onRevealInFinder = async (path: string) => {
|
||||
const fullPath = await joinPath([janDataFolderPath, path])
|
||||
openFileExplorer(fullPath)
|
||||
}
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ const Privacy = () => {
|
||||
<FolderOpenIcon
|
||||
size={16}
|
||||
className="absolute right-2 top-1/2 z-10 -translate-y-1/2 cursor-pointer"
|
||||
onClick={() => onRevealInFinder('Logs')}
|
||||
onClick={() => onRevealInFinder('logs')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user