mirror of https://github.com/Kylart/KawAnime.git
Added changeDir and refreshDir buttons to local Page.
Removed useless functions from main.js
This commit is contained in:
parent
7ae13dcd3b
commit
434af64850
28
main.js
28
main.js
|
@ -90,34 +90,6 @@ exports.openDownloader = () => {
|
|||
})
|
||||
}
|
||||
|
||||
exports.getInfoPage = () => {
|
||||
mainWindow.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'app', 'InformationPage', 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
}
|
||||
|
||||
exports.getMainPage = () => {
|
||||
mainWindow.loadURL(url.format({
|
||||
pathname: path.join(__dirname, 'index.html'),
|
||||
protocol: 'file:',
|
||||
slashes: true
|
||||
}))
|
||||
}
|
||||
|
||||
exports.openTorrents = () => {
|
||||
const TORRENT_PATH = path.join(BASE_PATH, '.KawAnime')
|
||||
|
||||
const tmpFiles = fs.readdirSync(TORRENT_PATH)
|
||||
|
||||
tmpFiles.forEach( (elem) => {
|
||||
if (elem.split('.').pop() === 'torrent')
|
||||
shell.openItem(path.join(TORRENT_PATH, elem))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
|
|
|
@ -15,10 +15,11 @@ const fs = require('fs')
|
|||
const path = require('path')
|
||||
const os = require('os')
|
||||
const shell = require('electron').shell
|
||||
const {dialog} = require('electron').remote
|
||||
|
||||
const mal = require('malapi').Anime
|
||||
|
||||
const DIR = path.join(os.userInfo().homedir, downloadRep)
|
||||
exports.DIR = path.join(os.userInfo().homedir, downloadRep)
|
||||
|
||||
exports.filterFiles = (files, filters) => {
|
||||
let filteredFiles = []
|
||||
|
@ -77,8 +78,8 @@ exports.searchAnime = (filename, object) => {
|
|||
})
|
||||
}
|
||||
|
||||
exports.findFiles = (object) => {
|
||||
const allFiles = fs.readdirSync(DIR)
|
||||
exports.findFiles = (object, dir) => {
|
||||
const allFiles = fs.readdirSync(dir)
|
||||
|
||||
const filteredFiles = self.filterFiles(allFiles, ['.mkv', '.mp4'])
|
||||
|
||||
|
@ -103,4 +104,12 @@ exports.delFile = (object, name) => {
|
|||
})
|
||||
}
|
||||
|
||||
exports.changePathDiaog = (object) => {
|
||||
dialog.showOpenDialog({properties: ['openDirectory']}, (dirPath) => {
|
||||
object.files = []
|
||||
object.currentDir = dirPath[0]
|
||||
self.findFiles(object, dirPath[0])
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: make an initial findFiles method
|
|
@ -11,6 +11,16 @@ const functions = require('./functions.js')
|
|||
const html = `
|
||||
<div>
|
||||
<div class="mdl-grid">
|
||||
<div class="mdl-cell mdl-cell--12-col top-buttons">
|
||||
<md-button class="md-icon-button play-button"
|
||||
@click.native="refreshDir()"
|
||||
title="Refresh current directory."
|
||||
v-bind:style="refreshButtonStyle">
|
||||
<i class="mdi mdi-refresh mdi-36px"></i>
|
||||
</md-button>
|
||||
<md-button @click.native="changeDir()">Change Dir</md-button>
|
||||
|
||||
</div>
|
||||
<template v-for="file in files">
|
||||
<div class="mdl-cell mdl-cell--6-col local-elem" v-bind:style="elemStyle">
|
||||
<md-ink-ripple></md-ink-ripple>
|
||||
|
@ -80,6 +90,7 @@ Vue.component('local-page', {
|
|||
data: function () {
|
||||
return {
|
||||
files: [],
|
||||
currentDir: functions.DIR,
|
||||
elemStyle: {
|
||||
marginBottom: '1.5%'
|
||||
},
|
||||
|
@ -91,18 +102,31 @@ Vue.component('local-page', {
|
|||
delButtonStyle: {
|
||||
paddingLeft: '8px',
|
||||
marginLeft: '0px'
|
||||
},
|
||||
refreshButtonStyle: {
|
||||
paddingLeft: '2px',
|
||||
marginRight: '0px',
|
||||
marginLeft: '0px',
|
||||
marginTop: '0.4%'
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
findFiles: function () {
|
||||
return functions.findFiles(this)
|
||||
return functions.findFiles(this, this.currentDir)
|
||||
},
|
||||
openFile: function (name) {
|
||||
functions.playFile(name)
|
||||
},
|
||||
delFile: function (name) {
|
||||
functions.delFile(this, name)
|
||||
},
|
||||
changeDir: function () {
|
||||
functions.changePathDiaog(this)
|
||||
},
|
||||
refreshDir: function () {
|
||||
this.files = []
|
||||
this.findFiles()
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
|
|
|
@ -285,6 +285,11 @@ body
|
|||
color: rgba(255, 255, 255, 0.8)
|
||||
}
|
||||
|
||||
#local-page .top-buttons
|
||||
{
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#local-page .local-elem
|
||||
{
|
||||
/*box-shadow: 0 2px 2px 0 rgba(255, 255, 255,.14),0 3px 1px -2px rgba(255, 255, 255,.2),0 1px 5px 0 rgba(255, 255, 255,.12);*/
|
||||
|
|
Loading…
Reference in New Issue