Skip to content

Commit

Permalink
enhance: display file paths of .leptonrc and log in the about page
Browse files Browse the repository at this point in the history
  • Loading branch information
hackjutsu committed Jun 6, 2020
1 parent 6420f91 commit dd8967f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
10 changes: 10 additions & 0 deletions app/containers/aboutPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import React, { Component } from 'react'
import './index.scss'

const conf = remote.getGlobal('conf')
const logFilePath = remote.getGlobal('logFilePath')
const configFilePath = remote.getGlobal('configFilePath')

class AboutPage extends Component {
renderAboutSection () {
Expand Down Expand Up @@ -48,6 +50,14 @@ class AboutPage extends Component {
<a className='logo-sub' href='https://github.com/hackjutsu/Lepton/issues'>Feedback</a>
<a className='logo-sub' href='https://github.com/hackjutsu/Lepton/blob/master/LICENSE'>License</a>
</div>
<div className='setting-title'>Configs(.leptonrc)</div>
<div className='one-line-section'>
{ configFilePath }
</div>
<div className='setting-title'>Logs</div>
<div className='one-line-section'>
{ logFilePath }
</div>
<div className='setting-title'>Contributors</div>
<div className='contributor-section'>
<div className='contributor'><a href='https://github.com/hackjutsu'>hackjutsu</a></div>
Expand Down
14 changes: 12 additions & 2 deletions app/containers/aboutPage/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}

.section-base {
height: 75vh;
height: 80vh;
}

.general-section {
Expand All @@ -34,7 +34,7 @@

.contributor-section {
overflow: auto;
min-height: 200px;
min-height: 150px;
border-radius: 5px;
padding: 0 20px;
border: solid 1px var(--border-color);
Expand All @@ -51,6 +51,16 @@
color: var(--text-secondary);
}

.one-line-section {
overflow: auto;
min-height: 28px;
border-radius: 5px;
padding: 0 20px;
white-space: nowrap;
border: solid 1px var(--border-color);
color: var(--text-secondary);
}

.license-item {
margin: 10px 0px;
}
Expand Down
11 changes: 7 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,26 @@ function initGlobalConfigs () {
}
nconf.defaults(defaultConfig)
global.conf = nconf
global.configFilePath = configFilePath
}

function initGlobalLogger () {
logger.level = nconf.get('logger:level')
let appFolder = app.getPath('userData')
const appFolder = app.getPath('userData')
if (!fs.existsSync(appFolder)) {
fs.mkdirSync(appFolder)
}
let logFolder = path.join(app.getPath('userData'), 'logs')
const logFolder = path.join(app.getPath('userData'), 'logs')
if (!fs.existsSync(logFolder)) {
fs.mkdirSync(logFolder)
}
let logFile = new Date().toISOString().replace(/:/g, '.') + '.log'
const logFile = new Date().toISOString().replace(/:/g, '.') + '.log'
const logFilePath = path.join(logFolder, logFile)
logger.add(logger.transports.File, {
json: false,
exitOnError: false,
filename: path.join(logFolder, logFile),
filename: logFilePath,
timestamp: true })
global.logger = logger
global.logFilePath = logFilePath
}

0 comments on commit dd8967f

Please sign in to comment.