新增软件最小化、关闭按钮位置设置

pull/277/head
lyswhut 2020-06-11 21:41:15 +08:00
parent 2a81d41c2c
commit b811906bae
18 changed files with 335 additions and 264 deletions

View File

@ -8,6 +8,7 @@
- 新增我的列表右键菜单复制歌曲名选项 - 新增我的列表右键菜单复制歌曲名选项
- 新增桌面歌词默认关闭可到设置或者托盘菜单开启调整字体大小、透明度时鼠标左击按钮正常调整右击微调已知windows下贴边拖拽调整歌词窗口大小时可能会导致窗口变黑这时只需将窗口拖屏幕离边缘再拖回去即可Windows 7未开启Aero效果时桌面歌词会有问题详情看常见问题解决Linux版桌面歌词有问题以后再尝试优化 - 新增桌面歌词默认关闭可到设置或者托盘菜单开启调整字体大小、透明度时鼠标左击按钮正常调整右击微调已知windows下贴边拖拽调整歌词窗口大小时可能会导致窗口变黑这时只需将窗口拖屏幕离边缘再拖回去即可Windows 7未开启Aero效果时桌面歌词会有问题详情看常见问题解决Linux版桌面歌词有问题以后再尝试优化
- 新增“清热板蓝”皮肤 - 新增“清热板蓝”皮肤
- 新增软件最小化、关闭按钮位置设置MAC版默认为左边非MAC为右边不想用默认的可到设置修改
### 优化 ### 优化

View File

@ -1,8 +1,9 @@
const path = require('path') const path = require('path')
const os = require('os') const os = require('os')
const { isMac } = require('./utils')
const defaultSetting = { const defaultSetting = {
version: '1.0.29', version: '1.0.30',
player: { player: {
togglePlayMethod: 'listLoop', togglePlayMethod: 'listLoop',
highQuality: false, highQuality: false,
@ -19,7 +20,7 @@ const defaultSetting = {
height: 700, height: 700,
x: -1, x: -1,
y: -1, y: -1,
theme: 'green', theme: 0,
style: { style: {
fontSize: 125, fontSize: 125,
opacity: 80, opacity: 80,
@ -84,6 +85,7 @@ const defaultSetting = {
randomAnimate: true, randomAnimate: true,
ignoreVersion: null, ignoreVersion: null,
isAgreePact: false, isAgreePact: false,
controlBtnPosition: isMac ? 'left' : 'right',
} }
const overwriteSetting = { const overwriteSetting = {

View File

@ -164,6 +164,7 @@ exports.initSetting = () => {
// 重置 ^0.18.2 排行榜ID // 重置 ^0.18.2 排行榜ID
if (!newSetting.leaderboard.tabId.includes('__')) newSetting.leaderboard.tabId = 'kw__16' if (!newSetting.leaderboard.tabId.includes('__')) newSetting.leaderboard.tabId = 'kw__16'
// newSetting.controlBtnPosition = 'right'
electronStore_config.set('version', settingVersion) electronStore_config.set('version', settingVersion)
electronStore_config.set('setting', newSetting) electronStore_config.set('setting', newSetting)
return newSetting return newSetting

View File

@ -28,6 +28,8 @@ import { rendererOn, rendererSend, rendererInvoke, NAMES } from '../common/ipc'
import { isLinux } from '../common/utils' import { isLinux } from '../common/utils'
import music from './utils/music' import music from './utils/music'
import { throttle, openUrl } from './utils' import { throttle, openUrl } from './utils'
import { base as eventBaseName } from './event/names'
window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS
dnscache({ dnscache({
enable: true, enable: true,
@ -92,7 +94,7 @@ export default {
}, },
mounted() { mounted() {
document.body.classList.add(this.isNt ? 'noTransparent' : 'transparent') document.body.classList.add(this.isNt ? 'noTransparent' : 'transparent')
window.eventHub.$emit('bindKey') window.eventHub.$emit(eventBaseName.bindKey)
this.init() this.init()
}, },
watch: { watch: {
@ -202,7 +204,7 @@ export default {
// this.setDesktopLyricConfig(config) // this.setDesktopLyricConfig(config)
// console.log('set_config', JSON.stringify(this.setting) === JSON.stringify(config)) // console.log('set_config', JSON.stringify(this.setting) === JSON.stringify(config))
this.setSetting(Object.assign({}, this.setting, config)) this.setSetting(Object.assign({}, this.setting, config))
window.eventHub.$emit('set_config', config) window.eventHub.$emit(eventBaseName.set_config, config)
}) })
// //
this.updateTimeout = setTimeout(() => { this.updateTimeout = setTimeout(() => {
@ -346,7 +348,7 @@ export default {
document.body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents) document.body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents)
} }
document.body.removeEventListener('click', this.handleBodyClick) document.body.removeEventListener('click', this.handleBodyClick)
window.eventHub.$emit('unbindKey') window.eventHub.$emit(eventBaseName.unbindKey)
}, },
} }
</script> </script>

View File

@ -638,7 +638,7 @@
@color-blue2-closeBtn-hover: fadeout(@color-blue2-closeBtn, 10%); @color-blue2-closeBtn-hover: fadeout(@color-blue2-closeBtn, 10%);
@color-blue2-badge-success: lighten(@color-blue2-theme, 15%); @color-blue2-badge-success: lighten(@color-blue2-theme, 15%);
@color-blue2-badge-success-font: #fff; @color-blue2-badge-success-font: #fff;
@color-blue2-badge-info: #6376a2; @color-blue2-badge-info: #b080db;
@color-blue2-badge-info-font: #fff; @color-blue2-badge-info-font: #fff;

View File

@ -1,6 +1,14 @@
<template lang="pug"> <template lang="pug">
div(:class="$style.aside") div(:class="$style.aside")
div(:class="['animated', logoAnimate, $style.logo]") L X div(:class="$style.controlBtn" v-if="setting.controlBtnPosition == 'left'")
button(type="button" :class="$style.close" :title="$t('core.toolbar.close')" @click="close")
svg(:class="$style.controlBtniIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-close')
button(type="button" :class="$style.min" :title="$t('core.toolbar.min')" @click="min")
svg(:class="$style.controlBtniIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-minimize')
div(:class="['animated', logoAnimate, $style.logo]" v-else) L X
//- svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' height='100%' viewBox='0 0 127 61' space='preserve') //- svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' height='100%' viewBox='0 0 127 61' space='preserve')
use(xlink:href='#icon-logo') use(xlink:href='#icon-logo')
@ -49,6 +57,7 @@ div(:class="$style.aside")
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { base as eventBaseName } from '../../event/names'
// import { getRandom } from '../../utils' // import { getRandom } from '../../utils'
export default { export default {
data() { data() {
@ -77,12 +86,21 @@ export default {
// mounted() { // mounted() {
// this.logoAnimate = this.animates[getRandom(0, this.animates.length)] // this.logoAnimate = this.animates[getRandom(0, this.animates.length)]
// }, // },
// methods: { methods: {
// handleMouseEnter() { // handleMouseEnter() {
// console.log('object') // console.log('object')
// this.logoAnimate = this.animates[getRandom(0, this.animates.length)] // this.logoAnimate = this.animates[getRandom(0, this.animates.length)]
// }, // },
// }, min() {
window.eventHub.$emit(eventBaseName.min)
},
max() {
window.eventHub.$emit(eventBaseName.max)
},
close() {
window.eventHub.$emit(eventBaseName.close)
},
},
} }
</script> </script>
@ -102,11 +120,58 @@ export default {
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
} }
:global(.nd) {
.aside { @control-btn-width: @height-toolbar * .26;
-webkit-app-region: no-drag; @control-btn-height: 6%;
.controlBtn {
box-sizing: border-box;
padding: 0 7px;
display: flex;
align-items: center;
justify-content: space-evenly;
width: 100%;
height: @control-btn-height;
-webkit-app-region: no-drag;
opacity: .5;
transition: opacity @transition-theme;
&:hover {
opacity: .8;
.controlBtniIcon {
opacity: 1;
}
}
button {
position: relative;
width: @control-btn-width;
height: @control-btn-width;
background: none;
border: none;
// display: flex;
// justify-content: center;
// align-items: center;
outline: none;
padding: 1px;
cursor: pointer;
border-radius: 50%;
color: #fff;
&.min {
background-color: @color-minBtn;
}
&.max {
background-color: @color-maxBtn;
}
&.close {
background-color: @color-closeBtn;
}
} }
} }
.controlBtniIcon {
opacity: 0;
transition: opacity 0.2s ease-in-out;
}
.logo { .logo {
box-sizing: border-box; box-sizing: border-box;
padding: 0 13%; padding: 0 13%;
@ -115,15 +180,18 @@ export default {
flex: none; flex: none;
text-align: center; text-align: center;
line-height: 50px; line-height: 50px;
font-weight: bold;
// -webkit-app-region: no-drag; // -webkit-app-region: no-drag;
} }
.menu { .menu {
flex: auto; flex: auto;
// display: flex; // &.controlBtnLeft {
// flex-flow: column nowrap; // display: flex;
// justify-content: center; // flex-flow: column nowrap;
// padding-bottom: 50px; // justify-content: center;
// padding-bottom: @control-btn-height;
// }
// padding: 5px; // padding: 5px;
dl { dl {
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
@ -187,6 +255,19 @@ each(@themes, {
.aside { .aside {
background-color: ~'@{color-@{value}-theme-sidebar}'; background-color: ~'@{color-@{value}-theme-sidebar}';
} }
.controlBtn {
button {
&.min {
background-color: ~'@{color-@{value}-minBtn}';
}
&.max {
background-color: ~'@{color-@{value}-maxBtn}';
}
&.close {
background-color: ~'@{color-@{value}-closeBtn}';
}
}
}
.logo { .logo {
color: ~'@{color-@{value}-theme-font}'; color: ~'@{color-@{value}-theme-font}';
} }

View File

@ -124,5 +124,17 @@ svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/19
g#icon-list-add(fill='currentColor') g#icon-list-add(fill='currentColor')
//- 0 0 24 24 //- 0 0 24 24
path(d='M2,16H10V14H2M18,14V10H16V14H12V16H16V20H18V16H22V14M14,6H2V8H14M14,10H2V12H14V10Z') path(d='M2,16H10V14H2M18,14V10H16V14H12V16H16V20H18V16H22V14M14,6H2V8H14M14,10H2V12H14V10Z')
g#icon-window-hide(fill='currentColor')
//- 0 0 30.727 30.727
path(d="M29.994,10.183L15.363,24.812L0.733,10.184c-0.977-0.978-0.977-2.561,0-3.536c0.977-0.977,2.559-0.976,3.536,0l11.095,11.093L26.461,6.647c0.977-0.976,2.559-0.976,3.535,0C30.971,7.624,30.971,9.206,29.994,10.183z")
g#icon-window-minimize(fill='currentColor')
//- 0 0 24 24
path(d="M20,14H4V10H20")
g#icon-window-close(fill='currentColor')
//- 0 0 24 24
path(d="M20 6.91L17.09 4L12 9.09L6.91 4L4 6.91L9.09 12L4 17.09L6.91 20L12 14.91L17.09 20L20 17.09L14.91 12L20 6.91Z")
</template> </template>

View File

@ -1,13 +1,20 @@
<template lang="pug"> <template lang="pug">
div(:class="$style.container" @contextmenu="handleContextMenu") div(:class="[$style.container, setting.controlBtnPosition == 'left' ? $style.controlBtnLeft : $style.controlBtnRight]" @contextmenu="handleContextMenu")
//- div(:class="$style.bg" :style="bgStyle") //- div(:class="$style.bg" :style="bgStyle")
//- div(:class="$style.bg2") //- div(:class="$style.bg2")
div(:class="$style.header") div(:class="$style.header")
div(:class="$style.control") div(:class="$style.controBtn")
button(type="button" :class="$style.hide" :title="$t('core.player.hide_detail')" @click="visiblePlayerDetail(false)") button(type="button" :class="$style.hide" :title="$t('core.player.hide_detail')" @click="visiblePlayerDetail(false)")
svg(:class="$style.controBtnIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='80%' viewBox='0 0 30.727 30.727' space='preserve')
use(xlink:href='#icon-window-hide')
button(type="button" :class="$style.min" :title="$t('core.toolbar.min')" @click="min") button(type="button" :class="$style.min" :title="$t('core.toolbar.min')" @click="min")
svg(:class="$style.controBtnIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-minimize')
//- button(type="button" :class="$style.max" @click="max") //- button(type="button" :class="$style.max" @click="max")
button(type="button" :class="$style.close" :title="$t('core.toolbar.close')" @click="close") button(type="button" :class="$style.close" :title="$t('core.toolbar.close')" @click="close")
svg(:class="$style.controBtnIcon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-close')
div(:class="$style.main") div(:class="$style.main")
div(:class="$style.left") div(:class="$style.left")
@ -59,7 +66,7 @@
<script> <script>
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
import { rendererSend, NAMES } from 'common/ipc' import { base as eventBaseName } from '../../event/names'
import { scrollTo } from '../../utils' import { scrollTo } from '../../utils'
let cancelScrollFn = null let cancelScrollFn = null
@ -215,6 +222,7 @@ export default {
window.removeEventListener('resize', this.handleResize) window.removeEventListener('resize', this.handleResize)
}, },
computed: { computed: {
...mapGetters(['setting']),
...mapGetters('player', ['isShowPlayerDetail']), ...mapGetters('player', ['isShowPlayerDetail']),
}, },
methods: { methods: {
@ -299,13 +307,13 @@ export default {
this.lyricEvent.timeout = null this.lyricEvent.timeout = null
}, },
min() { min() {
rendererSend(NAMES.mainWindow.min) window.eventHub.$emit(eventBaseName.min)
}, },
max() { max() {
rendererSend(NAMES.mainWindow.max) window.eventHub.$emit(eventBaseName.max)
}, },
close() { close() {
rendererSend(NAMES.mainWindow.close) window.eventHub.$emit(eventBaseName.close)
}, },
}, },
} }
@ -315,7 +323,7 @@ export default {
<style lang="less" module> <style lang="less" module>
@import '../../assets/styles/layout.less'; @import '../../assets/styles/layout.less';
@control-btn-width: @height-toolbar * .5; @control-btn-width: @height-toolbar * .26;
.container { .container {
position: absolute; position: absolute;
@ -332,6 +340,25 @@ export default {
border-radius: @radius-border; border-radius: @radius-border;
color: @color-theme_2-font; color: @color-theme_2-font;
border-left: 12px solid @color-theme; border-left: 12px solid @color-theme;
&.controlBtnLeft {
.controBtn {
left: 0;
flex-direction: row-reverse;
height: @height-toolbar * .7;
button + button {
margin-right: @control-btn-width / 2;
}
}
}
&.controlBtnRight {
.controBtn {
right: @control-btn-width * .5;
button + button {
margin-left: @control-btn-width * 1.2;
}
}
}
} }
.bg { .bg {
position: absolute; position: absolute;
@ -358,17 +385,17 @@ export default {
flex: 0 0 @height-toolbar; flex: 0 0 @height-toolbar;
-webkit-app-region: drag; -webkit-app-region: drag;
} }
.control {
.controBtn {
position: absolute; position: absolute;
right: 0;
top: 0; top: 0;
display: flex; display: flex;
align-items: center; align-items: center;
height: @height-toolbar; height: @height-toolbar;
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
padding: 0 @control-btn-width * 0.6; padding: 0 @control-btn-width;
&:hover { &:hover {
button:before { .controBtnIcon {
opacity: 1; opacity: 1;
} }
} }
@ -379,94 +406,33 @@ export default {
height: @control-btn-width; height: @control-btn-width;
background: none; background: none;
border: none; border: none;
outline: none;
padding: 1px;
cursor: pointer;
border-radius: 50%;
color: #fff;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
outline: none;
padding: 0;
cursor: pointer;
+ button {
margin-left: @control-btn-width * .4;
}
&:after { &.hide {
content: ' ';
display: block;
border-radius: 50%;
width: 14px;
height: 14px;
transition: background-color 0.2s ease-in-out;
}
&:before {
display: block;
position: absolute;
opacity: 0;
transition: opacity @transition-theme;
}
&.hide:after {
background-color: @color-hideBtn; background-color: @color-hideBtn;
} }
&.min:after { &.min {
background-color: @color-minBtn; background-color: @color-minBtn;
} }
&.max:after { &.max {
background-color: @color-maxBtn; background-color: @color-maxBtn;
} }
&.close:after { &.close {
background-color: @color-closeBtn; background-color: @color-closeBtn;
} }
&.hide:hover:after {
background-color: @color-hideBtn-hover;
}
&.min:hover:after {
background-color: @color-minBtn-hover;
opacity: 1;
}
&.max:hover:after {
background-color: @color-maxBtn-hover;
}
&.close:hover:after {
background-color: @color-closeBtn-hover;
}
} }
} }
.hide { .controBtnIcon {
&:before { opacity: 0;
content: ''; transition: opacity 0.2s ease-in-out;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 14px;
line-height: 1;
color: #fff;
}
}
.min {
&:before {
content: ' ';
width: 8px;
height: 2px;
left: @control-btn-width / 2 - 4;
top: @control-btn-width / 2 - 1;
background-color: #fff;
}
}
.close {
&:before {
content: '×';
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 14px;
line-height: 1;
color: #fff;
}
} }
.main { .main {
@ -684,31 +650,18 @@ each(@themes, {
// &.hide:after { // &.hide:after {
// background-color: ~'@{color-@{value}-hideBtn}'; // background-color: ~'@{color-@{value}-hideBtn}';
// } // }
&.hide:after { &.hide {
background-color: ~'@{color-@{value}-hideBtn}'; background-color: ~'@{color-@{value}-hideBtn}';
} }
&.min:after { &.min {
background-color: ~'@{color-@{value}-minBtn}'; background-color: ~'@{color-@{value}-minBtn}';
} }
&.max:after { &.max {
background-color: ~'@{color-@{value}-maxBtn}'; background-color: ~'@{color-@{value}-maxBtn}';
} }
&.close:after { &.close {
background-color: ~'@{color-@{value}-closeBtn}'; background-color: ~'@{color-@{value}-closeBtn}';
} }
&.hide:hover:after {
background-color: ~'@{color-@{value}-hideBtn-hover}';
}
&.min:hover:after {
background-color: ~'@{color-@{value}-minBtn-hover}';
}
&.max:hover:after {
background-color: ~'@{color-@{value}-maxBtn-hover}';
}
&.close:hover:after {
background-color: ~'@{color-@{value}-closeBtn-hover}';
}
} }
} }
.img { .img {

View File

@ -1,21 +1,28 @@
<template lang="pug"> <template lang="pug">
div(:class="$style.toolbar") div(:class="[$style.toolbar, setting.controlBtnPosition == 'left' ? $style.controlBtnLeft : $style.controlBtnRight]")
//- img(v-if="icon") //- img(v-if="icon")
//- h1 {{title}} //- h1 {{title}}
material-search-input(:class="$style.input" material-search-input(:class="$style.input"
@event="handleEvent" :list="tipList" :visibleList="visibleList" @event="handleEvent" :list="tipList" :visibleList="visibleList"
v-model="searchText") v-model="searchText")
div(:class="$style.control")
div(:class="$style.logo" v-if="setting.controlBtnPosition == 'left'") L X
div(:class="$style.control" v-else)
button(type="button" :class="$style.min" :title="$t('core.toolbar.min')" @click="min") button(type="button" :class="$style.min" :title="$t('core.toolbar.min')" @click="min")
svg(:class="$style.icon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-minimize')
//- button(type="button" :class="$style.max" @click="max") //- button(type="button" :class="$style.max" @click="max")
button(type="button" :class="$style.close" :title="$t('core.toolbar.close')" @click="close") button(type="button" :class="$style.close" :title="$t('core.toolbar.close')" @click="close")
svg(:class="$style.icon" version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' width='100%' viewBox='0 0 24 24' space='preserve')
use(xlink:href='#icon-window-close')
</template> </template>
<script> <script>
import { rendererSend, NAMES } from 'common/ipc'
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
import music from '../../utils/music' import music from '../../utils/music'
import { debounce } from '../../utils' import { debounce } from '../../utils'
import { base as eventBaseName } from '../../event/names'
export default { export default {
data() { data() {
return { return {
@ -113,13 +120,13 @@ export default {
}, },
min() { min() {
rendererSend(NAMES.mainWindow.min) window.eventHub.$emit(eventBaseName.min)
}, },
max() { max() {
rendererSend(NAMES.mainWindow.max) window.eventHub.$emit(eventBaseName.max)
}, },
close() { close() {
rendererSend(NAMES.mainWindow.close) window.eventHub.$emit(eventBaseName.close)
}, },
}, },
} }
@ -129,51 +136,48 @@ export default {
<style lang="less" module> <style lang="less" module>
@import '../../assets/styles/layout.less'; @import '../../assets/styles/layout.less';
@control-btn-width: @height-toolbar * .5; @control-btn-width: @height-toolbar * .26;
.toolbar { .toolbar {
display: flex; display: flex;
height: @height-toolbar; height: @height-toolbar;
justify-content: flex-end;
align-items: center; align-items: center;
justify-content: space-between;
padding-left: 15px; padding-left: 15px;
-webkit-app-region: drag; -webkit-app-region: drag;
z-index: 2; z-index: 2;
position: relative;
} &.controlBtnLeft {
:global(.nd) { .control {
.toolbar { display: none;
-webkit-app-region: no-drag; }
}
&.controlBtnRight {
justify-content: space-between;
} }
} }
.input {
-webkit-app-region: no-drag; .logo {
position: absolute; box-sizing: border-box;
left: 15px; padding: 0 @height-toolbar * .4;
top: 13px; height: @height-toolbar;
color: @color-theme;
flex: none;
text-align: center;
line-height: @height-toolbar;
font-weight: bold;
// -webkit-app-region: no-drag;
} }
// img {
// flex: none;
// height: 100%;
// }
// h1 {
// text-align: center;
// padding: 8px;
// flex: auto;
// -webkit-app-region: drag;
// -webkit-user-select: none;
// }
.control { .control {
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%; height: 100%;
left: 15px;
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
padding: 0 @control-btn-width * 0.6; padding: 0 @control-btn-width * 1.5;
&:hover { &:hover {
button:before { .icon {
opacity: 1; opacity: 1;
} }
} }
@ -184,100 +188,52 @@ export default {
height: @control-btn-width; height: @control-btn-width;
background: none; background: none;
border: none; border: none;
display: flex;
justify-content: center;
align-items: center;
outline: none; outline: none;
padding: 0; padding: 1px;
cursor: pointer; cursor: pointer;
border-radius: 50%;
color: #fff;
+ button { + button {
margin-left: @control-btn-width * 0.4; margin-left: @control-btn-width * 1.2;
} }
&:after { &.min {
content: ' ';
display: block;
border-radius: 50%;
width: 14px;
height: 14px;
transition: background-color 0.2s ease-in-out;
}
&:before {
display: block;
position: absolute;
opacity: 0;
transition: opacity @transition-theme;
}
&.min:after {
background-color: @color-minBtn; background-color: @color-minBtn;
} }
&.max:after { &.max {
background-color: @color-maxBtn; background-color: @color-maxBtn;
} }
&.close:after { &.close {
background-color: @color-closeBtn; background-color: @color-closeBtn;
} }
}
}
&.min:hover:after { .icon {
background-color: @color-minBtn-hover; opacity: 0;
opacity: 1; transition: opacity 0.2s ease-in-out;
}
&.max:hover:after {
background-color: @color-maxBtn-hover;
}
&.close:hover:after {
background-color: @color-closeBtn-hover;
}
}
}
.min {
&:before {
content: ' ';
width: 8px;
height: 2px;
left: @control-btn-width / 2 - 4;
top: @control-btn-width / 2 - 1;
background-color: #fff;
}
}
.close {
&:before {
content: '×';
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 14px;
line-height: 1;
color: #fff;
}
} }
each(@themes, { each(@themes, {
:global(#container.@{value}) { :global(#container.@{value}) {
.control { .control {
button { button {
&.min:after { &.min {
background-color: ~'@{color-@{value}-minBtn}'; background-color: ~'@{color-@{value}-minBtn}';
} }
&.max:after { &.max {
background-color: ~'@{color-@{value}-maxBtn}'; background-color: ~'@{color-@{value}-maxBtn}';
} }
&.close:after { &.close {
background-color: ~'@{color-@{value}-closeBtn}'; background-color: ~'@{color-@{value}-closeBtn}';
} }
&.min:hover:after {
background-color: ~'@{color-@{value}-minBtn-hover}';
}
&.max:hover:after {
background-color: ~'@{color-@{value}-maxBtn-hover}';
}
&.close:hover:after {
background-color: ~'@{color-@{value}-closeBtn-hover}';
}
} }
} }
.logo {
color: ~'@{color-@{value}-theme}';
}
} }
}) })
</style> </style>

View File

@ -1,24 +1,25 @@
<template lang="pug"> <template lang="pug">
div(:class="[$style.search, focus ? $style.active : '', big ? $style.big : '', small ? $style.small : '']") div(:class="$style.container")
div(:class="$style.form") div(:class="[$style.search, focus ? $style.active : '', big ? $style.big : '', small ? $style.small : '']")
input(:placeholder="placeholder" v-model.trim="text" ref="dom_input" div(:class="$style.form")
@focus="handleFocus" @blur="handleBlur" @input="$emit('input', text)" input(:placeholder="placeholder" v-model.trim="text" ref="dom_input"
@change="sendEvent('change')" @focus="handleFocus" @blur="handleBlur" @input="$emit('input', text)"
@keyup.enter="handleSearch" @change="sendEvent('change')"
@keyup.40.prevent="handleKeyDown" @keyup.enter="handleSearch"
@keyup.38.prevent="handleKeyUp" @keyup.40.prevent="handleKeyDown"
@contextmenu="handleContextMenu") @keyup.38.prevent="handleKeyUp"
button(type="button" @click="handleSearch") @contextmenu="handleContextMenu")
slot button(type="button" @click="handleSearch")
svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 30.239 30.239' space='preserve') slot
use(xlink:href='#icon-search') svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/1999/xlink' height='100%' viewBox='0 0 30.239 30.239' space='preserve')
//- transition(name="custom-classes-transition" use(xlink:href='#icon-search')
//- enter-active-class="animated flipInX" //- transition(name="custom-classes-transition"
//- leave-active-class="animated flipOutX") //- enter-active-class="animated flipInX"
div(v-if="list" :class="$style.list" :style="listStyle") //- leave-active-class="animated flipOutX")
ul(ref="dom_list") div(v-if="list" :class="$style.list" :style="listStyle")
li(v-for="(item, index) in list" :key="item" :class="selectIndex === index ? $style.select : null" @mouseenter="selectIndex = index" @click="handleTemplistClick(index)") ul(ref="dom_list")
span {{item}} li(v-for="(item, index) in list" :key="item" :class="selectIndex === index ? $style.select : null" @mouseenter="selectIndex = index" @click="handleTemplistClick(index)")
span {{item}}
</template> </template>
<script> <script>
@ -135,12 +136,20 @@ export default {
<style lang="less" module> <style lang="less" module>
@import '../../assets/styles/layout.less'; @import '../../assets/styles/layout.less';
.container {
position: relative;
width: 35%;
height: @height-toolbar * 0.52;
-webkit-app-region: no-drag;
}
.search { .search {
position: absolute;
width: 100%;
border-radius: @form-radius; border-radius: @form-radius;
transition: box-shadow .4s ease, background-color @transition-theme; transition: box-shadow .4s ease, background-color @transition-theme;
display: flex; display: flex;
flex-flow: column nowrap; flex-flow: column nowrap;
width: 35%;
background-color: @color-search-form-background; background-color: @color-search-form-background;
&.active { &.active {

View File

@ -1,18 +0,0 @@
import Vue from 'vue'
import keyBind from '../utils/keyBind'
import { rendererOn, NAMES } from '../../common/ipc'
const eventHub = window.eventHub = new Vue()
eventHub.$on('bindKey', () => {
keyBind.bindKey((key, type, event, keys) => {
// console.log(`key_${key}_${type}`)
eventHub.$emit(`key_${key}_${type}`, { event, keys, key })
})
})
eventHub.$on('unbindKey', keyBind.unbindKey)
rendererOn(NAMES.mainWindow.focus, () => {
keyBind.clearDownKeys()
eventHub.$emit('focus')
})

View File

@ -0,0 +1,23 @@
import Vue from 'vue'
import keyBind from '../utils/keyBind'
import { rendererOn, rendererSend, NAMES } from '../../common/ipc'
import { base as baseName } from './names'
const eventHub = window.eventHub = new Vue()
eventHub.$on(baseName.bindKey, () => {
keyBind.bindKey((key, type, event, keys) => {
// console.log(`key_${key}_${type}`)
eventHub.$emit(`key_${key}_${type}`, { event, keys, key })
})
})
eventHub.$on(baseName.bindKey, keyBind.unbindKey)
eventHub.$on(baseName.min, () => rendererSend(NAMES.mainWindow.min))
eventHub.$on(baseName.max, () => rendererSend(NAMES.mainWindow.max))
eventHub.$on(baseName.close, () => rendererSend(NAMES.mainWindow.close))
rendererOn(NAMES.mainWindow.focus, () => {
keyBind.clearDownKeys()
eventHub.$emit(baseName.focus)
})

View File

@ -0,0 +1,20 @@
const names = {
base: {
bindKey: 'bindKey',
unbindKey: 'unbindKey',
focus: 'focus',
min: 'min',
max: 'max',
close: 'close',
set_config: 'set_config',
},
}
for (const item of Object.keys(names)) {
let name = names[item]
for (const key of Object.keys(name)) {
name[key] = `${item}_${name[key]}`
}
}
export const base = names.base

View File

@ -24,6 +24,9 @@
"basic_to_tray": "关闭时最小化到系统托盘", "basic_to_tray": "关闭时最小化到系统托盘",
"basic_lang_title": "软件显示的语言", "basic_lang_title": "软件显示的语言",
"basic_lang": "语言", "basic_lang": "语言",
"basic_control_btn_position": "控制按钮位置",
"basic_control_btn_position_left": "左边",
"basic_control_btn_position_right": "右边",
"play": "播放设置", "play": "播放设置",
"play_toggle_title": "都不选时播放完当前歌曲就停止播放", "play_toggle_title": "都不选时播放完当前歌曲就停止播放",

View File

@ -24,6 +24,9 @@
"basic_to_tray": "關閉時最小化到系統托盤", "basic_to_tray": "關閉時最小化到系統托盤",
"basic_lang_title": "軟件顯示的語言", "basic_lang_title": "軟件顯示的語言",
"basic_lang": "語言", "basic_lang": "語言",
"basic_control_btn_position": "控制按鈕位置",
"basic_control_btn_position_left": "左邊",
"basic_control_btn_position_right": "右邊",
"play": "播放設置", "play": "播放設置",
"play_toggle_title": "都不選時播放完當前歌曲就停止播放", "play_toggle_title": "都不選時播放完當前歌曲就停止播放",
"play_toggle": "歌曲切換方式", "play_toggle": "歌曲切換方式",

View File

@ -24,6 +24,9 @@
"basic_to_tray": "Minimize to system tray when closing", "basic_to_tray": "Minimize to system tray when closing",
"basic_lang_title": "The language displayed in the software", "basic_lang_title": "The language displayed in the software",
"basic_lang": "Language", "basic_lang": "Language",
"basic_control_btn_position": "Control Button Position",
"basic_control_btn_position_left": "Left",
"basic_control_btn_position_right": "Right",
"play": "Play", "play": "Play",
"play_toggle_title": "If none selected, it stopped when the music playing is done.", "play_toggle_title": "If none selected, it stopped when the music playing is done.",

View File

@ -1,7 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import { sync } from 'vuex-router-sync' import { sync } from 'vuex-router-sync'
import './config/event' import './event'
// Components // Components
import './components' import './components'

View File

@ -46,6 +46,12 @@ div.scroll(:class="$style.setting")
material-checkbox(v-for="item in sourceNameTypes" :key="item.id" :class="$style.gapLeft" :id="`setting_abasic_sourcename_${item.id}`" material-checkbox(v-for="item in sourceNameTypes" :key="item.id" :class="$style.gapLeft" :id="`setting_abasic_sourcename_${item.id}`"
name="setting_basic_sourcename" need v-model="current_setting.sourceNameType" :value="item.id" :label="item.label") name="setting_basic_sourcename" need v-model="current_setting.sourceNameType" :value="item.id" :label="item.label")
dd
h3 {{$t('view.setting.basic_control_btn_position')}}
div
material-checkbox(v-for="item in controlBtnPositionList" :key="item.id" :class="$style.gapLeft" :id="`setting_basic_control_btn_position_${item.id}`"
name="setting_basic_control_btn_position" need v-model="current_setting.controlBtnPosition" :value="item.id" :label="item.name")
dt {{$t('view.setting.play')}} dt {{$t('view.setting.play')}}
dd(:title="$t('view.setting.play_toggle_title')") dd(:title="$t('view.setting.play_toggle_title')")
h3 {{$t('view.setting.play_toggle')}} h3 {{$t('view.setting.play_toggle')}}
@ -240,6 +246,7 @@ import { mergeSetting } from '../../common/utils'
import apiSourceInfo from '../utils/music/api-source-info' import apiSourceInfo from '../utils/music/api-source-info'
import fs from 'fs' import fs from 'fs'
import languageList from '@/lang/languages.json' import languageList from '@/lang/languages.json'
import { base as eventBaseName } from '../event/names'
export default { export default {
name: 'Setting', name: 'Setting',
@ -309,6 +316,18 @@ export default {
}, },
] ]
}, },
controlBtnPositionList() {
return [
{
name: this.$t('view.setting.basic_control_btn_position_left'),
id: 'left',
},
{
name: this.$t('view.setting.basic_control_btn_position_right'),
id: 'right',
},
]
},
}, },
data() { data() {
return { return {
@ -376,6 +395,7 @@ export default {
sourceId: 0, sourceId: 0,
randomAnimate: true, randomAnimate: true,
isAgreePact: false, isAgreePact: false,
controlBtnPosition: 'left',
apiSource: 'temp', apiSource: 'temp',
}, },
languageList, languageList,
@ -410,12 +430,12 @@ export default {
}, },
mounted() { mounted() {
navigator.mediaDevices.addEventListener('devicechange', this.getMediaDevice) navigator.mediaDevices.addEventListener('devicechange', this.getMediaDevice)
window.eventHub.$on('set_config', this.handleUpdateSetting) window.eventHub.$on(eventBaseName.set_config, this.handleUpdateSetting)
this.init() this.init()
}, },
beforeDestroy() { beforeDestroy() {
navigator.mediaDevices.removeEventListener('devicechange', this.getMediaDevice) navigator.mediaDevices.removeEventListener('devicechange', this.getMediaDevice)
window.eventHub.$off('set_config', this.handleUpdateSetting) window.eventHub.$off(eventBaseName.set_config, this.handleUpdateSetting)
}, },
methods: { methods: {
...mapMutations(['setSetting', 'setSettingVersion', 'setVersionModalVisible']), ...mapMutations(['setSetting', 'setSettingVersion', 'setVersionModalVisible']),