mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-03 10:47:34 +01:00
refs #186 Save display name style setting
This commit is contained in:
parent
3e75e18ffd
commit
d62a2bc24d
5
package-lock.json
generated
5
package-lock.json
generated
@ -11039,6 +11039,11 @@
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"object-assign-deep": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/object-assign-deep/-/object-assign-deep-0.4.0.tgz",
|
||||
"integrity": "sha512-54Uvn3s+4A/cMWx9tlRez1qtc7pN7pbQ+Yi7mjLjcBpWLlP+XbSHiHbQW6CElDiV4OvuzqnMrBdkgxI1mT8V/Q=="
|
||||
},
|
||||
"object-component": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz",
|
||||
|
@ -92,6 +92,7 @@
|
||||
"mastodon-api": "^1.3.0",
|
||||
"moment": "^2.21.0",
|
||||
"nedb": "^1.8.0",
|
||||
"object-assign-deep": "^0.4.0",
|
||||
"simplayer": "0.0.8",
|
||||
"vue": "^2.3.3",
|
||||
"vue-awesome": "^2.3.5",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import empty from 'is-empty'
|
||||
import storage from 'electron-json-storage'
|
||||
import objectAssignDeep from 'object-assign-deep'
|
||||
|
||||
const Base = {
|
||||
general: {
|
||||
@ -8,7 +8,7 @@ const Base = {
|
||||
toot: true
|
||||
},
|
||||
theme: 'white',
|
||||
displayName: 0
|
||||
displayNameStyle: 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,8 +21,7 @@ export default class Preferences {
|
||||
async load () {
|
||||
try {
|
||||
const preferences = await this.get()
|
||||
if (empty(preferences)) return Base
|
||||
return preferences
|
||||
return objectAssignDeep({}, Base, preferences)
|
||||
} catch (err) {
|
||||
return Base
|
||||
}
|
||||
|
@ -1,14 +1,36 @@
|
||||
<template>
|
||||
<div id="general" v-loading="loading">
|
||||
<h2>General</h2>
|
||||
<div class="theme">
|
||||
<h3>Theme color</h3>
|
||||
<el-radio v-model="theme" label="white">White</el-radio>
|
||||
<el-radio v-model="theme" label="dark">Dark</el-radio>
|
||||
<div class="appearance">
|
||||
<h3>Appearance</h3>
|
||||
<table class="theme">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="title">Theme color:</td>
|
||||
<td class="status">
|
||||
<el-radio v-model="theme" label="white">White</el-radio>
|
||||
<el-radio v-model="theme" label="dark">Dark</el-radio>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">Display name style:</td>
|
||||
<td class="status">
|
||||
<el-select v-model="displayNameStyle" placeholder="style">
|
||||
<el-option
|
||||
v-for="style in nameStyles"
|
||||
:key="style.value"
|
||||
:label="style.name"
|
||||
:value="style.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="sounds">
|
||||
<h3>Sounds</h3>
|
||||
<table class="sounds">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="title">Favourite, Reblog action sound:</td>
|
||||
@ -39,6 +61,24 @@ import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'general',
|
||||
data () {
|
||||
return {
|
||||
nameStyles: [
|
||||
{
|
||||
name: 'DisplayName and username',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: 'DisplayName',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: 'username',
|
||||
value: 2
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
loading: state => state.Preferences.General.loading
|
||||
@ -51,6 +91,14 @@ export default {
|
||||
this.$store.dispatch('Preferences/General/updateTheme', value)
|
||||
}
|
||||
},
|
||||
displayNameStyle: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.General.general.displayNameStyle
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/General/updateDisplayNameStyle', value)
|
||||
}
|
||||
},
|
||||
sound_fav_rb: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.General.general.sound.fav_rb
|
||||
@ -86,8 +134,28 @@ export default {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
#general {
|
||||
.theme {
|
||||
.appearance {
|
||||
color: var(--theme-secondary-color);
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
text-align: right;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.status {
|
||||
width: 50%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.sounds {
|
||||
@ -95,6 +163,10 @@ export default {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 16px 0;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ const App = {
|
||||
ipcRenderer.once('response-get-preferences', (event, conf) => {
|
||||
ipcRenderer.removeAllListeners('error-get-preferences')
|
||||
commit('updateTheme', conf.general.theme)
|
||||
commit('updateDisplayNameStyle', conf.general.displayName || 0)
|
||||
commit('updateDisplayNameStyle', conf.general.displayNameStyle)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ const General = {
|
||||
fav_rb: true,
|
||||
toot: true
|
||||
},
|
||||
theme: 'white'
|
||||
theme: 'white',
|
||||
displayNameStyle: 0
|
||||
},
|
||||
loading: false
|
||||
},
|
||||
@ -58,6 +59,23 @@ const General = {
|
||||
commit('changeLoading', false)
|
||||
})
|
||||
},
|
||||
updateDisplayNameStyle ({ dispatch, commit, state }, value) {
|
||||
const newGeneral = Object.assign({}, state.general, {
|
||||
displayNameStyle: value
|
||||
})
|
||||
const config = {
|
||||
general: newGeneral
|
||||
}
|
||||
ipcRenderer.send('save-preferences', config)
|
||||
ipcRenderer.once('error-save-preferences', (event, err) => {
|
||||
ipcRenderer.removeAllListeners('response-save-preferences')
|
||||
})
|
||||
ipcRenderer.once('response-save-preferences', (event, conf) => {
|
||||
ipcRenderer.removeAllListeners('error-save-preferences')
|
||||
dispatch('App/loadPreferences', null, { root: true })
|
||||
commit('updateGeneral', conf.general)
|
||||
})
|
||||
},
|
||||
updateSound ({ commit, state }, sound) {
|
||||
commit('changeLoading', true)
|
||||
const newSound = Object.assign({}, state.general.sound, sound)
|
||||
|
Loading…
x
Reference in New Issue
Block a user