* feat: add modal troubleshooting guideline * show app, server log and device specs from user agent * add function copy app, server log and device specs * add todo device specs * update style darkmode for modal troubleshoot * resolve inconsistent message hidden * fix: model failed to load but the server started successfully (#1971) * fix: start server success but modal load failed * add information model failed load while start server successfully
30 lines
793 B
TypeScript
30 lines
793 B
TypeScript
import {
|
|
fs,
|
|
joinPath,
|
|
openFileExplorer,
|
|
getJanDataFolderPath,
|
|
} from '@janhq/core'
|
|
|
|
export const useLogs = () => {
|
|
const getLogs = async (file: string) => {
|
|
if (!(await fs.existsSync(await joinPath(['file://logs', `${file}.log`]))))
|
|
return {}
|
|
const logs = await fs.readFileSync(
|
|
await joinPath(['file://logs', `${file}.log`]),
|
|
'utf-8'
|
|
)
|
|
|
|
return logs
|
|
}
|
|
const openServerLog = async () => {
|
|
const janDataFolderPath = await getJanDataFolderPath()
|
|
const fullPath = await joinPath([janDataFolderPath, 'logs', 'server.log'])
|
|
return openFileExplorer(fullPath)
|
|
}
|
|
|
|
const clearServerLog = async () => {
|
|
await fs.writeFileSync(await joinPath(['file://logs', 'server.log']), '')
|
|
}
|
|
return { getLogs, openServerLog, clearServerLog }
|
|
}
|