KawAnime now can be opened in the browser!

This commit is contained in:
Kylart 2017-04-27 23:38:07 +02:00
parent 9f1aa5c9f6
commit 7eacf18fdd
4 changed files with 19 additions and 17 deletions

View File

@ -87,8 +87,8 @@ exports.route = (nuxt) => {
switch (url.pathname)
{
case '/getConf':
const configPath = join(dir, 'config.json')
const configFile = require(configPath).config
const configPath = join(dir, 'config.json');
const configFile = JSON.parse(fs.readFileSync(configPath));
res.writeHead(200, {"Content-Type": "application/json"});
res.write(JSON.stringify(configFile));
@ -135,6 +135,16 @@ exports.route = (nuxt) => {
history.getHistory(res)
break
case '/saveConfig':
req.on('data', (chunk) => {
const data = JSON.parse(chunk)
fs.writeFileSync(join(dir, 'config.json'), JSON.stringify(data))
console.log('[Open-External]: Successfully saved config!')
})
res.writeHead(200, {});
res.end();
break
default:
nuxt.render(req, res)
}

View File

@ -9,11 +9,6 @@ module.exports = {
height: 800
},
build: {
extend (config, {isClient}) {
// Extend only webpack config for client-bundle
if (isClient)
config.target = 'electron-renderer'
},
vendor: ['vuetify', 'axios']
},
plugins: [

View File

@ -1,6 +1,6 @@
{
"name": "KawAnime",
"version": "0.3.0",
"version": "0.4.0",
"description": "A Software for Otaku Community.",
"main": "main.js",
"repository": "https://github.com/Kylart/KawAnime.git",

View File

@ -3,7 +3,6 @@ import Vue from 'vue'
//noinspection NpmUsedModulesInstalled
import Vuex from 'vuex'
import axios from 'axios'
import {writeFileSync} from 'fs'
Vue.use(Vuex)
@ -297,17 +296,15 @@ const store = new Vuex.Store({
})
}
else
{
console.log(`[${(new Date()).toLocaleTimeString()}]: Opening torrents directly on preferred torrent client.`)
}
},
async saveConfig({}, data) {
const toSave = JSON.stringify({
config: data
saveConfig({}, data) {
axios.post('saveConfig', JSON.stringify(data)).then((res) => {
if (res.status === 200)
console.log(`[${(new Date()).toLocaleTimeString()}]: Successfully updated config!`)
}).catch((err) => {
console.log(`[${(new Date()).toLocaleTimeString()}]: An error occurred while saving config: ${err}`)
})
writeFileSync(configPath, toSave)
console.log(`[${(new Date()).toLocaleTimeString()}]: New config saved!`)
},
async appendHistory({}, data) {
const {status} = await axios.get(`appendHistory?type=${data.type}&text=${data.text}`)