refs #527 Add time format setting in preferences
This commit is contained in:
parent
c5f1df1476
commit
46dc719666
|
@ -87,6 +87,11 @@
|
|||
"display_name": "Display name",
|
||||
"username": "Username"
|
||||
},
|
||||
"time_format": {
|
||||
"title": "Time format:",
|
||||
"absolute": "Absolute",
|
||||
"relative": "Relative"
|
||||
},
|
||||
"toot": "Toot",
|
||||
"visibility": {
|
||||
"title": "Default visibility:",
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
export default {
|
||||
Absolute: {
|
||||
name: 'preferences.general.time_format.absolute',
|
||||
value: 0
|
||||
},
|
||||
Relative: {
|
||||
name: 'preferences.general.time_format.relative'
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import Visibility from '../constants/visibility'
|
|||
import DisplayStyle from '../constants/displayStyle'
|
||||
import Theme from '../constants/theme'
|
||||
import Language from '../constants/language'
|
||||
import TimeFormat from '../constants/timeFormat'
|
||||
|
||||
const Base = {
|
||||
general: {
|
||||
|
@ -14,7 +15,8 @@ const Base = {
|
|||
theme: Theme.Light.key,
|
||||
fontSize: 14,
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
tootVisibility: Visibility.Public.value
|
||||
tootVisibility: Visibility.Public.value,
|
||||
timeFormat: TimeFormat.Absolute.value
|
||||
},
|
||||
state: {
|
||||
collapse: false
|
||||
|
|
|
@ -30,6 +30,19 @@
|
|||
</el-select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title">{{ $t('preferences.general.time_format.title') }}</td>
|
||||
<td class="status">
|
||||
<el-select v-model="timeFormat" placeholder="format">
|
||||
<el-option
|
||||
v-for="format in timeFormats"
|
||||
:key="format.value"
|
||||
:label="$t(format.name)"
|
||||
:value="format.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -86,6 +99,7 @@ import { mapState } from 'vuex'
|
|||
import Visibility from '~/src/constants/visibility'
|
||||
import DisplayStyle from '~/src/constants/displayStyle'
|
||||
import Theme from '~/src/constants/theme'
|
||||
import TimeFormat from '~/src/constants/timeFormat'
|
||||
|
||||
export default {
|
||||
name: 'general',
|
||||
|
@ -104,6 +118,10 @@ export default {
|
|||
themes: [
|
||||
Theme.Light,
|
||||
Theme.Dark
|
||||
],
|
||||
timeFormats: [
|
||||
TimeFormat.Absolute,
|
||||
TimeFormat.Relative
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -128,6 +146,14 @@ export default {
|
|||
this.$store.dispatch('Preferences/General/updateDisplayNameStyle', value)
|
||||
}
|
||||
},
|
||||
timeFormat: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.General.general.timeFormat
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/General/updateTimeFormat', value)
|
||||
}
|
||||
},
|
||||
tootVisibility: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.General.general.tootVisibility
|
||||
|
|
|
@ -2,6 +2,7 @@ import { ipcRenderer } from 'electron'
|
|||
import Visibility from '~/src/constants/visibility'
|
||||
import DisplayStyle from '~/src/constants/displayStyle'
|
||||
import Theme from '~/src/constants/theme'
|
||||
import TimeFormat from '~/src/constants/timeFormat'
|
||||
|
||||
const General = {
|
||||
namespaced: true,
|
||||
|
@ -14,7 +15,8 @@ const General = {
|
|||
theme: Theme.Light.key,
|
||||
fontSize: 14,
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
tootVisibility: Visibility.Public.value
|
||||
tootVisibility: Visibility.Public.value,
|
||||
timeFormat: TimeFormat.Absolute.value
|
||||
},
|
||||
loading: false
|
||||
},
|
||||
|
@ -98,6 +100,23 @@ const General = {
|
|||
commit('updateGeneral', conf.general)
|
||||
})
|
||||
},
|
||||
updateTimeFormat ({ dispatch, commit, state }, value) {
|
||||
const newGeneral = Object.assign({}, state.general, {
|
||||
timeFormat: value
|
||||
})
|
||||
const config = {
|
||||
general: newGeneral
|
||||
}
|
||||
ipcRenderer.send('update-preferences', config)
|
||||
ipcRenderer.once('error-update-preferences', (event, err) => {
|
||||
ipcRenderer.removeAllListeners('response-update-preferences')
|
||||
})
|
||||
ipcRenderer.once('response-update-preferences', (event, conf) => {
|
||||
ipcRenderer.removeAllListeners('error-update-preferences')
|
||||
dispatch('App/loadPreferences', null, { root: true })
|
||||
commit('updateGeneral', conf.general)
|
||||
})
|
||||
},
|
||||
updateTootVisibility ({ dispatch, commit, state }, value) {
|
||||
const newGeneral = Object.assign({}, state.general, {
|
||||
tootVisibility: value
|
||||
|
|
Loading…
Reference in New Issue