mirror of https://github.com/Kylart/KawAnime.git
KawAnime now can be opened in the browser!
This commit is contained in:
parent
9f1aa5c9f6
commit
7eacf18fdd
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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}`)
|
||||
|
|
Loading…
Reference in New Issue