Skip to content

Commit

Permalink
Format code by prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
g1eny0ung committed Apr 12, 2020
1 parent cec0c00 commit c147651
Show file tree
Hide file tree
Showing 60 changed files with 573 additions and 797 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ If you want to open an issue:

Please make sure:

* [ ] Tell about your system info. (你的系统信息)
* [ ] The steps of your action. (你的操作步骤)
* [ ] In order to solve this issue better, It's best to have your error message or a screenshot. (为了更好的解决这个问题,最好能够提供一下你的错误信息或者是一张截图)
- [ ] Tell about your system info. (你的系统信息)
- [ ] The steps of your action. (你的操作步骤)
- [ ] In order to solve this issue better, It's best to have your error message or a screenshot. (为了更好的解决这个问题,最好能够提供一下你的错误信息或者是一张截图)
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "node"
- node

install:
- yarn
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can also install [petal-bin](https://aur.archlinux.org/packages/petal-bin/)

如果 GitHub 下载速度缓慢的话,可以前往百度网盘下载:

链接:<https://pan.baidu.com/s/1l-3ExzKzsim3LBiJHzCY_Q> 密码:cjp1
链接:<https://pan.baidu.com/s/1l-3ExzKzsim3LBiJHzCY_Q> 密码:cjp1

## How to develop

Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ <h1 class="title">Petal</h1>
<footer>
<div>
Created with 💚by
<img style="position: relative; top: 3px; width: 18px" src="ilime.png" alt="ilime" />
<img style="position: relative; top: 3px; width: 18px;" src="ilime.png" alt="ilime" />
</div>
<p style="margin-bottom: 0;">Authors:</p>
<div>
Expand Down Expand Up @@ -172,7 +172,7 @@ <h1 class="title">Petal</h1>
typeSpeed: 50,
backSpeed: 30,
loop: true,
showCursor: false
showCursor: false,
})
</script>
</html>
4 changes: 2 additions & 2 deletions electron/background/ctrlPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ctrlBtnWidth = 22
const ctrlBtnCount = 5
export const ctrlPattern = {
songlist: 0,
playlist: 1
playlist: 1,
}

function getModeAwareImage(suffix, isDarkMode) {
Expand Down Expand Up @@ -37,7 +37,7 @@ export class Controller extends Canvas {
}

drawImageBtn(index, image) {
return new Promise(resolve => {
return new Promise((resolve) => {
const img = new Image()
img.onload = () => {
this.ctx.drawImage(img, ctrlBtnWidth * index * this.devicePixelRatio, this.canvas.height / 2 - img.height / 2)
Expand Down
10 changes: 3 additions & 7 deletions electron/background/trayPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,15 @@ export class TrayPainter extends Canvas {
ipcRenderer.send('trayDraw', this.canvas.toDataURL(), this.width)
})
} else {
Promise.all([
this.lyricPainter.draw(),
this.ctrlPainter.draw()
]).then(() => {
Promise.all([this.lyricPainter.draw(), this.ctrlPainter.draw()]).then(() => {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
this.ctx.drawImage(this.lyricPainter.canvas, 0, 0)
this.ctx.drawImage(this.ctrlPainter.canvas, this.lyricPainter.canvas.width, 0)
ipcRenderer.send('trayDraw', this.canvas.toDataURL(), this.width)
})
}
}

onThemeChange(val) {
this.isCompactTheme = val
if (this.isCompactTheme) {
Expand All @@ -87,8 +84,7 @@ export class TrayPainter extends Canvas {
const { title, artist, length } = song
let cycleText = `${title} - ${artist}`
// 30 second per cycle
for (let i = 0, n = parseInt(length / 30); i < n; i++)
cycleText = cycleText.concat(` ${title} - ${artist}`)
for (let i = 0, n = parseInt(length / 30); i < n; i++) cycleText = cycleText.concat(` ${title} - ${artist}`)
this.lyricPainter.setText(cycleText, length * 1000)
if (!this.isCompactTheme) {
this.refreshLyricInterval(cycleText, length * 1000)
Expand Down
6 changes: 3 additions & 3 deletions electron/backgroundWin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export const createBackgroundWindow = () => {
show: false,
webPreferences: {
backgroundThrottling: false,
nodeIntegration: true
nodeIntegration: true,
},
hasShadow: false
hasShadow: false,
})

backgroundWindow.loadURL(
process.env.NODE_ENV === 'development'
? url.format('http://localhost:3000/background.html')
: url.format({
pathname: __dirname + '/background.html',
protocol: 'file:'
protocol: 'file:',
})
)

Expand Down
2 changes: 1 addition & 1 deletion electron/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { app } from 'electron'

const db = new Datastore({
filename: app.getPath('home') + '/.petal.db',
autoload: true
autoload: true,
})

global.db = db
Expand Down
4 changes: 2 additions & 2 deletions electron/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import createMenu from './menu'
import fs from 'fs'

const createDB = () => {
fs.access(app.getPath('home') + '/.petal.db', err => {
fs.access(app.getPath('home') + '/.petal.db', (err) => {
/* eslint-disable */
if (!err) {
console.log('db file existed.')
} else {
fs.writeFile(app.getPath('home') + '/.petal.db', '', err => {
fs.writeFile(app.getPath('home') + '/.petal.db', '', (err) => {
if (err) throw err
console.log('db file created!')
})
Expand Down
46 changes: 23 additions & 23 deletions electron/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const template = [
{ role: 'hideothers' },
{ role: 'unhide' },
{ type: 'separator' },
{ role: 'quit' }
]
}
{ role: 'quit' },
],
},
]
: []),
{
Expand All @@ -39,11 +39,11 @@ const template = [
{ type: 'separator' },
{
label: 'Speech',
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }]
}
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
},
]
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }])
]
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }]),
],
},
{
label: 'View',
Expand All @@ -56,16 +56,16 @@ const template = [
{ role: 'zoomin' },
{ role: 'zoomout' },
{ type: 'separator' },
{ role: 'togglefullscreen' }
]
{ role: 'togglefullscreen' },
],
},
{
label: 'Window',
submenu: [
{ role: 'minimize' },
{ role: 'zoom' },
...(isDarwin ? [{ type: 'separator' }, { role: 'front' }] : [{ role: 'close' }])
]
...(isDarwin ? [{ type: 'separator' }, { role: 'front' }] : [{ role: 'close' }]),
],
},
{
label: 'Operations',
Expand All @@ -75,44 +75,44 @@ const template = [
accelerator: 'Space',
click() {
mainWindow.webContents.send('pause')
}
},
},
{
label: 'Love',
accelerator: 'CmdOrCtrl+l',
click() {
mainWindow.webContents.send('love')
}
},
},
{
label: 'Skip',
accelerator: 'CmdOrCtrl+k',
click() {
mainWindow.webContents.send('skip')
}
},
},
{
label: 'Trash',
accelerator: 'CmdOrCtrl+t',
click() {
mainWindow.webContents.send('trash')
}
},
},
{
label: 'Forward',
accelerator: 'CmdOrCtrl+Right',
click() {
mainWindow.webContents.send('forward')
}
},
},
{
label: 'Backward',
accelerator: 'CmdOrCtrl+Left',
click() {
mainWindow.webContents.send('backward')
}
}
]
},
},
],
},
{
label: 'Help',
Expand All @@ -121,10 +121,10 @@ const template = [
label: 'Source Code Repository',
click() {
require('electron').shell.openExternal('https://github.com/ilime/Petal')
}
}
]
}
},
},
],
},
]

export default function createMenu() {
Expand Down
4 changes: 2 additions & 2 deletions electron/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Mpris {
identity: 'douban.FM player',
supportedUriSchemes: ['file'],
supportedMimeTypes: ['audio/mpeg', 'application/ogg'],
supportedInterfaces: ['player']
supportedInterfaces: ['player'],
})

this.player.getPosition = () => 0 // TODO
Expand Down Expand Up @@ -47,7 +47,7 @@ class Mpris {
'mpris:artUrl': song.picture,
'xesam:title': song.title,
'xesam:album': song.albumtitle,
'xesam:artist': [song.artist]
'xesam:artist': [song.artist],
}
}

Expand Down
2 changes: 1 addition & 1 deletion electron/pattern.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export let pattern = {
// PlayList => 0
// SongList => 1
state: 0
state: 0,
}
10 changes: 5 additions & 5 deletions electron/touchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const pauseAndStart = new TouchBarButton({
icon: `${resourcesFolder}pause.png`,
click() {
mainWindow.webContents.send('pause')
}
},
})

export const rateAndUnrate = new TouchBarButton({
icon: `${resourcesFolder}unrate.png`,
click() {
mainWindow.webContents.send('love')
}
},
})

export const trashOrBackward = new TouchBarButton({
Expand All @@ -29,7 +29,7 @@ export const trashOrBackward = new TouchBarButton({
if (pattern.state === 1) {
mainWindow.webContents.send('backward')
}
}
},
})

export const skipOrForward = new TouchBarButton({
Expand All @@ -41,9 +41,9 @@ export const skipOrForward = new TouchBarButton({
if (pattern.state === 1) {
mainWindow.webContents.send('forward')
}
}
},
})

export default new TouchBar({
items: [trashOrBackward, pauseAndStart, skipOrForward, rateAndUnrate]
items: [trashOrBackward, pauseAndStart, skipOrForward, rateAndUnrate],
})
26 changes: 13 additions & 13 deletions electron/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,44 @@ export default {
setTrayImage(img) {
const bounds = this.tray.getBounds()
const Image = nativeImage.createFromDataURL(img).resize({
height: bounds ? bounds.height : 22
height: bounds ? bounds.height : 22,
})
this.tray.setImage(Image)
},
popUpContextMenu() {
this.tray.popUpContextMenu(this.osxContextMenu)
}
},
}

function initNormalContextMenu() {
this.contextMenu = Menu.buildFromTemplate([
{
label: '切换显示/隐藏',
enabled: true,
click: mainWindowVisiableSwitch
click: mainWindowVisiableSwitch,
},
{ type: 'separator' },
{
label: '切换暂停/开始',
click: () => mainWindow.webContents.send('pause')
click: () => mainWindow.webContents.send('pause'),
},
{
label: '红心',
click: () => mainWindow.webContents.send('love')
click: () => mainWindow.webContents.send('love'),
},
{
label: '跳过',
click: () => mainWindow.webContents.send('skip')
click: () => mainWindow.webContents.send('skip'),
},
{
label: '垃圾桶',
click: () => mainWindow.webContents.send('trash')
click: () => mainWindow.webContents.send('trash'),
},
{ type: 'separator' },
{
label: '退出',
click: app.quit
}
click: app.quit,
},
])
}

Expand All @@ -88,7 +88,7 @@ function initOSXContextMenu() {
{
label: '切换显示/隐藏',
enabled: true,
click: mainWindowVisiableSwitch
click: mainWindowVisiableSwitch,
},
{ type: 'separator' },
{
Expand All @@ -109,13 +109,13 @@ function initOSXContextMenu() {
} else {
mainWindow.center()
}
}
},
},
{ type: 'separator' },
{
label: '退出',
click: app.quit
}
click: app.quit,
},
])
}

Expand Down
Loading

0 comments on commit c147651

Please sign in to comment.