Feat(tag): Can modify tags and save it into config.yml
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readFile } from 'fs'
|
||||
import { readFile, writeFile } from 'fs'
|
||||
import Vue from 'vue'
|
||||
import path from 'path'
|
||||
import yaml from 'js-yaml'
|
||||
@@ -50,6 +50,7 @@ export default {
|
||||
},
|
||||
actions: {
|
||||
load (context) {
|
||||
// load config file
|
||||
readFile(path.join(context.getters.config_dir, context.getters.config_filename), 'utf8', (err, content) => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
@@ -63,8 +64,22 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
save (context) {
|
||||
// save config file
|
||||
var config = {
|
||||
categories: context.state.categories,
|
||||
tags: context.state.tags,
|
||||
}
|
||||
var yamlConfig = yaml.safeDump(config)
|
||||
writeFile(path.join(context.getters.config_dir, context.getters.config_filename), yamlConfig, (err) => {
|
||||
if (err) throw err
|
||||
console.log('The file has been saved!')
|
||||
})
|
||||
|
||||
},
|
||||
edit_tag (context, tag) {
|
||||
context.commit('APPEND_TAG', { tag: tag })
|
||||
}
|
||||
context.dispatch('save')
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user