mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-04-21 00:12:05 +00:00
Change application data path
This commit is contained in:
parent
b24a55c8a3
commit
e6d5dab21a
4 changed files with 58 additions and 10 deletions
12
TODO.md
12
TODO.md
|
|
@ -1,3 +1,5 @@
|
|||
# GUI
|
||||
|
||||
- [ ] Hls-Download force yes or no on rewrite promt as well as for mkvmerge/ffmpeg
|
||||
- [x] Pick up if a download is currently in progress
|
||||
- [x] Send more information with the progress event like the title and image to display more information
|
||||
|
|
@ -6,8 +8,14 @@
|
|||
- [ ] Set Options font in divider
|
||||
- [x] Window title
|
||||
- [x] Only open dev tools in test version
|
||||
- [ ] Add help information (version, contributor, documentation...)
|
||||
- [x] Add help information (version, contributor, documentation...)
|
||||
- [ ] App Icon with electron-forge make
|
||||
- [x] ContextMenu
|
||||
- [x] Better episode listing with selectio via left mouse button
|
||||
- [x] Use Child for Context Menu
|
||||
- [x] Use Child for Context Menu
|
||||
|
||||
# CLI
|
||||
## New API ?
|
||||
- [ ] https://playback.prd.funimationsvc.com/v1/play/FMB0001?deviceType=web&playbackStreamId=137917d5-dc9b-4a72-83da-14231fd1d05e
|
||||
- [ ] https://playlist-service.prd.funimationsvc.com/v1/playlist/show/FMB
|
||||
- [ ] https://d33et77evd9bgg.cloudfront.net/data/v1/episodes/fullmetal-alchemist.json
|
||||
|
|
@ -5,8 +5,45 @@ import fs from 'fs';
|
|||
import dotenv from 'dotenv';
|
||||
import express from "express";
|
||||
import { Console } from 'console';
|
||||
import json from '../../../package.json';
|
||||
|
||||
const getDataDirectory = () => {
|
||||
switch (process.platform) {
|
||||
case "darwin": {
|
||||
if (!process.env.HOME) {
|
||||
console.error('Unknown home directory');
|
||||
process.exit(1);
|
||||
}
|
||||
return path.join(process.env.HOME, "Library", "Application Support", json.name);
|
||||
}
|
||||
case "win32": {
|
||||
if (!process.env.APPDATA) {
|
||||
console.error('Unknown home directory');
|
||||
process.exit(1);
|
||||
}
|
||||
return path.join(process.env.APPDATA, json.name);
|
||||
}
|
||||
case "linux": {
|
||||
if (!process.env.HOME) {
|
||||
console.error('Unknown home directory');
|
||||
process.exit(1);
|
||||
}
|
||||
return path.join(process.env.HOME, `.${json.name}`);
|
||||
}
|
||||
default: {
|
||||
console.error("Unsupported platform!");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fs.existsSync(getDataDirectory()))
|
||||
fs.mkdirSync(getDataDirectory());
|
||||
|
||||
export { getDataDirectory };
|
||||
|
||||
import './menu';
|
||||
|
||||
|
||||
if (fs.existsSync(path.join(__dirname, '.env')))
|
||||
dotenv.config({ path: path.join(__dirname, '.env'), debug: true });
|
||||
|
||||
|
|
@ -14,7 +51,7 @@ if (require('electron-squirrel-startup')) {
|
|||
app.quit();
|
||||
}
|
||||
|
||||
export const isWindows = __dirname.indexOf('\\') !== -1;
|
||||
export const isWindows = process.platform === 'win32';
|
||||
|
||||
let mainWindow: BrowserWindow|undefined = undefined;
|
||||
export { mainWindow };
|
||||
|
|
@ -23,7 +60,7 @@ const icon = path.join(__dirname, 'images', `Logo_Inverted.${isWindows ? 'ico' :
|
|||
|
||||
if (!process.env.TEST) {
|
||||
console = (() => {
|
||||
const logFolder = path.join(__dirname, 'logs');
|
||||
const logFolder = path.join(getDataDirectory(), 'logs');
|
||||
if (!fs.existsSync(logFolder))
|
||||
fs.mkdirSync(logFolder);
|
||||
return new Console(fs.createWriteStream(path.join(logFolder, `${Date.now()}.log`)));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Menu, MenuItem, MenuItemConstructorOptions, shell } from "electron";
|
||||
import path from 'path';
|
||||
import { getDataDirectory } from ".";
|
||||
import json from '../../../package.json';
|
||||
|
||||
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||
|
|
@ -35,7 +36,7 @@ const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
|||
{
|
||||
label: 'Open log folder',
|
||||
click: () => {
|
||||
shell.openPath(path.join(__dirname, 'logs'))
|
||||
shell.openPath(path.join(getDataDirectory(), 'logs'))
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
12
tsc.ts
12
tsc.ts
|
|
@ -96,14 +96,16 @@ export { ignore };
|
|||
}
|
||||
});
|
||||
|
||||
process.stdout.write('✓\nInstalling dependencies');
|
||||
process.stdout.write('✓\nInstalling dependencies... ');
|
||||
if (!isTest && !isGUI) {
|
||||
alterJSON();
|
||||
}
|
||||
const dependencies = exec(`npm install ${isGUI ? '' : '--production'}`, {
|
||||
cwd: path.join(__dirname, 'lib')
|
||||
});
|
||||
await waitForProcess(dependencies);
|
||||
if (!isTest) {
|
||||
const dependencies = exec(`npm install ${isGUI ? '' : '--production'}`, {
|
||||
cwd: path.join(__dirname, 'lib')
|
||||
});
|
||||
await waitForProcess(dependencies);
|
||||
}
|
||||
|
||||
process.stdout.write('✓\n');
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue