refs #2028 Add a configuration item to disable spellchecker

This commit is contained in:
AkiraFukushima 2021-01-24 15:06:16 +09:00
parent 3d4ffb5812
commit 24a7cb14ed
8 changed files with 82 additions and 7 deletions

View File

@ -19,7 +19,8 @@ const state = (): GeneralState => {
hideAllAttachments: false
},
other: {
launch: false
launch: false,
spellcheck: true
}
},
loading: false

View File

@ -15,7 +15,8 @@ describe('Preferences/General', () => {
hideAllAttachments: false
},
other: {
launch: false
launch: false,
spellcheck: true
}
},
loading: false

View File

@ -135,7 +135,17 @@
},
"other": {
"title": "Other options",
"launch": "Launch app on login"
"launch": "Launch app on login",
"spellcheck": {
"description": "Enable spellchecker",
"notice": "Requires relaunch",
"confirm": {
"title": "Warning",
"message": "You have to restart this application. Continue?",
"ok": "Restart Now",
"cancel": "Cancel"
}
}
}
},
"appearance": {

View File

@ -200,6 +200,16 @@ async function getLanguage() {
}
}
const getSpellChecker = async (): Promise<boolean> => {
try {
const preferences = new Preferences(preferencesDBPath)
const conf = await preferences.load()
return conf.general.other.spellcheck
} catch (err) {
return true
}
}
const getMenuPreferences = async (): Promise<MenuPreferences> => {
const preferences = new Preferences(preferencesDBPath)
const conf = await preferences.load()
@ -225,6 +235,11 @@ async function createWindow() {
const language = await getLanguage()
i18next.changeLanguage(language)
/**
* Get spellcheck
*/
const spellcheck = await getSpellChecker()
/**
* Load system theme color for dark mode
*/
@ -283,7 +298,7 @@ async function createWindow() {
nodeIntegration: true,
contextIsolation: false,
preload: path.resolve(__dirname, './preload.js'),
spellcheck: true
spellcheck: spellcheck
}
}
const config: Config = {
@ -907,7 +922,9 @@ ipcMain.handle('get-preferences', async (_: IpcMainInvokeEvent) => {
await preferences
.update({
general: {
other: enabled
other: {
launch: enabled
}
}
})
.catch(err => console.error(err))

View File

@ -27,7 +27,8 @@ const timeline: Timeline = {
}
const other: Other = {
launch: false
launch: false,
spellcheck: true
}
const general: General = {

View File

@ -29,6 +29,10 @@
<el-form-item for="launch" :label="$t('preferences.general.other.launch')">
<el-switch id="launch" v-model="other_launch" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item for="spellcheck" :label="$t('preferences.general.other.spellcheck.description')">
<el-switch id="spellcheck" v-model="other_spellcheck" active-color="#13ce66"> </el-switch>
<p class="notice">{{ $t('preferences.general.other.spellcheck.notice') }}</p>
</el-form-item>
</el-form>
</div>
</template>
@ -105,6 +109,20 @@ export default {
launch: value
})
}
},
other_spellcheck: {
get() {
return this.$store.state.Preferences.General.general.other.spellcheck
},
set(value) {
this.$store
.dispatch('Preferences/General/updateOther', {
spellcheck: value
})
.then(() => {
this.confirm()
})
}
}
},
created() {
@ -114,6 +132,23 @@ export default {
type: 'error'
})
})
},
methods: {
confirm() {
this.$confirm(
this.$t('preferences.general.other.spellcheck.confirm.message'),
this.$t('preferences.general.other.spellcheck.confirm.title'),
{
confirmButtonText: this.$t('preferences.general.other.spellcheck.confirm.ok'),
cancelButtonText: this.$t('preferences.general.other.spellcheck.confirm.cancel'),
type: 'warning'
}
)
.then(() => {
this.$store.dispatch('Preferences/General/relaunch')
})
.catch(() => {})
}
}
}
</script>
@ -140,5 +175,10 @@ export default {
font-weight: 800;
}
}
.notice {
color: #c0c4cc;
font-size: 12px;
}
}
</style>

View File

@ -24,7 +24,8 @@ const state = (): GeneralState => ({
hideAllAttachments: false
},
other: {
launch: false
launch: false,
spellcheck: true
}
},
loading: false
@ -96,6 +97,9 @@ const actions: ActionTree<GeneralState, RootState> = {
commit(MUTATION_TYPES.UPDATE_GENERAL, conf.general as General)
dispatch('App/loadPreferences', null, { root: true })
await win.ipcRenderer.invoke('change-auto-launch', newOther.launch)
},
relaunch: () => {
win.ipcRenderer.send('relaunch')
}
}

View File

@ -7,6 +7,7 @@ import { Proxy } from '~/src/types/proxy'
export type Other = {
launch: boolean
spellcheck: boolean
}
export type General = {