forked from AkkomaGang/akkoma-fe
fixed keep checkboxes working when exporting
This commit is contained in:
parent
f039b79e5a
commit
2ebc06e30f
2 changed files with 40 additions and 13 deletions
|
@ -332,16 +332,34 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
exportCurrentTheme () {
|
exportCurrentTheme () {
|
||||||
const stringified = JSON.stringify({
|
const saveEverything = !this.keepFonts && !this.keepShadows && !this.keepColors && !this.keepOpacity && !this.keepRoundness
|
||||||
// To separate from other random JSON files and possible future theme formats
|
const theme = {
|
||||||
_pleroma_theme_version: 2,
|
|
||||||
theme: {
|
|
||||||
shadows: this.shadowsLocal,
|
shadows: this.shadowsLocal,
|
||||||
fonts: this.fontsLocal,
|
fonts: this.fontsLocal,
|
||||||
opacity: this.currentOpacity,
|
opacity: this.currentOpacity,
|
||||||
colors: this.currentColors,
|
colors: this.currentColors,
|
||||||
radii: this.currentRadii
|
radii: this.currentRadii
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.keepFonts && !saveEverything) {
|
||||||
|
delete theme.fonts
|
||||||
|
}
|
||||||
|
if (!this.keepShadows && !saveEverything) {
|
||||||
|
delete theme.shadows
|
||||||
|
}
|
||||||
|
if (!this.keepOpacity && !saveEverything) {
|
||||||
|
delete theme.opacity
|
||||||
|
}
|
||||||
|
if (!this.keepColors && !saveEverything) {
|
||||||
|
delete theme.colors
|
||||||
|
}
|
||||||
|
if (!this.keepRoundness && !saveEverything) {
|
||||||
|
delete theme.radii
|
||||||
|
}
|
||||||
|
|
||||||
|
const stringified = JSON.stringify({
|
||||||
|
// To separate from other random JSON files and possible future theme formats
|
||||||
|
_pleroma_theme_version: 2, theme
|
||||||
}, null, 2) // Pretty-print and indent with 2 spaces
|
}, null, 2) // Pretty-print and indent with 2 spaces
|
||||||
|
|
||||||
// Create an invisible link with a data url and simulate a click
|
// Create an invisible link with a data url and simulate a click
|
||||||
|
@ -404,7 +422,9 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
clearAll () {
|
clearAll () {
|
||||||
this.normalizeLocalState(this.$store.state.config.customTheme)
|
const state = this.$store.state.config.customTheme
|
||||||
|
const version = state.colors ? 2 : 'l1'
|
||||||
|
this.normalizeLocalState(this.$store.state.config.customTheme, version)
|
||||||
},
|
},
|
||||||
|
|
||||||
// Clears all the extra stuff when loading V1 theme
|
// Clears all the extra stuff when loading V1 theme
|
||||||
|
@ -442,9 +462,13 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This applies stored theme data onto form.
|
* This applies stored theme data onto form. Supports three versions of data:
|
||||||
|
* v2 (version = 2) - newer version of themes.
|
||||||
|
* v1 (version = 1) - older version of themes (import from file)
|
||||||
|
* v1l (version = l1) - older version of theme (load from local storage)
|
||||||
|
* v1 and v1l differ because of way themes were stored/exported.
|
||||||
* @param {Object} input - input data
|
* @param {Object} input - input data
|
||||||
* @param {Number} version - version of data. 0 means try to guess based on data.
|
* @param {Number} version - version of data. 0 means try to guess based on data. "l1" means v1, locastorage type
|
||||||
*/
|
*/
|
||||||
normalizeLocalState (input, version = 0) {
|
normalizeLocalState (input, version = 0) {
|
||||||
const colors = input.colors || input
|
const colors = input.colors || input
|
||||||
|
@ -465,6 +489,8 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(version)
|
||||||
|
|
||||||
// Stuff that differs between V1 and V2
|
// Stuff that differs between V1 and V2
|
||||||
if (version === 1) {
|
if (version === 1) {
|
||||||
this.fgColorLocal = rgb2hex(colors.btn)
|
this.fgColorLocal = rgb2hex(colors.btn)
|
||||||
|
@ -472,7 +498,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = new Set(version !== 1 ? Object.keys(colors) : [])
|
const keys = new Set(version !== 1 ? Object.keys(colors) : [])
|
||||||
if (version === 1) {
|
if (version === 1 || version === 'l1') {
|
||||||
// V1 ignores the rest
|
// V1 ignores the rest
|
||||||
this.clearV1()
|
this.clearV1()
|
||||||
keys
|
keys
|
||||||
|
@ -483,6 +509,7 @@ export default {
|
||||||
.add('cGreen')
|
.add('cGreen')
|
||||||
.add('cOrange')
|
.add('cOrange')
|
||||||
}
|
}
|
||||||
|
|
||||||
keys.forEach(key => {
|
keys.forEach(key => {
|
||||||
this[key + 'ColorLocal'] = rgb2hex(colors[key])
|
this[key + 'ColorLocal'] = rgb2hex(colors[key])
|
||||||
})
|
})
|
||||||
|
|
|
@ -183,7 +183,7 @@
|
||||||
"keep_opacity": "Keep opacity",
|
"keep_opacity": "Keep opacity",
|
||||||
"keep_roundness": "Keep roundness",
|
"keep_roundness": "Keep roundness",
|
||||||
"keep_fonts": "Keep fonts",
|
"keep_fonts": "Keep fonts",
|
||||||
"save_load_hint": "\"Keep\" options preserve currently set options when selecting or loading themes, it also stores said options when exporting a theme.",
|
"save_load_hint": "\"Keep\" options preserve currently set options when selecting or loading themes, it also stores said options when exporting a theme. When all checkboxes unset, exporting theme will save everything.",
|
||||||
"reset": "Reset",
|
"reset": "Reset",
|
||||||
"clear_all": "Clear all",
|
"clear_all": "Clear all",
|
||||||
"clear_opacity": "Clear opacity"
|
"clear_opacity": "Clear opacity"
|
||||||
|
|
Loading…
Reference in a new issue