Skip to content
This repository was archived by the owner on Feb 5, 2021. It is now read-only.

Commit 47c5a8f

Browse files
authored
Merge pull request #59 from eNkru/feature/xiami_2.0
Feature/xiami 2.0
2 parents 6b9c4d2 + f9f9558 commit 47c5a8f

File tree

12 files changed

+285
-220
lines changed

12 files changed

+285
-220
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ yarn\.lock
44
dist/
55
electron-xiami\.iml
66
/yarn-error.log
7+
/.project
Lines changed: 89 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,97 @@
11
class CssInjector {}
22

33
CssInjector.main = `
4-
#playInAppWrap, .tip-twitter {
4+
.top-nav {
5+
-webkit-app-region: drag;
6+
}
7+
.top-nav-wrapper > a {
8+
margin-left: 16px;
9+
-webkit-app-region: no-drag;
10+
}
11+
.top-nav-wrapper .links a:nth-last-of-type(-n+4) {
12+
display: none;
13+
}
14+
.top-nav-wrapper a {
15+
order: -1;
16+
-webkit-app-region: no-drag;
17+
}
18+
.top-nav-wrapper .message-center {
19+
-webkit-app-region: no-drag;
20+
}
21+
.top-nav-wrapper .user {
22+
-webkit-app-region: no-drag;
23+
}
24+
.top-nav-wrapper .search {
25+
order: -1;
26+
margin-left: auto;
27+
margin-right: 0;
28+
-webkit-app-region: no-drag;
29+
}
30+
.top-nav-wrapper .links {
31+
margin-right: 20px !important;
32+
}
33+
.discovery-view .sticky-leftbar {
34+
position: absolute !important;
35+
width: fit-content !important;
36+
}
37+
.download-panel {
38+
display: none;
39+
}
40+
.discovery-view .leftbar-content {
41+
background-color: transparent !important;
42+
width: fit-content !important;
43+
height: fit-content !important;
44+
}
45+
.discovery-view .leftbar-content .links a {
46+
background-color: #747474;
47+
width: 30px;
48+
border-radius: 50%;
49+
overflow: hidden;
50+
border: 0 !important;
51+
padding: 1px;
52+
color: #FFF !important;
53+
font-weight: bolder !important;
54+
}
55+
.discovery-view .leftbar-content .links a:hover {
56+
background: #ff410f;
57+
}
58+
.page-container .content-wrapper .discovery-view .view-body {
59+
margin: 0 !important;
60+
padding: 125px 0 0 0 !important;
61+
}
62+
.billboard-view {
63+
padding-top: 1px !important;
64+
}
65+
.list-view.view-without-leftbar {
66+
margin: 32px 0 0 32px !important;
67+
}
68+
.xm-footer {
569
display: none !important;
670
}
71+
.page-container {
72+
padding-bottom: 88px !important;
73+
}
74+
.iconfont.button-home {
75+
position: fixed;
76+
right: 40px;
77+
top: 40px;
78+
font-size: 32px;
79+
z-index: 9;
80+
background: #4a4a4a;
81+
color: white;
82+
width: 36px;
83+
border-radius: 50%;
84+
height: 36px;
85+
cursor: pointer;
86+
transition: opacity .2s;
87+
}
88+
.iconfont.button-home:hover {
89+
background: #ff410f;
90+
}
91+
.iconfont.button-home.hide {
92+
display: none;
93+
opacity: 0;
94+
}
795
`;
896

997
CssInjector.macos = `
@@ -21,42 +109,6 @@ CssInjector.macos = `
21109
}
22110
`;
23111

24-
CssInjector.hideSidebar = `
25-
.main-wrap {
26-
padding-left: 0 !important;
27-
}
28-
.main-sidebar {
29-
display:none;
30-
}
31-
`;
32-
33-
CssInjector.hideLyrics = `
34-
.main-wrap {
35-
padding-right: 0 !important;
36-
}
37-
.main-outher {
38-
display:none;
39-
}
40-
.ui-track-all {
41-
width: initial !important;
42-
}
43-
`;
44-
45-
CssInjector.songListOnly = `
46-
.main-wrap {
47-
padding: 0 !important;
48-
}
49-
.main-outher {
50-
display:none;
51-
}
52-
.main-sidebar {
53-
display:none;
54-
}
55-
.ui-track-all {
56-
width: initial !important;
57-
}
58-
`;
59-
60112
CssInjector.mini = `
61113
#player-main {
62114
height: 160px !important;

src/configuration/urls.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class URLS {}
2+
3+
URLS.home = 'https://www.xiami.com/';
4+
URLS.billboard = 'https://www.xiami.com/billboard';
5+
URLS.collection = 'https://www.xiami.com/list/collect';
6+
URLS.artist = 'https://www.xiami.com/list/artist';
7+
URLS.album = 'https://www.xiami.com/list/album';
8+
9+
URLS.getUrl = (mode) => {
10+
switch (mode) {
11+
case 'suggestion':
12+
return URLS.home;
13+
case 'billboard':
14+
return URLS.billboard;
15+
case 'collection':
16+
return URLS.collection;
17+
case 'artist':
18+
return URLS.artist;
19+
case 'album':
20+
return URLS.album;
21+
default:
22+
return URLS.home;
23+
}
24+
};
25+
26+
module.exports = URLS;

src/controller/app-tray-controller.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ const storage = require('electron-json-storage');
44
const fs = require('fs-extra');
55
const settings = require('electron-settings');
66
const SettingsController = require('./settings-controller');
7+
const URLS = require('../configuration/urls');
78

8-
const language = fs.existsSync(`${app.getPath('userData')}/Settings`) ? settings.get('language', 'en') : 'en';
9-
const Locale = language === 'en' ? require('../locale/locale_en') : require('../locale/locale_sc');
10-
const macOS = process.platform === 'darwin' ? true : false;
9+
// const language = fs.existsSync(`${app.getPath('userData')}/Settings`) ? settings.get('language', 'sc') : 'sc';
10+
// const Locale = language === 'en' ? require('../locale/locale_en') : require('../locale/locale_sc');
11+
const Locale = require('../locale/locale_sc');
12+
const macOS = process.platform === 'darwin';
1113

1214
class AppTray {
1315
constructor(playerController, lyricsController, notificationController) {
@@ -25,18 +27,20 @@ class AppTray {
2527
//set the context menu
2628
const context = Menu.buildFromTemplate([
2729
{label: Locale.TRAY_SHOW_MAIN, click: () => this.togglePlayerWindow()},
28-
{label: Locale.TRAY_PLAY_PAUSE, click: () => this.playerController.toggle()},
30+
{label: Locale.TRAY_PLAY_PAUSE, click: () => this.playerController.pausePlay()},
2931
{label: Locale.TRAY_NEXT, click: () => this.playerController.next()},
3032
{label: Locale.TRAY_PREVIOUS, click: () => this.playerController.previous()},
3133
{label: 'Separator', type: 'separator'},
34+
{label: Locale.TRAY_WINDOW_FRAME, type: 'checkbox', checked: settings.get('showWindowFrame', true), click: () => this.toggleWindowFrame()},
3235
{label: Locale.TRAY_PLAYER_MODE, submenu: [
33-
{label: Locale.TRAY_PLAYER_MODE_DEFAULT, click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_DEFAULT_VALUE)},
34-
{label: Locale.TRAY_PLAYER_MODE_HIDE_LYRICS, click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_HIDE_LYRICS_VALUE)},
35-
{label: Locale.TRAY_PLAYER_MODE_HIDE_SIDEBAR, click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_HIDE_SIDEBAR_VALUE)},
36-
{label: Locale.TRAY_PLAYER_MODE_SONG_LIST_ONLY, click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_SONG_LIST_ONLY_VALUE)},
37-
{label: Locale.TRAY_PLAYER_MODE_MINI, click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_MINI_VALUE)}
36+
{label: Locale.TRAY_PLAYER_MODE_SUGGESTION, type: 'radio', checked: 'suggestion' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_SUGGESTION_VALUE)},
37+
{label: Locale.TRAY_PLAYER_MODE_BILLBOARD, type: 'radio', checked: 'billboard' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_BILLBOARD_VALUE)},
38+
{label: Locale.TRAY_PLAYER_MODE_COLLECTION, type: 'radio', checked: 'collection' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_COLLECTION_VALUE)},
39+
{label: Locale.TRAY_PLAYER_MODE_ARTIST, type: 'radio', checked: 'artist' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_ARTIST_VALUE)},
40+
{label: Locale.TRAY_PLAYER_MODE_ALBUM, type: 'radio', checked: 'album' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_ALBUM_VALUE)},
41+
// {label: Locale.TRAY_PLAYER_MODE_MINI, type: 'radio', checked: 'mini' === settings.get('customLayout', 'suggestion'), click: () => this.changePlayerMode(Locale.TRAY_PLAYER_MODE_MINI_VALUE)}
3842
]},
39-
{label: Locale.TRAY_LYRICS_TOGGLE, click: () => this.toggleLyrics()},
43+
// {label: Locale.TRAY_LYRICS_TOGGLE, click: () => this.toggleLyrics()},
4044
{label: Locale.TRAY_SWITCH_TO_RADIO, click: () => this.switchToRadioMode()},
4145
{label: 'Separator', type: 'separator'},
4246
{label: Locale.TRAY_SETTINGS, click: () => this.openSettings()},
@@ -63,6 +67,12 @@ class AppTray {
6367
}
6468
}
6569

70+
toggleWindowFrame() {
71+
settings.set('showWindowFrame', !settings.get('showWindowFrame'));
72+
this.playerController.window.destroy();
73+
this.playerController.init();
74+
}
75+
6676
toggleLyrics() {
6777
if (!this.lyricsController.window.isVisible()) {
6878
this.playerController.addPlaytimeObserver();
@@ -119,9 +129,7 @@ ${Locale.NOTIFICATION_ALBUM}: ${trackInfo.album_name}`;
119129

120130
changePlayerMode(mode) {
121131
settings.set('customLayout', mode);
122-
this.lyricsController.window.isVisible() && this.lyricsController.window.hide();
123-
this.playerController.window.destroy();
124-
this.playerController.init();
132+
this.playerController.window.loadURL(URLS.getUrl(mode));
125133
}
126134

127135
openSettings() {

0 commit comments

Comments
 (0)