A full-featured download manager.
refactor: rename & adjust
Dr_rOotdc2a11cd1aa0
diff --git a/.babelrc b/.babelrcnew file mode 100644index 00000000..494effc0--- /dev/null+++ b/.babelrc@@ -0,0 +1,48 @@+{+ "comments": false,+ "env": {+ "main": {+ "presets": [+ ["env", {+ "targets": { "node": 7 }+ }],+ "stage-0"+ ]+ },+ "renderer": {+ "presets": [+ ["env", {+ "modules": false+ }],+ "stage-0"+ ],+ "plugins": [+ [+ "component",+ {+ "libraryName": "element-ui",+ "styleLibraryName": "theme-chalk"+ }+ ]+ ]+ },+ "web": {+ "presets": [+ ["env", {+ "modules": false+ }],+ "stage-0"+ ],+ "plugins": [+ [+ "component",+ {+ "libraryName": "element-ui",+ "styleLibraryName": "theme-chalk"+ }+ ]+ ]+ }+ },+ "plugins": ["transform-runtime"]+}diff --git a/.electron-vue/build.js b/.electron-vue/build.jsnew file mode 100644index 00000000..2455fbcb--- /dev/null+++ b/.electron-vue/build.js@@ -0,0 +1,132 @@+'use strict'++process.env.NODE_ENV = 'production'++const { say } = require('cfonts')+const chalk = require('chalk')+const del = require('del')+const { spawn } = require('child_process')+const webpack = require('webpack')+const Multispinner = require('multispinner')+++const mainConfig = require('./webpack.main.config')+const rendererConfig = require('./webpack.renderer.config')+const webConfig = require('./webpack.web.config')++const doneLog = chalk.bgGreen.white(' DONE ') + ' '+const errorLog = chalk.bgRed.white(' ERROR ') + ' '+const okayLog = chalk.bgBlue.white(' OKAY ') + ' '+const isCI = process.env.CI || false++if (process.env.BUILD_TARGET === 'clean') clean()+else if (process.env.BUILD_TARGET === 'web') web()+else build()++function clean () {+ del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])+ console.log(`\n${doneLog}\n`)+ process.exit()+}++function build () {+ greeting()++ del.sync(['dist/electron/*', '!.gitkeep'])++ const tasks = ['main', 'renderer']+ const m = new Multispinner(tasks, {+ preText: 'building',+ postText: 'process'+ })++ let results = ''++ m.on('success', () => {+ process.stdout.write('\x1B[2J\x1B[0f')+ console.log(`\n\n${results}`)+ console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)+ process.exit()+ })++ pack(mainConfig).then(result => {+ results += result + '\n\n'+ m.success('main')+ }).catch(err => {+ m.error('main')+ console.log(`\n ${errorLog}failed to build main process`)+ console.error(`\n${err}\n`)+ process.exit(1)+ })++ pack(rendererConfig).then(result => {+ results += result + '\n\n'+ m.success('renderer')+ }).catch(err => {+ m.error('renderer')+ console.log(`\n ${errorLog}failed to build renderer process`)+ console.error(`\n${err}\n`)+ process.exit(1)+ })+}++function pack (config) {+ return new Promise((resolve, reject) => {+ config.mode = 'production'+ webpack(config, (err, stats) => {+ if (err) reject(err.stack || err)+ else if (stats.hasErrors()) {+ let err = ''++ stats.toString({+ chunks: false,+ colors: true+ })+ .split(/\r?\n/)+ .forEach(line => {+ err += ` ${line}\n`+ })++ reject(err)+ } else {+ resolve(stats.toString({+ chunks: false,+ colors: true+ }))+ }+ })+ })+}++function web () {+ del.sync(['dist/web/*', '!.gitkeep'])+ webConfig.mode = 'production'+ webpack(webConfig, (err, stats) => {+ if (err || stats.hasErrors()) console.log(err)++ console.log(stats.toString({+ chunks: false,+ colors: true+ }))++ process.exit()+ })+}++function greeting () {+ const cols = process.stdout.columns+ let text = ''++ if (cols > 85) text = 'lets-build'+ else if (cols > 60) text = 'lets-|build'+ else text = false++ if (text && !isCI) {+ say(text, {+ colors: ['yellow'],+ font: 'simple3d',+ space: false+ })+ } else console.log(chalk.yellow.bold('\n lets-build'))+ console.log()+}\ No newline at end of filediff --git a/.electron-vue/dev-client.js b/.electron-vue/dev-client.jsnew file mode 100644index 00000000..2913ea4b--- /dev/null+++ b/.electron-vue/dev-client.js@@ -0,0 +1,40 @@+const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')++hotClient.subscribe(event => {+ /**+ * Reload browser when HTMLWebpackPlugin emits a new index.html+ *+ * Currently disabled until jantimon/html-webpack-plugin#680 is resolved.+ * https://github.com/SimulatedGREG/electron-vue/issues/437+ * https://github.com/jantimon/html-webpack-plugin/issues/680+ */+ // if (event.action === 'reload') {+ // window.location.reload()+ // }++ /**+ * Notify `mainWindow` when `main` process is compiling,+ * giving notice for an expected reload of the `electron` process+ */+ if (event.action === 'compiling') {+ document.body.innerHTML += `+ <style>+ #dev-client {+ background: #4fc08d;+ border-radius: 4px;+ bottom: 20px;+ box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);+ color: #fff;+ font-family: 'Source Sans Pro', sans-serif;+ left: 20px;+ padding: 8px 12px;+ position: absolute;+ }+ </style>++ <div id="dev-client">+ Compiling Main Process...+ </div>+ `+ }+})diff --git a/.electron-vue/dev-runner.js b/.electron-vue/dev-runner.jsnew file mode 100644index 00000000..247f4f09--- /dev/null+++ b/.electron-vue/dev-runner.js@@ -0,0 +1,178 @@+'use strict'++const chalk = require('chalk')+const electron = require('electron')+const path = require('path')+const { say } = require('cfonts')+const { spawn } = require('child_process')+const webpack = require('webpack')+const WebpackDevServer = require('webpack-dev-server')+const webpackHotMiddleware = require('webpack-hot-middleware')++const mainConfig = require('./webpack.main.config')+const rendererConfig = require('./webpack.renderer.config')++let electronProcess = null+let manualRestart = false+let hotMiddleware++function logStats (proc, data) {+ let log = ''++ log += chalk.yellow.bold(`┏ ${proc} Process ${new Array((19 - proc.length) + 1).join('-')}`)+ log += '\n\n'++ if (typeof data === 'object') {+ data.toString({+ colors: true,+ chunks: false+ }).split(/\r?\n/).forEach(line => {+ log += ' ' + line + '\n'+ })+ } else {+ log += ` ${data}\n`+ }++ log += '\n' + chalk.yellow.bold(`┗ ${new Array(28 + 1).join('-')}`) + '\n'++ console.log(log)+}++function startRenderer () {+ return new Promise((resolve, reject) => {+ rendererConfig.entry.index = [path.join(__dirname, 'dev-client')].concat(rendererConfig.entry.index)+ rendererConfig.mode = 'development'+ const compiler = webpack(rendererConfig)+ hotMiddleware = webpackHotMiddleware(compiler, {+ log: false,+ heartbeat: 2500+ })++ compiler.hooks.compilation.tap('compilation', compilation => {+ compilation.hooks.htmlWebpackPluginAfterEmit.tapAsync('html-webpack-plugin-after-emit', (data, cb) => {+ hotMiddleware.publish({ action: 'reload' })+ cb()+ })+ })++ compiler.hooks.done.tap('done', stats => {+ logStats('Renderer', stats)+ })++ const server = new WebpackDevServer(+ compiler,+ {+ contentBase: path.join(__dirname, '../'),+ quiet: true,+ before (app, ctx) {+ app.use(hotMiddleware)+ ctx.middleware.waitUntilValid(() => {+ resolve()+ })+ }+ }+ )++ server.listen(9080)+ })+}++function startMain () {+ return new Promise((resolve, reject) => {+ mainConfig.entry.main = [path.join(__dirname, '../src/main/index.dev.js')].concat(mainConfig.entry.main)+ mainConfig.mode = 'development'+ const compiler = webpack(mainConfig)++ compiler.hooks.watchRun.tapAsync('watch-run', (compilation, done) => {+ logStats('Main', chalk.white.bold('compiling...'))+ hotMiddleware.publish({ action: 'compiling' })+ done()+ })++ compiler.watch({}, (err, stats) => {+ if (err) {+ console.log(err)+ return+ }++ logStats('Main', stats)++ if (electronProcess && electronProcess.kill) {+ manualRestart = true+ process.kill(electronProcess.pid)+ electronProcess = null+ startElectron()++ setTimeout(() => {+ manualRestart = false+ }, 5000)+ }++ resolve()+ })+ })+}++function startElectron () {+ electronProcess = spawn(electron, ['--inspect=5858', path.join(__dirname, '../dist/electron/main.js')])++ electronProcess.stdout.on('data', data => {+ electronLog(data, 'blue')+ })+ electronProcess.stderr.on('data', data => {+ electronLog(data, 'red')+ })++ electronProcess.on('close', () => {+ if (!manualRestart) process.exit()+ })+}++function electronLog (data, color) {+ let log = ''+ data = data.toString().split(/\r?\n/)+ data.forEach(line => {+ log += ` ${line}\n`+ })+ if (/[0-9A-z]+/.test(log)) {+ console.log(+ chalk[color].bold('┏ Electron -------------------') ++ '\n\n' ++ log ++ chalk[color].bold('┗ ----------------------------') ++ '\n'+ )+ }+}++function greeting () {+ const cols = process.stdout.columns+ let text = ''++ if (cols > 104) text = 'electron-vue'+ else if (cols > 76) text = 'electron-|vue'+ else text = false++ if (text) {+ say(text, {+ colors: ['yellow'],+ font: 'simple3d',+ space: false+ })+ } else console.log(chalk.yellow.bold('\n electron-vue'))+ console.log(chalk.blue(' getting ready...') + '\n')+}++function init () {+ greeting()++ Promise.all([startRenderer(), startMain()])+ .then(() => {+ startElectron()+ })+ .catch(err => {+ console.error(err)+ })+}++init()diff --git a/.electron-vue/webpack.main.config.js b/.electron-vue/webpack.main.config.jsnew file mode 100644index 00000000..3bf2de22--- /dev/null+++ b/.electron-vue/webpack.main.config.js@@ -0,0 +1,89 @@+'use strict'++process.env.BABEL_ENV = 'main'++const devMode = process.env.NODE_ENV !== 'production'+const path = require('path')+const { dependencies, build } = require('../package.json')+const webpack = require('webpack')++const BabiliWebpackPlugin = require('babili-webpack-plugin')++let mainConfig = {+ entry: {+ main: path.join(__dirname, '../src/main/index.js')+ },+ externals: [+ ...Object.keys(dependencies || {})+ ],+ module: {+ rules: [+ {+ test: /\.(js)$/,+ enforce: 'pre',+ exclude: /node_modules/,+ use: {+ loader: 'eslint-loader',+ options: {+ formatter: require('eslint-friendly-formatter')+ }+ }+ },+ {+ test: /\.js$/,+ use: 'babel-loader',+ exclude: /node_modules/+ },+ {+ test: /\.node$/,+ use: 'node-loader'+ }+ ]+ },+ node: {+ __dirname: devMode,+ __filename: devMode+ },+ output: {+ filename: '[name].js',+ libraryTarget: 'commonjs2',+ path: path.join(__dirname, '../dist/electron')+ },+ plugins: [+ new webpack.NoEmitOnErrorsPlugin()+ ],+ resolve: {+ alias: {+ '@': path.join(__dirname, '../src/main'),+ '@shared': path.join(__dirname, '../src/shared')+ },+ extensions: ['.js', '.json', '.node']+ },+ target: 'electron-main'+}++/**+ * Adjust mainConfig for development settings+ */+if (devMode) {+ mainConfig.plugins.push(+ new webpack.DefinePlugin({+ '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`+ })+ )+}++/**+ * Adjust mainConfig for production settings+ */+if (!devMode) {+ mainConfig.plugins.push(+ new BabiliWebpackPlugin(),+ new webpack.DefinePlugin({+ 'process.env.NODE_ENV': '"production"',+ 'appId': `"${build.appId}"`+ })+ )+}++module.exports = mainConfigdiff --git a/.electron-vue/webpack.renderer.config.js b/.electron-vue/webpack.renderer.config.jsnew file mode 100644index 00000000..1daa2a56--- /dev/null+++ b/.electron-vue/webpack.renderer.config.js@@ -0,0 +1,232 @@+'use strict'++process.env.BABEL_ENV = 'renderer'++const devMode = process.env.NODE_ENV !== 'production'+const path = require('path')+const { dependencies } = require('../package.json')+const webpack = require('webpack')++const BabiliWebpackPlugin = require('babili-webpack-plugin')+const CopyWebpackPlugin = require('copy-webpack-plugin')+const MiniCssExtractPlugin = require('mini-css-extract-plugin')+const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')+const HtmlWebpackPlugin = require('html-webpack-plugin')+const { VueLoaderPlugin } = require('vue-loader')++/**+ * List of node_modules to include in webpack bundle+ *+ * Required for specific packages like Vue UI libraries+ * that provide pure *.vue files that need compiling+ * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals+ */+let whiteListedModules = ['vue']++let rendererConfig = {+ devtool: '#cheap-module-eval-source-map',+ entry: {+ index: path.join(__dirname, '../src/renderer/pages/index/main.js')+ },+ externals: [+ ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))+ ],+ module: {+ rules: [+ {+ test: /\.(js|vue)$/,+ enforce: 'pre',+ exclude: /node_modules/,+ use: {+ loader: 'eslint-loader',+ options: {+ formatter: require('eslint-friendly-formatter')+ }+ }+ },+ {+ test: /\.scss$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ {+ loader: 'sass-loader',+ options: {+ data: '@import "@/components/Theme/Variables.scss";',+ includePaths:[__dirname, 'src']+ },+ }+ ]+ },+ {+ test: /\.sass$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ {+ loader: 'sass-loader',+ options: {+ indentedSyntax: true,+ data: '@import "@/components/Theme/Variables.scss";',+ includePaths:[__dirname, 'src']+ },+ }+ ]+ },+ {+ test: /\.less$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ 'less-loader'+ ]+ },+ {+ test: /\.css$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader'+ ]+ },+ {+ test: /\.html$/,+ use: 'vue-html-loader'+ },+ {+ test: /\.js$/,+ use: 'babel-loader',+ exclude: /node_modules/+ },+ {+ test: /\.node$/,+ use: 'node-loader'+ },+ {+ test: /\.vue$/,+ use: {+ loader: 'vue-loader',+ options: {+ extractCSS: process.env.NODE_ENV === 'production',+ loaders: {+ sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',+ scss: 'vue-style-loader!css-loader!sass-loader',+ less: 'vue-style-loader!css-loader!less-loader'+ }+ }+ }+ },+ {+ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,+ use: {+ loader: 'url-loader',+ query: {+ limit: 10000,+ name: 'imgs/[name]--[folder].[ext]'+ }+ }+ },+ {+ test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,+ loader: 'url-loader',+ options: {+ limit: 10000,+ name: 'media/[name]--[folder].[ext]'+ }+ },+ {+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,+ use: {+ loader: 'url-loader',+ query: {+ limit: 10000,+ name: 'fonts/[name]--[folder].[ext]'+ }+ }+ }+ ]+ },+ node: {+ __dirname: devMode,+ __filename: devMode+ },+ plugins: [+ new VueLoaderPlugin(),+ new MiniCssExtractPlugin({+ filename: '[name].css',+ chunkFilename: '[id].css'+ }),+ new OptimizeCSSPlugin({+ cssProcessorOptions: {+ safe: true,+ discardComments: { removeAll: true }+ }+ }),+ new HtmlWebpackPlugin({+ title: 'Motrix',+ filename: 'index.html',+ chunks: ['index'],+ template: path.resolve(__dirname, '../src/index.ejs'),+ // minify: {+ // collapseWhitespace: true,+ // removeAttributeQuotes: true,+ // removeComments: true+ // },+ nodeModules: devMode+ ? path.resolve(__dirname, '../node_modules')+ : false+ }),+ new webpack.HotModuleReplacementPlugin(),+ new webpack.NoEmitOnErrorsPlugin()+ ],+ output: {+ filename: '[name].js',+ libraryTarget: 'commonjs2',+ path: path.join(__dirname, '../dist/electron')+ },+ resolve: {+ alias: {+ '@': path.join(__dirname, '../src/renderer'),+ '@shared': path.join(__dirname, '../src/shared'),+ 'vue$': 'vue/dist/vue.esm.js'+ },+ extensions: ['.js', '.vue', '.json', '.css', '.node']+ },+ target: 'electron-renderer'+}++/**+ * Adjust rendererConfig for development settings+ */+if (devMode) {+ rendererConfig.plugins.push(+ new webpack.DefinePlugin({+ '__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`+ })+ )+}++/**+ * Adjust rendererConfig for production settings+ */+if (!devMode) {+ rendererConfig.devtool = ''++ rendererConfig.plugins.push(+ new BabiliWebpackPlugin(),+ new CopyWebpackPlugin([+ {+ from: path.join(__dirname, '../static'),+ to: path.join(__dirname, '../dist/electron/static'),+ ignore: ['.*']+ }+ ]),+ new webpack.DefinePlugin({+ 'process.env.NODE_ENV': '"production"'+ }),+ new webpack.LoaderOptionsPlugin({+ minimize: false+ })+ )+}++module.exports = rendererConfigdiff --git a/.electron-vue/webpack.web.config.js b/.electron-vue/webpack.web.config.jsnew file mode 100644index 00000000..7d67bf70--- /dev/null+++ b/.electron-vue/webpack.web.config.js@@ -0,0 +1,205 @@+'use strict'++process.env.BABEL_ENV = 'web'++const devMode = process.env.NODE_ENV !== 'production'+const path = require('path')+const { dependencies } = require('../package.json')+const webpack = require('webpack')++const BabiliWebpackPlugin = require('babili-webpack-plugin')+const CopyWebpackPlugin = require('copy-webpack-plugin')+const MiniCssExtractPlugin = require('mini-css-extract-plugin')+const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')+const HtmlWebpackPlugin = require('html-webpack-plugin')+const { VueLoaderPlugin } = require('vue-loader')++/**+ * List of node_modules to include in webpack bundle+ *+ * Required for specific packages like Vue UI libraries+ * that provide pure *.vue files that need compiling+ * https://simulatedgreg.gitbooks.io/electron-vue/content/en/webpack-configurations.html#white-listing-externals+ */+let whiteListedModules = ['vue']++let webConfig = {+ devtool: '#cheap-module-eval-source-map',+ entry: {+ index: path.join(__dirname, '../src/renderer/pages/index/main.js')+ },+ externals: [+ ...Object.keys(dependencies || {}).filter(d => !whiteListedModules.includes(d))+ ],+ module: {+ rules: [+ {+ test: /\.(js|vue)$/,+ enforce: 'pre',+ exclude: /node_modules/,+ use: {+ loader: 'eslint-loader',+ options: {+ formatter: require('eslint-friendly-formatter')+ }+ }+ },+ {+ test: /\.scss$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ 'sass-loader'+ ]+ },+ {+ test: /\.sass$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ 'sass-loader?indentedSyntax'+ ]+ },+ {+ test: /\.less$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader',+ 'less-loader'+ ]+ },+ {+ test: /\.css$/,+ use: [+ devMode ? 'vue-style-loader' : MiniCssExtractPlugin.loader,+ 'css-loader'+ ]+ },+ {+ test: /\.js$/,+ use: 'babel-loader',+ include: [ path.resolve(__dirname, '../src/renderer') ],+ exclude: /node_modules/+ },+ {+ test: /\.vue$/,+ use: {+ loader: 'vue-loader',+ options: {+ extractCSS: true,+ loaders: {+ sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax=1',+ scss: 'vue-style-loader!css-loader!sass-loader',+ less: 'vue-style-loader!css-loader!less-loader'+ }+ }+ }+ },+ {+ test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,+ use: {+ loader: 'url-loader',+ query: {+ limit: 10000,+ name: 'imgs/[name].[ext]'+ }+ }+ },+ {+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,+ use: {+ loader: 'url-loader',+ query: {+ limit: 10000,+ name: 'fonts/[name].[ext]'+ }+ }+ }+ ]+ },+ plugins: [+ new VueLoaderPlugin(),+ new MiniCssExtractPlugin({+ filename: '[name].css',+ chunkFilename: '[id].css'+ }),+ new OptimizeCSSPlugin({+ cssProcessorOptions: {+ safe: true,+ discardComments: { removeAll: true }+ }+ }),+ new HtmlWebpackPlugin({+ title: 'Motrix',+ filename: 'index.html',+ chunks: ['index'],+ template: path.resolve(__dirname, '../src/index.ejs'),+ // minify: {+ // collapseWhitespace: true,+ // removeAttributeQuotes: true,+ // removeComments: true+ // },+ nodeModules: devMode+ ? path.resolve(__dirname, '../node_modules')+ : false+ }),+ new HtmlWebpackPlugin({+ title: '关于',+ filename: 'about.html',+ chunks: ['about'],+ template: path.resolve(__dirname, '../src/about.ejs'),+ // minify: {+ // collapseWhitespace: true,+ // removeAttributeQuotes: true,+ // removeComments: true+ // },+ nodeModules: devMode+ ? path.resolve(__dirname, '../node_modules')+ : false+ }),+ new webpack.DefinePlugin({+ 'process.env.IS_WEB': 'true'+ }),+ new webpack.HotModuleReplacementPlugin(),+ new webpack.NoEmitOnErrorsPlugin()+ ],+ output: {+ filename: '[name].js',+ path: path.join(__dirname, '../dist/web')+ },+ resolve: {+ alias: {+ '@': path.join(__dirname, '../src/renderer'),+ '@shared': path.join(__dirname, '../src/shared'),+ 'vue$': 'vue/dist/vue.esm.js'+ },+ extensions: ['.js', '.vue', '.json', '.css']+ },+ target: 'web'+}++/**+ * Adjust webConfig for production settings+ */+if (!devMode) {+ webConfig.devtool = ''++ webConfig.plugins.push(+ new BabiliWebpackPlugin(),+ new CopyWebpackPlugin([+ {+ from: path.join(__dirname, '../static'),+ to: path.join(__dirname, '../dist/web/static'),+ ignore: ['.*']+ }+ ]),+ new webpack.DefinePlugin({+ 'process.env.NODE_ENV': '"production"'+ }),+ new webpack.LoaderOptionsPlugin({+ minimize: true+ })+ )+}++module.exports = webConfigdiff --git a/.eslintignore b/.eslintignorenew file mode 100644index 00000000..e69de29bdiff --git a/.eslintrc.js b/.eslintrc.jsnew file mode 100644index 00000000..1f38288c--- /dev/null+++ b/.eslintrc.js@@ -0,0 +1,27 @@+module.exports = {+ root: true,+ parser: 'babel-eslint',+ parserOptions: {+ sourceType: 'module'+ },+ env: {+ browser: true,+ node: true+ },+ extends: 'standard',+ globals: {+ appId: true,+ __static: true+ },+ plugins: [+ 'html'+ ],+ 'rules': {+ // allow paren-less arrow functions+ 'arrow-parens': 0,+ // allow async-await+ 'generator-star-spacing': 0,+ // allow debugger during development+ 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0+ }+}diff --git a/.gitignore b/.gitignorenew file mode 100644index 00000000..a8464969--- /dev/null+++ b/.gitignore@@ -0,0 +1,11 @@+.DS_Store+dist/electron/*+dist/web/*+*.provisionprofile+build/*.plist+node_modules/+npm-debug.log+npm-debug.log.*+thumbs.db+!.gitkeep+release/*diff --git a/.travis.yml b/.travis.ymlnew file mode 100644index 00000000..fd14ca51--- /dev/null+++ b/.travis.yml@@ -0,0 +1,36 @@+osx_image: xcode8.3+sudo: required+dist: trusty+language: c+matrix:+ include:+ - os: osx+ - os: linux+ env: CC=clang CXX=clang++ npm_config_clang=1+ compiler: clang+cache:+ directories:+ - node_modules+ - "$HOME/.electron"+ - "$HOME/.cache"+addons:+ apt:+ packages:+ - libgnome-keyring-dev+ - icnsutils+before_install:+- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([+ "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz+ | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull+- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi+install:+- nvm install 7+- curl -o- -L https://yarnpkg.com/install.sh | bash+- source ~/.bashrc+- npm install -g xvfb-maybe+- yarn+script:+- yarn run build+branches:+ only:+ - masterdiff --git a/app-update.yml b/app-update.ymlnew file mode 100644index 00000000..1019a55f--- /dev/null+++ b/app-update.yml@@ -0,0 +1,2 @@+provider: generic+url: 'https://motrix.app/release/'diff --git a/appveyor.yml b/appveyor.ymlnew file mode 100644index 00000000..c9e3248a--- /dev/null+++ b/appveyor.yml@@ -0,0 +1,29 @@+version: 0.1.{build}++branches:+ only:+ - master++image: Visual Studio 2017+platform:+ - x64++cache:+ - node_modules+ - '%APPDATA%\npm-cache'+ - '%USERPROFILE%\.electron'+ - '%USERPROFILE%\AppData\Local\Yarn\cache'++init:+ - git config --global core.autocrlf input++install:+ - ps: Install-Product node 8 x64+ - git reset --hard HEAD+ - yarn+ - node --version++build_script:+ - yarn build++test: offdiff --git a/build/256x256.png b/build/256x256.pngnew file mode 100644index 00000000..cc743497Binary files /dev/null and b/build/256x256.png differdiff --git a/build/background.tiff b/build/background.tiffnew file mode 100644index 00000000..51a380beBinary files /dev/null and b/build/background.tiff differdiff --git a/build/icon.icns b/build/icon.icnsnew file mode 100644index 00000000..f0feb7e3Binary files /dev/null and b/build/icon.icns differdiff --git a/build/icon.ico b/build/icon.iconew file mode 100644index 00000000..6be8a299Binary files /dev/null and b/build/icon.ico differdiff --git a/extra/darwin/engine/aria2.conf b/extra/darwin/engine/aria2.confnew file mode 100755index 00000000..8157c67c--- /dev/null+++ b/extra/darwin/engine/aria2.conf@@ -0,0 +1,108 @@+## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##+## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##+## 添加了@和默认启用的选项都是系统需要调用的,请不要随意改动否则可能无法正常运行++## 文件保存相关 ##++# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置+# 此项 OS X 无法使用 $HOME 及 ~/ 设置路径 建议使用 /users/用户名/downloads+#@dir=$HOME/downloads+# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M+#@disk-cache=32M+# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc+# 预分配所需时间: none < falloc ? trunc < prealloc+# falloc和trunc则需要文件系统和内核支持+# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项+# file-allocation=none+# 断点续传+#@continue=true++## 下载连接相关 ##++# 最大同时下载任务数, 运行时可修改, 默认:5+#@max-concurrent-downloads=10+# 同一服务器连接数, 添加时可指定, 默认:1+#@max-connection-per-server=15+# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M+# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载+#@min-split-size=10M+# 单个任务最大线程数, 添加时可指定, 默认:5+#@split=15+# 整体下载速度限制, 运行时可修改, 默认:0+#@max-overall-download-limit=0+# 单个任务下载速度限制, 默认:0+#@max-download-limit=0+# 整体上传速度限制, 运行时可修改, 默认:0+#@max-overall-upload-limit=0+# 单个任务上传速度限制, 默认:0+#@max-upload-limit=0+# 禁用IPv6, 默认:false+disable-ipv6=false+#运行覆盖已存在文件+#@allow-overwrite=true+#自动重命名+#@auto-file-renaming=true++## 进度保存相关 ##++# 从会话文件中读取下载任务+#@input-file=/Users/Shared/aria2.session+# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件+#@save-session=/Users/Shared/aria2.session+# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0+save-session-interval=30++## RPC相关设置 ##++# 启用RPC, 默认:false+enable-rpc=true+# 允许所有来源, 默认:false+rpc-allow-origin-all=true+# 允许非外部访问, 默认:false+rpc-listen-all=true+# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同+#event-poll=select+# RPC监听端口, 端口被占用时可以修改, 默认:6800+# 使用本客户端请勿修改此项+# rpc-listen-port=6800+# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项+#rpc-secret=token++## BT/PT下载相关 ##++# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true+#follow-torrent=true+# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999+listen-port=51413+# 单个种子最大连接数, 默认:55+#bt-max-peers=55+# 打开DHT功能, PT需要禁用, 默认:true+enable-dht=false+# 打开IPv6 DHT功能, PT需要禁用+#enable-dht6=false+# DHT网络监听端口, 默认:6881-6999+#dht-listen-port=6881-6999+# 本地节点查找, PT需要禁用, 默认:false+#bt-enable-lpd=false+# 种子交换, PT需要禁用, 默认:true+#enable-peer-exchange=false+# 每个种子限速, 对少种的PT很有用, 默认:50K+#bt-request-peer-speed-limit=50K+# 客户端伪装, PT需要+peer-id-prefix=-TR2770-+user-agent=Transmission/2.94+# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0+seed-ratio=0+# 强制保存会话, 即使任务已经完成, 默认:false+# 较新的版本开启后会在任务完成后依然保留.aria2文件+#force-save=false+# BT校验相关, 默认:true+#bt-hash-check-seed=true+# 继续之前的BT任务时, 无需再次校验, 默认:false+bt-seed-unverified=true+# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false+bt-save-metadata=true++# bt-tracker数据来自https://github.com/ngosang/trackerslist/blob/master/trackers_all_udp.txt++bt-tracker=udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.leechers-paradise.org:6969/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.zer0day.to:1337/announce,udp://9.rarbg.com:2710/announce,udp://p4p.arenabg.com:1337/announce,udp://explodie.org:6969/announce,udp://tracker.mg64.net:6969/announce,udp://mgtracker.org:2710/announce,udp://tracker.yoshi210.com:6969/announce,udp://tracker.tiny-vps.com:6969/announce,udp://tracker.skyts.net:6969/announce,udp://tracker.tordb.ml:6881/announce,udp://tracker.piratepublic.com:1337/announce,udp://tracker.grepler.com:6969/announce,udp://tracker.filetracker.pl:8089/announce,udp://tracker.edoardocolombo.eu:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://91.218.230.81:6969/announce,udp://tracker.vanitycore.co:6969/announce,udp://tracker.kuroy.me:5944/announce,udp://zephir.monocul.us:6969/announce,udp://tracker.desu.sh:6969/announce,udp://bt.xxx-tracker.com:2710/announcediff --git a/extra/darwin/engine/aria2c b/extra/darwin/engine/aria2cnew file mode 100755index 00000000..487526bdBinary files /dev/null and b/extra/darwin/engine/aria2c differdiff --git a/extra/linux/engine/aria2.conf b/extra/linux/engine/aria2.confnew file mode 100755index 00000000..8157c67c--- /dev/null+++ b/extra/linux/engine/aria2.conf@@ -0,0 +1,108 @@+## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##+## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##+## 添加了@和默认启用的选项都是系统需要调用的,请不要随意改动否则可能无法正常运行++## 文件保存相关 ##++# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置+# 此项 OS X 无法使用 $HOME 及 ~/ 设置路径 建议使用 /users/用户名/downloads+#@dir=$HOME/downloads+# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M+#@disk-cache=32M+# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc+# 预分配所需时间: none < falloc ? trunc < prealloc+# falloc和trunc则需要文件系统和内核支持+# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项+# file-allocation=none+# 断点续传+#@continue=true++## 下载连接相关 ##++# 最大同时下载任务数, 运行时可修改, 默认:5+#@max-concurrent-downloads=10+# 同一服务器连接数, 添加时可指定, 默认:1+#@max-connection-per-server=15+# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M+# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载+#@min-split-size=10M+# 单个任务最大线程数, 添加时可指定, 默认:5+#@split=15+# 整体下载速度限制, 运行时可修改, 默认:0+#@max-overall-download-limit=0+# 单个任务下载速度限制, 默认:0+#@max-download-limit=0+# 整体上传速度限制, 运行时可修改, 默认:0+#@max-overall-upload-limit=0+# 单个任务上传速度限制, 默认:0+#@max-upload-limit=0+# 禁用IPv6, 默认:false+disable-ipv6=false+#运行覆盖已存在文件+#@allow-overwrite=true+#自动重命名+#@auto-file-renaming=true++## 进度保存相关 ##++# 从会话文件中读取下载任务+#@input-file=/Users/Shared/aria2.session+# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件+#@save-session=/Users/Shared/aria2.session+# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0+save-session-interval=30++## RPC相关设置 ##++# 启用RPC, 默认:false+enable-rpc=true+# 允许所有来源, 默认:false+rpc-allow-origin-all=true+# 允许非外部访问, 默认:false+rpc-listen-all=true+# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同+#event-poll=select+# RPC监听端口, 端口被占用时可以修改, 默认:6800+# 使用本客户端请勿修改此项+# rpc-listen-port=6800+# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项+#rpc-secret=token++## BT/PT下载相关 ##++# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true+#follow-torrent=true+# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999+listen-port=51413+# 单个种子最大连接数, 默认:55+#bt-max-peers=55+# 打开DHT功能, PT需要禁用, 默认:true+enable-dht=false+# 打开IPv6 DHT功能, PT需要禁用+#enable-dht6=false+# DHT网络监听端口, 默认:6881-6999+#dht-listen-port=6881-6999+# 本地节点查找, PT需要禁用, 默认:false+#bt-enable-lpd=false+# 种子交换, PT需要禁用, 默认:true+#enable-peer-exchange=false+# 每个种子限速, 对少种的PT很有用, 默认:50K+#bt-request-peer-speed-limit=50K+# 客户端伪装, PT需要+peer-id-prefix=-TR2770-+user-agent=Transmission/2.94+# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0+seed-ratio=0+# 强制保存会话, 即使任务已经完成, 默认:false+# 较新的版本开启后会在任务完成后依然保留.aria2文件+#force-save=false+# BT校验相关, 默认:true+#bt-hash-check-seed=true+# 继续之前的BT任务时, 无需再次校验, 默认:false+bt-seed-unverified=true+# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false+bt-save-metadata=true++# bt-tracker数据来自https://github.com/ngosang/trackerslist/blob/master/trackers_all_udp.txt++bt-tracker=udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.leechers-paradise.org:6969/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.zer0day.to:1337/announce,udp://9.rarbg.com:2710/announce,udp://p4p.arenabg.com:1337/announce,udp://explodie.org:6969/announce,udp://tracker.mg64.net:6969/announce,udp://mgtracker.org:2710/announce,udp://tracker.yoshi210.com:6969/announce,udp://tracker.tiny-vps.com:6969/announce,udp://tracker.skyts.net:6969/announce,udp://tracker.tordb.ml:6881/announce,udp://tracker.piratepublic.com:1337/announce,udp://tracker.grepler.com:6969/announce,udp://tracker.filetracker.pl:8089/announce,udp://tracker.edoardocolombo.eu:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://91.218.230.81:6969/announce,udp://tracker.vanitycore.co:6969/announce,udp://tracker.kuroy.me:5944/announce,udp://zephir.monocul.us:6969/announce,udp://tracker.desu.sh:6969/announce,udp://bt.xxx-tracker.com:2710/announcediff --git a/extra/linux/engine/aria2c b/extra/linux/engine/aria2cnew file mode 100755index 00000000..00fa8314Binary files /dev/null and b/extra/linux/engine/aria2c differdiff --git a/extra/win32/engine/aria2.conf b/extra/win32/engine/aria2.confnew file mode 100755index 00000000..8157c67c--- /dev/null+++ b/extra/win32/engine/aria2.conf@@ -0,0 +1,108 @@+## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##+## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##+## 添加了@和默认启用的选项都是系统需要调用的,请不要随意改动否则可能无法正常运行++## 文件保存相关 ##++# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置+# 此项 OS X 无法使用 $HOME 及 ~/ 设置路径 建议使用 /users/用户名/downloads+#@dir=$HOME/downloads+# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M+#@disk-cache=32M+# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc+# 预分配所需时间: none < falloc ? trunc < prealloc+# falloc和trunc则需要文件系统和内核支持+# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项+# file-allocation=none+# 断点续传+#@continue=true++## 下载连接相关 ##++# 最大同时下载任务数, 运行时可修改, 默认:5+#@max-concurrent-downloads=10+# 同一服务器连接数, 添加时可指定, 默认:1+#@max-connection-per-server=15+# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M+# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载+#@min-split-size=10M+# 单个任务最大线程数, 添加时可指定, 默认:5+#@split=15+# 整体下载速度限制, 运行时可修改, 默认:0+#@max-overall-download-limit=0+# 单个任务下载速度限制, 默认:0+#@max-download-limit=0+# 整体上传速度限制, 运行时可修改, 默认:0+#@max-overall-upload-limit=0+# 单个任务上传速度限制, 默认:0+#@max-upload-limit=0+# 禁用IPv6, 默认:false+disable-ipv6=false+#运行覆盖已存在文件+#@allow-overwrite=true+#自动重命名+#@auto-file-renaming=true++## 进度保存相关 ##++# 从会话文件中读取下载任务+#@input-file=/Users/Shared/aria2.session+# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件+#@save-session=/Users/Shared/aria2.session+# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0+save-session-interval=30++## RPC相关设置 ##++# 启用RPC, 默认:false+enable-rpc=true+# 允许所有来源, 默认:false+rpc-allow-origin-all=true+# 允许非外部访问, 默认:false+rpc-listen-all=true+# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同+#event-poll=select+# RPC监听端口, 端口被占用时可以修改, 默认:6800+# 使用本客户端请勿修改此项+# rpc-listen-port=6800+# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项+#rpc-secret=token++## BT/PT下载相关 ##++# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true+#follow-torrent=true+# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999+listen-port=51413+# 单个种子最大连接数, 默认:55+#bt-max-peers=55+# 打开DHT功能, PT需要禁用, 默认:true+enable-dht=false+# 打开IPv6 DHT功能, PT需要禁用+#enable-dht6=false+# DHT网络监听端口, 默认:6881-6999+#dht-listen-port=6881-6999+# 本地节点查找, PT需要禁用, 默认:false+#bt-enable-lpd=false+# 种子交换, PT需要禁用, 默认:true+#enable-peer-exchange=false+# 每个种子限速, 对少种的PT很有用, 默认:50K+#bt-request-peer-speed-limit=50K+# 客户端伪装, PT需要+peer-id-prefix=-TR2770-+user-agent=Transmission/2.94+# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0+seed-ratio=0+# 强制保存会话, 即使任务已经完成, 默认:false+# 较新的版本开启后会在任务完成后依然保留.aria2文件+#force-save=false+# BT校验相关, 默认:true+#bt-hash-check-seed=true+# 继续之前的BT任务时, 无需再次校验, 默认:false+bt-seed-unverified=true+# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false+bt-save-metadata=true++# bt-tracker数据来自https://github.com/ngosang/trackerslist/blob/master/trackers_all_udp.txt++bt-tracker=udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.leechers-paradise.org:6969/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.zer0day.to:1337/announce,udp://9.rarbg.com:2710/announce,udp://p4p.arenabg.com:1337/announce,udp://explodie.org:6969/announce,udp://tracker.mg64.net:6969/announce,udp://mgtracker.org:2710/announce,udp://tracker.yoshi210.com:6969/announce,udp://tracker.tiny-vps.com:6969/announce,udp://tracker.skyts.net:6969/announce,udp://tracker.tordb.ml:6881/announce,udp://tracker.piratepublic.com:1337/announce,udp://tracker.grepler.com:6969/announce,udp://tracker.filetracker.pl:8089/announce,udp://tracker.edoardocolombo.eu:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://91.218.230.81:6969/announce,udp://tracker.vanitycore.co:6969/announce,udp://tracker.kuroy.me:5944/announce,udp://zephir.monocul.us:6969/announce,udp://tracker.desu.sh:6969/announce,udp://bt.xxx-tracker.com:2710/announcediff --git a/extra/win32/engine/aria2.exe b/extra/win32/engine/aria2.exenew file mode 100755index 00000000..7de7a06fBinary files /dev/null and b/extra/win32/engine/aria2.exe differdiff --git a/package.json b/package.jsonnew file mode 100644index 00000000..fd8d12a8--- /dev/null+++ b/package.json@@ -0,0 +1,189 @@+{+ "name": "Motrix",+ "version": "1.0.2",+ "description": "A full-featured macOS download manager",+ "homepage": "https://motrix.app",+ "author": {+ "name": "AGALWOOD",+ "email": "[email protected]"+ },+ "copyright": "Copyright© AGALWOOD",+ "main": "./dist/electron/main.js",+ "repository": {+ "type": "git",+ "url": "[email protected]:agalwood/Motrix.git"+ },+ "scripts": {+ "build": "cross-env DEBUG=electron-osx-sign* node .electron-vue/build.js && electron-builder",+ "build:dir": "node .electron-vue/build.js && electron-builder --dir",+ "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",+ "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",+ "dev": "node .electron-vue/dev-runner.js",+ "dev:renderer": "webpack-dev-server --hot --colors --config .electron-vue/webpack.renderer.config.js --port 9080 --content-base app/dist",+ "lint": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter src",+ "lint:fix": "eslint --ext .js,.vue -f ./node_modules/eslint-friendly-formatter --fix src",+ "pack": "npm run pack:main && npm run pack:renderer",+ "pack:main": "cross-env NODE_ENV=production webpack --mode production --progress --colors --config .electron-vue/webpack.main.config.js",+ "pack:renderer": "cross-env NODE_ENV=production webpack --mode production --progress --colors --config .electron-vue/webpack.renderer.config.js",+ "postinstall": "npm run lint:fix"+ },+ "build": {+ "productName": "Motrix",+ "appId": "net.agalwood.Motrix",+ "asar": true,+ "directories": {+ "output": "release"+ },+ "files": [+ "dist/electron/**/*"+ ],+ "dmg": {+ "window": {+ "width": 540,+ "height": 380+ },+ "contents": [+ {+ "x": 410,+ "y": 230,+ "type": "link",+ "path": "/Applications"+ },+ {+ "x": 130,+ "y": 230,+ "type": "file"+ }+ ]+ },+ "mac": {+ "target": [+ "dmg",+ "zip"+ ],+ "type": "distribution",+ "darkModeSupport": true,+ "extraResources": {+ "from": "./extra/darwin/",+ "to": "./",+ "filter": [+ "**/*"+ ]+ },+ "binaries": [+ "./release/mac/Motrix.app/Contents/Resources/engine/aria2c"+ ],+ "category": "public.app-category.utilities",+ "protocols": [+ {+ "name": "Motrix Protocol",+ "schemes": [+ "mo",+ "motrix"+ ]+ }+ ]+ },+ "win": {+ "extraResources": {+ "from": "./extra/win32/",+ "to": "./",+ "filter": [+ "**/*"+ ]+ }+ },+ "linux": {+ "extraResources": {+ "from": "./extra/linux/",+ "to": "./",+ "filter": [+ "**/*"+ ]+ }+ },+ "publish": [+ {+ "provider": "generic",+ "url": "https://motrix.app/release/"+ }+ ]+ },+ "dependencies": {+ "aria2": "^4.0.3",+ "axios": "^0.18.0",+ "clipboard-polyfill": "^2.7.0",+ "electron-debug": "^2.0.0",+ "electron-is": "^3.0.0",+ "electron-log": "^2.2.17",+ "electron-updater": "^4.0.4",+ "element-ui": "^2.4.11",+ "forever-monitor": "^1.7.1",+ "lodash": "^4.17.11",+ "normalize.css": "^8.0.1",+ "parse-torrent": "^6.1.2",+ "svg-innerhtml": "^1.1.0",+ "vue": "^2.5.17",+ "vue-electron": "^1.0.6",+ "vue-router": "^3.0.2",+ "vuex": "^3.0.1",+ "vuex-router-sync": "^5.0.0"+ },+ "devDependencies": {+ "@vue/cli-plugin-babel": "^3.1.1",+ "@vue/cli-plugin-eslint": "^3.1.5",+ "@vue/cli-service": "^3.1.4",+ "@vue/eslint-config-standard": "^4.0.0",+ "ajv": "^6.5.5",+ "babel-core": "^6.26.3",+ "babel-eslint": "^10.0.1",+ "babel-loader": "^7.1.4",+ "babel-plugin-component": "^1.1.1",+ "babel-plugin-transform-runtime": "^6.23.0",+ "babel-preset-env": "^1.7.0",+ "babel-preset-stage-0": "^6.24.1",+ "babel-register": "^6.26.0",+ "babili-webpack-plugin": "^0.1.2",+ "cfonts": "^2.2.3",+ "chalk": "^2.4.1",+ "copy-webpack-plugin": "^4.6.0",+ "cross-env": "^5.1.6",+ "css-loader": "^1.0.1",+ "del": "^3.0.0",+ "devtron": "^1.4.0",+ "electron": "^3.0.11",+ "electron-builder": "^20.38.3",+ "electron-devtools-installer": "^2.2.4",+ "electron-notarize": "^0.0.5",+ "electron-osx-sign": "^0.4.11",+ "electron-store": "^2.0.0",+ "eslint": "^5.6.1",+ "eslint-config-standard": "^12.0.0",+ "eslint-friendly-formatter": "^4.0.1",+ "eslint-loader": "^2.1.1",+ "eslint-plugin-html": "^4.0.6",+ "eslint-plugin-import": "^2.12.0",+ "eslint-plugin-node": "^7.0.1",+ "eslint-plugin-promise": "^4.0.1",+ "eslint-plugin-standard": "^4.0.0",+ "file-loader": "^2.0.0",+ "html-webpack-plugin": "^3.2.0",+ "mini-css-extract-plugin": "0.4.5",+ "multispinner": "^0.2.1",+ "node-loader": "^0.6.0",+ "node-sass": "^4.10.0",+ "optimize-css-assets-webpack-plugin": "^5.0.1",+ "sass-loader": "^7.1.0",+ "style-loader": "^0.23.1",+ "url-loader": "^1.1.2",+ "vue-html-loader": "^1.2.4",+ "vue-loader": "^15.4.2",+ "vue-style-loader": "^4.1.2",+ "vue-template-compiler": "^2.5.17",+ "webpack": "^4.26.1",+ "webpack-cli": "^3.1.2",+ "webpack-dev-server": "^3.1.10",+ "webpack-hot-middleware": "^2.24.3",+ "webpack-merge": "^4.1.4"+ }+}diff --git a/src/index.ejs b/src/index.ejsnew file mode 100644index 00000000..26e94d84--- /dev/null+++ b/src/index.ejs@@ -0,0 +1,32 @@+<!DOCTYPE html>+<html>+ <head>+ <meta charset="utf-8">+ <title>Motrix</title>+ <% if (htmlWebpackPlugin.options.nodeModules) { %>+ <!-- Add `node_modules/` to global paths so `require` works properly in development -->+ <script>+ require('module').globalPaths.push('<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>')+ </script>+ <% } %>+ </head>+ <body>+ <div id="app">+ <div class="title-bar"></div>+ <section class="el-container" id="container">+ <aside class="el-aside aside" style="width: 78px;">+ </aside>+ <aside class="el-aside subnav" style="width: 200px;">+ </aside>+ <section class="el-container main">+ </section>+ </section>+ </div>+ <!-- Set `__static` path to static files in production -->+ <script>+ if (process.env.NODE_ENV !== 'development') window.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')+ </script>++ <!-- webpack builds are automatically injected -->+ </body>+</html>diff --git a/src/main/Application.js b/src/main/Application.jsnew file mode 100644index 00000000..cc9946a5--- /dev/null+++ b/src/main/Application.js@@ -0,0 +1,228 @@+import { EventEmitter } from 'events'+import { app, shell, dialog, ipcMain } from 'electron'+import is from 'electron-is'+import logger from './core/Logger'+import ConfigManager from './core/ConfigManager'+import Engine from './core/Engine'+import UpdateManager from './core/UpdateManager'+import EnergyManager from './core/EnergyManager'+import ProtocolManager from './core/ProtocolManager'+import WindowManager from './ui/WindowManager'+import MenuManager from './ui/MenuManager'+import TouchBarManager from './ui/TouchBarManager'++export default class Application extends EventEmitter {+ constructor () {+ super()++ this.locale = app.getLocale()+ logger.log('this.locale', this.locale)++ this.configManager = new ConfigManager()++ this.engine = new Engine({+ systemConfig: this.configManager.getSystemConfig(),+ userConfig: this.configManager.getUserConfig()+ })+ this.startEngine()++ this.windowManager = new WindowManager()++ this.menuManager = new MenuManager()+ this.menuManager.setup(this.locale)++ this.touchBarManager = new TouchBarManager()++ this.energyManager = new EnergyManager()++ this.initUpdaterManager()++ this.initProtocolManager()++ this.handleCommands()+ this.handleIpcMessages()+ }++ startEngine () {+ try {+ this.engine.start()+ } catch (err) {+ dialog.showMessageBox({+ type: 'error',+ title: '系统错误',+ message: `应用启动失败:${err.message}`,+ buttons: ['知道了'],+ cancelId: 1+ }, () => {+ setTimeout(() => {+ app.quit()+ }, 100)+ })+ }+ }++ start (page) {+ this.showPage(page)+ }++ showPage (page) {+ const win = this.windowManager.openWindow(page)+ this.touchBarManager.setup(page, win)+ }++ closePage (page) {+ this.windowManager.destroyWindow(page)+ }++ stop () {+ this.engine.stop()+ this.energyManager.stopPowerSaveBlocker()+ }++ sendCommand (command, ...args) {+ if (!this.emit(command, ...args)) {+ const window = this.windowManager.getFocusedWindow()+ if (window) {+ this.windowManager.sendCommandTo(window, command, ...args)+ }+ }+ }++ sendCommandToAll (command, ...args) {+ if (!this.emit(command, ...args)) {+ this.windowManager.getWindows().forEach(window => {+ this.windowManager.sendCommandTo(window, command, ...args)+ })+ }+ }++ sendMessageToAll (channel, ...args) {+ this.windowManager.getWindows().forEach(window => {+ this.windowManager.sendMessageTo(window, channel, ...args)+ })+ }++ initProtocolManager () {+ if (is.mas()) {+ return+ }+ this.protocolManager = new ProtocolManager()+ }++ handleProtocol (event, url) {+ if (is.mas()) {+ return+ }+ this.protocolManager.handle(event, url)+ this.showPage('index')+ }++ initUpdaterManager () {+ if (is.mas()) {+ return+ }+ this.updateManager = new UpdateManager()+ this.handleUpdaterEvents()+ }++ handleUpdaterEvents () {+ this.updateManager.on('checking', (event) => {+ this.menuManager.updateMenuItemEnabledState('app.check-for-updates', false)+ })++ this.updateManager.on('download-progress', (event) => {+ const win = this.windowManager.getWindow('index')+ win.setProgressBar(event.percent / 100)+ })++ this.updateManager.on('update-not-available', (event) => {+ this.menuManager.updateMenuItemEnabledState('app.check-for-updates', true)+ })++ this.updateManager.on('update-downloaded', (event) => {+ this.menuManager.updateMenuItemEnabledState('app.check-for-updates', true)+ const win = this.windowManager.getWindow('index')+ win.setProgressBar(0)+ })++ this.updateManager.on('will-updated', (event) => {+ this.windowManager.setWillQuit(true)+ })++ this.updateManager.on('error', (event) => {+ this.menuManager.updateMenuItemEnabledState('app.check-for-updates', true)+ })+ }++ relaunch (page = 'index') {+ this.stop()+ app.relaunch()+ app.exit()+ // this.closePage(page)+ // if (page === 'index') {+ // this.engine.restart()+ // }+ // setTimeout(() => {+ // this.showPage(page)+ // }, 500)+ }++ handleCommands () {+ this.on('application:relaunch', () => {+ this.relaunch()+ })++ this.on('application:exit', () => {+ this.engine.stop()+ app.exit()+ })++ this.on('application:show', (page = 'index') => {+ this.showPage(page)+ })++ this.on('application:reset', () => {+ this.configManager.reset()+ this.relaunch()+ })++ this.on('application:check-for-updates', () => {+ this.updateManager.check()+ })++ this.on('application:set-locale', (locale) => {+ this.menuManager.setup(locale)+ })++ this.on('help:official-website', () => {+ const url = 'https://moapp.me/'+ shell.openExternal(url)+ })++ this.on('help:manual', () => {+ const url = 'https://moapp.me/manual'+ shell.openExternal(url)+ })++ this.on('help:release-notes', () => {+ const url = 'https://moapp.me/release'+ shell.openExternal(url)+ })++ this.on('help:report-problem', () => {+ const url = 'https://moapp.me/report'+ shell.openExternal(url)+ })+ }++ handleIpcMessages () {+ ipcMain.on('command', (event, command, ...args) => {+ logger.log('receive command', command, ...args)+ this.emit(command, ...args)+ })++ ipcMain.on('update-menu-states', (event, visibleStates, enabledStates, checkedStates) => {+ this.menuManager.updateStates(visibleStates, enabledStates, checkedStates)+ })+ }+}diff --git a/src/main/configs/engine.js b/src/main/configs/engine.jsnew file mode 100644index 00000000..07eff08e--- /dev/null+++ b/src/main/configs/engine.js@@ -0,0 +1,5 @@+export default {+ 'darwin': 'aria2c',+ 'win32': 'aria2c.exe',+ 'linux': 'aria2c'+}diff --git a/src/main/configs/page.js b/src/main/configs/page.jsnew file mode 100644index 00000000..dc54f91d--- /dev/null+++ b/src/main/configs/page.js@@ -0,0 +1,29 @@+import is from 'electron-is'++export default {+ index: {+ attrs: {+ title: 'Motrix',+ width: 1024,+ height: 768,+ minWidth: 840,+ minHeight: 420,+ // backgroundColor: '#FFFFFF',+ transparent: true+ },+ bindCloseToHide: true,+ url: is.dev() ? `http://localhost:9080` : `file://${__dirname}/index.html`+ },+ about: {+ attrs: {+ title: '关于',+ width: 580,+ height: 320,+ backgroundColor: '#FFFFFF',+ resizable: false,+ minimizable: false,+ maximizable: false+ },+ url: is.dev() ? `http://localhost:9080/about` : `file://${__dirname}/about.html`+ }+}diff --git a/src/main/configs/protocol.js b/src/main/configs/protocol.jsnew file mode 100644index 00000000..85408563--- /dev/null+++ b/src/main/configs/protocol.js@@ -0,0 +1,8 @@+export default {+ 'task-list': 'application:task-list',+ 'new-task': 'application:new-task',+ 'pause-all-task': 'application:pause-all-task',+ 'resume-all-task': 'application:resume-all-task',+ 'preferences': 'application:preferences',+ 'about': 'application:about'+}diff --git a/src/main/core/ConfigManager.js b/src/main/core/ConfigManager.jsnew file mode 100644index 00000000..6ef10173--- /dev/null+++ b/src/main/core/ConfigManager.js@@ -0,0 +1,94 @@+import { app } from 'electron'+import Store from 'electron-store'+import {+ getLogPath,+ getSessionPath,+ getUserDownloadsPath+} from '../utils/index'++export default class ConfigManager {+ constructor () {+ this.systemConfig = {}+ this.userConfig = {}++ this.init()+ }++ init () {+ this.initSystemConfig()+ this.initUserConfig()+ }++ initSystemConfig () {+ this.systemConfig = new Store({+ name: 'system',+ defaults: {+ dir: getUserDownloadsPath(),+ continue: true, // 断点续传+ pause: true,+ split: 32,+ 'rpc-listen-port': 16800,+ 'rpc-secret': '',+ 'auto-file-renaming': true,+ 'allow-overwrite': true,+ 'max-concurrent-downloads': 5,+ 'max-connection-per-server': 64,+ 'min-split-size': '1M',+ 'max-overall-download-limit': 0,+ 'max-overall-upload-limit': 0,+ 'max-download-limit': 0,+ 'all-proxy': '',+ 'user-agent': 'Transmission/2.94'+ }+ })+ }++ initUserConfig () {+ this.userConfig = new Store({+ name: 'user',+ defaults: {+ 'resume-all-when-app-launched': false,+ 'task-notification': true,+ 'new-task-show-downloading': true,+ 'auto-check-for-updates': false,+ 'update-channel': 'latest',+ 'use-proxy': false,+ 'all-proxy-backup': '',+ 'log-path': getLogPath(),+ 'session-path': getSessionPath(),+ 'locale': app.getLocale()+ }+ })+ }++ getSystemConfig (key, defaultValue) {+ if (typeof key === 'undefined' &&+ typeof defaultValue === 'undefined') {+ return this.systemConfig.store+ }++ return this.systemConfig.get(key, defaultValue)+ }++ getUserConfig (key, defaultValue) {+ if (typeof key === 'undefined' &&+ typeof defaultValue === 'undefined') {+ return this.userConfig.store+ }++ return this.userConfig.get(key, defaultValue)+ }++ setSystemConfig (...args) {+ this.systemConfig.set(...args)+ }++ setUserConfig (...args) {+ this.userConfig.set(...args)+ }++ reset () {+ this.systemConfig.clear()+ this.userConfig.clear()+ }+}diff --git a/src/main/core/Context.js b/src/main/core/Context.jsnew file mode 100644index 00000000..39ea9ef1--- /dev/null+++ b/src/main/core/Context.js@@ -0,0 +1,3 @@+export default class Context {++}diff --git a/src/main/core/EnergyManager.js b/src/main/core/EnergyManager.jsnew file mode 100644index 00000000..9a85494b--- /dev/null+++ b/src/main/core/EnergyManager.js@@ -0,0 +1,23 @@+import { powerSaveBlocker } from 'electron'++let psbId = null+export default class EnergyManager {+ startPowerSaveBlocker () {+ if (psbId && powerSaveBlocker.isStarted(psbId)) {+ return+ }++ psbId = powerSaveBlocker.start('prevent-app-suspension')+ console.log('startPowerSaveBlocker===>', psbId)+ }++ stopPowerSaveBlocker () {+ if (!psbId || !powerSaveBlocker.isStarted(psbId)) {+ return+ }++ powerSaveBlocker.stop(psbId)+ console.log('stopPowerSaveBlocker===>', psbId)+ psbId = null+ }+}diff --git a/src/main/core/Engine.js b/src/main/core/Engine.jsnew file mode 100644index 00000000..4d983def--- /dev/null+++ b/src/main/core/Engine.js@@ -0,0 +1,98 @@+'use strict'++import { app } from 'electron'+import is from 'electron-is'+import { existsSync } from 'fs'+import { resolve, join } from 'path'+import forever from 'forever-monitor'+import logger from './Logger'+import { getEngineBin, getSessionPath, transformConfig } from '../utils/index'++export default class Engine {+ static instance = null++ constructor (options = {}) {+ this.systemConfig = options.systemConfig+ this.userConfig = options.userConfig+ }++ getStartSh () {+ const { platform } = process+ let basePath = resolve(app.getAppPath(), '..').replace(/(\s)/, '\\ ')+ logger.info('basePath===>', basePath)++ if (is.dev()) {+ basePath = resolve(__dirname, `../../../extra/${platform}`)+ }++ const binName = getEngineBin(platform)+ if (!binName) {+ throw new Error('引擎已损坏,请重新安装: (')+ }+ const binPath = join(basePath, `/engine/${binName}`)+ const confPath = join(basePath, '/engine/aria2.conf')++ let sessionPath = this.userConfig['session-path'] || getSessionPath()+ logger.info('sessionPath===>', sessionPath)+ let result = [`${binPath}`, `--conf-path=${confPath}`, `--save-session=${sessionPath}`]++ const sessionIsExist = existsSync(sessionPath)+ logger.info('sessionIsExist===>', sessionIsExist)++ if (sessionIsExist) {+ result = [...result, `--input-file=${sessionPath}`]+ }++ const extraConfig = transformConfig(this.systemConfig)+ result = [...result, ...extraConfig]++ return result+ }++ start () {+ const sh = this.getStartSh()+ logger.info('[Motrix] Engine start===>', sh)+ this.instance = forever.start(sh, {+ max: 3,+ silent: false // !is.dev()+ })++ logger.info('[Motrix] Engine pid===>', this.instance.child.pid)++ this.instance.on('exit:code', function (code) {+ logger.info(`[Motrix] Engine has exited after 3 restarts===> ${code}`)+ })++ this.instance.on('error', (err) => {+ logger.info(`[Motrix] Engine has exited after 3 restarts===> ${err}`)+ })+ }++ stop () {+ const { pid } = this.instance.child+ try {+ logger.info('[Motrix] Engine stopping===>')+ this.instance.stop()+ logger.info('[Motrix] Engine stopped===>', this.instance)+ } catch (err) {+ logger.error('[Motrix] Engine stop fail===>', err)+ this.forceStop(pid)+ } finally {+ }+ }++ forceStop (pid) {+ try {+ if (pid) {+ process.kill(pid)+ }+ } catch (err) {+ logger.warn('[Motrix] Engine forceStop fail===>', err)+ }+ }++ restart () {+ this.stop()+ this.start()+ }+}diff --git a/src/main/core/Logger.js b/src/main/core/Logger.jsnew file mode 100644index 00000000..8929766b--- /dev/null+++ b/src/main/core/Logger.js@@ -0,0 +1,7 @@+import is from 'electron-is'+import logger from 'electron-log'++logger.transports.file.level = is.production() ? 'warn' : 'info'+logger.info('Logger init')++export default loggerdiff --git a/src/main/core/ProtocolManager.js b/src/main/core/ProtocolManager.jsnew file mode 100644index 00000000..1f9b5ff6--- /dev/null+++ b/src/main/core/ProtocolManager.js@@ -0,0 +1,38 @@++import { EventEmitter } from 'events'+import { app } from 'electron'+import * as URL from 'url'+import logger from './Logger'+import protocolMap from '../configs/protocol'++export default class ProtocolManager extends EventEmitter {+ constructor (options = {}) {+ super()+ this.options = options++ this.init()+ }++ init () {+ // package.json:build.mac.protocols[].schemes[]+ app.setAsDefaultProtocolClient('motrix')+ }++ handle (event, url) {+ logger.info(`[Motrix] protocol url: ${url}`)+ const parsed = URL.parse(url)+ const { host } = parsed+ logger.info('[Motrix] protocol parsed:', parsed, host)++ const command = protocolMap[host]+ if (!command) {+ return+ }++ // @TODO 没想明白怎么传参数好+ // 如果按顺序传递,那 url 的 query string 就要求有序的了+ // const query = queryString.parse(parsed.query)+ const args = []+ global.application.sendCommand(command, ...args)+ }+}diff --git a/src/main/core/UpdateManager.js b/src/main/core/UpdateManager.jsnew file mode 100644index 00000000..3d79e68a--- /dev/null+++ b/src/main/core/UpdateManager.js@@ -0,0 +1,100 @@+import { EventEmitter } from 'events'+import { dialog } from 'electron'+import is from 'electron-is'+import { autoUpdater } from 'electron-updater'+import { resolve } from 'path'+import logger from './Logger'++if (is.dev()) {+ autoUpdater.updateConfigPath = resolve(__dirname, '../../../app-update.yml')+}++export default class UpdateManager extends EventEmitter {+ constructor (options = {}) {+ super()+ this.options = options++ this.updater = autoUpdater+ this.updater.logger = logger+ this.init()+ }++ init () {+ // Event: error+ // Event: checking-for-update+ // Event: update-available+ // Event: update-not-available+ // Event: download-progress+ // Event: update-downloaded++ this.updater.on('checking-for-update', this.checkingForUpdate.bind(this))+ this.updater.on('update-available', this.updateAvailable.bind(this))+ this.updater.on('update-not-available', this.updateNotAvailable.bind(this))+ this.updater.on('download-progress', this.updateDownloadProgress.bind(this))+ this.updater.on('download-downloaded', this.updateDownloaded.bind(this))+ this.updater.on('error', this.updateError.bind(this))+ }++ check () {+ this.updater.checkForUpdates()+ }++ checkingForUpdate () {+ this.emit('checking')+ }++ updateAvailable (event, info) {+ this.emit('update-available', info)+ dialog.showMessageBox({+ type: 'info',+ title: '发现新版本',+ message: '发现新版本,是否现在更新?',+ buttons: ['是', '否'],+ cancelId: 1+ }, (buttonIndex) => {+ if (buttonIndex === 0) {+ this.updater.downloadUpdate()+ }+ })+ }++ updateNotAvailable (event, info) {+ this.emit('update-not-available', info)+ dialog.showMessageBox({+ title: '没有更新的版本',+ message: '您目前使用的已是最新版本'+ })+ }++ /**+ * autoUpdater:download-progress+ * @param {Object} event+ * progress,+ * bytesPerSecond,+ * percent,+ * total,+ * transferred+ */+ updateDownloadProgress (event) {+ this.emit('download-progress', event)+ }++ updateDownloaded (event, info) {+ this.emit('update-downloaded', info)+ dialog.showMessageBox({+ title: '安装更新',+ message: '更新下载完成,应用程序将退出并开始更新...'+ }, () => {+ this.emit('will-updated')+ setImmediate(() => {+ this.updater.quitAndInstall()+ })+ })+ }++ updateError (event, error) {+ this.emit('update-error', error)+ const msg = error == null ? '未知错误' : (error.stack || error).toString()+ dialog.showErrorBox('错误: ', msg)+ }+}diff --git a/src/main/index.dev.js b/src/main/index.dev.jsnew file mode 100644index 00000000..7b00245f--- /dev/null+++ b/src/main/index.dev.js@@ -0,0 +1,27 @@+/**+ * This file is used specifically and only for development. It installs+ * `electron-debug` & `vue-devtools`. There shouldn't be any need to+ * modify this file, but it can be used to extend your development+ * environment.+ */++/* eslint-disable */++// Install `electron-debug` with `devtron`+require('electron-debug')({+ // devToolsMode: 'right',+ showDevTools: true+})++// Install `vue-devtools`+require('electron').app.on('ready', () => {+ let installExtension = require('electron-devtools-installer')+ installExtension.default(installExtension.VUEJS_DEVTOOLS)+ .then(() => {})+ .catch(err => {+ console.log('Unable to install `vue-devtools`: \n', err)+ })+})++// Require `main` process to boot app+require('./index')diff --git a/src/main/index.js b/src/main/index.jsnew file mode 100644index 00000000..dbc0f235--- /dev/null+++ b/src/main/index.js@@ -0,0 +1,63 @@+import { app } from 'electron'+import is from 'electron-is'++import logger from './core/Logger'+import Application from './Application'++if (process.env.NODE_ENV !== 'development') {+ global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')+}++function init () {+ app.on('ready', () => {+ global.application = new Application()++ global.application.start('index')+ })++ app.on('will-quit', () => {+ logger.warn('will-quit')+ global.application && global.application.stop()+ })++ // Quit when all windows are closed.+ app.on('window-all-closed', function () {+ // On OS X it's common NOT to close app even if all windows are closed+ if (process.platform !== 'darwin') {+ app.quit()+ }+ })++ app.on('activate', () => {+ global.application.showPage('index')+ })++ if (is.mas()) {+ return+ }+ /**+ * May not working on MAS build+ * https://stackoverflow.com/questions/26601840/making-app-default-handler-on-osx-10-10-with-sandbox-enabled+ */+ app.on('open-url', (event, url) => {+ logger.info(`You arrived from: ${url}`)+ global.application.handleProtocol(event, url)+ })+}++// Mac App Store Sandboxed App Not support requestSingleInstanceLock+if (is.mas()) {+ init()+} else {+ const gotSingleLock = app.requestSingleInstanceLock()++ if (!gotSingleLock) {+ app.quit()+ } else {+ app.on('second-instance', (event, commandLine, workingDirectory) => {+ global.application.showPage('index')+ })++ init()+ }+}diff --git a/src/main/menus/darwin.js b/src/main/menus/darwin.jsnew file mode 100644index 00000000..e69de29bdiff --git a/src/main/menus/en-US/darwin.json b/src/main/menus/en-US/darwin.jsonnew file mode 100644index 00000000..634aca69--- /dev/null+++ b/src/main/menus/en-US/darwin.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "About Motrix", "id": "app.about", "command": "application:about", "command-before": "application:show,index"},+ { "type": "separator" },+ { "label": "Preferences...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "Check for Updates...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "Services", "role": "services", "submenu": [] },+ { "label": "Hide Motrix", "role": "hide" },+ { "label": "Hide Others", "role": "hideothers" },+ { "label": "Show All", "role": "unhide" },+ { "type": "separator" },+ { "label": "Quit Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "Task",+ "id": "task",+ "submenu": [+ { "label": "New Task", "id": "task.new-task", "command": "application:new-task", "command-arg": "uri", "command-after": "application:show,index"},+ { "label": "New BT Task", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent", "command-after": "application:show,index"},+ { "type": "separator" },+ { "label": "Pause Task", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "Resume Task", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "Delete Task", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "Move Task Up", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "Move Task Down", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "Pause All Task", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "Resume All Task", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "Clear Recent Tasks", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "Edit",+ "id": "edit",+ "submenu": [+ { "label": "Undo", "id": "edit.undo", "role": "undo" },+ { "label": "Redo", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "Cut", "id": "edit.cut", "role": "cut" },+ { "label": "Copy", "id": "edit.copy", "role": "copy" },+ { "label": "Paste", "id": "edit.paste", "role": "paste" },+ { "label": "Delete", "id": "edit.delete", "role": "delete" },+ { "label": "Select All", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "Window",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "Reload", "id": "view.reload", "role": "reload" },+ { "label": "Close", "role": "close" },+ { "label": "Minimize", "role": "minimize" },+ { "label": "Zoom", "role": "zoom" },+ { "label": "Enter Full Screen", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "Bring All to Front", "role": "front" }+ ]+ },+ {+ "label": "Help",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix Website", "id": "help.official-website", "command": "help:official-website" },+ { "label": "Manual", "id": "help.manual", "command": "help:manual" },+ { "label": "Release Notes...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "Report Problem", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "Toggle Developer Tools", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/menus/en-US/linux.json b/src/main/menus/en-US/linux.jsonnew file mode 100644index 00000000..7cc51db9--- /dev/null+++ b/src/main/menus/en-US/linux.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "About Motrix", "id": "app.about", "command": "application:about" },+ { "type": "separator" },+ { "label": "Preferences...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "Check for Updates...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "Services", "role": "services", "submenu": [] },+ { "label": "Hide Motrix", "role": "hide" },+ { "label": "Hide Others", "role": "hideothers" },+ { "label": "Show All", "role": "unhide" },+ { "type": "separator" },+ { "label": "Quit Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "Task",+ "id": "task",+ "submenu": [+ { "label": "New Task", "id": "task.new-task", "command": "application:new-task", "command-arg": "uri" },+ { "label": "New BT Task", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent" },+ { "type": "separator" },+ { "label": "Pause Task", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "Resume Task", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "Delete Task", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "Move Task Up", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "Move Task Down", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "Pause All Task", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "Resume All Task", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "Clear Recent Tasks", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "Edit",+ "id": "edit",+ "submenu": [+ { "label": "Undo", "id": "edit.undo", "role": "undo" },+ { "label": "Redo", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "Cut", "id": "edit.cut", "role": "cut" },+ { "label": "Copy", "id": "edit.copy", "role": "copy" },+ { "label": "Paste", "id": "edit.paste", "role": "paste" },+ { "label": "Delete", "id": "edit.delete", "role": "delete" },+ { "label": "Select All", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "Window",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "Reload", "id": "view.reload", "role": "reload" },+ { "label": "Close", "role": "close" },+ { "label": "Minimize", "role": "minimize" },+ { "label": "Zoom", "role": "zoom" },+ { "label": "Enter Full Screen", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "Bring All to Front", "role": "front" }+ ]+ },+ {+ "label": "Help",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix Website", "id": "help.official-website", "command": "help:official-website" },+ { "label": "Manual", "id": "help.manual", "command": "help:manual" },+ { "label": "Release Notes...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "Report Problem", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "Toggle Developer Tools", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/menus/en-US/win32.json b/src/main/menus/en-US/win32.jsonnew file mode 100644index 00000000..634aca69--- /dev/null+++ b/src/main/menus/en-US/win32.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "About Motrix", "id": "app.about", "command": "application:about", "command-before": "application:show,index"},+ { "type": "separator" },+ { "label": "Preferences...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "Check for Updates...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "Services", "role": "services", "submenu": [] },+ { "label": "Hide Motrix", "role": "hide" },+ { "label": "Hide Others", "role": "hideothers" },+ { "label": "Show All", "role": "unhide" },+ { "type": "separator" },+ { "label": "Quit Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "Task",+ "id": "task",+ "submenu": [+ { "label": "New Task", "id": "task.new-task", "command": "application:new-task", "command-arg": "uri", "command-after": "application:show,index"},+ { "label": "New BT Task", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent", "command-after": "application:show,index"},+ { "type": "separator" },+ { "label": "Pause Task", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "Resume Task", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "Delete Task", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "Move Task Up", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "Move Task Down", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "Pause All Task", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "Resume All Task", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "Clear Recent Tasks", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "Edit",+ "id": "edit",+ "submenu": [+ { "label": "Undo", "id": "edit.undo", "role": "undo" },+ { "label": "Redo", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "Cut", "id": "edit.cut", "role": "cut" },+ { "label": "Copy", "id": "edit.copy", "role": "copy" },+ { "label": "Paste", "id": "edit.paste", "role": "paste" },+ { "label": "Delete", "id": "edit.delete", "role": "delete" },+ { "label": "Select All", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "Window",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "Reload", "id": "view.reload", "role": "reload" },+ { "label": "Close", "role": "close" },+ { "label": "Minimize", "role": "minimize" },+ { "label": "Zoom", "role": "zoom" },+ { "label": "Enter Full Screen", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "Bring All to Front", "role": "front" }+ ]+ },+ {+ "label": "Help",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix Website", "id": "help.official-website", "command": "help:official-website" },+ { "label": "Manual", "id": "help.manual", "command": "help:manual" },+ { "label": "Release Notes...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "Report Problem", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "Toggle Developer Tools", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/menus/touchBar.json b/src/main/menus/touchBar.jsonnew file mode 100644index 00000000..956a5863--- /dev/null+++ b/src/main/menus/touchBar.json@@ -0,0 +1,35 @@+[+ {+ "type": "button", "icon": "new-task", "id": "task.new-task", "command": "application:new-task", "command-arg": "uri", "command-after": "application:show,index"+ },+ {+ "type": "spacer", "size": "small"+ },+ {+ "type": "group",+ "id": "task.task-list",+ "items": [+ {+ "type": "button", "icon": "task-active", "command": "application:task-list", "command-arg": "active"+ },+ {+ "type": "button", "icon": "task-waiting", "command": "application:task-list", "command-arg": "waiting"+ },+ {+ "type": "button", "icon": "task-stopped", "command": "application:task-list", "command-arg": "stopped"+ }+ ]+ },+ {+ "type": "spacer", "size": "large"+ },+ {+ "type": "button", "icon": "preferences", "id": "app.preferences", "command": "application:preferences"+ },+ {+ "type": "spacer", "size": "small"+ },+ {+ "type": "button", "icon": "about", "id": "app.about", "command": "application:about", "command-before": "application:show,index"+ }+]diff --git a/src/main/menus/zh-CN/darwin.json b/src/main/menus/zh-CN/darwin.jsonnew file mode 100644index 00000000..d1608227--- /dev/null+++ b/src/main/menus/zh-CN/darwin.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "关于 Motrix", "id": "app.about", "command": "application:about", "command-before": "application:show,index"},+ { "type": "separator" },+ { "label": "偏好设置...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "检查更新...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "服务", "role": "services", "submenu": [] },+ { "label": "隐藏 Motrix", "role": "hide" },+ { "label": "隐藏其他", "role": "hideothers" },+ { "label": "显示全部", "role": "unhide" },+ { "type": "separator" },+ { "label": "退出 Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "任务",+ "id": "task",+ "submenu": [+ { "label": "新建任务", "id": "task.new-task", "command": "application:new-task", "command-after": "application:show,index"},+ { "label": "新建 BT 任务", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent", "command-after": "application:show,index"},+ { "type": "separator" },+ { "label": "暂停任务", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "恢复任务", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "删除任务", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "上移任务", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "下移任务", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "暂停所有任务", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "恢复所有任务", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "清除最近的下载记录", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "编辑",+ "id": "edit",+ "submenu": [+ { "label": "撤销", "id": "edit.undo", "role": "undo" },+ { "label": "重做", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "剪切", "id": "edit.cut", "role": "cut" },+ { "label": "复制", "id": "edit.copy", "role": "copy" },+ { "label": "黏贴", "id": "edit.paste", "role": "paste" },+ { "label": "删除", "id": "edit.delete", "role": "delete" },+ { "label": "全选", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "窗口",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "重新加载", "id": "view.reload", "role": "reload" },+ { "label": "关闭", "role": "close" },+ { "label": "最小化", "role": "minimize" },+ { "label": "放大", "role": "zoom" },+ { "label": "进入全屏幕", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "前置全部窗口", "role": "front" }+ ]+ },+ {+ "label": "帮助",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix 官网", "id": "help.official-website", "command": "help:official-website" },+ { "label": "使用手册", "id": "help.manual", "command": "help:manual" },+ { "label": "发行说明...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "报告问题", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "开发者工具", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/menus/zh-CN/linux.json b/src/main/menus/zh-CN/linux.jsonnew file mode 100644index 00000000..f4b83ac7--- /dev/null+++ b/src/main/menus/zh-CN/linux.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "关于 Motrix", "id": "app.about", "command": "application:about" },+ { "type": "separator" },+ { "label": "偏好设置...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "检查更新...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "服务", "role": "services", "submenu": [] },+ { "label": "隐藏 Motrix", "role": "hide" },+ { "label": "隐藏其他", "role": "hideothers" },+ { "label": "显示全部", "role": "unhide" },+ { "type": "separator" },+ { "label": "退出 Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "任务",+ "id": "task",+ "submenu": [+ { "label": "新建任务", "id": "task.new-task", "command": "application:new-task" },+ { "label": "新建 BT 任务", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent" },+ { "type": "separator" },+ { "label": "暂停任务", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "恢复任务", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "删除任务", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "上移任务", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "下移任务", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "暂停所有任务", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "恢复所有任务", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "清除最近的下载记录", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "编辑",+ "id": "edit",+ "submenu": [+ { "label": "撤销", "id": "edit.undo", "role": "undo" },+ { "label": "重做", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "剪切", "id": "edit.cut", "role": "cut" },+ { "label": "复制", "id": "edit.copy", "role": "copy" },+ { "label": "黏贴", "id": "edit.paste", "role": "paste" },+ { "label": "删除", "id": "edit.delete", "role": "delete" },+ { "label": "全选", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "窗口",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "重新加载", "id": "view.reload", "role": "reload" },+ { "label": "关闭", "role": "close" },+ { "label": "最小化", "role": "minimize" },+ { "label": "放大", "role": "zoom" },+ { "label": "进入全屏幕", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "前置全部窗口", "role": "front" }+ ]+ },+ {+ "label": "帮助",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix 官网", "id": "help.official-website", "command": "help:official-website" },+ { "label": "使用手册", "id": "help.manual", "command": "help:manual" },+ { "label": "发行说明...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "报告问题", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "开发者工具", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/menus/zh-CN/win32.json b/src/main/menus/zh-CN/win32.jsonnew file mode 100644index 00000000..d1608227--- /dev/null+++ b/src/main/menus/zh-CN/win32.json@@ -0,0 +1,81 @@+{+ "menu": [+ {+ "label": "Motrix",+ "id": "app",+ "submenu": [+ { "label": "关于 Motrix", "id": "app.about", "command": "application:about", "command-before": "application:show,index"},+ { "type": "separator" },+ { "label": "偏好设置...", "id": "app.preferences", "command": "application:preferences" },+ { "label": "检查更新...", "id": "app.check-for-updates", "command": "application:check-for-updates" },+ { "label": "服务", "role": "services", "submenu": [] },+ { "label": "隐藏 Motrix", "role": "hide" },+ { "label": "隐藏其他", "role": "hideothers" },+ { "label": "显示全部", "role": "unhide" },+ { "type": "separator" },+ { "label": "退出 Motrix", "id": "app.quit", "role": "quit" }+ ]+ },+ {+ "label": "任务",+ "id": "task",+ "submenu": [+ { "label": "新建任务", "id": "task.new-task", "command": "application:new-task", "command-after": "application:show,index"},+ { "label": "新建 BT 任务", "id": "task.new-bt-task", "command": "application:new-bt-task", "command-arg": "torrent", "command-after": "application:show,index"},+ { "type": "separator" },+ { "label": "暂停任务", "id": "task.pause-task", "command": "application:pause-task" },+ { "label": "恢复任务", "id": "task.resume-task", "command": "application:resume-task" },+ { "label": "删除任务", "id": "task.delete-task", "command": "application:delete-task" },+ { "label": "上移任务", "id": "task.move-task-up", "command": "application:move-task-up" },+ { "label": "下移任务", "id": "task.move-task-down", "command": "application:move-task-down" },+ { "type": "separator" },+ { "label": "暂停所有任务", "id": "task.pause-all-task", "command": "application:pause-all-task" },+ { "label": "恢复所有任务", "id": "task.resume-all-task", "command": "application:resume-all-task" },+ { "type": "separator" },+ { "label": "清除最近的下载记录", "id": "task.clear-recent-tasks", "command": "application:clear-recent-tasks" }+ ]+ },+ {+ "label": "编辑",+ "id": "edit",+ "submenu": [+ { "label": "撤销", "id": "edit.undo", "role": "undo" },+ { "label": "重做", "id": "edit.redo", "role": "redo" },+ { "type": "separator" },+ { "label": "剪切", "id": "edit.cut", "role": "cut" },+ { "label": "复制", "id": "edit.copy", "role": "copy" },+ { "label": "黏贴", "id": "edit.paste", "role": "paste" },+ { "label": "删除", "id": "edit.delete", "role": "delete" },+ { "label": "全选", "id": "edit.select-all", "role": "selectall" }+ ]+ },+ {+ "label": "窗口",+ "role": "window",+ "id": "window",+ "submenu": [+ { "label": "重新加载", "id": "view.reload", "role": "reload" },+ { "label": "关闭", "role": "close" },+ { "label": "最小化", "role": "minimize" },+ { "label": "放大", "role": "zoom" },+ { "label": "进入全屏幕", "role": "togglefullscreen" },+ { "type": "separator" },+ { "label": "前置全部窗口", "role": "front" }+ ]+ },+ {+ "label": "帮助",+ "role": "help",+ "id": "help",+ "submenu": [+ { "label": "Motrix 官网", "id": "help.official-website", "command": "help:official-website" },+ { "label": "使用手册", "id": "help.manual", "command": "help:manual" },+ { "label": "发行说明...", "id": "help.release-notes", "command": "help:release-notes" },+ { "type": "separator" },+ { "label": "报告问题", "id": "help.report-problem", "command": "help:report-problem" },+ { "type": "separator" },+ { "label": "开发者工具", "id": "help.toggle-dev-tools", "role": "toggledevtools" }+ ]+ }+ ]+}diff --git a/src/main/pages/about.html b/src/main/pages/about.htmlnew file mode 100644index 00000000..a148fe65--- /dev/null+++ b/src/main/pages/about.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta http-equiv="X-UA-Compatible" content="ie=edge">+ <title>Document</title>+</head>+<body>++</body>+</html>diff --git a/src/main/pages/index.html b/src/main/pages/index.htmlnew file mode 100644index 00000000..a148fe65--- /dev/null+++ b/src/main/pages/index.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <meta http-equiv="X-UA-Compatible" content="ie=edge">+ <title>Document</title>+</head>+<body>++</body>+</html>diff --git a/src/main/ui/MenuManager.js b/src/main/ui/MenuManager.jsnew file mode 100644index 00000000..52db43a8--- /dev/null+++ b/src/main/ui/MenuManager.js@@ -0,0 +1,64 @@+import { EventEmitter } from 'events'+import { Menu } from 'electron'+import {+ translateTemplate,+ flattenMenuItems,+ updateStates+} from '../utils/menu'+import keymap from '@shared/keymap'++export default class MenuManager extends EventEmitter {+ constructor (options) {+ super()+ this.options = options++ this.keymap = keymap+ this.template = []++ this.menu = null+ this.items = {}+ }++ load (locale = 'en-US') {+ let template = require(`../menus/${locale}/${process.platform}.json`)+ if (!template) {+ template = require(`../menus/en-US/${process.platform}.json`)+ }+ this.template = template['menu']+ }++ build () {+ const keystrokesByCommand = {}+ for (let item in this.keymap) {+ keystrokesByCommand[this.keymap[item]] = item+ }++ const tpl = translateTemplate(this.template, keystrokesByCommand)+ this.menu = Menu.buildFromTemplate(tpl)+ }++ setup (locale) {+ this.load(locale)+ this.build()+ Menu.setApplicationMenu(this.menu)+ this.items = flattenMenuItems(this.menu)+ }++ updateStates (visibleStates, enabledStates, checkedStates) {+ updateStates(this.items, visibleStates, enabledStates, checkedStates)+ }++ updateMenuItemVisibleState (id, flag) {+ const visibleStates = {+ [id]: flag+ }+ this.updateStates(visibleStates, null, null)+ }++ updateMenuItemEnabledState (id, flag) {+ const enabledStates = {+ [id]: flag+ }+ this.updateStates(null, enabledStates, null)+ }+}diff --git a/src/main/ui/TouchBarManager.js b/src/main/ui/TouchBarManager.jsnew file mode 100644index 00000000..06a23b86--- /dev/null+++ b/src/main/ui/TouchBarManager.js@@ -0,0 +1,106 @@+import { EventEmitter } from 'events'+import { join } from 'path'+import { TouchBar, nativeImage } from 'electron'+import { handleCommand } from '../utils/menu'+import logger from '../core/Logger'++const { TouchBarButton, TouchBarLabel, TouchBarSpacer, TouchBarGroup } = TouchBar++export default class TouchBarManager extends EventEmitter {+ constructor (options) {+ super()+ this.options = options+ this.bars = {}+ this.load()+ }++ load () {+ this.template = require(`../menus/touchBar.json`)+ }++ getClickFn (item) {+ let fn = () => {}+ if (item.command) {+ fn = () => {+ handleCommand(item)+ }+ }+ return fn+ }++ getIconImage (icon) {+ if (!icon) {+ return+ }+ const img = join(__static, `./icons/${icon}.png`)+ return nativeImage.createFromPath(img)+ }++ buildItem (type, options) {+ let result = null+ const { label, backgroundColor, textColor, size } = options++ switch (type) {+ case 'button':+ const icon = this.getIconImage(options.icon)+ const click = this.getClickFn(options)+ result = new TouchBarButton({+ label,+ backgroundColor,+ icon,+ click+ })+ break+ case 'label':+ result = new TouchBarLabel({+ label,+ textColor+ })+ break+ case 'spacer':+ result = new TouchBarSpacer({ size })+ break+ case 'group':+ result = new TouchBarGroup({ items: options.items })+ break+ default:+ result = null+ }++ return result+ }++ build (template) {+ const result = []++ template.forEach(tpl => {+ const { id, type, ...rest } = tpl+ let options = { ...rest }+ if (type === 'group') {+ options = { type, items: this.build(options.items) }+ }+ const item = this.buildItem(type, options)+ result.push(item)+ })+ return result+ }++ getTouchBarByPage (page) {+ let bar = this.bars[page] || null+ if (!bar) {+ try {+ const items = this.build(this.template)+ bar = new TouchBar(items)+ this.bars[page] = bar+ } catch (e) {+ logger.info('getTouchBarByPage fail', e)+ }+ }+ return bar+ }++ setup (page, window) {+ const bar = this.getTouchBarByPage(page)+ window.setTouchBar(bar)+ }+}diff --git a/src/main/ui/TrayManager.js b/src/main/ui/TrayManager.jsnew file mode 100644index 00000000..ec7601c3--- /dev/null+++ b/src/main/ui/TrayManager.js@@ -0,0 +1,3 @@+export default class TrayManager {++}diff --git a/src/main/ui/WindowManager.js b/src/main/ui/WindowManager.jsnew file mode 100644index 00000000..07540738--- /dev/null+++ b/src/main/ui/WindowManager.js@@ -0,0 +1,123 @@+import { EventEmitter } from 'events'+import { app, shell, BrowserWindow } from 'electron'+import pageConfig from '../configs/page'++const defaultBrowserOptions = {+ titleBarStyle: 'hiddenInset',+ useContentSize: true,+ show: false,+ width: 1024,+ height: 768+}++export default class WindowManager extends EventEmitter {+ constructor (options = {}) {+ super()+ this.options = options++ this.windows = {}++ this.willQuit = false++ app.on('before-quit', () => {+ this.setWillQuit(true)+ })+ }++ setWillQuit (flag) {+ this.willQuit = flag+ }++ openWindow (page) {+ const options = pageConfig[page] || {}+ let window = this.windows[page] || null+ if (window) {+ window.restore()+ window.focus()+ return window+ }++ window = new BrowserWindow({+ ...defaultBrowserOptions,+ ...options.attrs+ })++ window.webContents.on('new-window', (e, url) => {+ e.preventDefault()+ shell.openExternal(url)+ })++ if (options.url) {+ window.loadURL(options.url)+ }++ window.once('ready-to-show', () => {+ window.show()+ })++ if (options.bindCloseToHide && process.platform === 'darwin') {+ this.bindCloseToHide(page, window)+ }++ this.bindAfterClosed(page, window)++ this.addWindow(page, window)+ return window+ }++ getWindow (page) {+ return this.windows[page]+ }++ getWindows () {+ return this.windows+ }++ addWindow (page, window) {+ this.windows[page] = window+ }++ destroyWindow (page) {+ const win = this.getWindow(page)+ this.removeWindow(page)+ win.destroy()+ }++ removeWindow (page) {+ this.windows[page] = null+ }++ bindAfterClosed (page, window) {+ window.on('closed', (event) => {+ this.removeWindow(page)+ })+ }++ bindCloseToHide (page, window) {+ window.on('close', (event) => {+ if (!this.willQuit) {+ event.preventDefault()+ window.hide()+ }+ })+ }++ getFocusedWindow () {+ return BrowserWindow.getFocusedWindow()+ }++ sendCommandTo (window, command, ...args) {+ if (!window) {+ return+ }+ console.log('sendCommandTo====>', window, command, ...args)+ window.webContents.send('command', command, ...args)+ }++ sendMessageTo (window, channel, ...args) {+ if (!window) {+ return+ }+ window.webContents.send(channel, ...args)+ }+}diff --git a/src/main/utils/index.js b/src/main/utils/index.jsnew file mode 100644index 00000000..7f9d513e--- /dev/null+++ b/src/main/utils/index.js@@ -0,0 +1,35 @@+import { app } from 'electron'+import { resolve } from 'path'+import logger from '../core/Logger'+import engineBinMap from '../configs/engine'++export function getLogPath () {+ return logger.transports.file.file+}++export function getSessionPath () {+ return resolve(app.getPath('userData'), './download.session')+}++export function getUserDataPath () {+ return app.getPath('userData')+}++export function getUserDownloadsPath () {+ return app.getPath('downloads')+}++export function getEngineBin (platform) {+ let result = engineBinMap.hasOwnProperty(platform) ? engineBinMap[platform] : ''+ return result+}++export function transformConfig (config) {+ let result = []+ for (const [k, v] of Object.entries(config)) {+ if (v !== '') {+ result.push(`--${k}=${v}`)+ }+ }+ return result+}diff --git a/src/main/utils/menu.js b/src/main/utils/menu.jsnew file mode 100644index 00000000..c928b24b--- /dev/null+++ b/src/main/utils/menu.js@@ -0,0 +1,189 @@+export function concat (template, submenu, submenuToAdd) {+ submenuToAdd.forEach(sub => {+ let relativeItem = null+ if (sub.position) {+ switch (sub.position) {+ case 'first':+ submenu.unshift(sub)+ break+ case 'last':+ submenu.push(sub)+ break+ case 'before':+ relativeItem = findById(template, sub['relative-id'])+ if (relativeItem) {+ let array = relativeItem.__parent+ let index = array.indexOf(relativeItem)+ array.splice(index, 0, sub)+ }+ break+ case 'after':+ relativeItem = findById(template, sub['relative-id'])+ if (relativeItem) {+ let array = relativeItem.__parent+ let index = array.indexOf(relativeItem)+ array.splice(index + 1, 0, sub)+ }+ break+ default:+ submenu.push(sub)+ break+ }+ } else {+ submenu.push(sub)+ }+ })+}++export function merge (template, item) {+ if (item.id) {+ let matched = findById(template, item.id)+ if (matched) {+ if (item.submenu && Array.isArray(item.submenu)) {+ if (!Array.isArray(matched.submenu)) {+ matched.submenu = []+ }+ concat(template, matched.submenu, item.submenu)+ }+ } else {+ concat(template, template, [item])+ }+ } else {+ template.push(item)+ }+}++function findById (template, id) {+ for (let i in template) {+ let item = template[i]+ if (item.id === id) {+ // Returned item need to have a reference to parent Array (.__parent).+ // This is required to handle `position` and `relative-id`+ item.__parent = template+ return item+ } else if (Array.isArray(item.submenu)) {+ let result = findById(item.submenu, id)+ if (result) {+ return result+ }+ }+ }+ return null+}++export function translateTemplate (template, keystrokesByCommand) {+ for (let i in template) {+ let item = template[i]+ if (item.command) {+ item.accelerator = acceleratorForCommand(item.command, keystrokesByCommand)+ }+ item.click = () => {+ console.log('click sendCommand', item)+ handleCommand(item)+ }++ if (item.submenu) {+ translateTemplate(item.submenu, keystrokesByCommand)+ }+ }+ return template+}++export function handleCommand (item) {+ handleCommandBefore(item)++ const args = item['command-arg']+ ? [item.command, item['command-arg']]+ : [item.command]++ global.application.sendCommand(...args)++ handleCommandAfter(item)+}++function handleCommandBefore (item) {+ console.log('handleCommandBefore==1=>', item)+ if (!item['command-before']) {+ return+ }+ const [ command, ...args ] = item['command-before'].split(',')+ console.log('handleCommandBefore==2=>', command, ...args)+ global.application.sendCommand(command, ...args)+}++function handleCommandAfter (item) {+ console.log('handleCommandAfter==1=>', item)+ if (!item['command-after']) {+ return+ }+ const [ command, ...args ] = item['command-after'].split(',')+ console.log('handleCommandAfter==2=>', command, ...args)+ global.application.sendCommand(command, ...args)+}++function acceleratorForCommand (command, keystrokesByCommand) {+ const keystroke = keystrokesByCommand[command]+ if (keystroke) {+ let modifiers = keystroke.split(/-(?=.)/)+ let key = modifiers.pop().toUpperCase()+ .replace('+', 'Plus')+ .replace('MINUS', '-')+ modifiers = modifiers.map((modifier) => {+ if (process.platform === 'darwin') {+ return modifier.replace(/cmdctrl/ig, 'Cmd')+ .replace(/shift/ig, 'Shift')+ .replace(/cmd/ig, 'Cmd')+ .replace(/ctrl/ig, 'Ctrl')+ .replace(/alt/ig, 'Alt')+ } else {+ return modifier.replace(/cmdctrl/ig, 'Ctrl')+ .replace(/shift/ig, 'Shift')+ .replace(/ctrl/ig, 'Ctrl')+ .replace(/alt/ig, 'Alt')+ }+ })+ let keys = modifiers.concat([key])+ return keys.join('+')+ }+ return null+}++export function flattenMenuItems (menu) {+ let flattenItems = {}+ menu.items.forEach(item => {+ if (item.id) {+ flattenItems[item.id] = item+ if (item.submenu) {+ Object.assign(flattenItems, flattenMenuItems(item.submenu))+ }+ }+ })+ return flattenItems+}++export function updateStates (itemsById, visibleStates, enabledStates, checkedStates) {+ if (visibleStates) {+ for (let command in visibleStates) {+ let item = itemsById[command]+ if (item) {+ item.visible = visibleStates[command]+ }+ }+ }+ if (enabledStates) {+ for (let command in enabledStates) {+ let item = itemsById[command]+ if (item) {+ item.enabled = enabledStates[command]+ }+ }+ }+ if (checkedStates) {+ for (let id in checkedStates) {+ let item = itemsById[id]+ if (item) {+ item.checked = checkedStates[id]+ }+ }+ }+}diff --git a/src/renderer/api/Api.js b/src/renderer/api/Api.jsnew file mode 100644index 00000000..b4885d3e--- /dev/null+++ b/src/renderer/api/Api.js@@ -0,0 +1,259 @@+import { remote } from 'electron'+import is from 'electron-is'+import { isEmpty } from 'lodash'+import Aria2 from 'aria2'+import {+ separateConfig,+ compactUndefined,+ mergeTaskResult,+ changeKeysToCamelCase,+ changeKeysToKebabCase+} from '@shared/utils'++const application = remote.getGlobal('application')++export default class Api {+ constructor (options = {}) {+ this.options = options++ this.client = null+ this.init()+ }++ init () {+ this.loadConfig()+ this.initClient()+ }++ loadConfigFromLocalStorage () {+ // TODO+ const result = {}+ return result+ }++ loadConfigFromNativeStore () {+ const systemConfig = application.configManager.getSystemConfig()+ const userConfig = application.configManager.getUserConfig()++ const result = { ...systemConfig, ...userConfig }+ return result+ }++ loadConfig () {+ let result = is.renderer()+ ? this.loadConfigFromNativeStore()+ : this.loadConfigFromLocalStorage()++ result = changeKeysToCamelCase(result)+ this.config = result+ }++ initClient () {+ const {+ rpcListenPort: port,+ rpcSecret: secret+ } = this.config+ this.client = new Aria2({+ port,+ secret+ })+ this.client.open()+ }++ closeClient () {+ this.client.close()+ .then(() => {+ this.client = null+ })+ .catch(err => {+ console.log('engine client close fail', err)+ })+ }++ fetchPreference () {+ return new Promise((resolve) => {+ this.loadConfig()+ resolve(this.config)+ })+ }++ savePreference (params = {}) {+ const kebabParams = changeKeysToKebabCase(params)+ if (is.renderer()) {+ this.savePreferenceToNativeStore(kebabParams)+ } else {+ this.savePreferenceToLocalStorage(kebabParams)+ }+ }++ savePreferenceToLocalStorage () {+ // TODO+ }++ savePreferenceToNativeStore (params = {}) {+ const { user, system, others } = separateConfig(params)+ if (!isEmpty(system)) {+ console.info('[Motrix] save system config: ', system)+ application.configManager.setSystemConfig(system)+ }++ if (!isEmpty(user)) {+ console.info('[Motrix] save user config: ', user)+ application.configManager.setUserConfig(user)+ }++ if (!isEmpty(others)) {+ console.info('[Motrix] save config found iillegal key: ', others)+ }+ }++ getVersion () {+ return this.client.call('getVersion')+ }++ getGlobalStat () {+ return this.client.call('getGlobalStat')+ }++ addUri (params) {+ const {+ uris,+ options+ } = params+ const args = compactUndefined([uris, options])+ return this.client.call('addUri', ...args)+ }++ addTorrent (params) {+ const {+ torrent,+ options+ } = params+ const args = compactUndefined([torrent, [], options])+ return this.client.call('addTorrent', ...args)+ }++ addMetalink (params) {+ const {+ metalink,+ options+ } = params+ const args = compactUndefined([metalink, options])+ return this.client.call('addMetalink', ...args)+ }++ fetchDownloadingTaskList (params = {}) {+ const { offset = 0, num = 200, keys } = params+ const activeArgs = compactUndefined([keys])+ const waitingArgs = compactUndefined([offset, num, keys])+ return new Promise((resolve, reject) => {+ this.client.multicall([+ [ 'aria2.tellActive', ...activeArgs ],+ [ 'aria2.tellWaiting', ...waitingArgs ]+ ]).then((data) => {+ console.log('fetchDownloadingTaskList data', data)+ const result = mergeTaskResult(data)+ resolve(result)+ }).catch((err) => {+ console.log('fetchDownloadingTaskList fail===>', err)+ reject(err)+ })+ })+ }++ fetchWaitingTaskList (params = {}) {+ const { offset = 0, num = 200, keys } = params+ const args = compactUndefined([offset, num, keys])+ return this.client.call('tellWaiting', ...args)+ }++ fetchStoppedTaskList (params = {}) {+ const { offset = 0, num = 200, keys } = params+ const args = compactUndefined([offset, num, keys])+ return this.client.call('tellStopped', ...args)+ }++ fetchTaskList (params = {}) {+ const { type } = params+ switch (type) {+ case 'active':+ return this.fetchDownloadingTaskList(params)+ case 'waiting':+ return this.fetchWaitingTaskList(params)+ case 'stopped':+ return this.fetchStoppedTaskList(params)+ default:+ return this.fetchDownloadingTaskList(params)+ }+ }++ fetchTaskItem (params = {}) {+ const { gid, keys } = params+ const args = compactUndefined([gid, keys])+ return this.client.call('tellStatus', ...args)+ }++ pauseTask (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('pause', ...args)+ }++ pauseAllTask (params = {}) {+ return this.client.call('pauseAll')+ }++ forcePauseTask (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('forcePause', ...args)+ }++ forcePauseAllTask (params = {}) {+ return this.client.call('forcePauseAll')+ }++ resumeTask (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('unpause', ...args)+ }++ resumeAllTask (params = {}) {+ return this.client.call('unpauseAll')+ }++ removeTask (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('remove', ...args)+ }++ forceRemoveTask (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('forceRemove', ...args)+ }++ saveSession (params = {}) {+ return this.client.call('saveSession')+ }++ purgeTaskRecord (params = {}) {+ return this.client.call('purgeDownloadResult')+ }++ removeTaskRecord (params = {}) {+ const { gid } = params+ const args = compactUndefined([gid])+ return this.client.call('removeDownloadResult', ...args)+ }++ startPowerSaveBlocker () {+ application.energyManager.startPowerSaveBlocker()+ }++ stopPowerSaveBlocker () {+ application.energyManager.stopPowerSaveBlocker()+ }+}diff --git a/src/renderer/api/index.js b/src/renderer/api/index.jsnew file mode 100644index 00000000..066da13f--- /dev/null+++ b/src/renderer/api/index.js@@ -0,0 +1,5 @@+import Api from './Api'++const api = new Api()++export default apidiff --git a/src/renderer/assets/.gitkeep b/src/renderer/assets/.gitkeepnew file mode 100644index 00000000..e69de29bdiff --git a/src/renderer/assets/app-icon.png b/src/renderer/assets/app-icon.pngnew file mode 100644index 00000000..0f051899Binary files /dev/null and b/src/renderer/assets/app-icon.png differdiff --git a/src/renderer/assets/icons/delete.svg b/src/renderer/assets/icons/delete.svgnew file mode 100644index 00000000..66c8136a--- /dev/null+++ b/src/renderer/assets/icons/delete.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="19" y1="5" x2="5" y2="19" />+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="19" y1="19" x2="5" y2="5" />+ </g>+</svg>diff --git a/src/renderer/assets/icons/engine-mode-max.svg b/src/renderer/assets/icons/engine-mode-max.svgnew file mode 100644index 00000000..d1f4e0db--- /dev/null+++ b/src/renderer/assets/icons/engine-mode-max.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">+ <path fill="none" d="M12,3.609375 C13.1562558,3.609375 14.2460886,3.82812281 15.2695312,4.265625 C16.2929739,4.70312719 17.18359,5.30077746 17.9414062,6.05859375 C18.6992225,6.81641004 19.2968728,7.70702613 19.734375,8.73046875 C20.1718772,9.75391137 20.390625,10.8437442 20.390625,12 C20.390625,12.2187511 20.3242194,12.3984368 20.1914062,12.5390625 C20.0585931,12.6796882 19.8750012,12.75 19.640625,12.75 C19.4218739,12.75 19.2421882,12.6796882 19.1015625,12.5390625 C18.9609368,12.3984368 18.890625,12.2187511 18.890625,12 C18.890625,11.0468702 18.7109393,10.1484417 18.3515625,9.3046875 C17.9921857,8.46093328 17.5039093,7.73047184 16.8867188,7.11328125 C16.2695282,6.49609066 15.5390667,6.0078143 14.6953125,5.6484375 C13.8515583,5.2890607 12.9531298,5.109375 12,5.109375 C11.5468727,5.109375 11.0859398,5.14843711 10.6171875,5.2265625 C10.1484352,5.30468789 9.71093953,5.43749906 9.3046875,5.625 C9.11718656,5.70312539 8.92578223,5.7070316 8.73046875,5.63671875 C8.53515527,5.5664059 8.39843789,5.43750094 8.3203125,5.25 C8.24218711,5.06249906 8.2382809,4.87109473 8.30859375,4.67578125 C8.3789066,4.48046777 8.50781156,4.34375039 8.6953125,4.265625 C9.22656516,4.04687391 9.76952848,3.88281305 10.3242187,3.7734375 C10.878909,3.66406195 11.4374972,3.609375 12,3.609375 Z M5.25,8.3203125 C5.43750094,8.39843789 5.57421832,8.53515527 5.66015625,8.73046875 C5.74609418,8.92578223 5.73437555,9.11718656 5.625,9.3046875 C5.43749906,9.71093953 5.30468789,10.1406227 5.2265625,10.59375 C5.14843711,11.0468773 5.109375,11.5156226 5.109375,12 C5.109375,12.2187511 5.0390632,12.3984368 4.8984375,12.5390625 C4.7578118,12.6796882 4.57812609,12.75 4.359375,12.75 C4.12499883,12.75 3.94140691,12.6796882 3.80859375,12.5390625 C3.67578059,12.3984368 3.609375,12.2187511 3.609375,12 C3.609375,11.4374972 3.66406195,10.878909 3.7734375,10.3242188 C3.88281305,9.76952848 4.04687391,9.22656516 4.265625,8.6953125 C4.34375039,8.50781156 4.48046777,8.3789066 4.67578125,8.30859375 C4.87109473,8.2382809 5.06249906,8.24218711 5.25,8.3203125 Z M12,0 C13.6562583,0 15.2109302,0.316403086 16.6640625,0.94921875 C18.1171948,1.58203441 19.3867133,2.44140082 20.4726562,3.52734375 C21.5585992,4.61328668 22.4179656,5.88280523 23.0507812,7.3359375 C23.6835969,8.78906977 24,10.3437417 24,12 C24,13.6562583 23.6835969,15.2109302 23.0507812,16.6640625 C22.4179656,18.1171948 21.5585992,19.3867133 20.4726562,20.4726562 C19.3867133,21.5585992 18.1171948,22.4179656 16.6640625,23.0507812 C15.2109302,23.6835969 13.6562583,24 12,24 C10.3437417,24 8.78906977,23.6835969 7.3359375,23.0507812 C5.88280523,22.4179656 4.61328668,21.5585992 3.52734375,20.4726562 C2.44140082,19.3867133 1.58203441,18.1171948 0.94921875,16.6640625 C0.316403086,15.2109302 0,13.6562583 0,12 C0,10.3437417 0.316403086,8.78906977 0.94921875,7.3359375 C1.58203441,5.88280523 2.44140082,4.61328668 3.52734375,3.52734375 C4.61328668,2.44140082 5.88280523,1.58203441 7.3359375,0.94921875 C8.78906977,0.316403086 10.3437417,0 12,0 Z M12,22.5 C13.4375072,22.5 14.7968686,22.222659 16.078125,21.6679688 C17.3593814,21.1132785 18.4726515,20.3593798 19.4179688,19.40625 C20.363286,18.4531202 21.1132785,17.3398501 21.6679688,16.0664062 C22.222659,14.7929624 22.5,13.4375072 22.5,12 C22.5,10.5624928 22.222659,9.20313141 21.6679688,7.921875 C21.1132785,6.64061859 20.3593798,5.52734848 19.40625,4.58203125 C18.4531202,3.63671402 17.3398501,2.88672152 16.0664062,2.33203125 C14.7929624,1.77734098 13.4375072,1.5 12,1.5 C10.5624928,1.5 9.20313141,1.77734098 7.921875,2.33203125 C6.64061859,2.88672152 5.52734848,3.64062023 4.58203125,4.59375 C3.63671402,5.54687977 2.88672152,6.66014988 2.33203125,7.93359375 C1.77734098,9.20703762 1.5,10.5624928 1.5,12 C1.5,13.4375072 1.77734098,14.7929624 2.33203125,16.0664062 C2.88672152,17.3398501 3.64062023,18.4531202 4.59375,19.40625 C5.54687977,20.3593798 6.66014988,21.1132785 7.93359375,21.6679688 C9.20703762,22.222659 10.5624928,22.5 12,22.5 Z M12,9 C12.8281291,9 13.5351533,9.29296582 14.1210938,9.87890625 C14.7070342,10.4648467 15,11.1718709 15,12 C15,12.8281291 14.7070342,13.5351533 14.1210938,14.1210938 C13.5351533,14.7070342 12.8281291,15 12,15 C11.1718709,15 10.4648467,14.7070342 9.87890625,14.1210938 C9.29296582,13.5351533 9,12.8281291 9,12 C9,11.7343737 9.03906211,11.4726575 9.1171875,11.2148438 C9.19531289,10.95703 9.3046868,10.7187511 9.4453125,10.5 L5.765625,6.8203125 C5.6249993,6.6796868 5.5546875,6.50781352 5.5546875,6.3046875 C5.5546875,6.10156148 5.6249993,5.92187578 5.765625,5.765625 C5.92187578,5.6249993 6.10156148,5.5546875 6.3046875,5.5546875 C6.50781352,5.5546875 6.6796868,5.6249993 6.8203125,5.765625 L10.5,9.4453125 C10.7187511,9.3046868 10.95703,9.19531289 11.2148438,9.1171875 C11.4726575,9.03906211 11.7343737,9 12,9 Z M12,13.5 C12.406252,13.5 12.757811,13.351564 13.0546875,13.0546875 C13.351564,12.757811 13.5,12.406252 13.5,12 C13.5,11.593748 13.351564,11.242189 13.0546875,10.9453125 C12.757811,10.648436 12.406252,10.5 12,10.5 C11.593748,10.5 11.242189,10.648436 10.9453125,10.9453125 C10.648436,11.242189 10.5,11.593748 10.5,12 C10.5,12.406252 10.648436,12.757811 10.9453125,13.0546875 C11.242189,13.351564 11.593748,13.5 12,13.5 Z" transform="matrix(-1 0 0 1 24 0)"/>+</svg>diff --git a/src/renderer/assets/icons/folder.svg b/src/renderer/assets/icons/folder.svgnew file mode 100644index 00000000..a6badd1e--- /dev/null+++ b/src/renderer/assets/icons/folder.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="1" y1="8" x2="23" y2="8" />+ <polygon fill="none" stroke="#111111" stroke-miterlimit="10" points="23,23 1,23 1,1 10,1 12,4 23,4 " />+ </g>+</svg>diff --git a/src/renderer/assets/icons/inbox.svg b/src/renderer/assets/icons/inbox.svgnew file mode 100644index 00000000..edd6f519--- /dev/null+++ b/src/renderer/assets/icons/inbox.svg@@ -0,0 +1,8 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <polyline data-cap="butt" fill="none" stroke="#111111" stroke-miterlimit="10" points="23,15 16,15 16,18 8,18 8,15 1,15 "/>+ <line data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" x1="12" y1="1" x2="12" y2="11"/>+ <polyline fill="none" stroke="#111111" stroke-miterlimit="10" points="19,6 20,6 23,15 23,23 1,23 1,15 4,6 5,6 "/>+ <polyline data-color="color-2" fill="none" stroke-miterlimit="10" points=" 15,8 12,11 9,8 "/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/info-circle.svg b/src/renderer/assets/icons/info-circle.svgnew file mode 100644index 00000000..66f60580--- /dev/null+++ b/src/renderer/assets/icons/info-circle.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="square" stroke-linejoin="miter" stroke-width="2" fill="#111111" stroke="#111111">+ <circle cx="12" cy="12" r="11" fill="none" stroke="#111111" stroke-miterlimit="10"/>+ <line data-color="color-2" x1="11.959" y1="11" x2="11.959" y2="17" fill="none" stroke-miterlimit="10"/>+ <circle data-color="color-2" data-stroke="none" cx="11.959" cy="7" r="1" stroke="none"/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/info-square.svg b/src/renderer/assets/icons/info-square.svgnew file mode 100644index 00000000..34c719e2--- /dev/null+++ b/src/renderer/assets/icons/info-square.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="square" stroke-linejoin="miter" stroke-width="2" fill="#111111" stroke="#111111">+ <rect x="2" y="2" width="20" height="20" fill="none" stroke="#111111" stroke-miterlimit="10"/>+ <line data-color="color-2" x1="12" y1="11" x2="12" y2="17" fill="none" stroke-miterlimit="10"/>+ <circle data-color="color-2" data-stroke="none" cx="12" cy="7" r="1" stroke="none"/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/link.svg b/src/renderer/assets/icons/link.svgnew file mode 100644index 00000000..9d898a37--- /dev/null+++ b/src/renderer/assets/icons/link.svg@@ -0,0 +1,9 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <path fill="none" stroke="#111111" stroke-miterlimit="10" d="M11,6l2.5-2.5 c1.9-1.9,5.1-1.9,7,0l0,0c1.9,1.9,1.9,5.1,0,7L18,13"+ />+ <path fill="none" stroke="#111111" stroke-miterlimit="10" d="M13,18l-2.5,2.5 c-1.9,1.9-5.1,1.9-7,0l0,0c-1.9-1.9-1.9-5.1,0-7L6,11"+ />+ <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="9" y1="15" x2="15" y2="9" />+ </g>+</svg>diff --git a/src/renderer/assets/icons/menu-about.svg b/src/renderer/assets/icons/menu-about.svgnew file mode 100644index 00000000..b71648ab--- /dev/null+++ b/src/renderer/assets/icons/menu-about.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#000000" stroke="#000000"><circle fill="none" stroke="#000000" stroke-miterlimit="10" cx="12" cy="12" r="11"/> <path data-color="color-2" fill="none" stroke-miterlimit="10" d="M12,15v-2 c1.609,0,3-1.391,3-3s-1.391-3-3-3c-1.194,0-2.342,0.893-2.792,1.921"/> <circle data-color="color-2" data-stroke="none" cx="12" cy="18" r="1" stroke-linejoin="miter" stroke-linecap="square" stroke="none"/></g>+</svg>diff --git a/src/renderer/assets/icons/menu-add.svg b/src/renderer/assets/icons/menu-add.svgnew file mode 100644index 00000000..f048325c--- /dev/null+++ b/src/renderer/assets/icons/menu-add.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#000000" stroke="#000000">+ <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="12" y1="2" x2="12" y2="22" />+ <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="22" y1="12" x2="2" y2="12" />+ </g>+</svg>diff --git a/src/renderer/assets/icons/menu-preference.svg b/src/renderer/assets/icons/menu-preference.svgnew file mode 100644index 00000000..fb8ef6d5--- /dev/null+++ b/src/renderer/assets/icons/menu-preference.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#000000" stroke="#000000"><line fill="none" stroke="#000000" stroke-miterlimit="10" x1="14" y1="4" x2="23" y2="4"/> <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="1" y1="4" x2="4" y2="4"/> <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="22" y1="12" x2="23" y2="12"/> <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="1" y1="12" x2="12" y2="12"/> <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="14" y1="20" x2="23" y2="20"/> <line fill="none" stroke="#000000" stroke-miterlimit="10" x1="1" y1="20" x2="4" y2="20"/> <circle fill="none" stroke="#000000" stroke-miterlimit="10" cx="7" cy="4" r="3"/> <circle data-color="color-2" fill="none" stroke-miterlimit="10" cx="15" cy="12" r="3"/> <circle fill="none" stroke="#000000" stroke-miterlimit="10" cx="7" cy="20" r="3"/></g>+</svg>diff --git a/src/renderer/assets/icons/menu-task.svg b/src/renderer/assets/icons/menu-task.svgnew file mode 100644index 00000000..616dc3e9--- /dev/null+++ b/src/renderer/assets/icons/menu-task.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" fill="#111111">+ <path data-color="color-2" d="M14,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h13c0.6,0,1,0.4,1,1S14.6,13,14,13z"/>+ <path fill="#111111" d="M23,6H1C0.4,6,0,5.6,0,5s0.4-1,1-1h22c0.6,0,1,0.4,1,1S23.6,6,23,6z"/>+ <path fill="#111111" d="M23,20H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h22c0.6,0,1,0.4,1,1S23.6,20,23,20z"/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/more.svg b/src/renderer/assets/icons/more.svgnew file mode 100644index 00000000..2527e30c--- /dev/null+++ b/src/renderer/assets/icons/more.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">+ <path fill="#9B9B9B" fill-rule="evenodd" d="M3,15 C2.17187086,15 1.46484668,14.7070342 0.87890625,14.1210938 C0.29296582,13.5351533 0,12.8281291 0,12 C0,11.1718709 0.29296582,10.4648467 0.87890625,9.87890625 C1.46484668,9.29296582 2.17187086,9 3,9 C3.82812914,9 4.53515332,9.29296582 5.12109375,9.87890625 C5.70703418,10.4648467 6,11.1718709 6,12 C6,12.8281291 5.70703418,13.5351533 5.12109375,14.1210938 C4.53515332,14.7070342 3.82812914,15 3,15 Z M3,10.5 C2.59374797,10.5 2.24218898,10.648436 1.9453125,10.9453125 C1.64843602,11.242189 1.5,11.593748 1.5,12 C1.5,12.406252 1.64843602,12.757811 1.9453125,13.0546875 C2.24218898,13.351564 2.59374797,13.5 3,13.5 C3.40625203,13.5 3.75781102,13.351564 4.0546875,13.0546875 C4.35156398,12.757811 4.5,12.406252 4.5,12 C4.5,11.593748 4.35156398,11.242189 4.0546875,10.9453125 C3.75781102,10.648436 3.40625203,10.5 3,10.5 Z M12,15 C11.1718709,15 10.4648467,14.7070342 9.87890625,14.1210938 C9.29296582,13.5351533 9,12.8281291 9,12 C9,11.1718709 9.29296582,10.4648467 9.87890625,9.87890625 C10.4648467,9.29296582 11.1718709,9 12,9 C12.8281291,9 13.5351533,9.29296582 14.1210938,9.87890625 C14.7070342,10.4648467 15,11.1718709 15,12 C15,12.8281291 14.7070342,13.5351533 14.1210938,14.1210938 C13.5351533,14.7070342 12.8281291,15 12,15 Z M12,10.5 C11.593748,10.5 11.242189,10.648436 10.9453125,10.9453125 C10.648436,11.242189 10.5,11.593748 10.5,12 C10.5,12.406252 10.648436,12.757811 10.9453125,13.0546875 C11.242189,13.351564 11.593748,13.5 12,13.5 C12.406252,13.5 12.757811,13.351564 13.0546875,13.0546875 C13.351564,12.757811 13.5,12.406252 13.5,12 C13.5,11.593748 13.351564,11.242189 13.0546875,10.9453125 C12.757811,10.648436 12.406252,10.5 12,10.5 Z M21,9 C21.8281291,9 22.5351533,9.29296582 23.1210938,9.87890625 C23.7070342,10.4648467 24,11.1718709 24,12 C24,12.8281291 23.7070342,13.5351533 23.1210938,14.1210938 C22.5351533,14.7070342 21.8281291,15 21,15 C20.1718709,15 19.4648467,14.7070342 18.8789062,14.1210938 C18.2929658,13.5351533 18,12.8281291 18,12 C18,11.1718709 18.2929658,10.4648467 18.8789062,9.87890625 C19.4648467,9.29296582 20.1718709,9 21,9 Z M21,13.5 C21.406252,13.5 21.757811,13.351564 22.0546875,13.0546875 C22.351564,12.757811 22.5,12.406252 22.5,12 C22.5,11.593748 22.351564,11.242189 22.0546875,10.9453125 C21.757811,10.648436 21.406252,10.5 21,10.5 C20.593748,10.5 20.242189,10.648436 19.9453125,10.9453125 C19.648436,11.242189 19.5,11.593748 19.5,12 C19.5,12.406252 19.648436,12.757811 19.9453125,13.0546875 C20.242189,13.351564 20.593748,13.5 21,13.5 Z"/>+</svg>diff --git a/src/renderer/assets/icons/preference-advanced.svg b/src/renderer/assets/icons/preference-advanced.svgnew file mode 100644index 00000000..94d29cbf--- /dev/null+++ b/src/renderer/assets/icons/preference-advanced.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper"><polygon data-color="color-2" points="10.853,9.439 6.707,5.293 8,4 4,0 0,4 4,8 5.293,6.707 9.189,10.603 "/> <path data-color="color-2" d="M18.94,13.94C18.631,13.976,18.318,14,18,14c-0.305,0-0.608-0.018-0.912-0.053l-3.641,4.499 l4.518,4.518c1.381,1.381,3.619,1.381,5,0v0c1.381-1.381,1.381-3.619,0-5L18.94,13.94z"/> <path d="M20.271,6.771l-3.042-3.042l3.208-3.208C19.692,0.189,18.869,0,18,0c-3.314,0-6,2.686-6,6 c0,0.594,0.089,1.166,0.25,1.708l-10.789,8.73c-0.891,0.787-1.423,1.919-1.459,3.106c-0.037,1.188,0.424,2.351,1.264,3.19 C2.082,23.551,3.167,24,4.321,24c1.239,0,2.421-0.532,3.241-1.461l8.73-10.789C16.834,11.911,17.406,12,18,12c3.314,0,6-2.686,6-6 c0-0.869-0.189-1.692-0.521-2.438L20.271,6.771z"/></g>+</svg>diff --git a/src/renderer/assets/icons/preference-basic.svg b/src/renderer/assets/icons/preference-basic.svgnew file mode 100644index 00000000..06832b58--- /dev/null+++ b/src/renderer/assets/icons/preference-basic.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper"><path d="M6.5,11h11c3,0,5.5-2.5,5.5-5.5S20.5,0,17.5,0h-11C3.5,0,1,2.5,1,5.5S3.5,11,6.5,11z M6.5,2 C8.4,2,10,3.6,10,5.5S8.4,9,6.5,9S3,7.4,3,5.5S4.6,2,6.5,2z"/> <path data-color="color-2" d="M17.5,13h-11c-3,0-5.5,2.5-5.5,5.5S3.5,24,6.5,24h11c3,0,5.5-2.5,5.5-5.5S20.5,13,17.5,13z M17.5,22c-1.9,0-3.5-1.6-3.5-3.5s1.6-3.5,3.5-3.5s3.5,1.6,3.5,3.5S19.4,22,17.5,22z"/></g>+</svg>diff --git a/src/renderer/assets/icons/purge.svg b/src/renderer/assets/icons/purge.svgnew file mode 100644index 00000000..b1a0c43a--- /dev/null+++ b/src/renderer/assets/icons/purge.svg@@ -0,0 +1,10 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="1" y1="9" x2="23" y2="9"/>+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="1" y1="3" x2="23" y2="3"/>+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="1" y1="15" x2="11" y2="15"/>+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="1" y1="21" x2="11" y2="21"/>+ <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="16" y1="15" x2="22" y2="21"/>+ <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="22" y1="15" x2="16" y2="21"/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/refresh.svg b/src/renderer/assets/icons/refresh.svgnew file mode 100644index 00000000..a92c902d--- /dev/null+++ b/src/renderer/assets/icons/refresh.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <path data-cap="butt" fill="none" stroke="#111111" stroke-miterlimit="10" d="M22,12c0,5.5-4.5,10-10,10 S2,17.5,2,12S6.5,2,12,2c3.9,0,7.3,2.2,8.9,5.5"/>+ <polyline fill="none" stroke="#111111" stroke-miterlimit="10" points="21.8,1.7 21,7.6 15,6.8 "/>+ </g>+</svg>diff --git a/src/renderer/assets/icons/speedometer.svg b/src/renderer/assets/icons/speedometer.svgnew file mode 100644index 00000000..7036fc5a--- /dev/null+++ b/src/renderer/assets/icons/speedometer.svg@@ -0,0 +1,10 @@+<svg viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111"+ stroke="#111111">+ <path data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" d="M6.3,10C6.1,10.6,6,11.3,6,12"></path>+ <path data-cap="butt" data-color="color-2" fill="none" stroke-miterlimit="10" d="M18,12c0-3.3-2.7-6-6-6 c-0.7,0-1.4,0.1-2,0.3"></path>+ <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="10.6" y1="10.6" x2="7" y2="7"></line>+ <circle data-color="color-2" fill="none" stroke-miterlimit="10" cx="12" cy="12" r="2"></circle>+ <circle fill="none" stroke="#111111" stroke-miterlimit="10" cx="12" cy="12" r="11"></circle>+ </g>+</svg>diff --git a/src/renderer/assets/icons/task-done.svg b/src/renderer/assets/icons/task-done.svgnew file mode 100644index 00000000..2d01d962--- /dev/null+++ b/src/renderer/assets/icons/task-done.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><g class="nc-icon-wrapper" fill="#111111"><path fill="#111111" d="M12,0C5.4,0,0,5.4,0,12s5.4,12,12,12s12-5.4,12-12S18.6,0,12,0z M18.7,8.7l-8,8C10.5,16.9,10.3,17,10,17 s-0.5-0.1-0.7-0.3l-4-4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l3.3,3.3l7.3-7.3c0.4-0.4,1-0.4,1.4,0S19.1,8.3,18.7,8.7z"/></g></svg>\ No newline at end of filediff --git a/src/renderer/assets/icons/task-pause-line.svg b/src/renderer/assets/icons/task-pause-line.svgnew file mode 100644index 00000000..3111539a--- /dev/null+++ b/src/renderer/assets/icons/task-pause-line.svg@@ -0,0 +1,6 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <rect x="3" y="2" fill="none" stroke="#111111" stroke-miterlimit="10" width="6" height="20" />+ <rect x="15" y="2" fill="none" stroke="#111111" stroke-miterlimit="10" width="6" height="20" />+ </g>+</svg>diff --git a/src/renderer/assets/icons/task-pause.svg b/src/renderer/assets/icons/task-pause.svgnew file mode 100644index 00000000..0d0fc81c--- /dev/null+++ b/src/renderer/assets/icons/task-pause.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper"><path d="M9,1H3C2.447,1,2,1.447,2,2v20c0,0.553,0.447,1,1,1h6c0.553,0,1-0.447,1-1V2C10,1.447,9.553,1,9,1z"/> <path d="M21,1h-6c-0.553,0-1,0.447-1,1v20c0,0.553,0.447,1,1,1h6c0.553,0,1-0.447,1-1V2C22,1.447,21.553,1,21,1z"/></g>+</svg>diff --git a/src/renderer/assets/icons/task-start-line.svg b/src/renderer/assets/icons/task-start-line.svgnew file mode 100644index 00000000..f85ae329--- /dev/null+++ b/src/renderer/assets/icons/task-start-line.svg@@ -0,0 +1,5 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="#111111">+ <polygon fill="none" stroke-miterlimit="10" points="5,22 5,2 20,12 " />+ </g>+</svg>diff --git a/src/renderer/assets/icons/task-start.svg b/src/renderer/assets/icons/task-start.svgnew file mode 100644index 00000000..93d0671f--- /dev/null+++ b/src/renderer/assets/icons/task-start.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper"><path d="M20.555,11.168l-15-10c-0.307-0.204-0.702-0.224-1.026-0.05C4.203,1.292,4,1.631,4,2v20 c0,0.369,0.203,0.708,0.528,0.882C4.676,22.961,4.838,23,5,23c0.194,0,0.388-0.057,0.555-0.168l15-10C20.833,12.646,21,12.334,21,12 S20.833,11.354,20.555,11.168z"/></g>+</svg>diff --git a/src/renderer/assets/icons/task-stop-line.svg b/src/renderer/assets/icons/task-stop-line.svgnew file mode 100644index 00000000..11384895--- /dev/null+++ b/src/renderer/assets/icons/task-stop-line.svg@@ -0,0 +1,5 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <rect x="2" y="2" fill="none" stroke="#111111" stroke-miterlimit="10" width="20" height="20" />+ </g>+</svg>diff --git a/src/renderer/assets/icons/task-stop.svg b/src/renderer/assets/icons/task-stop.svgnew file mode 100644index 00000000..2cc52895--- /dev/null+++ b/src/renderer/assets/icons/task-stop.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper"><path d="M22,1H2C1.447,1,1,1.447,1,2v20c0,0.553,0.447,1,1,1h20c0.553,0,1-0.447,1-1V2C23,1.447,22.553,1,22,1z"/></g>+</svg>diff --git a/src/renderer/assets/icons/trash.svg b/src/renderer/assets/icons/trash.svgnew file mode 100644index 00000000..2282a1ca--- /dev/null+++ b/src/renderer/assets/icons/trash.svg@@ -0,0 +1,10 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">+ <g class="nc-icon-wrapper" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#111111" stroke="#111111">+ <polyline fill="none" stroke="#111111" stroke-miterlimit="10" points="20,9 20,23 4,23 4,9 " />+ <line fill="none" stroke="#111111" stroke-miterlimit="10" x1="1" y1="5" x2="23" y2="5" />+ <line fill="none" stroke-miterlimit="10" x1="12" y1="12" x2="12" y2="18" />+ <line fill="none" stroke-miterlimit="10" x1="8" y1="12" x2="8" y2="18" />+ <line fill="none" stroke-miterlimit="10" x1="16" y1="12" x2="16" y2="18" />+ <polyline fill="none" stroke="#111111" stroke-miterlimit="10" points="8,5 8,1 16,1 16,5 " />+ </g>+</svg>diff --git a/src/renderer/assets/logo-mini.svg b/src/renderer/assets/logo-mini.svgnew file mode 100644index 00000000..a96c1610--- /dev/null+++ b/src/renderer/assets/logo-mini.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="28" height="14" viewBox="0 0 28 14">+ <path fill="#FFF" fill-rule="evenodd" d="M4,9 L28,9 C29,9 30,10 30,11 L30,23 L26,23 L26,12.5 C26,12 25.5,11.5 25,11.5 L18,11.5 L18,23 L14,23 L14,11.5 L7,11.5 C6.5,11.5 6,12 6,12.5 L6,23 L2,23 L2,11 C2,10 3,9 4,9 Z" transform="translate(-2 -9)"/>+</svg>diff --git a/src/renderer/assets/logo.svg b/src/renderer/assets/logo.svgnew file mode 100644index 00000000..3766e605--- /dev/null+++ b/src/renderer/assets/logo.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" width="62" height="14" viewBox="0 0 62 14">+ <g fill="#4D515A" fill-rule="evenodd">+ <path d="M40,2 C40,1 41,1.53477231e-14 42,1.53477231e-14 C42,1.53477231e-14 60,1.27897692e-14 60,1.53477231e-14 C61,1.27897692e-14 62,1 62,2 C62,2 62,12 62,12 C62,13 61,14 60,14 C60,14 42,14 42,14 C41,14 40,13 40,12 C40,12 40,2 40,2 Z M44,3.5 C44,3.5 44,10.5 44,10.5 C44,11 44.5,11.5 45,11.5 C45,11.5 57,11.5 57,11.5 C57.5,11.5 58,11 58,10.5 C58,10.5 58,3.5 58,3.5 C58,3 57.5,2.5 57,2.5 C57,2.5 45,2.5 45,2.5 C44.5,2.5 44,3 44,3.5 Z"/>+ <rect width="4" height="2" x="32" y="6" rx=".5"/>+ <path d="M2,0 L26,0 C27,-2.04003481e-15 28,1 28,2 L28,14 L24,14 L24,3.5 C24,3 23.5,2.5 23,2.5 L16,2.5 L16,14 L12,14 L12,2.5 L5,2.5 C4.5,2.5 4,3 4,3.5 L4,14 L0,14 L0,2 C0,1 1,-2.04003481e-15 2,0 Z"/>+ </g>+</svg>diff --git a/src/renderer/assets/no-task.svg b/src/renderer/assets/no-task.svgnew file mode 100644index 00000000..79a84505--- /dev/null+++ b/src/renderer/assets/no-task.svg@@ -0,0 +1,47 @@+<svg xmlns="http://www.w3.org/2000/svg" width="504" height="309" viewBox="0 0 504 309">+ <defs>+ <linearGradient id="no-task-a" x1="50%" x2="50%" y1="33.114%" y2="0%">+ <stop offset="0%" stop-color="#2D2D2D" stop-opacity="0"/>+ <stop offset="100%" stop-color="#FFF" stop-opacity=".216"/>+ </linearGradient>+ <linearGradient id="no-task-b" x1="54.257%" x2="54.257%" y1="27.941%" y2="0%">+ <stop offset="0%" stop-color="#6D6D6D" stop-opacity="0"/>+ <stop offset="100%" stop-color="#FFF" stop-opacity=".216"/>+ </linearGradient>+ <linearGradient id="no-task-c" x1="67.64%" x2="67.64%" y1="-1.183%" y2="87.046%">+ <stop offset="0%" stop-color="#BBB"/>+ <stop offset="100%" stop-color="#1B1B1B"/>+ </linearGradient>+ <linearGradient id="no-task-d" x1="72.034%" x2="62.937%" y1=".549%" y2="70.566%">+ <stop offset="0%" stop-color="#5B5AEA"/>+ <stop offset="100%" stop-color="#E7D1AF" stop-opacity="0"/>+ </linearGradient>+ </defs>+ <g fill="none" fill-rule="evenodd" transform="matrix(-1 0 0 1 523 -26)">+ <path fill="url(#no-task-a)" d="M405.205443,457 C474.127574,457 530,416.257912 530,366 C530,315.742088 474.127574,275 405.205443,275 C357.777319,275 316.351719,308.5 273.422392,320 C230.493064,331.5 280.410887,350.326604 280.410887,366 C280.410887,416.257912 336.283313,457 405.205443,457 Z"/>+ <path fill="url(#no-task-b)" d="M187.396666,506 C290.892986,506 374.793331,444.886868 374.793331,369.5 C374.793331,343.379708 438.258336,300 374.793331,288 C311.328327,276 255.033239,233 187.396666,233 C83.9003451,233 0,294.113132 0,369.5 C0,444.886868 83.9003451,506 187.396666,506 Z"/>+ <g transform="translate(251)">+ <g transform="rotate(-9 131.07 -174.485)">+ <path fill="#4C4C4C" d="M62.7987624,55.0107658 C81.722385,55.0107658 97.0630122,48.3331613 97.0630122,40.0959187 C97.0630122,31.8586761 81.8337958,20.3734081 62.9101731,20.3734081 C43.9865505,20.3734081 28.5345125,31.8586761 28.5345125,40.0959187 C28.5345125,48.3331613 43.8751397,55.0107658 62.7987624,55.0107658 Z" transform="rotate(28 62.799 37.692)"/>+ <path fill="#6C6971" stroke="#1B1B1B" stroke-width="1.5" d="M58.7849596,61.2042558 C89.7511315,61.2042558 114.854174,54.0572115 114.854174,45.2408856 C114.854174,36.4245597 89.9334414,24.7704052 58.9672695,24.7704052 C28.0010976,24.7704052 2.71574548,36.4245597 2.71574548,45.2408856 C2.71574548,54.0572115 27.8187877,61.2042558 58.7849596,61.2042558 Z" transform="rotate(28 58.785 42.987)"/>+ <ellipse cx="57.554" cy="45.301" fill="#3E3E3E" stroke="#1B1B1B" stroke-width="1.5" rx="56.069" ry="15.595" transform="rotate(28 57.554 45.301)"/>+ <path fill="#1C1C1C" d="M54.0341689,61.034986 C71.9305201,61.034986 86.4383793,57.5754212 86.4383793,53.3078316 C86.4383793,49.0402421 71.9045985,44.0956263 54.0082472,44.0956263 C36.111896,44.0956263 21.6299585,49.0402421 21.6299585,53.3078316 C21.6299585,57.5754212 36.1378177,61.034986 54.0341689,61.034986 Z" transform="rotate(28 54.034 52.565)"/>+ <path fill="#5B5AEA" d="M24.6356751,65.6103894 C28.977282,67.3406868 43.8486711,68.2460037 51.2115661,68.2460037 C62.9314122,68.2460037 76.8638753,67.0866357 80.0696418,63.5616001 C79.1980224,61.9223221 77.8034291,59.2994789 77.4547802,58.6437682 C73.3503403,54.0911274 65.5268862,51.1289038 51.2115661,51.1289038 C36.896246,51.1289038 25.2913861,54.9606971 25.2913861,59.6874537 C25.2799811,59.8311745 24.8971094,62.6181062 24.6356751,65.6103894 Z" opacity=".2" transform="rotate(28 52.353 59.687)"/>+ </g>+ <g transform="rotate(17 -127.302 156.199)">+ <path fill="url(#no-task-c)" d="M0.437855341,122.756063 C6.9305143,103.820174 23.4032209,19.86934 28.722962,7.43976857 C31.2151567,1.85116474 46.1461798,0.442635317 57.1290936,0.606476509 C68.1120075,0.770317701 77.6353158,2.27177407 79.7750096,10.1463265 C82.5994055,20.5407356 100.631664,125.817368 100.631664,125.817368 C100.631664,125.817368 85.4641952,135.806163 51.2553929,136.208574 C17.0465905,136.610985 0.437855341,122.756063 0.437855341,122.756063" opacity=".2"/>+ <path fill="url(#no-task-d)" d="M16.9815633,126.328017 C21.4934522,108.52909 34.184762,14.8688391 37.8589786,3.31978228 C40.6849978,0.698206848 48.1144315,0.373582109 55.897648,0.69820706 C63.6808645,1.02283201 70.9203368,2.51931696 71.1102971,3.61983098 C72.9366421,14.2005606 85.1896902,130.47143 85.1896902,130.47143 C85.1896902,130.47143 71.1622902,134.410059 51.855144,134.426852 C32.5479978,134.443645 16.9815633,126.328017 16.9815633,126.328017" opacity=".5"/>+ </g>+ </g>+ <g fill="#646464" transform="translate(143 190)">+ <polygon points="15.556 17.111 26.444 46.667 3.889 46.667" transform="rotate(-5 15.167 31.889)"/>+ <polygon points="13.909 1.529 25.05 31.084 1.972 31.084" transform="rotate(-5 13.511 16.306)"/>+ </g>+ <g fill="#5D5D5D" opacity=".7" transform="matrix(-1 0 0 1 417 252)">+ <polygon points="7.778 8.556 13.222 23.333 1.944 23.333" transform="rotate(-5 7.583 15.944)"/>+ <polygon points="6.955 .764 12.525 15.542 .986 15.542" transform="rotate(-5 6.756 8.153)"/>+ </g>+ <polygon fill="#6B6B6B" points="7.953 1.395 13.786 23.439 1.703 23.439" opacity=".4" transform="rotate(3 -3911.454 3545.51)"/>+ <polygon fill="#686868" points="10.166 1.324 17.4 38.065 2.415 38.065" transform="scale(-1 1) rotate(3 -4751.022 -7416.36)"/>+ </g>+</svg>diff --git a/src/renderer/components/About.vue b/src/renderer/components/About.vuenew file mode 100644index 00000000..e69de29bdiff --git a/src/renderer/components/About/AboutPanel.vue b/src/renderer/components/About/AboutPanel.vuenew file mode 100644index 00000000..dfc7c762--- /dev/null+++ b/src/renderer/components/About/AboutPanel.vue@@ -0,0 +1,67 @@+<template>+ <el-dialog+ custom-class="app-about-dialog"+ width="61.8vw"+ :visible.sync="visible"+ @open="handleOpen"+ :before-close="handleClose"+ @closed="handleClosed">+ <mo-app-info :version="version" :engine="engineInfo" />+ <mo-copyright slot="footer" />+ </el-dialog>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import AppInfo from '@/components/About/AppInfo'+ import Copyright from '@/components/About/Copyright'++ export default {+ name: 'mo-about-panel',+ components: {+ [AppInfo.name]: AppInfo,+ [Copyright.name]: Copyright+ },+ props: {+ visible: {+ type: Boolean,+ default: false+ }+ },+ data () {+ const version = this.$electron.remote.app.getVersion()+ console.log('version===>', version)+ return {+ version+ }+ },+ computed: {+ ...mapState('app', {+ engineInfo: state => state.engineInfo+ })+ },+ methods: {+ isRenderer: is.renderer,+ isMas: is.mas,+ handleOpen () {+ this.$store.dispatch('app/fetchEngineInfo')+ },+ handleClose (done) {+ this.$store.dispatch('app/hideAboutPanel')+ },+ handleClosed () {+ }+ }+ }+</script>++<style lang="scss">+ .app-about-dialog {+ max-width: 632px;+ .el-dialog__header {+ padding-top: 0;+ padding-bottom: 0;+ }+ }+</style>diff --git a/src/renderer/components/About/AppInfo.vue b/src/renderer/components/About/AppInfo.vuenew file mode 100644index 00000000..c3d36bff--- /dev/null+++ b/src/renderer/components/About/AppInfo.vue@@ -0,0 +1,92 @@+<template>+ <div class="app-info">+ <div class="app-version">+ <mo-logo :width="93" :height="21" style="vertical-align: bottom;" />+ <span>Version {{version}}</span>+ <!-- <p>一款 macOS 全能下载工具</p> -->+ </div>+ <div class="app-icon"></div>+ <div class="engine-info" v-if="!!engine">+ <h4>引擎版本 {{engine.version}}</h4>+ <ul v-if="!isMas()">+ <li+ v-for="(feature, index) in engine.enabledFeatures"+ v-bind:key="`feature-${index}`">+ {{ feature }}+ </li>+ </ul>+ </div>+ </div>+</template>++<script>+ import is from 'electron-is'+ import Logo from '@/components/Logo/Logo'++ export default {+ name: 'mo-app-info',+ components: {+ [Logo.name]: Logo+ },+ props: {+ version: {+ type: String,+ default: ''+ },+ engine: {+ type: Object,+ default: {+ version: '',+ enabledFeatures: []+ }+ }+ },+ methods: {+ isMas: is.mas+ }+ }+</script>++<style lang="scss">+ .app-info {+ position: relative;+ padding: 8px 0;+ .app-version span {+ display: inline-block;+ vertical-align: bottom;+ font-size: $--font-size-large;+ margin-left: 20px;+ color: $--color-text-regular;+ line-height: 18px;+ }+ .app-icon {+ position: absolute;+ top: 0;+ right: 0;+ background: transparent url('~@/assets/app-icon.png') center center no-repeat;+ background-size: 128px 128px;+ width: 128px;+ height: 128px;+ }+ .engine-info {+ margin: 50px 35% 0 8px;+ h4 {+ font-size: $--font-size-base;+ font-weight: $--font-weight-secondary;+ color: $--color-text-regular;+ }+ ul {+ font-size: 12px;+ color: $--color-text-secondary;+ list-style: none;+ padding: 0;+ line-height: 20px;+ @include clearfix();+ li {+ float: left;+ width: 50%;+ }+ }+ }+ }+</style>diff --git a/src/renderer/components/About/Copyright.vue b/src/renderer/components/About/Copyright.vuenew file mode 100644index 00000000..ddf0a70e--- /dev/null+++ b/src/renderer/components/About/Copyright.vue@@ -0,0 +1,49 @@+<template>+ <el-row class="copyright">+ <el-col :span="8" class="copyright-left">+ <a target="_blank" href="https://motrix.app/" rel="noopener noreferrer">+ ©2018 Motrix+ </a>+ </el-col>+ <el-col :span="16" class="copyright-right">+ <a target="_blank" href="https://motrix.app/about" rel="noopener noreferrer">+ 关于我们+ </a>+ <a target="_blank" href="https://motrix.app/support" rel="noopener noreferrer">+ 帮助支持+ </a>+ </el-col>+ </el-row>+</template>++<script>+ export default {+ name: 'mo-copyright'+ }+</script>+++<style lang="scss">+ .copyright {+ width: 100%;+ font-size: $--font-size-small;+ a {+ color: $--color-text-regular;+ text-decoration: none;+ }+ }+ .copyright-left {+ text-align: left;+ a {+ color: $--color-text-regular;+ }+ }++ .copyright-right {+ text-align: right;+ a {+ margin-left: 30px;+ }+ }++</style>diff --git a/src/renderer/components/Aside/Index.vue b/src/renderer/components/Aside/Index.vuenew file mode 100644index 00000000..b1f48ecd--- /dev/null+++ b/src/renderer/components/Aside/Index.vue@@ -0,0 +1,109 @@+<template>+ <el-aside width="78px" class="aside">+ <div class="aside-inner">+ <mo-logo-mini />+ <ul class="menu top-menu">+ <li @click="nav('/task')">+ <mo-icon name="menu-task" width="20" height="20" />+ </li>+ <li @click="showAddTask()">+ <mo-icon name="menu-add" width="20" height="20" />+ </li>+ </ul>+ <ul class="menu bottom-menu">+ <li @click="nav('/preference')">+ <mo-icon name="menu-preference" width="20" height="20" />+ </li>+ <li @click="showAboutPanel">+ <mo-icon name="menu-about" width="20" height="20" />+ </li>+ </ul>+ </div>+ </el-aside>+</template>++<script>+ import is from 'electron-is'+ import { mapState, mapActions } from 'vuex'+ import LogoMini from '@/components/Logo/LogoMini'+ import '@/components/Icons/menu-task'+ import '@/components/Icons/menu-add'+ import '@/components/Icons/menu-preference'+ import '@/components/Icons/menu-about'++ export default {+ name: 'mo-aside',+ components: {+ [LogoMini.name]: LogoMini+ },+ computed: {+ ...mapState('app', {+ currentPage: state => state.currentPage+ })+ },+ methods: {+ isRenderer: is.renderer,+ open (link) {+ this.$electron.shell.openExternal(link)+ },+ showAddTask (taskType = 'uri') {+ this.$store.dispatch('app/showAddTaskDialog', taskType)+ },+ showAboutPanel () {+ // if (this.isRenderer()) {+ // this.$electron.ipcRenderer.send('command', 'application:about')+ // } else {+ this.$store.dispatch('app/showAboutPanel')+ // }+ },+ nav (page) {+ console.log('nav page===>', page)+ this.$router.push({+ path: page+ })+ },+ ...mapActions('app', [+ 'changeCurrentPage'+ ])+ }+ }+</script>++<style lang="scss">+ .aside-inner {+ display: flex;+ height: 100%;+ flex-flow: column;+ }+ .logo-mini {+ margin-top: 40px;+ }+ .menu {+ list-style: none;+ padding: 0;+ margin: 0 auto;+ user-select: none;+ cursor: default;+ > li {+ width: 32px;+ height: 32px;+ margin-top: 24px;+ cursor: pointer;+ border-radius: 16px;+ transition: background-color 0.25s;+ &:hover {+ background-color: rgba(255, 255, 255, 0.15);+ }+ }+ svg {+ padding: 6px;+ color: #fff;+ }+ }+ .top-menu {+ flex: 1;+ }+ .bottom-menu {+ margin-bottom: 24px;+ }+</style>diff --git a/src/renderer/components/Command/CommandManager.js b/src/renderer/components/Command/CommandManager.jsnew file mode 100644index 00000000..c94cc258--- /dev/null+++ b/src/renderer/components/Command/CommandManager.js@@ -0,0 +1,38 @@+import { EventEmitter } from 'events'++export default class CommandManager extends EventEmitter {+ constructor () {+ super()++ this.commands = {}+ }++ register (id, fn) {+ if (this.commands[id]) {+ console.log('Attempting to register an already-registered command: ' + id)+ return null+ }+ if (!id || !fn) {+ console.error('Attempting to register a command with a missing id, or command function.')+ return null+ }+ this.commands[id] = fn++ this.emit('commandRegistered', id)+ }++ execute (id, ...args) {+ var fn = this.commands[id]+ if (fn) {+ try {+ this.emit('beforeExecuteCommand', id)+ } catch (err) {+ console.error(err)+ }+ const result = fn(...args)+ return result+ } else {+ return false+ }+ }+}diff --git a/src/renderer/components/Command/index.js b/src/renderer/components/Command/index.jsnew file mode 100644index 00000000..adfb52f5--- /dev/null+++ b/src/renderer/components/Command/index.js@@ -0,0 +1,67 @@+import router from '@/router'+import store from '@/store'+import CommandManager from './CommandManager'++const commands = new CommandManager()++function showAboutPanel () {+ store.dispatch('app/showAboutPanel')+}++function showAddTask (taskType = 'uri') {+ store.dispatch('app/showAddTaskDialog', taskType)+}++function navigateTaskList (status = 'active') {+ router.push({ path: `/task/${status}` })+}++function navigatePreferences () {+ router.push({ path: '/preference' })+}++function pauseTask () {++}++function resumeTask () {++}++function deleteTask () {++}++function moveTaskUp () {++}++function moveTaskDown () {++}++function pauseAllTask () {+ store.dispatch('task/pauseAllTask')+}++function resumeAllTask () {+ store.dispatch('task/resumeAllTask')+}++commands.register('application:about', showAboutPanel)+commands.register('application:new-task', showAddTask)+commands.register('application:new-bt-task', showAddTask)+commands.register('application:task-list', navigateTaskList)+commands.register('application:preferences', navigatePreferences)++commands.register('application:pause-task', pauseTask)+commands.register('application:resume-task', resumeTask)+commands.register('application:delete-task', deleteTask)+commands.register('application:move-task-up', moveTaskUp)+commands.register('application:move-task-down', moveTaskDown)+commands.register('application:pause-all-task', pauseAllTask)+commands.register('application:resume-all-task', resumeAllTask)++export {+ commands+}diff --git a/src/renderer/components/Icons/Icon.vue b/src/renderer/components/Icons/Icon.vuenew file mode 100644index 00000000..2102f762--- /dev/null+++ b/src/renderer/components/Icons/Icon.vue@@ -0,0 +1,228 @@+<template>+ <svg version="1.1"+ :class="klass"+ :role="label ? 'img' : 'presentation'"+ :aria-label="label"+ :x="x"+ :y="y"+ :width="width"+ :height="height"+ :viewBox="box"+ :style="style">+ <slot>+ <template v-if="icon && icon.paths">+ <path v-for="(path, i) in icon.paths" :key="`path-${i}`" v-bind="path"/>+ </template>+ <template v-if="icon && icon.polygons">+ <polygon v-for="(polygon, i) in icon.polygons" :key="`polygon-${i}`" v-bind="polygon"/>+ </template>+ <template v-if="icon && icon.raw"><g v-html="raw" v-bind="icon.g"></g></template>+ </slot>+ </svg>+</template>++<style>+.fa-icon {+ display: inline-block;+ fill: currentColor;+}++.fa-flip-horizontal {+ transform: scale(-1, 1);+}++.fa-flip-vertical {+ transform: scale(1, -1);+}++.fa-spin {+ animation: fa-spin 0.5s 0s infinite linear;+}++.fa-inverse {+ color: #fff;+}++.fa-pulse {+ animation: fa-spin 1s infinite steps(8);+}++@keyframes fa-spin {+ 0% {+ transform: rotate(0deg);+ }+ 100% {+ transform: rotate(360deg);+ }+}+</style>++<script>+let icons = {}++export default {+ name: 'fa-icon',+ props: {+ name: {+ type: String,+ validator (val) {+ if (val && !(val in icons)) {+ console.warn(`Invalid prop: prop "name" is referring to an unregistered icon "${val}".` ++ `\nPlease make sure you have imported this icon before using it.`)+ return false+ }+ return true+ }+ },+ scale: [Number, String],+ spin: Boolean,+ inverse: Boolean,+ pulse: Boolean,+ flip: {+ validator (val) {+ return val === 'horizontal' || val === 'vertical'+ }+ },+ label: String+ },+ data () {+ return {+ x: false,+ y: false,+ childrenWidth: 0,+ childrenHeight: 0,+ outerScale: 1+ }+ },+ computed: {+ normalizedScale () {+ let scale = this.scale+ scale = typeof scale === 'undefined' ? 1 : Number(scale)+ if (isNaN(scale) || scale <= 0) {+ console.warn(`Invalid prop: prop "scale" should be a number over 0.`, this)+ return this.outerScale+ }+ return scale * this.outerScale+ },+ klass () {+ return {+ 'fa-icon': true,+ 'fa-spin': this.spin,+ 'fa-flip-horizontal': this.flip === 'horizontal',+ 'fa-flip-vertical': this.flip === 'vertical',+ 'fa-inverse': this.inverse,+ 'fa-pulse': this.pulse,+ [this.$options.name]: true+ }+ },+ icon () {+ if (this.name) {+ return icons[this.name]+ }+ return null+ },+ box () {+ if (this.icon) {+ return `0 0 ${this.icon.width} ${this.icon.height}`+ }+ return `0 0 ${this.width} ${this.height}`+ },+ ratio () {+ if (!this.icon) {+ return 1+ }+ let { width, height } = this.icon+ return Math.max(width, height) / 16+ },+ width () {+ return this.childrenWidth || (this.icon && this.icon.width / this.ratio * this.normalizedScale) || 0+ },+ height () {+ return this.childrenHeight || (this.icon && this.icon.height / this.ratio * this.normalizedScale) || 0+ },+ style () {+ if (this.normalizedScale === 1) {+ return false+ }+ return {+ fontSize: this.normalizedScale + 'em'+ }+ },+ raw () {+ // generate unique id for each icon's SVG element with ID+ if (!this.icon || !this.icon.raw) {+ return null+ }+ let raw = this.icon.raw+ let ids = {}+ raw = raw.replace(/\s(?:xml:)?id=(["']?)([^"')\s]+)\1/g, (match, quote, id) => {+ let uniqueId = getId()+ ids[id] = uniqueId+ return ` id="${uniqueId}"`+ })+ raw = raw.replace(/#(?:([^'")\s]+)|xpointer\(id\((['"]?)([^')]+)\2\)\))/g, (match, rawId, _, pointerId) => {+ let id = rawId || pointerId+ if (!id || !ids[id]) {+ return match+ }++ return `#${ids[id]}`+ })++ return raw+ }+ },+ mounted () {+ if (!this.name && this.$children.length === 0) {+ console.warn(`Invalid prop: prop "name" is required.`)+ return+ }++ if (this.icon) {+ return+ }++ let width = 0+ let height = 0+ this.$children.forEach(child => {+ child.outerScale = this.normalizedScale++ width = Math.max(width, child.width)+ height = Math.max(height, child.height)+ })+ this.childrenWidth = width+ this.childrenHeight = height+ this.$children.forEach(child => {+ child.x = (width - child.width) / 2+ child.y = (height - child.height) / 2+ })+ },+ register (data) {+ for (let name in data) {+ let icon = data[name]++ if (!icon.paths) {+ icon.paths = []+ }+ if (icon.d) {+ icon.paths.push({ d: icon.d })+ }++ if (!icon.polygons) {+ icon.polygons = []+ }+ if (icon.points) {+ icon.polygons.push({ points: icon.points })+ }++ icons[name] = icon+ }+ },+ icons+}++let cursor = 0xd4937+function getId () {+ return `fa-${(cursor++).toString(16)}`+}+</script>diff --git a/src/renderer/components/Icons/delete.js b/src/renderer/components/Icons/delete.jsnew file mode 100644index 00000000..3668aaa0--- /dev/null+++ b/src/renderer/components/Icons/delete.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'delete': {+ 'width': 24,+ 'height': 24,+ 'raw': `<line fill="none" stroke-miterlimit="10" x1="19" y1="5" x2="5" y2="19" /><line fill="none" stroke-miterlimit="10" x1="19" y1="19" x2="5" y2="5" />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/folder.js b/src/renderer/components/Icons/folder.jsnew file mode 100644index 00000000..f3fdee7e--- /dev/null+++ b/src/renderer/components/Icons/folder.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'folder': {+ 'width': 24,+ 'height': 24,+ 'raw': `<line fill="none" stroke-miterlimit="10" x1="1" y1="8" x2="23" y2="8" /><polygon fill="none" stroke-miterlimit="10" points="23,23 1,23 1,1 10,1 12,4 23,4 " />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/inbox.js b/src/renderer/components/Icons/inbox.jsnew file mode 100644index 00000000..1fcec53a--- /dev/null+++ b/src/renderer/components/Icons/inbox.js@@ -0,0 +1,18 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'inbox': {+ 'width': 24,+ 'height': 24,+ 'raw': `<polyline data-cap="butt" fill="none" stroke-miterlimit="10" points="23,15 16,15 16,18 8,18 8,15 1,15 "/>+ <line data-cap="butt" fill="none" stroke-miterlimit="10" x1="12" y1="1" x2="12" y2="11"/>+ <polyline fill="none" stroke-miterlimit="10" points="19,6 20,6 23,15 23,23 1,23 1,15 4,6 5,6 "/>+ <polyline fill="none" stroke-miterlimit="10" points=" 15,8 12,11 9,8 "/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '1.5'+ }+ }+})diff --git a/src/renderer/components/Icons/info-circle.js b/src/renderer/components/Icons/info-circle.jsnew file mode 100644index 00000000..3c320e1c--- /dev/null+++ b/src/renderer/components/Icons/info-circle.js@@ -0,0 +1,17 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'info-circle': {+ 'width': 24,+ 'height': 24,+ 'raw': `<circle cx="12" cy="12" r="11" fill="none" stroke-miterlimit="10"/>+ <line data-color="color-2" x1="11.959" y1="11" x2="11.959" y2="17" fill="none" stroke-miterlimit="10"/>+ <circle data-color="color-2" data-stroke="none" cx="11.959" cy="7" r="1" stroke="none"/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/info-square.js b/src/renderer/components/Icons/info-square.jsnew file mode 100644index 00000000..208379d7--- /dev/null+++ b/src/renderer/components/Icons/info-square.js@@ -0,0 +1,17 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'info-square': {+ 'width': 24,+ 'height': 24,+ 'raw': `<rect x="2" y="2" width="20" height="20" fill="none" stroke-miterlimit="10"/>+ <line data-color="color-2" x1="12" y1="11" x2="12" y2="17" fill="none" stroke-miterlimit="10"/>+ <circle data-color="color-2" data-stroke="none" cx="12" cy="7" r="1" stroke="none"/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/link.js b/src/renderer/components/Icons/link.jsnew file mode 100644index 00000000..2547b774--- /dev/null+++ b/src/renderer/components/Icons/link.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'link': {+ 'width': 24,+ 'height': 24,+ 'raw': `<path fill="none" stroke-miterlimit="10" d="M11,6l2.5-2.5 c1.9-1.9,5.1-1.9,7,0l0,0c1.9,1.9,1.9,5.1,0,7L18,13" /><path fill="none" stroke-miterlimit="10" d="M13,18l-2.5,2.5 c-1.9,1.9-5.1,1.9-7,0l0,0c-1.9-1.9-1.9-5.1,0-7L6,11"/><line fill="none" stroke-miterlimit="10" x1="9" y1="15" x2="15" y2="9" />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/menu-about.js b/src/renderer/components/Icons/menu-about.jsnew file mode 100644index 00000000..838915f1--- /dev/null+++ b/src/renderer/components/Icons/menu-about.js@@ -0,0 +1,9 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'menu-about': {+ 'width': 24,+ 'height': 24,+ 'raw': `<g stroke-linecap="round" stroke-linejoin="round" stroke-width="2" fill="#fff" stroke="#fff"><circle fill="none" stroke="#fff" stroke-miterlimit="10" cx="12" cy="12" r="11"/> <path data-color="color-2" fill="none" stroke-miterlimit="10" d="M12,15v-2 c1.609,0,3-1.391,3-3s-1.391-3-3-3c-1.194,0-2.342,0.893-2.792,1.921"/> <circle data-color="color-2" data-stroke="none" cx="12" cy="18" r="1" stroke-linejoin="miter" stroke-linecap="square" stroke="none"/></g>`+ }+})diff --git a/src/renderer/components/Icons/menu-add.js b/src/renderer/components/Icons/menu-add.jsnew file mode 100644index 00000000..e03bfe76--- /dev/null+++ b/src/renderer/components/Icons/menu-add.js@@ -0,0 +1,16 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'menu-add': {+ 'width': 24,+ 'height': 24,+ 'raw': `<line fill="none" stroke="#fff" stroke-miterlimit="10" x1="12" y1="2" x2="12" y2="22" />+ <line fill="none" stroke="#fff" stroke-miterlimit="10" x1="22" y1="12" x2="2" y2="12" />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/menu-preference.js b/src/renderer/components/Icons/menu-preference.jsnew file mode 100644index 00000000..d2091ed8--- /dev/null+++ b/src/renderer/components/Icons/menu-preference.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'menu-preference': {+ 'width': 24,+ 'height': 24,+ 'raw': `<line fill="none" stroke-miterlimit="10" x1="14" y1="4" x2="23" y2="4"/> <line fill="none" stroke-miterlimit="10" x1="1" y1="4" x2="4" y2="4"/> <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="22" y1="12" x2="23" y2="12"/> <line data-color="color-2" fill="none" stroke-miterlimit="10" x1="1" y1="12" x2="12" y2="12"/> <line fill="none" stroke-miterlimit="10" x1="14" y1="20" x2="23" y2="20"/> <line fill="none" stroke-miterlimit="10" x1="1" y1="20" x2="4" y2="20"/> <circle fill="none" stroke-miterlimit="10" cx="7" cy="4" r="3"/> <circle data-color="color-2" fill="none" stroke-miterlimit="10" cx="15" cy="12" r="3"/> <circle fill="none" stroke-miterlimit="10" cx="7" cy="20" r="3"/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/menu-task.js b/src/renderer/components/Icons/menu-task.jsnew file mode 100644index 00000000..804bbdc1--- /dev/null+++ b/src/renderer/components/Icons/menu-task.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'menu-task': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M14,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h13c0.6,0,1,0.4,1,1S14.6,13,14,13z'+ }, {+ 'd': 'M23,6H1C0.4,6,0,5.6,0,5s0.4-1,1-1h22c0.6,0,1,0.4,1,1S23.6,6,23,6z'+ }, {+ 'd': 'M23,20H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h22c0.6,0,1,0.4,1,1S23.6,20,23,20z'+ }]+ }+})diff --git a/src/renderer/components/Icons/more.js b/src/renderer/components/Icons/more.jsnew file mode 100644index 00000000..9f441897--- /dev/null+++ b/src/renderer/components/Icons/more.js@@ -0,0 +1,11 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'more': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M3,15 C2.17187086,15 1.46484668,14.7070342 0.87890625,14.1210938 C0.29296582,13.5351533 0,12.8281291 0,12 C0,11.1718709 0.29296582,10.4648467 0.87890625,9.87890625 C1.46484668,9.29296582 2.17187086,9 3,9 C3.82812914,9 4.53515332,9.29296582 5.12109375,9.87890625 C5.70703418,10.4648467 6,11.1718709 6,12 C6,12.8281291 5.70703418,13.5351533 5.12109375,14.1210938 C4.53515332,14.7070342 3.82812914,15 3,15 Z M3,10.5 C2.59374797,10.5 2.24218898,10.648436 1.9453125,10.9453125 C1.64843602,11.242189 1.5,11.593748 1.5,12 C1.5,12.406252 1.64843602,12.757811 1.9453125,13.0546875 C2.24218898,13.351564 2.59374797,13.5 3,13.5 C3.40625203,13.5 3.75781102,13.351564 4.0546875,13.0546875 C4.35156398,12.757811 4.5,12.406252 4.5,12 C4.5,11.593748 4.35156398,11.242189 4.0546875,10.9453125 C3.75781102,10.648436 3.40625203,10.5 3,10.5 Z M12,15 C11.1718709,15 10.4648467,14.7070342 9.87890625,14.1210938 C9.29296582,13.5351533 9,12.8281291 9,12 C9,11.1718709 9.29296582,10.4648467 9.87890625,9.87890625 C10.4648467,9.29296582 11.1718709,9 12,9 C12.8281291,9 13.5351533,9.29296582 14.1210938,9.87890625 C14.7070342,10.4648467 15,11.1718709 15,12 C15,12.8281291 14.7070342,13.5351533 14.1210938,14.1210938 C13.5351533,14.7070342 12.8281291,15 12,15 Z M12,10.5 C11.593748,10.5 11.242189,10.648436 10.9453125,10.9453125 C10.648436,11.242189 10.5,11.593748 10.5,12 C10.5,12.406252 10.648436,12.757811 10.9453125,13.0546875 C11.242189,13.351564 11.593748,13.5 12,13.5 C12.406252,13.5 12.757811,13.351564 13.0546875,13.0546875 C13.351564,12.757811 13.5,12.406252 13.5,12 C13.5,11.593748 13.351564,11.242189 13.0546875,10.9453125 C12.757811,10.648436 12.406252,10.5 12,10.5 Z M21,9 C21.8281291,9 22.5351533,9.29296582 23.1210938,9.87890625 C23.7070342,10.4648467 24,11.1718709 24,12 C24,12.8281291 23.7070342,13.5351533 23.1210938,14.1210938 C22.5351533,14.7070342 21.8281291,15 21,15 C20.1718709,15 19.4648467,14.7070342 18.8789062,14.1210938 C18.2929658,13.5351533 18,12.8281291 18,12 C18,11.1718709 18.2929658,10.4648467 18.8789062,9.87890625 C19.4648467,9.29296582 20.1718709,9 21,9 Z M21,13.5 C21.406252,13.5 21.757811,13.351564 22.0546875,13.0546875 C22.351564,12.757811 22.5,12.406252 22.5,12 C22.5,11.593748 22.351564,11.242189 22.0546875,10.9453125 C21.757811,10.648436 21.406252,10.5 21,10.5 C20.593748,10.5 20.242189,10.648436 19.9453125,10.9453125 C19.648436,11.242189 19.5,11.593748 19.5,12 C19.5,12.406252 19.648436,12.757811 19.9453125,13.0546875 C20.242189,13.351564 20.593748,13.5 21,13.5 Z'+ }]+ }+})diff --git a/src/renderer/components/Icons/preference-advanced.js b/src/renderer/components/Icons/preference-advanced.jsnew file mode 100644index 00000000..7cc08f3b--- /dev/null+++ b/src/renderer/components/Icons/preference-advanced.js@@ -0,0 +1,16 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'preference-advanced': {+ 'width': 24,+ 'height': 24,+ 'polygons': [{+ 'points': '10.853,9.439 6.707,5.293 8,4 4,0 0,4 4,8 5.293,6.707 9.189,10.603'+ }],+ 'paths': [{+ 'd': 'M18.94,13.94C18.631,13.976,18.318,14,18,14c-0.305,0-0.608-0.018-0.912-0.053l-3.641,4.499 l4.518,4.518c1.381,1.381,3.619,1.381,5,0v0c1.381-1.381,1.381-3.619,0-5L18.94,13.94z'+ }, {+ 'd': 'M20.271,6.771l-3.042-3.042l3.208-3.208C19.692,0.189,18.869,0,18,0c-3.314,0-6,2.686-6,6 c0,0.594,0.089,1.166,0.25,1.708l-10.789,8.73c-0.891,0.787-1.423,1.919-1.459,3.106c-0.037,1.188,0.424,2.351,1.264,3.19 C2.082,23.551,3.167,24,4.321,24c1.239,0,2.421-0.532,3.241-1.461l8.73-10.789C16.834,11.911,17.406,12,18,12c3.314,0,6-2.686,6-6 c0-0.869-0.189-1.692-0.521-2.438L20.271,6.771z'+ }]+ }+})diff --git a/src/renderer/components/Icons/preference-basic.js b/src/renderer/components/Icons/preference-basic.jsnew file mode 100644index 00000000..c74f0ffe--- /dev/null+++ b/src/renderer/components/Icons/preference-basic.js@@ -0,0 +1,13 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'preference-basic': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M6.5,11h11c3,0,5.5-2.5,5.5-5.5S20.5,0,17.5,0h-11C3.5,0,1,2.5,1,5.5S3.5,11,6.5,11z M6.5,2 C8.4,2,10,3.6,10,5.5S8.4,9,6.5,9S3,7.4,3,5.5S4.6,2,6.5,2z'+ }, {+ 'd': 'M17.5,13h-11c-3,0-5.5,2.5-5.5,5.5S3.5,24,6.5,24h11c3,0,5.5-2.5,5.5-5.5S20.5,13,17.5,13z M17.5,22c-1.9,0-3.5-1.6-3.5-3.5s1.6-3.5,3.5-3.5s3.5,1.6,3.5,3.5S19.4,22,17.5,22z'+ }]+ }+})diff --git a/src/renderer/components/Icons/preference-lab.js b/src/renderer/components/Icons/preference-lab.jsnew file mode 100644index 00000000..52910ffd--- /dev/null+++ b/src/renderer/components/Icons/preference-lab.js@@ -0,0 +1,14 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'preference-lab': {+ 'width': 24,+ 'height': 24,+ 'polygons': [{+ 'points': '9,11.675 5.855,16 18.145,16 15,11.675 15,5 17,5 17,0 7,0 7,5 9,5'+ }],+ 'paths': [{+ 'd': 'M19.6,18H4.4l-0.898,1.235c-0.668,0.917-0.763,2.115-0.248,3.126S4.793,24,5.928,24h12.145 c1.135,0,2.159-0.628,2.674-1.639s0.42-2.209-0.248-3.126L19.6,18z'+ }]+ }+})diff --git a/src/renderer/components/Icons/purge.js b/src/renderer/components/Icons/purge.jsnew file mode 100644index 00000000..3fdea5ba--- /dev/null+++ b/src/renderer/components/Icons/purge.js@@ -0,0 +1,20 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'purge': {+ 'width': 24,+ 'height': 24,+ 'raw': `<line fill="none" stroke-miterlimit="10" x1="1" y1="9" x2="23" y2="9"/>+ <line fill="none" stroke-miterlimit="10" x1="1" y1="3" x2="23" y2="3"/>+ <line fill="none" stroke-miterlimit="10" x1="1" y1="15" x2="11" y2="15"/>+ <line fill="none" stroke-miterlimit="10" x1="1" y1="21" x2="11" y2="21"/>+ <line fill="none" stroke-miterlimit="10" x1="16" y1="15" x2="22" y2="21"/>+ <line fill="none" stroke-miterlimit="10" x1="22" y1="15" x2="16" y2="21"/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/refresh.js b/src/renderer/components/Icons/refresh.jsnew file mode 100644index 00000000..3e32c724--- /dev/null+++ b/src/renderer/components/Icons/refresh.js@@ -0,0 +1,16 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'refresh': {+ 'width': 24,+ 'height': 24,+ 'raw': `<path data-cap="butt" fill="none" stroke-miterlimit="10" d="M22,12c0,5.5-4.5,10-10,10 S2,17.5,2,12S6.5,2,12,2c3.9,0,7.3,2.2,8.9,5.5"/>+ <polyline fill="none" stroke-miterlimit="10" points="21.8,1.7 21,7.6 15,6.8 "/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/speedometer.js b/src/renderer/components/Icons/speedometer.jsnew file mode 100644index 00000000..d88f1d83--- /dev/null+++ b/src/renderer/components/Icons/speedometer.js@@ -0,0 +1,11 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'speedometer': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M12,3.609375 C13.1562558,3.609375 14.2460886,3.82812281 15.2695312,4.265625 C16.2929739,4.70312719 17.18359,5.30077746 17.9414062,6.05859375 C18.6992225,6.81641004 19.2968728,7.70702613 19.734375,8.73046875 C20.1718772,9.75391137 20.390625,10.8437442 20.390625,12 C20.390625,12.2187511 20.3242194,12.3984368 20.1914062,12.5390625 C20.0585931,12.6796882 19.8750012,12.75 19.640625,12.75 C19.4218739,12.75 19.2421882,12.6796882 19.1015625,12.5390625 C18.9609368,12.3984368 18.890625,12.2187511 18.890625,12 C18.890625,11.0468702 18.7109393,10.1484417 18.3515625,9.3046875 C17.9921857,8.46093328 17.5039093,7.73047184 16.8867188,7.11328125 C16.2695282,6.49609066 15.5390667,6.0078143 14.6953125,5.6484375 C13.8515583,5.2890607 12.9531298,5.109375 12,5.109375 C11.5468727,5.109375 11.0859398,5.14843711 10.6171875,5.2265625 C10.1484352,5.30468789 9.71093953,5.43749906 9.3046875,5.625 C9.11718656,5.70312539 8.92578223,5.7070316 8.73046875,5.63671875 C8.53515527,5.5664059 8.39843789,5.43750094 8.3203125,5.25 C8.24218711,5.06249906 8.2382809,4.87109473 8.30859375,4.67578125 C8.3789066,4.48046777 8.50781156,4.34375039 8.6953125,4.265625 C9.22656516,4.04687391 9.76952848,3.88281305 10.3242187,3.7734375 C10.878909,3.66406195 11.4374972,3.609375 12,3.609375 Z M5.25,8.3203125 C5.43750094,8.39843789 5.57421832,8.53515527 5.66015625,8.73046875 C5.74609418,8.92578223 5.73437555,9.11718656 5.625,9.3046875 C5.43749906,9.71093953 5.30468789,10.1406227 5.2265625,10.59375 C5.14843711,11.0468773 5.109375,11.5156226 5.109375,12 C5.109375,12.2187511 5.0390632,12.3984368 4.8984375,12.5390625 C4.7578118,12.6796882 4.57812609,12.75 4.359375,12.75 C4.12499883,12.75 3.94140691,12.6796882 3.80859375,12.5390625 C3.67578059,12.3984368 3.609375,12.2187511 3.609375,12 C3.609375,11.4374972 3.66406195,10.878909 3.7734375,10.3242188 C3.88281305,9.76952848 4.04687391,9.22656516 4.265625,8.6953125 C4.34375039,8.50781156 4.48046777,8.3789066 4.67578125,8.30859375 C4.87109473,8.2382809 5.06249906,8.24218711 5.25,8.3203125 Z M12,0 C13.6562583,0 15.2109302,0.316403086 16.6640625,0.94921875 C18.1171948,1.58203441 19.3867133,2.44140082 20.4726562,3.52734375 C21.5585992,4.61328668 22.4179656,5.88280523 23.0507812,7.3359375 C23.6835969,8.78906977 24,10.3437417 24,12 C24,13.6562583 23.6835969,15.2109302 23.0507812,16.6640625 C22.4179656,18.1171948 21.5585992,19.3867133 20.4726562,20.4726562 C19.3867133,21.5585992 18.1171948,22.4179656 16.6640625,23.0507812 C15.2109302,23.6835969 13.6562583,24 12,24 C10.3437417,24 8.78906977,23.6835969 7.3359375,23.0507812 C5.88280523,22.4179656 4.61328668,21.5585992 3.52734375,20.4726562 C2.44140082,19.3867133 1.58203441,18.1171948 0.94921875,16.6640625 C0.316403086,15.2109302 0,13.6562583 0,12 C0,10.3437417 0.316403086,8.78906977 0.94921875,7.3359375 C1.58203441,5.88280523 2.44140082,4.61328668 3.52734375,3.52734375 C4.61328668,2.44140082 5.88280523,1.58203441 7.3359375,0.94921875 C8.78906977,0.316403086 10.3437417,0 12,0 Z M12,22.5 C13.4375072,22.5 14.7968686,22.222659 16.078125,21.6679688 C17.3593814,21.1132785 18.4726515,20.3593798 19.4179688,19.40625 C20.363286,18.4531202 21.1132785,17.3398501 21.6679688,16.0664062 C22.222659,14.7929624 22.5,13.4375072 22.5,12 C22.5,10.5624928 22.222659,9.20313141 21.6679688,7.921875 C21.1132785,6.64061859 20.3593798,5.52734848 19.40625,4.58203125 C18.4531202,3.63671402 17.3398501,2.88672152 16.0664062,2.33203125 C14.7929624,1.77734098 13.4375072,1.5 12,1.5 C10.5624928,1.5 9.20313141,1.77734098 7.921875,2.33203125 C6.64061859,2.88672152 5.52734848,3.64062023 4.58203125,4.59375 C3.63671402,5.54687977 2.88672152,6.66014988 2.33203125,7.93359375 C1.77734098,9.20703762 1.5,10.5624928 1.5,12 C1.5,13.4375072 1.77734098,14.7929624 2.33203125,16.0664062 C2.88672152,17.3398501 3.64062023,18.4531202 4.59375,19.40625 C5.54687977,20.3593798 6.66014988,21.1132785 7.93359375,21.6679688 C9.20703762,22.222659 10.5624928,22.5 12,22.5 Z M12,9 C12.8281291,9 13.5351533,9.29296582 14.1210938,9.87890625 C14.7070342,10.4648467 15,11.1718709 15,12 C15,12.8281291 14.7070342,13.5351533 14.1210938,14.1210938 C13.5351533,14.7070342 12.8281291,15 12,15 C11.1718709,15 10.4648467,14.7070342 9.87890625,14.1210938 C9.29296582,13.5351533 9,12.8281291 9,12 C9,11.7343737 9.03906211,11.4726575 9.1171875,11.2148438 C9.19531289,10.95703 9.3046868,10.7187511 9.4453125,10.5 L5.765625,6.8203125 C5.6249993,6.6796868 5.5546875,6.50781352 5.5546875,6.3046875 C5.5546875,6.10156148 5.6249993,5.92187578 5.765625,5.765625 C5.92187578,5.6249993 6.10156148,5.5546875 6.3046875,5.5546875 C6.50781352,5.5546875 6.6796868,5.6249993 6.8203125,5.765625 L10.5,9.4453125 C10.7187511,9.3046868 10.95703,9.19531289 11.2148438,9.1171875 C11.4726575,9.03906211 11.7343737,9 12,9 Z M12,13.5 C12.406252,13.5 12.757811,13.351564 13.0546875,13.0546875 C13.351564,12.757811 13.5,12.406252 13.5,12 C13.5,11.593748 13.351564,11.242189 13.0546875,10.9453125 C12.757811,10.648436 12.406252,10.5 12,10.5 C11.593748,10.5 11.242189,10.648436 10.9453125,10.9453125 C10.648436,11.242189 10.5,11.593748 10.5,12 C10.5,12.406252 10.648436,12.757811 10.9453125,13.0546875 C11.242189,13.351564 11.593748,13.5 12,13.5 Z'+ }]+ }+})diff --git a/src/renderer/components/Icons/task-pause-line.js b/src/renderer/components/Icons/task-pause-line.jsnew file mode 100644index 00000000..09aab853--- /dev/null+++ b/src/renderer/components/Icons/task-pause-line.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-pause-line': {+ 'width': 24,+ 'height': 24,+ 'raw': `<rect x="3" y="2" fill="none" stroke-miterlimit="10" width="6" height="20" /><rect x="15" y="2" fill="none" stroke-miterlimit="10" width="6" height="20" />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/task-pause.js b/src/renderer/components/Icons/task-pause.jsnew file mode 100644index 00000000..a1d8e213--- /dev/null+++ b/src/renderer/components/Icons/task-pause.js@@ -0,0 +1,13 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-pause': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M9,1H3C2.447,1,2,1.447,2,2v20c0,0.553,0.447,1,1,1h6c0.553,0,1-0.447,1-1V2C10,1.447,9.553,1,9,1z'+ }, {+ 'd': 'M21,1h-6c-0.553,0-1,0.447-1,1v20c0,0.553,0.447,1,1,1h6c0.553,0,1-0.447,1-1V2C22,1.447,21.553,1,21,1z'+ }]+ }+})diff --git a/src/renderer/components/Icons/task-start-line.js b/src/renderer/components/Icons/task-start-line.jsnew file mode 100644index 00000000..8729bfa4--- /dev/null+++ b/src/renderer/components/Icons/task-start-line.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-start-line': {+ 'width': 24,+ 'height': 24,+ 'raw': `<polygon fill="none" stroke-miterlimit="10" points="5,22 5,2 20,12 "/>`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/task-start.js b/src/renderer/components/Icons/task-start.jsnew file mode 100644index 00000000..3d6e89d6--- /dev/null+++ b/src/renderer/components/Icons/task-start.js@@ -0,0 +1,11 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-start': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M20.555,11.168l-15-10c-0.307-0.204-0.702-0.224-1.026-0.05C4.203,1.292,4,1.631,4,2v20 c0,0.369,0.203,0.708,0.528,0.882C4.676,22.961,4.838,23,5,23c0.194,0,0.388-0.057,0.555-0.168l15-10C20.833,12.646,21,12.334,21,12 S20.833,11.354,20.555,11.168z'+ }]+ }+})diff --git a/src/renderer/components/Icons/task-stop-line.js b/src/renderer/components/Icons/task-stop-line.jsnew file mode 100644index 00000000..564a3a9b--- /dev/null+++ b/src/renderer/components/Icons/task-stop-line.js@@ -0,0 +1,15 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-stop-line': {+ 'width': 24,+ 'height': 24,+ 'raw': `<rect x="2" y="2" fill="none" stroke-miterlimit="10" width="20" height="20" />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Icons/task-stop.js b/src/renderer/components/Icons/task-stop.jsnew file mode 100644index 00000000..cca8c438--- /dev/null+++ b/src/renderer/components/Icons/task-stop.js@@ -0,0 +1,11 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'task-stop': {+ 'width': 24,+ 'height': 24,+ 'paths': [{+ 'd': 'M22,1H2C1.447,1,1,1.447,1,2v20c0,0.553,0.447,1,1,1h20c0.553,0,1-0.447,1-1V2C23,1.447,22.553,1,22,1z'+ }]+ }+})diff --git a/src/renderer/components/Icons/trash.js b/src/renderer/components/Icons/trash.jsnew file mode 100644index 00000000..5dcb3a5a--- /dev/null+++ b/src/renderer/components/Icons/trash.js@@ -0,0 +1,20 @@+import Icon from '@/components/Icons/Icon'++Icon.register({+ 'trash': {+ 'width': 24,+ 'height': 24,+ 'raw': `<polyline fill="none" stroke-miterlimit="10" points="20,9 20,23 4,23 4,9 " />+ <line fill="none" stroke-miterlimit="10" x1="1" y1="5" x2="23" y2="5" />+ <line fill="none" stroke-miterlimit="10" x1="12" y1="12" x2="12" y2="18" />+ <line fill="none" stroke-miterlimit="10" x1="8" y1="12" x2="8" y2="18" />+ <line fill="none" stroke-miterlimit="10" x1="16" y1="12" x2="16" y2="18" />+ <polyline fill="none" stroke-miterlimit="10" points="8,5 8,1 16,1 16,5 " />`,+ 'g': {+ 'stroke': 'currentColor',+ 'stroke-linecap': 'round',+ 'stroke-linejoin': 'round',+ 'stroke-width': '2'+ }+ }+})diff --git a/src/renderer/components/Logo/Logo.vue b/src/renderer/components/Logo/Logo.vuenew file mode 100644index 00000000..e58ad20c--- /dev/null+++ b/src/renderer/components/Logo/Logo.vue@@ -0,0 +1,48 @@+<template>+ <div class="logo">+ <a target="_blank" href="https://motrix.app/">+ <svg xmlns="http://www.w3.org/2000/svg" :width="width" :height="height" viewBox="0 0 62 14">+ <g :fill="fill" fill-rule="evenodd">+ <path d="M40,2 C40,1 41,1.53477231e-14 42,1.53477231e-14 C42,1.53477231e-14 60,1.27897692e-14 60,1.53477231e-14 C61,1.27897692e-14 62,1 62,2 C62,2 62,12 62,12 C62,13 61,14 60,14 C60,14 42,14 42,14 C41,14 40,13 40,12 C40,12 40,2 40,2 Z M44,3.5 C44,3.5 44,10.5 44,10.5 C44,11 44.5,11.5 45,11.5 C45,11.5 57,11.5 57,11.5 C57.5,11.5 58,11 58,10.5 C58,10.5 58,3.5 58,3.5 C58,3 57.5,2.5 57,2.5 C57,2.5 45,2.5 45,2.5 C44.5,2.5 44,3 44,3.5 Z"/>+ <rect width="4" height="2" x="32" y="6" rx=".5"/>+ <path d="M2,0 L26,0 C27,-2.04003481e-15 28,1 28,2 L28,14 L24,14 L24,3.5 C24,3 23.5,2.5 23,2.5 L16,2.5 L16,14 L12,14 L12,2.5 L5,2.5 C4.5,2.5 4,3 4,3.5 L4,14 L0,14 L0,2 C0,1 1,-2.04003481e-15 2,0 Z"/>+ </g>+ </svg>+ </a>+ </div>+</template>++<script>+ export default {+ name: 'mo-logo',+ props: {+ width: {+ type: Number,+ default: 62+ },+ height: {+ type: Number,+ default: 14+ },+ fill: {+ type: String,+ default: '#4D515A'+ }+ }+ }+</script>++<style lang="scss">+.logo {+ display: inline-block;+ margin: 0;+ padding: 0;+ > a {+ display: block;+ width: 100%;+ height: 100%;+ text-align: center;+ font-size: 0;+ }+}+</style>diff --git a/src/renderer/components/Logo/LogoMini.vue b/src/renderer/components/Logo/LogoMini.vuenew file mode 100644index 00000000..bedcf210--- /dev/null+++ b/src/renderer/components/Logo/LogoMini.vue@@ -0,0 +1,36 @@+<template>+ <h1 class="logo-mini">+ <a target="_blank" href="https://motrix.app/">+ <svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 14">+ <path fill="#FFF" fill-rule="evenodd" d="M4,9 L28,9 C29,9 30,10 30,11 L30,23 L26,23 L26,12.5 C26,12 25.5,11.5 25,11.5 L18,11.5 L18,23 L14,23 L14,11.5 L7,11.5 C6.5,11.5 6,12 6,12.5 L6,23 L2,23 L2,11 C2,10 3,9 4,9 Z" transform="translate(-2 -9)"/>+ </svg>+ </a>+ </h1>+</template>++<script>+ export default {+ name: 'mo-logo-mini',+ components: {+ },+ methods: {+ }+ }+</script>++<style lang="scss">+.logo-mini {+ margin: 0;+ padding: 0;+ width: 100%;+ > a {+ display: block;+ width: 28px;+ height: 28px;+ text-align: center;+ font-size: 0;+ padding: 2px;+ margin: 0 auto;+ }+}+</style>diff --git a/src/renderer/components/Logo/Mascot.vue b/src/renderer/components/Logo/Mascot.vuenew file mode 100644index 00000000..e69de29bdiff --git a/src/renderer/components/Main.vue b/src/renderer/components/Main.vuenew file mode 100644index 00000000..f2828611--- /dev/null+++ b/src/renderer/components/Main.vue@@ -0,0 +1,74 @@+<template>+ <el-container id="container">+ <mo-aside />+ <router-view></router-view>+ <mo-speedometer />+ <mo-add-task :visible="addTaskVisible" :type="addTaskType" />+ <mo-about-panel :visible="aboutPanelVisible" />+ <mo-task-item-info :visible="taskItemInfoVisible" :task="currentTaskItem" />+ </el-container>+</template>++<script>+ import { mapState } from 'vuex'+ import AboutPanel from '@/components/About/AboutPanel'+ import Aside from '@/components/Aside/Index'+ import Subnav from '@/components/Subnav/Index'+ import Speedometer from '@/components/Speedometer/Speedometer'+ import AddTask from '@/components/Task/AddTask'+ import TaskItemInfo from '@/components/Task/TaskItemInfo'++ export default {+ name: 'mo-main',+ components: {+ [AboutPanel.name]: AboutPanel,+ [Aside.name]: Aside,+ [Subnav.name]: Subnav,+ [Speedometer.name]: Speedometer,+ [AddTask.name]: AddTask,+ [TaskItemInfo.name]: TaskItemInfo+ },+ computed: {+ ...mapState('app', {+ aboutPanelVisible: state => state.aboutPanelVisible,+ addTaskVisible: state => state.addTaskVisible,+ addTaskType: state => state.addTaskType+ }),+ ...mapState('task', {+ taskItemInfoVisible: state => state.taskItemInfoVisible,+ currentTaskItem: state => state.currentTaskItem+ })+ },+ methods: {+ }+ }+</script>++<style lang="scss">+ .mo-speedometer {+ position: fixed;+ right: 36px;+ bottom: 24px;+ }+ .panel {+ background: $--panel-background;+ .panel-header {+ position: relative;+ padding: 44px 0 12px;+ margin: 0 36px;+ border-bottom: 2px solid $--panel-border-color;+ h4 {+ margin: 0;+ color: $--panel-title-color;+ font-size: 16px;+ font-weight: normal;+ line-height: 24px;+ }+ }+ .panel-content {+ position: relative;+ padding: 16px 36px 24px;+ height: 100%;+ }+ }+</style>diff --git a/src/renderer/components/Native/EngineClient.vue b/src/renderer/components/Native/EngineClient.vuenew file mode 100644index 00000000..295e749d--- /dev/null+++ b/src/renderer/components/Native/EngineClient.vue@@ -0,0 +1,182 @@+<template>+ <div v-if="false"></div>+</template>++<script>+ import { mapState } from 'vuex'+ import api from '@/api'+ import {+ showItemInFolder,+ addToRecentTask,+ openDownloadDock,+ showDownloadSpeedInDock+ } from '@/components/Native/utils'+ import {+ getTaskName,+ getTaskFullPath+ } from '@shared/utils'++ export default {+ name: 'mo-engine-client',+ computed: {+ ...mapState('app', {+ downloadSpeed: state => state.stat.downloadSpeed,+ interval: state => state.interval+ }),+ ...mapState('task', {+ taskItemInfoVisible: state => state.taskItemInfoVisible,+ currentTaskItem: state => state.currentTaskItem+ }),+ ...mapState('preference', {+ taskNotification: state => state.config.taskNotification+ })+ },+ watch: {+ downloadSpeed: function (val, oldVal) {+ showDownloadSpeedInDock(val)+ }+ },+ methods: {+ onDownloadStart: function (event) {+ this.$store.dispatch('task/fetchList')+ this.$store.dispatch('app/resetInterval')+ console.log('aria2 onDownloadStart', event)+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ const message = `开始下载 ${getTaskName(task)}`+ this.$message.info(message)+ })+ },+ onDownloadPause: function (event) {+ console.log('aria2 onDownloadPause')+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ const message = `暂停下载 ${getTaskName(task)}`+ this.$message.info(message)+ })+ },+ onDownloadStop: function (event) {+ console.log('aria2 onDownloadStop')+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ const message = `${getTaskName(task)} 下载中止`+ this.$message.info(message)+ })+ },+ onDownloadError: function (event) {+ console.log('aria2 onDownloadError', event)+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ const message = `${getTaskName(task)} 下载发生错误`+ this.$message.error(message)+ })+ },+ onDownloadComplete: function (event) {+ console.log('aria2 onDownloadComplete')+ this.$store.dispatch('task/fetchList')+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ this.showTaskCompleteNotify(task)+ })+ },+ onBtDownloadComplete: function (event) {+ console.log('aria2 onBtDownloadComplete')+ this.$store.dispatch('task/fetchList')+ const [{ gid }] = event+ api.fetchTaskItem({ gid })+ .then((task) => {+ this.showTaskCompleteNotify(task)+ })+ },+ showTaskCompleteNotify: function (task) {+ if (!this.taskNotification) {+ return+ }++ const taskName = getTaskName(task)+ const path = getTaskFullPath(task)++ addToRecentTask(task)+ openDownloadDock(path)++ const message = `${taskName} 下载完成`+ this.$message.success(message)++ /* eslint-disable no-new */+ const notify = new Notification('下载完成', {+ body: taskName+ })+ notify.onclick = () => {+ showItemInFolder(path)+ }+ },+ showTaskErrorNotify: function (task) {+ if (!this.taskNotification) {+ return+ }++ const taskName = getTaskName(task)++ const message = `${taskName} 下载失败`+ this.$message.success(message)++ /* eslint-disable no-new */+ new Notification('下载失败', {+ body: taskName+ })+ },+ bindEngineEvents: function () {+ api.client.on('onDownloadStart', this.onDownloadStart)+ api.client.on('onDownloadPause', this.onDownloadPause)+ api.client.on('onDownloadStop', this.onDownloadStop)+ api.client.on('onDownloadComplete', this.onDownloadComplete)+ api.client.on('onDownloadError', this.onDownloadError)+ api.client.on('onBtDownloadComplete', this.onBtDownloadComplete)+ },+ unbindEngineEvents: function () {+ api.client.removeListener('onDownloadStart', this.onDownloadStart)+ api.client.removeListener('onDownloadPause', this.onDownloadPause)+ api.client.removeListener('onDownloadStop', this.onDownloadStop)+ api.client.removeListener('onDownloadComplete', this.onDownloadComplete)+ api.client.removeListener('onDownloadError', this.onDownloadError)+ api.client.removeListener('onBtDownloadComplete', this.onBtDownloadComplete)+ },+ startPolling: function () {+ this.timer = setTimeout(() => {+ this.polling()+ this.startPolling()+ }, this.interval)+ },+ polling: function () {+ this.$store.dispatch('app/fetchGlobalStat')+ this.$store.dispatch('task/fetchList')+ if (this.taskItemInfoVisible && this.currentTaskItem) {+ this.$store.dispatch('task/fetchItem', this.currentTaskItem.gid)+ }+ },+ stopPolling: function () {+ clearTimeout(this.timer)+ this.timer = null+ }+ },+ created: function () {+ this.$store.dispatch('app/fetchEngineInfo')++ this.startPolling()++ this.bindEngineEvents()+ },+ destroyed: function () {+ this.$store.dispatch('task/saveSession')++ this.unbindEngineEvents()++ this.stopPolling()+ }+ }+</script>diff --git a/src/renderer/components/Native/Ipc.vue b/src/renderer/components/Native/Ipc.vuenew file mode 100644index 00000000..0ab1d7c8--- /dev/null+++ b/src/renderer/components/Native/Ipc.vue@@ -0,0 +1,47 @@+<template>+ <div v-if="false"></div>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import {+ commands+ } from '@/components/Command/index'++ export default {+ name: 'mo-ipc',+ computed: {+ ...mapState('preference', {+ enableEggFeatures: state => state.config.enableEggFeatures+ })+ },+ watch: {+ },+ methods: {+ bindIpcEvents: function () {+ this.$electron.ipcRenderer.on('command', (event, command, ...args) => {+ commands.execute(command, ...args)+ })+ },+ unbindIpcEvents: function () {+ this.$electron.ipcRenderer.removeAllListeners('command')+ }+ },+ created: function () {+ this.bindIpcEvents()+ // id of the menu item+ let visibleStates = {}+ if (is.mas()) {+ visibleStates['app.check-for-updates'] = false+ if (!this.enableEggFeatures) {+ visibleStates['task.new-bt-task'] = false+ }+ }+ this.$electron.ipcRenderer.send('update-menu-states', visibleStates, null, null)+ },+ destroyed: function () {+ this.unbindIpcEvents()+ }+ }+</script>diff --git a/src/renderer/components/Native/SelectDirectory.vue b/src/renderer/components/Native/SelectDirectory.vuenew file mode 100644index 00000000..07e1ce58--- /dev/null+++ b/src/renderer/components/Native/SelectDirectory.vue@@ -0,0 +1,35 @@+<template>+ <el-button+ class="select-directory"+ @click.stop="onFolderClick"+ >+ <mo-icon name="folder" width="10" height="10" />+ </el-button>+</template>++<script>+ import '@/components/Icons/folder'++ export default {+ name: 'mo-select-directory',+ props: {+ },+ methods: {+ onFolderClick: function () {+ const self = this+ this.$electron.remote.dialog.showOpenDialog({+ properties: ['openDirectory']+ }, (filePaths) => {+ if (!filePaths) {+ return+ }+ const [path] = filePaths+ self.$emit('selected', path)+ })+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Native/ShowInFolder.vue b/src/renderer/components/Native/ShowInFolder.vuenew file mode 100644index 00000000..cf83a0a8--- /dev/null+++ b/src/renderer/components/Native/ShowInFolder.vue@@ -0,0 +1,31 @@+<template>+ <i @click.stop="onFolderClick">+ <mo-icon name="folder" width="14" height="14" />+ </i>+</template>++<script>+ import '@/components/Icons/folder'++ export default {+ name: 'mo-show-in-folder',+ props: {+ path: {+ type: String+ }+ },+ computed: {+ },+ methods: {+ onFolderClick: function () {+ if (!this.path) {+ return+ }+ this.$electron.shell.showItemInFolder(this.path)+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Native/index.js b/src/renderer/components/Native/index.jsnew file mode 100644index 00000000..e69de29bdiff --git a/src/renderer/components/Native/utils.js b/src/renderer/components/Native/utils.jsnew file mode 100644index 00000000..80140eca--- /dev/null+++ b/src/renderer/components/Native/utils.js@@ -0,0 +1,81 @@+import is from 'electron-is'+import { existsSync } from 'fs'+import { Message } from 'element-ui'+import {+ getTaskFullPath,+ bytesToSize+} from '@shared/utils'++const remote = is.renderer() ? require('electron').remote : {}++export function getUserDownloadsPath () {+ return remote.app.getPath('downloads')+}++export function prettifyDir (dir) {+ const downloads = getUserDownloadsPath()+ const result = dir === downloads ? '下载' : dir+ return result+}++export function showItemInFolder (fullPath) {+ if (!fullPath) {+ return+ }+ const result = remote.shell.showItemInFolder(fullPath)+ if (!result) {+ Message.error('目标文件不存在或已删除')+ }+ return result+}++export function moveTaskFilesToTrash (task) {+ const path = getTaskFullPath(task)+ if (!path) {+ Message.error('文件路径异常,请手动删除')+ return false+ }++ const deleteResult1 = remote.shell.moveItemToTrash(path)+ if (!deleteResult1) {+ Message.error('删除任务文件失败,请手动删除')+ }++ let deleteResult2 = true+ const extraFilePath = `${path}.aria2`+ const isExtraExist = existsSync(extraFilePath)+ if (isExtraExist) {+ deleteResult2 = remote.shell.moveItemToTrash(extraFilePath)+ if (!deleteResult2) {+ Message.error('删除任务配置文件失败,请手动删除')+ }+ }++ return deleteResult1 && deleteResult2+}++export function openDownloadDock (path) {+ remote.app.dock.downloadFinished(path)+}++export function updateDockBadge (text) {+ remote.app.dock.setBadge(text)+}++export function showDownloadSpeedInDock (downloadSpeed) {+ const text = downloadSpeed > 0 ? bytesToSize(downloadSpeed) : ''+ updateDockBadge(text)+}++export function addToRecentTask (task) {+ const path = getTaskFullPath(task)+ remote.app.addRecentDocument(path)+}++export function addToRecentTaskByPath (path) {+ remote.app.addRecentDocument(path)+}++export function clearRecentTasks () {+ remote.app.clearRecentDocuments()+}diff --git a/src/renderer/components/Preference/Advanced.vue b/src/renderer/components/Preference/Advanced.vuenew file mode 100644index 00000000..1015e8e6--- /dev/null+++ b/src/renderer/components/Preference/Advanced.vue@@ -0,0 +1,183 @@+<template>+ <el-container class="content panel" direction="vertical">+ <el-header class="panel-header" height="84">+ <h4>{{ title }}</h4>+ </el-header>+ <el-main class="panel-content">+ <el-form+ class="form-preference"+ ref="basicForm"+ label-position="right"+ size="mini"+ :model="form"+ :rules="rules">+ <el-form-item label="代理: " :label-width="formLabelWidth">+ <el-switch+ v-model="form.useProxy"+ active-text="使用代理服务器"+ @change="onUseProxyChange"+ >+ </el-switch>+ </el-form-item>+ <el-form-item label="" :label-width="formLabelWidth" v-if="form.useProxy">+ <el-col class="form-item-sub" :span="16">+ <el-input+ placeholder="[http://][USER:PASSWORD@]HOST[:PORT]"+ @change="onAllProxyBackupChange"+ v-model="form.allProxyBackup">+ </el-input>+ </el-col>+ </el-form-item>+ <el-form-item label="开发者: " :label-width="formLabelWidth">+ <el-col class="form-item-sub" :span="24">+ 模拟用户代理+ <el-input+ type="textarea"+ :autosize="{ minRows: 2, maxRows: 3 }"+ auto-complete="off"+ placeholder="User-Agent"+ v-model="form.userAgent">+ </el-input>+ <el-button-group class="ua-group">+ <el-button @click="() => changeUA('transmission')">Transmission</el-button>+ <el-button @click="() => changeUA('chrome')">Chrome</el-button>+ <el-button @click="() => changeUA('du')">du</el-button>+ </el-button-group>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ 应用日志路径+ <el-input placeholder="" disabled v-model="logPath">+ <mo-show-in-folder+ slot="append"+ v-if="isRenderer()"+ :path="logPath"+ />+ </el-input>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ 下载会话记录+ <el-input placeholder="" disabled v-model="sessionPath">+ <mo-show-in-folder+ slot="append"+ v-if="isRenderer()"+ :path="sessionPath"+ />+ </el-input>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ <el-button plain type="danger" @click="() => onResetClick()">恢复初始设置</el-button>+ </el-col>+ </el-form-item>+ </el-form>+ <div class="form-actions">+ <el-button type="primary" @click="submitForm('basicForm')">保存并应用</el-button>+ <el-button @click="resetForm('basicForm')">放弃</el-button>+ </div>+ </el-main>+ </el-container>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import ShowInFolder from '@/components/Native/ShowInFolder'+ import userAgentMap from '@shared/ua'++ const initialForm = (config) => {+ const {+ useProxy,+ allProxy,+ allProxyBackup,+ userAgent+ } = config+ const result = {+ useProxy,+ allProxy,+ allProxyBackup,+ userAgent+ }+ return result+ }++ export default {+ name: 'mo-preference-advanced',+ components: {+ [ShowInFolder.name]: ShowInFolder+ },+ data: function () {+ return {+ formLabelWidth: '23%',+ form: initialForm(this.$store.state.preference.config),+ rules: {}+ }+ },+ computed: {+ title: function () {+ return '进阶设置'+ },+ ...mapState('preference', {+ config: state => state.config,+ logPath: state => state.config.logPath,+ sessionPath: state => state.config.sessionPath+ })+ },+ watch: {++ },+ methods: {+ isRenderer: is.renderer,+ onUseProxyChange (flag) {+ this.form.allProxy = flag ? this.form.allProxyBackup : ''+ console.log('this.form.allProxy===>', flag, this.form.allProxy)+ },+ onAllProxyBackupChange (value) {+ this.form.allProxy = value+ },+ changeUA (type) {+ const ua = userAgentMap[type]+ console.log('changeUA===>', ua)+ if (!ua) {+ return+ }+ this.form.userAgent = ua+ },+ onResetClick () {+ this.$electron.remote.dialog.showMessageBox({+ type: 'warning',+ title: '恢复初始设置',+ message: '你确定要恢复为初始设置吗?',+ buttons: ['是', '否'],+ cancelId: 1+ }, (buttonIndex) => {+ // 点击的按钮是哪个按钮 0: 是, 1: 否+ if (buttonIndex === 0) {+ this.$electron.ipcRenderer.send('command', 'application:reset')+ }+ })+ },+ submitForm (formName) {+ this.$refs[formName].validate((valid) => {+ if (!valid) {+ console.log('error submit!!')+ return false+ }++ console.log('this.form===>', this.form)+ this.$store.dispatch('preference/save', this.form)+ if (this.isRenderer()) {+ this.$electron.ipcRenderer.send('command', 'application:relaunch')+ }+ })+ },+ resetForm (formName) {+ this.form = initialForm(this.$store.state.preference.config)+ }+ }+ }+</script>++<style lang="scss">+ .ua-group {+ margin-top: 8px;+ }+</style>diff --git a/src/renderer/components/Preference/Basic.vue b/src/renderer/components/Preference/Basic.vuenew file mode 100644index 00000000..43625d3b--- /dev/null+++ b/src/renderer/components/Preference/Basic.vue@@ -0,0 +1,158 @@+<template>+ <el-container class="content panel" direction="vertical">+ <el-header class="panel-header" height="84">+ <h4>{{ title }}</h4>+ </el-header>+ <el-main class="panel-content">+ <el-form+ class="form-preference"+ ref="basicForm"+ label-position="right"+ size="mini"+ :model="form"+ :rules="rules">+ <el-form-item label="启动: " :label-width="formLabelWidth">+ <el-checkbox v-model="form.resumeAllWhenAppLaunched">+ 启动后自动开始未完成任务+ </el-checkbox>+ </el-form-item>+ <el-form-item label="默认下载路径: " :label-width="formLabelWidth">+ <el-input placeholder="" v-model="downloadDir" :readonly="isMas()">+ <mo-select-directory+ v-if="isRenderer()"+ slot="append"+ @selected="onDirectorySelected"+ />+ </el-input>+ <div class="el-form-item__info" v-if="isMas()" style="margin-top: 8px;">+ 因 App Store 的沙箱权限限制,默认下载路径建议设置为您的「下载」目录+ </div>+ </el-form-item>+ <el-form-item label="任务管理: " :label-width="formLabelWidth">+ <el-col class="form-item-sub" :span="24">+ 同时下载的最大任务数+ <el-input-number+ v-model="form.maxConcurrentDownloads"+ controls-position="right"+ :min="1"+ :max="10"+ label="同时下载最大任务数">+ </el-input-number>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ 单任务下载的线程数+ <el-input-number+ v-model="form.split"+ controls-position="right"+ :min="1"+ :max="64"+ label="单任务下载线程数">+ </el-input-number>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ <el-checkbox v-model="form.continue">+ 断点续传+ </el-checkbox>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ <el-checkbox v-model="form.newTaskShowDownloading">+ 新建任务后自动跳转到下载页面+ </el-checkbox>+ </el-col>+ <el-col class="form-item-sub" :span="24">+ <el-checkbox v-model="form.taskNotification">+ 下载完成后通知+ </el-checkbox>+ </el-col>+ </el-form-item>+ </el-form>+ <div class="form-actions">+ <el-button type="primary" @click="submitForm('basicForm')">保存并应用</el-button>+ <el-button @click="resetForm('basicForm')">放弃</el-button>+ </div>+ </el-main>+ </el-container>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import SelectDirectory from '@/components/Native/SelectDirectory'+ import { prettifyDir } from '@/components/Native/utils'++ const initialForm = (config) => {+ const {+ dir,+ split,+ resumeAllWhenAppLaunched,+ maxConcurrentDownloads,+ taskNotification,+ newTaskShowDownloading+ } = config+ console.log('initialForm===>', dir, split)+ const result = {+ dir,+ split,+ userAgent: '',+ referer: '',+ cookie: '',+ continue: config.continue,+ resumeAllWhenAppLaunched,+ maxConcurrentDownloads,+ taskNotification,+ newTaskShowDownloading+ }+ return result+ }++ export default {+ name: 'mo-preference-basic',+ components: {+ [SelectDirectory.name]: SelectDirectory+ },+ data: function () {+ return {+ formLabelWidth: '23%',+ form: initialForm(this.$store.state.preference.config),+ rules: {}+ }+ },+ computed: {+ title: function () {+ return '基础设置'+ },+ downloadDir: function () {+ return prettifyDir(this.form.dir)+ },+ ...mapState('preference', {+ config: state => state.config+ })+ },+ methods: {+ isRenderer: is.renderer,+ isMas: is.mas,+ onDirectorySelected (dir) {+ this.form.dir = dir+ },+ submitForm (formName) {+ this.$refs[formName].validate((valid) => {+ if (!valid) {+ console.log('error submit!!')+ return false+ }++ this.$store.dispatch('preference/save', this.form)+ if (this.isRenderer()) {+ this.$electron.ipcRenderer.send('command', 'application:relaunch')+ }+ })+ },+ resetForm (formName) {+ this.form = initialForm(this.$store.state.preference.config)+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Preference/Index.vue b/src/renderer/components/Preference/Index.vuenew file mode 100644index 00000000..11d66999--- /dev/null+++ b/src/renderer/components/Preference/Index.vue@@ -0,0 +1,68 @@+<template>+ <el-container class="content panel" direction="horizontal">+ <el-aside width="200px" class="subnav">+ <router-view name="subnav"></router-view>+ </el-aside>+ <router-view name="form"></router-view>+ </el-container>+</template>++<script>+ export default {+ name: 'mo-content-preference',+ props: {+ category: {+ type: String+ }+ },+ computed: {+ title: function () {+ const titles = {+ 'basic': '基础设置',+ 'advanced': '进阶设置',+ 'lab': '实验室'+ }+ return titles[this.category]+ }+ },+ components: {+ },+ methods: {+ }+ }+</script>++<style lang="scss">+ .form-preference {+ padding-right: 7%;+ .el-switch__label {+ font-weight: $--font-weight-secondary;+ color: $--color-text-regular;+ }+ .el-form-item.el-form-item--mini {+ margin-bottom: 24px;+ }+ .el-form-item__content {+ color: $--color-text-regular;+ }+ .form-item-sub {+ margin-bottom: 12px;+ a {+ color: $--color-text-regular;+ text-decoration: none;+ &:hover {+ color: $--color-text-primary;+ text-decoration: underline;+ }+ }+ }+ }+ .form-actions {+ position: absolute;+ bottom: 0;+ left: 0;+ width: 100%;+ box-sizing: border-box;+ padding: 24px 36px;+ }+</style>diff --git a/src/renderer/components/Preference/Lab.vue b/src/renderer/components/Preference/Lab.vuenew file mode 100644index 00000000..6437ce38--- /dev/null+++ b/src/renderer/components/Preference/Lab.vue@@ -0,0 +1,110 @@+<template>+ <el-container class="content panel" direction="vertical">+ <el-header class="panel-header" height="84">+ <h4>{{ title }}</h4>+ </el-header>+ <el-main class="panel-content">+ <el-form+ class="form-preference"+ ref="basicForm"+ label-position="right"+ size="mini"+ :model="form"+ :rules="rules">+ <el-form-item :label-width="formLabelWidth">+ <div class="el-form-item__error">⚠️启用实验特性可能造成应用崩溃或数据丢失,请自行决定!</div>+ </el-form-item>+ <el-form-item label="下载协议: " :label-width="formLabelWidth">+ <el-col class="form-item-sub" :span="24">+ <el-switch+ v-model="form.enableEggFeatures"+ active-text="支持更多下载协议"+ >+ </el-switch>+ </el-col>+ </el-form-item>+ <el-form-item label="浏览器扩展: " :label-width="formLabelWidth">+ <el-col class="form-item-sub" :span="24">+ <a target="_blank" href="https://motrix.app/release/BaiduExporter.zip" rel="noopener noreferrer">+ 百度网盘助手+ <mo-icon name="link" width="14" height="14" />+ </a>+ <div class="el-form-item__info" style="margin-top: 8px;">+ 社区提供的浏览器扩展「不保证可用性」,+ <a target="_blank" href="https://motrix.app/extensions/baidu" rel="noopener noreferrer">+ 点此查看使用说明+ </a>+ </div>+ </el-col>+ </el-form-item>+ </el-form>+ <div class="form-actions">+ <el-button type="primary" @click="submitForm('basicForm')">保存并应用</el-button>+ <el-button @click="resetForm('basicForm')">放弃</el-button>+ </div>+ </el-main>+ </el-container>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import '@/components/Icons/info-square'++ const initialForm = (config) => {+ const {+ enableEggFeatures+ } = config+ const result = {+ enableEggFeatures+ }+ return result+ }++ export default {+ name: 'mo-preference-lab',+ components: {+ },+ data: function () {+ return {+ formLabelWidth: '23%',+ form: initialForm(this.$store.state.preference.config),+ rules: {}+ }+ },+ computed: {+ title: function () {+ return '实验室'+ },+ ...mapState('preference', {+ config: state => state.config+ })+ },+ watch: {++ },+ methods: {+ isRenderer: is.renderer,+ submitForm (formName) {+ this.$refs[formName].validate((valid) => {+ if (!valid) {+ console.log('error submit!!')+ return false+ }++ console.log('this.form===>', this.form)+ this.$store.dispatch('preference/save', this.form)+ if (this.isRenderer()) {+ this.$electron.ipcRenderer.send('command', 'application:relaunch')+ }+ })+ },+ resetForm (formName) {+ this.form = initialForm(this.$store.state.preference.config)+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Speedometer/Speedometer.vue b/src/renderer/components/Speedometer/Speedometer.vuenew file mode 100644index 00000000..3b7c6242--- /dev/null+++ b/src/renderer/components/Speedometer/Speedometer.vue@@ -0,0 +1,155 @@+<template>+ <div class="mo-speedometer" :class="{ stopped: stat.numActive === 0 }">+ <div+ class="mode"+ @click="toggleEngineMode"+ >+ <i>+ <mo-icon name="speedometer" width="24" height="24" />+ </i>+ <em>{{ engineMode }}</em>+ </div>+ <div class="value" v-if="stat.numActive > 0">+ <em >{{ stat.uploadSpeed | bytesToSize }}/s</em>+ <span>{{ stat.downloadSpeed | bytesToSize }}/s</span>+ </div>+ </div>+</template>++<script>+ import { mapState, mapActions } from 'vuex'+ import '@/components/Icons/speedometer'+ import {+ bytesToSize+ } from '@shared/utils'++ export default {+ name: 'mo-speedometer',+ components: {+ },+ computed: {+ ...mapState('app', [+ 'stat'+ ]),+ ...mapState('preference', [+ 'engineMode'+ ])+ },+ filters: {+ bytesToSize+ },+ methods: {+ ...mapActions('preference', [+ 'toggleEngineMode'+ ])+ }+ }+</script>++<style lang="scss">+ @import '../Theme/Variables';+ @import '../Theme/Darkness/Variables';++ .mo-speedometer {+ font-size: 12px;+ position: relative;+ display: inline-block;+ box-sizing: border-box;+ width: 150px;+ height: 40px;+ padding: 5px 10px 5px 48px;+ border-radius: 100px;+ transition: $--all-transition;+ border: 1px solid $--speedometer-border-color;+ background: $--speedometer-background;+ &:hover {+ border-color: $--speedometer-hover-border-color;+ }+ &.stopped {+ width: 40px;+ padding: 0;+ .mode i {+ color: $--speedometer-stopped-color;+ }+ .mode em {+ display: none;+ }++ }+ em {+ font-style: normal;+ }+ .mode {+ font-size: 0;+ position: absolute;+ top: 5px;+ left: 5px;+ }+ .mode i {+ font-size: 20px;+ font-style: normal;+ line-height: 28px;+ display: inline-block;+ box-sizing: border-box;+ width: 28px;+ height: 28px;+ padding: 2px;+ text-align: center;+ vertical-align: top;+ color: $--speedometer-primary-color;+ }+ .mode em {+ display: inline-block;+ width: 0;+ height: 8px;+ margin-left: 4px;+ font-size: 16px;+ line-height: 15px;+ transform: scale(.5);+ vertical-align: top;+ color: $--speedometer-primary-color;+ }+ .mode.mode-auto em {+ color: $--speedometer-text-color;+ }+ .mode.mode-max em {+ color: $--speedometer-primary-color;+ }+ .value {+ font-size: 0;+ overflow: hidden;+ width: 100%;+ text-align: right;+ white-space: nowrap;+ text-overflow: ellipsis;+ }+ .value em {+ font-size: 16px;+ line-height: 12px;+ display: block;+ width: 120%;+ transform: scale(.625);+ color: $--speedometer-text-color;+ }+ .value span {+ font-size: 13px;+ line-height: 14px;+ display: block;+ margin-top: 2px;+ color: $--speedometer-primary-color;+ }+ .no-active {+ font-size: 14px;+ line-height: 28px;+ color: $--speedometer-primary-color;+ }+ }++ .darkness .mo-speedometer {+ border: 1px solid $--dk-speedometer-border-color;+ background: $--dk-speedometer-background;+ &:hover {+ border-color: $--dk-speedometer-hover-border-color;+ }+ }+</style>diff --git a/src/renderer/components/Subnav/Index.vue b/src/renderer/components/Subnav/Index.vuenew file mode 100644index 00000000..22cffb7a--- /dev/null+++ b/src/renderer/components/Subnav/Index.vue@@ -0,0 +1,73 @@+<template>+ <el-aside width="200px" class="subnav">+ <router-view name="subnav"></router-view>+ </el-aside>+</template>++<script>+ // import { mapState, mapGetters } from 'vuex'++ export default {+ name: 'mo-subnav',+ components: {+ },+ computed: {+ // ...mapState('app', {+ // currentPage: state => state.currentPage+ // }),+ // ...mapGetters('app', {+ // title: 'currentPageTitle'+ // })+ },+ methods: {+ }+ }+</script>++<style lang="scss">+ .subnav-inner {+ margin-top: 44px;+ padding: 0 16px;+ h3 {+ font-size: 16px;+ color: #071D43;+ font-weight: normal;+ line-height: 24px;+ margin: 0 0 28px;+ }+ ul {+ list-style: none;+ padding: 0;+ margin: 0;+ user-select: none;+ cursor: default;+ li {+ margin-bottom: 8px;+ padding: 8px 10px;+ font-size: 14px;+ line-height: 20px;+ border-radius: 3px;+ cursor: pointer;+ i, span {+ vertical-align: middle;+ display: inline-block;+ }+ &:hover, &.active {+ background-color: #EAECF0;+ i, span, svg {+ color: $--subnav-active-text-color;+ }+ }+ }+ }+ }+ .subnav-icon {+ padding: 2px;+ height: 16px;+ margin-right: 12px;+ svg {+ width: 16px;+ height: 16px;+ }+ }+</style>diff --git a/src/renderer/components/Subnav/PreferenceSubnav.vue b/src/renderer/components/Subnav/PreferenceSubnav.vuenew file mode 100644index 00000000..390856c2--- /dev/null+++ b/src/renderer/components/Subnav/PreferenceSubnav.vue@@ -0,0 +1,68 @@+<template>+ <nav class="subnav-inner">+ <h3>{{ title }}</h3>+ <ul>+ <li+ @click="() => nav('basic')"+ v-bind:class="[ current === 'basic' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name='preference-basic' width="20" height="20" />+ </i>+ <span>基础设置</span>+ </li>+ <li+ @click="() => nav('advanced')"+ v-bind:class="[ current === 'advanced' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name='preference-advanced' width="20" height="20" />+ </i>+ <span>进阶设置</span>+ </li>+ <li+ @click="() => nav('lab')"+ v-bind:class="[ current === 'lab' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name='preference-lab' width="20" height="20" />+ </i>+ <span>实验室</span>+ </li>+ </ul>+ </nav>+</template>++<script>+ import is from 'electron-is'+ import '@/components/Icons/preference-basic'+ import '@/components/Icons/preference-advanced'+ import '@/components/Icons/preference-lab'++ export default {+ name: 'mo-preference-subnav',+ props: {+ current: {+ type: String,+ default: 'basic'+ }+ },+ computed: {+ title: function () {+ return '偏好设置'+ }+ },+ methods: {+ isMas: is.mas,+ nav: function (category = 'basic') {+ console.log('nav category===>', category)+ this.$router.push({+ path: `/preference/${category}`+ })+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Subnav/TaskSubnav.vue b/src/renderer/components/Subnav/TaskSubnav.vuenew file mode 100644index 00000000..8560f9c3--- /dev/null+++ b/src/renderer/components/Subnav/TaskSubnav.vue@@ -0,0 +1,66 @@+<template>+ <nav class="subnav-inner">+ <h3>{{ title }}</h3>+ <ul>+ <li+ @click="() => nav('active')"+ v-bind:class="[ current === 'active' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name="task-start" width="20" height="20" />+ </i>+ <span>下载中</span>+ </li>+ <li+ @click="() => nav('waiting')"+ v-bind:class="[ current === 'waiting' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name="task-pause" width="20" height="20" />+ </i>+ <span>已暂停</span>+ </li>+ <li+ @click="() => nav('stopped')"+ v-bind:class="[ current === 'stopped' ? 'active' : '' ]"+ >+ <i class="subnav-icon">+ <mo-icon name="task-stop" width="20" height="20" />+ </i>+ <span>已完成</span>+ </li>+ </ul>+ </nav>+</template>++<script>+ import '@/components/Icons/task-start'+ import '@/components/Icons/task-pause'+ import '@/components/Icons/task-stop'++ export default {+ name: 'mo-task-subnav',+ props: {+ current: {+ type: String,+ default: 'active'+ }+ },+ computed: {+ title: function () {+ return '任务列表'+ }+ },+ methods: {+ nav: function (status = 'active') {+ console.log('nav status===>', status)+ this.$router.push({+ path: `/task/${status}`+ })+ }+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Task/AddTask.vue b/src/renderer/components/Task/AddTask.vuenew file mode 100644index 00000000..31a45fee--- /dev/null+++ b/src/renderer/components/Task/AddTask.vue@@ -0,0 +1,391 @@+<template>+ <el-dialog+ custom-class="tab-title-dialog add-task-dialog"+ width="61.8vw"+ :visible.sync="visible"+ :before-close="handleClose"+ @open="handleOpen"+ @closed="handleClosed">+ <el-form+ ref="taskForm"+ label-position="left"+ :model="form"+ :rules="rules">+ <el-tabs :value="type" @tab-click="handleTabClick">+ <el-tab-pane label="链接任务" name="uri">+ <el-form-item>+ <el-input+ ref="uri"+ type="textarea"+ :autosize="{ minRows: 3, maxRows: 5 }"+ auto-complete="off"+ placeholder="添加多个下载链接时,请确保每行只有一个链接"+ v-model="form.uris">+ </el-input>+ </el-form-item>+ </el-tab-pane>+ <el-tab-pane+ label="种子任务"+ name="torrent"+ v-if="iLoveEggFeatures"+ >+ <el-form-item>+ <mo-select-torrent+ v-on:change="handleTorrentChange"+ />+ </el-form-item>+ </el-tab-pane>+ </el-tabs>+ <el-row :gutter="12">+ <el-col :span="15">+ <el-form-item label="文件名: " :label-width="formLabelWidth">+ <el-input placeholder="请输入文件名" v-model="form.out">+ </el-input>+ </el-form-item>+ </el-col>+ <el-col :span="9">+ <el-form-item label="下载线程: " :label-width="formLabelWidth">+ <el-input-number+ v-model="form.split"+ @change="handleSplitChange"+ controls-position="right"+ :min="1"+ :max="config.maxConnectionPerServer"+ :value="config.split"+ label="下载线程">+ </el-input-number>+ </el-form-item>+ </el-col>+ </el-row>+ <el-form-item label="存储路径: " :label-width="formLabelWidth">+ <el-input placeholder="" v-model="downloadDir" :readonly="isMas()">+ <mo-select-directory+ v-if="isRenderer()"+ slot="append"+ @selected="onDirectorySelected"+ />+ </el-input>+ </el-form-item>+ <div v-if="showAdvanced">+ <el-form-item label="UA: " :label-width="formLabelWidth">+ <el-input+ type="textarea"+ :autosize="{ minRows: 2, maxRows: 3 }"+ auto-complete="off"+ placeholder="User-Agent"+ v-model="form.userAgent">+ </el-input>+ </el-form-item>+ <el-form-item label="Referer: " :label-width="formLabelWidth">+ <el-input+ type="textarea"+ :autosize="{ minRows: 2, maxRows: 3 }"+ auto-complete="off"+ placeholder="Referer"+ v-model="form.referer">+ </el-input>+ </el-form-item>+ <el-form-item label="Cookie: " :label-width="formLabelWidth">+ <el-input+ type="textarea"+ :autosize="{ minRows: 2, maxRows: 3 }"+ auto-complete="off"+ placeholder="Cookie"+ v-model="form.cookie">+ </el-input>+ </el-form-item>+ <el-form-item label="" :label-width="formLabelWidth">+ <el-checkbox class="chk" v-model="form.newTaskShowDownloading">跳转到下载页面</el-checkbox>+ </el-form-item>+ </div>+ </el-form>+ <div slot="footer" class="dialog-footer">+ <el-checkbox class="chk" v-model="showAdvanced">显示高级选项</el-checkbox>+ <el-button @click="handleCancel('taskForm')">取 消</el-button>+ <el-button type="primary" @click="submitForm('taskForm')">确 定</el-button>+ </div>+ </el-dialog>+</template>++<script>+ import is from 'electron-is'+ import { mapState } from 'vuex'+ import { isEmpty, compact } from 'lodash'+ import SelectDirectory from '@/components/Native/SelectDirectory'+ import SelectTorrent from '@/components/Task/SelectTorrent'+ import { prettifyDir } from '@/components/Native/utils'+ import '@/components/Icons/inbox'+ import { splitTextRows, needCheckCopyright } from '@shared/utils'++ const initialForm = (state) => {+ const { dir, split, newTaskShowDownloading } = state.preference.config+ const result = {+ uris: '',+ torrent: '',+ out: '',+ userAgent: '',+ referer: '',+ cookie: '',+ dir,+ split,+ newTaskShowDownloading+ }+ return result+ }++ export default {+ name: 'mo-add-task',+ components: {+ [SelectDirectory.name]: SelectDirectory,+ [SelectTorrent.name]: SelectTorrent+ },+ props: {+ visible: {+ type: Boolean,+ default: false+ },+ type: {+ type: String,+ default: 'uri'+ }+ },+ data () {+ return {+ formLabelWidth: '75px',+ showAdvanced: false,+ torrentName: '',+ form: {},+ rules: {+ }+ }+ },+ computed: {+ taskType: function () {+ return this.type+ },+ downloadDir: function () {+ return prettifyDir(this.form.dir)+ },+ ...mapState('app', {+ taskList: state => state.taskList+ }),+ ...mapState('preference', {+ config: state => state.config+ }),+ iLoveEggFeatures: function () {+ return !this.isMas() || (this.isMas() && this.config.enableEggFeatures)+ }+ },+ watch: {+ taskType: function (current, previous) {+ if (this.visible && previous === 'uri') {+ return+ }++ if (current === 'uri') {+ setTimeout(() => {+ this.$refs.uri && this.$refs.uri.focus()+ }, 50)+ }+ }+ },+ methods: {+ isRenderer: is.renderer,+ isMas: is.mas,+ handleOpen () {+ this.form = initialForm(this.$store.state)+ if (this.taskType === 'uri') {+ setTimeout(() => {+ this.$refs.uri && this.$refs.uri.focus()+ }, 50)+ }+ },+ handleClose (done) {+ this.$store.dispatch('app/hideAddTaskDialog')+ },+ handleClosed () {+ this.reset()+ },+ handleTabClick (tab, event) {+ console.log(tab, tab.name, event)+ this.$store.dispatch('app/changeAddTaskType', tab.name)+ },+ handleTorrentChange (torrent, file, fileList) {+ // TODO 种子选择部分文件下载+ // console.log('handleTorrentChange===>', torrent, file, fileList)+ this.form.torrent = torrent+ },+ handleSplitChange (value) {+ console.log('handleSplitChange===>', value)+ },+ onDirectorySelected (dir) {+ this.form.dir = dir+ },+ reset () {+ this.form = initialForm(this.$store.state)+ },+ handleCancel (formName) {+ this.$store.dispatch('app/hideAddTaskDialog')+ },+ buildHeader (form) {+ const {+ userAgent, referer, cookie+ } = form+ const result = []++ if (!isEmpty(userAgent)) {+ result.push(`User-Agent: ${userAgent}`)+ }+ if (!isEmpty(referer)) {+ result.push(`Referer: ${referer}`)+ }+ if (!isEmpty(cookie)) {+ result.push(`Cookie: ${cookie}`)+ }+ return result+ },+ buildOption (form) {+ const {+ dir, out, split+ } = form+ const result = {}++ if (!isEmpty(dir)) {+ result.dir = dir+ }++ if (!isEmpty(out)) {+ result.out = out+ }++ if (split > 0) {+ result.split = split+ }++ const header = this.buildHeader(form)+ if (!isEmpty(header)) {+ result.header = header+ }+ return result+ },+ buildUriPayload (form) {+ let { uris } = form+ uris = compact(splitTextRows(uris))+ const options = this.buildOption(form)+ const result = {+ uris,+ options+ }+ return result+ },+ buildTorrentPayload (form) {+ const { torrent } = form+ const options = this.buildOption(form)+ const result = {+ torrent,+ options+ }+ console.log('buildTorrentPayload===>', result)+ return result+ },+ addTask (type, form) {+ let payload = null+ if (type === 'uri') {+ payload = this.buildUriPayload(form)+ this.$store.dispatch('task/addUri', payload)+ .catch((err) => {+ this.$message.error(err.message)+ })+ } else if (type === 'torrent') {+ payload = this.buildTorrentPayload(form)+ this.$store.dispatch('task/addTorrent', payload)+ .catch((err) => {+ this.$message.error(err.message)+ })+ } else if (type === 'metalink') {+ // @TODO addMetalink+ } else {+ console.error('addTask fail', form)+ }+ },+ checkCopyright (type, form) {+ let { uris } = form+ uris = compact(splitTextRows(uris))++ return new Promise((resolve, reject) => {+ if (type !== 'uri') {+ resolve()+ }++ if (!needCheckCopyright(uris)) {+ resolve()+ return+ }++ if (this.iLoveEggFeatures) {+ resolve()+ return+ }++ this.$electron.remote.dialog.showMessageBox({+ type: 'warning',+ title: '版权检查',+ message: '您要下载的文件可能是有版权的音视频,请确保您有相应的版权方授权!',+ buttons: ['是,我有版权方授权', '否'],+ cancelId: 1+ }, (buttonIndex, checkboxChecked) => {+ // 点击的按钮是哪个按钮 0: 是, 1: 否+ if (buttonIndex === 0) {+ resolve()+ } else {+ reject(new Error('因版权问题,添加任务失败'))+ }+ })+ })+ },+ submitForm (formName) {+ this.$refs[formName].validate((valid) => {+ if (!valid) {+ return false+ }++ this.checkCopyright(this.type, this.form)+ .then(() => {+ this.addTask(this.type, this.form)+ this.$store.dispatch('app/hideAddTaskDialog')+ if (this.form.newTaskShowDownloading) {+ this.$router.push({+ path: '/task/active'+ })+ }+ })+ .catch((err) => {+ this.$message.error(err.message)+ // this.reset()+ })+ })+ }+ }+ }+</script>++<style lang="scss">+ .add-task-dialog {+ max-width: 632px;+ .el-input-number.el-input-number--mini {+ width: 100%;+ }+ .el-dialog__footer {+ padding-top: 20px;+ background: #f5f5f5;+ border-radius: 0 0 5px 5px;+ }+ .dialog-footer {+ .chk {+ float: left;+ line-height: 28px;+ }+ }++ }+</style>diff --git a/src/renderer/components/Task/Index.vue b/src/renderer/components/Task/Index.vuenew file mode 100644index 00000000..2cb1f9a2--- /dev/null+++ b/src/renderer/components/Task/Index.vue@@ -0,0 +1,67 @@+<template>+ <el-container class="content panel" direction="horizontal">+ <el-aside width="200px" class="subnav">+ <mo-task-subnav :current="status" />+ </el-aside>+ <el-container class="content panel" direction="vertical">+ <el-header class="panel-header" height="84">+ <h4>{{ title }}</h4>+ <mo-task-actions />+ </el-header>+ <el-main class="panel-content">+ <mo-task-list />+ </el-main>+ </el-container>+ </el-container>+</template>++<script>+ import TaskSubnav from '@/components/Subnav/TaskSubnav'+ import TaskActions from '@/components/Task/TaskActions'+ import TaskList from '@/components/Task/TaskList'++ export default {+ name: 'mo-content-task',+ components: {+ [TaskSubnav.name]: TaskSubnav,+ [TaskActions.name]: TaskActions,+ [TaskList.name]: TaskList+ },+ props: {+ status: {+ type: String,+ default: 'active'+ }+ },+ computed: {+ title: function () {+ const titles = {+ 'active': '下载中',+ 'waiting': '已暂停',+ 'stopped': '已完成'+ }+ return titles[this.status]+ }+ },+ watch: {+ 'status': 'onStatusChange'+ },+ methods: {+ open (link) {+ this.$electron.shell.openExternal(link)+ },+ onStatusChange () {+ this.changeCurrentList()+ },+ changeCurrentList () {+ this.$store.dispatch('task/changeCurrentList', this.status)+ }+ },+ created: function () {+ this.changeCurrentList()+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Task/SelectTorrent.vue b/src/renderer/components/Task/SelectTorrent.vuenew file mode 100644index 00000000..226be043--- /dev/null+++ b/src/renderer/components/Task/SelectTorrent.vue@@ -0,0 +1,86 @@+<template>+ <el-upload+ class="upload-torrent"+ drag+ action="/"+ accept=".torrent"+ :on-change="handleChange"+ :auto-upload="false"+ :show-file-list="false">+ <i class="upload-inbox-icon"><mo-icon name="inbox" width="24" height="24" /></i>+ <div class="el-upload__text">+ 将种子拖到此处,或<em>点击选择</em>+ <div class="torrent-name" v-if="name">{{ name }}</div>+ </div>+ </el-upload>+</template>++<script>+ import { mapState } from 'vuex'+ import parseTorrent from 'parse-torrent'+ import '@/components/Icons/inbox'+ import { getAsBase64 } from '@shared/utils'++ export default {+ name: 'mo-select-torrent',+ components: {+ },+ props: {+ },+ data () {+ return {+ name: ''+ }+ },+ computed: {+ ...mapState('preference', {+ config: state => state.config+ })+ },+ methods: {+ handleChange (file, fileList) {+ console.log('file===>', file)+ if (!file.raw) {+ return+ }++ parseTorrent.remote(file.raw, (err, parsedTorrent) => {+ if (err) throw err+ console.log(parsedTorrent)+ })++ getAsBase64(file.raw, (torrent) => {+ this.name = file.name+ this.$emit('change', torrent, file, fileList)+ })+ }+ }+ }+</script>++<style lang="scss">+ @import '../Theme/Variables';+ @import '../Theme/Darkness/Variables';++ .upload-torrent {+ width: 100%;+ .el-upload, .el-upload-dragger {+ width: 100%;+ }+ .el-upload-dragger {+ border-radius: 4px;+ padding: 24px;+ height: auto;+ }+ .upload-inbox-icon {+ display: inline-block;+ margin-bottom: 12px;+ }+ .torrent-name {+ margin-top: 4px;+ font-size: $--font-size-small;+ color: $--color-text-secondary;+ line-height: 16px;+ }+ }+</style>diff --git a/src/renderer/components/Task/TaskActions.vue b/src/renderer/components/Task/TaskActions.vuenew file mode 100644index 00000000..32fb3dfc--- /dev/null+++ b/src/renderer/components/Task/TaskActions.vue@@ -0,0 +1,142 @@+<template>+ <div class="task-actions">+ <el-tooltip class="item" effect="dark" content="刷新列表" placement="bottom">+ <i @click="onRefreshClick">+ <mo-icon name="refresh" width="14" height="14" :spin="refreshing" />+ </i>+ </el-tooltip>+ <el-tooltip class="item" effect="dark" content="恢复所有任务" placement="bottom">+ <i @click="onResumeAllClick">+ <mo-icon name="task-start-line" width="14" height="14" />+ </i>+ </el-tooltip>+ <el-tooltip class="item" effect="dark" content="暂停所有任务" placement="bottom">+ <i @click="onPauseAllClick">+ <mo-icon name="task-pause-line" width="14" height="14" />+ </i>+ </el-tooltip>+ <!-- <el-tooltip class="item" effect="dark" content="移除选中的任务" placement="bottom">+ <i>+ <mo-icon name="delete" width="14" height="14" />+ </i>+ </el-tooltip> -->+ <el-tooltip+ class="item"+ effect="dark"+ content="清除已完成的任务"+ placement="bottom"+ v-if="currentList === 'stopped'"+ >+ <i @click="onPurgeRecordClick">+ <mo-icon name="purge" width="14" height="14" />+ </i>+ </el-tooltip>+ </div>+</template>++<script>+ import { mapState } from 'vuex'+ import TaskProgress from './TaskProgress'+ import '@/components/Icons/refresh'+ import '@/components/Icons/task-start-line'+ import '@/components/Icons/task-pause-line'+ import '@/components/Icons/delete'+ import '@/components/Icons/purge'+ import '@/components/Icons/more'+ import {+ getTaskName,+ bytesToSize,+ timeFormat+ } from '@shared/utils'++ export default {+ name: 'mo-task-actions',+ components: {+ [TaskProgress.name]: TaskProgress+ },+ props: ['task'],+ data: function () {+ return {+ refreshing: false+ }+ },+ computed: {+ ...mapState('task', {+ currentList: state => state.currentList+ })+ },+ filters: {+ bytesToSize,+ timeFormat+ },+ methods: {+ getTaskName,+ refreshSpin: function () {+ this.t && clearTimeout(this.t)++ this.refreshing = true+ this.t = setTimeout(() => {+ this.refreshing = false+ }, 500)+ },+ onRefreshClick: function () {+ this.refreshSpin()+ this.$store.dispatch('task/fetchList')+ },+ onResumeAllClick: function () {+ this.$store.dispatch('task/resumeAllTask')+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`恢复全部任务失败`)+ }+ })+ },+ onPauseAllClick: function () {+ this.$store.dispatch('task/pauseAllTask')+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`暂停全部任务失败`)+ }+ })+ },+ onPurgeRecordClick: function () {+ this.$store.dispatch('task/purgeTaskRecord')+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`移除全部下载记录失败`)+ }+ })+ }+ }+ }+</script>++<style lang="scss">+ @import '../Theme/Variables';+ @import '../Theme/Darkness/Variables';++ .task-actions {+ position: absolute;+ top: 44px;+ right: 0;+ height: 24px;+ padding: 0;+ overflow: hidden;+ user-select: none;+ cursor: default;+ text-align: right;+ color: #4D515A;+ transition: all 0.25s;+ &> i {+ display: inline-block;+ padding: 5px;+ margin: 0 4px;+ font-size: 0;+ cursor: pointer;+ outline: none;+ &:hover {+ color: $--color-primary;+ }+ }+ }+</style>diff --git a/src/renderer/components/Task/TaskItem.vue b/src/renderer/components/Task/TaskItem.vuenew file mode 100644index 00000000..a32ab5e1--- /dev/null+++ b/src/renderer/components/Task/TaskItem.vue@@ -0,0 +1,119 @@+<template>+ <li :key="task.gid" class="task-item" v-on:dblclick="toggleTask">+ <div class="task-name" :title="taskName">{{ taskName }}</div>+ <mo-task-item-actions mode="LIST" :task="task" />+ <div class="task-progress">+ <mo-task-progress :completed="Number(task.completedLength)" :total="Number(task.totalLength)" :status="task.status" />+ <el-row class="task-speed">+ <el-col :span="12" class="task-speed-left">+ <div v-if="task.totalLength > 0">+ {{ task.completedLength | bytesToSize }} / {{ task.totalLength | bytesToSize }}+ </div>+ <div v-else><!-- 等待中... --></div>+ </el-col>+ <el-col :span="12" class="task-speed-right">+ <div v-if="task.status ==='active'">+ <span>{{ task.downloadSpeed | bytesToSize }}/s</span>+ <span>+ {{ remaining | timeFormat('剩余') }}+ </span>+ </div>+ </el-col>+ </el-row>+ </div>+ </li>+</template>++<script>+ import TaskItemActions from './TaskItemActions'+ import TaskProgress from './TaskProgress'+ import '@/components/Icons/task-start-line'+ import '@/components/Icons/task-pause-line'+ import '@/components/Icons/delete'+ import '@/components/Icons/folder'+ import '@/components/Icons/link'+ import '@/components/Icons/more'+ import {+ getTaskName,+ timeRemaining,+ bytesToSize,+ timeFormat+ } from '@shared/utils'++ export default {+ name: 'mo-task-item',+ components: {+ [TaskItemActions.name]: TaskItemActions,+ [TaskProgress.name]: TaskProgress+ },+ props: {+ task: {+ type: Object+ }+ },+ computed: {+ taskName: function () {+ return getTaskName(this.task, '获取任务名中...')+ },+ remaining: function () {+ const { totalLength, completedLength, downloadSpeed } = this.task+ return timeRemaining(totalLength, completedLength, downloadSpeed)+ }+ },+ filters: {+ bytesToSize,+ timeFormat+ },+ methods: {+ getTaskName,+ toggleTask () {+ const { status } = this.task+ if (['waiting', 'paused'].indexOf(status) === -1) {+ return+ }+ this.$store.dispatch('task/toggleTask', this.task)+ }+ }+ }+</script>++<style lang="scss">+ .task-item {+ position: relative;+ padding: 16px 12px;+ border: 1px solid #ccc;+ border-radius: 6px;+ margin-bottom: 16px;+ transition: $--border-transition-base;+ &:hover {+ border-color: $--task-item-hover-border-color;+ }+ .task-item-actions {+ position: absolute;+ top: 16px;+ right: 12px;+ }+ }+ .task-name {+ font-size: 14px;+ color: #505753;+ line-height: 26px;+ margin-bottom: 32px;+ margin-right: 200px;+ }+ .task-speed {+ font-size: 12px;+ line-height: 14px;+ min-height: 14px;+ color: #9B9B9B;+ margin-top: 8px;+ }+ .task-speed-left {+ min-height: 14px;+ text-align: left;+ }+ .task-speed-right {+ min-height: 14px;+ text-align: right;+ }+</style>diff --git a/src/renderer/components/Task/TaskItemActions.vue b/src/renderer/components/Task/TaskItemActions.vuenew file mode 100644index 00000000..a474cb92--- /dev/null+++ b/src/renderer/components/Task/TaskItemActions.vue@@ -0,0 +1,217 @@+<template>+ <div class="task-item-actions" v-on:dblclick.stop="() => null">+ <i @click.stop="onMoreClick">+ <mo-icon name="more" width="14" height="14" />+ </i>+ <i @click.stop="onInfoClick" v-if="mode === 'LIST'">+ <mo-icon name="info-circle" width="14" height="14" />+ </i>+ <i @click.stop="onLinkClick">+ <mo-icon name="link" width="14" height="14" />+ </i>+ <i v-if="isRenderer()" @click.stop="onFolderClick">+ <mo-icon name="folder" width="14" height="14" />+ </i>+ <i v-if="task.status ==='complete' ||+ task.status ==='removed' ||+ task.status ==='error'"+ @click.stop="onTrashClick">+ <mo-icon name="trash" width="14" height="14" />+ </i>+ <i v-if="task.status ==='active' ||+ task.status ==='waiting' ||+ task.status ==='paused'"+ @click.stop="onDeleteClick">+ <mo-icon name="delete" width="14" height="14" />+ </i>+ <i v-if="task.status ==='active'" @click.stop="onPauseClick">+ <mo-icon name="task-pause-line" width="14" height="14" />+ </i>+ <i v-if="task.status ==='waiting' || task.status ==='paused'" @click.stop="onResumeClick">+ <mo-icon name="task-start-line" width="14" height="14" />+ </i>+ </div>+</template>++<script>+ import is from 'electron-is'+ import clipboard from 'clipboard-polyfill'+ import '@/components/Icons/task-start-line'+ import '@/components/Icons/task-pause-line'+ import '@/components/Icons/delete'+ import '@/components/Icons/folder'+ import '@/components/Icons/link'+ import '@/components/Icons/info-circle'+ import '@/components/Icons/more'+ import '@/components/Icons/trash'+ import {+ showItemInFolder,+ moveTaskFilesToTrash+ } from '@/components/Native/utils'+ import {+ getTaskName,+ getTaskUri,+ getTaskFullPath+ } from '@shared/utils'++ export default {+ name: 'mo-task-item-actions',+ props: {+ mode: {+ type: String,+ default: 'LIST'+ },+ task: {+ type: Object,+ required: true+ }+ },+ computed: {+ taskName: function () {+ return getTaskName(this.task)+ },+ path: function () {+ return getTaskFullPath(this.task)+ }+ },+ filters: {+ },+ methods: {+ isRenderer: is.renderer,+ showConfirmBox: function () {++ },+ removeTaskItem: function (task, isRemoveWithFiles) {+ this.$store.dispatch('task/removeTask', this.task)+ .then(() => {+ if (isRemoveWithFiles) {+ moveTaskFilesToTrash(task)+ }+ this.$message.success(`移除任务「${this.taskName}」成功`)+ })+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`移除任务「${this.taskName}」失败`)+ }+ })+ },+ removeTaskRecord: function (task, isRemoveWithFiles) {+ this.$store.dispatch('task/removeTaskRecord', this.task)+ .then(() => {+ if (isRemoveWithFiles) {+ moveTaskFilesToTrash(task)+ }+ this.$message.success(`移除「${this.taskName}」下载记录成功`)+ })+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`移除「${this.taskName}」下载记录失败`)+ }+ })+ },+ onResumeClick: function () {+ this.$store.dispatch('task/resumeTask', this.task)+ .then(() => {+ this.$message.success(`恢复任务「${this.taskName}」成功`)+ })+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`恢复任务「${this.taskName}」失败`)+ }+ })+ },+ onPauseClick: function () {+ this.$store.dispatch('task/pauseTask', this.task)+ .then(() => {+ this.$message.success(`暂停任务「${this.taskName}」成功`)+ })+ .catch(({ code }) => {+ if (code === 1) {+ this.$message.error(`暂停任务「${this.taskName}」失败`)+ }+ })+ },+ onDeleteClick: function () {+ const self = this+ const { task } = this+ this.$electron.remote.dialog.showMessageBox({+ type: 'warning',+ title: '移除任务',+ message: `你确定要移除任务「${this.taskName}」吗?`,+ buttons: ['是', '否'],+ cancelId: 1,+ checkboxLabel: '同时删除文件'+ }, (buttonIndex, checkboxChecked) => {+ // 点击的按钮是哪个按钮 0: 是, 1: 否+ if (buttonIndex === 0) {+ self.removeTaskItem(task, checkboxChecked)+ }+ })+ },+ onTrashClick: function () {+ const self = this+ const { task } = this+ this.$electron.remote.dialog.showMessageBox({+ type: 'warning',+ title: '移除下载记录',+ message: `你确定要移除「${this.taskName}」下载记录吗?`,+ buttons: ['是', '否'],+ cancelId: 1,+ checkboxLabel: '同时删除文件'+ }, (buttonIndex, checkboxChecked) => {+ // 点击的按钮是哪个按钮 0: 是, 1: 否+ if (buttonIndex === 0) {+ self.removeTaskRecord(task, checkboxChecked)+ }+ })+ },+ onFolderClick: function () {+ showItemInFolder(this.path)+ },+ onLinkClick: function () {+ const uri = getTaskUri(this.task)+ clipboard.writeText(uri)+ .then(() => {+ this.$message.success('复制下载地址成功')+ })+ },+ onInfoClick: function () {+ this.$store.dispatch('task/showTaskItemInfoDialog', this.task)+ },+ onMoreClick: function () {+ console.log('onMoreClick===>')+ }+ }+ }+</script>++<style lang="scss">+ .task-item-actions {+ // width: 28px;+ height: 24px;+ padding: 0 10px;+ overflow: hidden;+ user-select: none;+ cursor: default;+ text-align: right;+ direction: rtl;+ border: 1px solid #F5F5F5;+ color: #9B9B9B;+ background-color: #fff;+ border-radius: 14px;+ transition: $--all-transition;+ &:hover {+ border-color: $--task-item-hover-border-color;+ color: #fff;+ background-color: $--task-item-hover-background;+ width: auto;+ }+ &> i {+ display: inline-block;+ padding: 5px;+ margin: 0 4px;+ font-size: 0;+ cursor: pointer;+ }+ }+</style>diff --git a/src/renderer/components/Task/TaskItemInfo.vue b/src/renderer/components/Task/TaskItemInfo.vuenew file mode 100644index 00000000..49cbf9c5--- /dev/null+++ b/src/renderer/components/Task/TaskItemInfo.vue@@ -0,0 +1,133 @@+<template>+ <el-dialog+ custom-class="task-info-dialog"+ width="61.8vw"+ v-if="task"+ :title="`${taskName} 详情`"+ :show-close="true"+ :visible.sync="visible"+ :before-close="handleClose"+ @closed="handleClosed"+ >+ <div class="task-name" :title="taskName">{{ taskName }}</div>+ <mo-task-item-actions mode="ITEM" :task="task" />+ <div class="task-progress">+ <mo-task-progress :completed="Number(task.completedLength)" :total="Number(task.totalLength)" :status="task.status" />+ <el-row class="task-speed">+ <el-col :span="12" class="task-speed-left">+ <div v-if="task.totalLength > 0">+ {{ task.completedLength | bytesToSize }} / {{ task.totalLength | bytesToSize }}+ </div>+ <div v-else><!-- 等待中... --></div>+ </el-col>+ <el-col :span="12" class="task-speed-right">+ <div v-if="task.status ==='active'">+ <span>{{ task.downloadSpeed | bytesToSize }}/s</span>+ <span>+ {{ remaining | timeFormat('剩余') }}+ </span>+ </div>+ </el-col>+ </el-row>+ </div>+ </el-dialog>+</template>++<script>+ import { mapActions } from 'vuex'+ import TaskItemActions from './TaskItemActions'+ import TaskProgress from './TaskProgress'+ import '@/components/Icons/task-start-line'+ import '@/components/Icons/task-pause-line'+ import '@/components/Icons/delete'+ import '@/components/Icons/folder'+ import '@/components/Icons/link'+ import '@/components/Icons/more'+ import {+ getTaskName,+ timeRemaining,+ bytesToSize,+ timeFormat+ } from '@shared/utils'++ export default {+ name: 'mo-task-item-info',+ components: {+ [TaskItemActions.name]: TaskItemActions,+ [TaskProgress.name]: TaskProgress+ },+ props: {+ task: {+ type: Object+ },+ visible: {+ type: Boolean,+ default: false+ }+ },+ computed: {+ taskName: function () {+ return getTaskName(this.task, '获取任务名中...')+ },+ remaining: function () {+ const { totalLength, completedLength, downloadSpeed } = this.task+ return timeRemaining(totalLength, completedLength, downloadSpeed)+ }+ },+ filters: {+ bytesToSize,+ timeFormat+ },+ methods: {+ getTaskName,+ handleClose (done) {+ this.$store.dispatch('task/hideTaskItemInfoDialog')+ },+ handleClosed (done) {+ this.$store.dispatch('task/updateCurrentTaskItem', null)+ },+ ...mapActions('task', [+ 'toggleTask'+ ])+ }+ }+</script>++<style lang="scss">+ .task-info-dialog {+ .el-dialog__body {+ position: relative;+ }+ }+ .task-item-info {+ padding: 16px 12px;+ }+ .task-name {+ font-size: 14px;+ color: #505753;+ line-height: 26px;+ margin-bottom: 32px;+ margin-right: 240px;+ }+ .task-item-actions {+ display: inline-block;+ position: absolute;+ top: 30px;+ right: 20px;+ }+ .task-speed {+ font-size: 12px;+ line-height: 14px;+ min-height: 14px;+ color: #9B9B9B;+ margin-top: 8px;+ }+ .task-speed-left {+ min-height: 14px;+ text-align: left;+ }+ .task-speed-right {+ min-height: 14px;+ text-align: right;+ }+</style>diff --git a/src/renderer/components/Task/TaskList.vue b/src/renderer/components/Task/TaskList.vuenew file mode 100644index 00000000..bcb4012f--- /dev/null+++ b/src/renderer/components/Task/TaskList.vue@@ -0,0 +1,60 @@+<template>+ <ul class="task-list" v-if="taskList.length > 0">+ <mo-task-item v-for="task in taskList" :key="task.gid" :task="task" />+ </ul>+ <div class="no-task" v-else>+ <div class="no-task-inner">+ 当前没有下载任务+ </div>+ </div>+</template>++<script>+ import { mapState } from 'vuex'+ import TaskItem from './TaskItem'+ import {+ getTaskName,+ bytesToSize,+ timeRemaining,+ timeFormat+ } from '@shared/utils'++ export default {+ name: 'mo-task-list',+ components: {+ [TaskItem.name]: TaskItem+ },+ computed: {+ ...mapState('task', {+ taskList: state => state.taskList+ })+ },+ methods: {+ getTaskName,+ bytesToSize,+ timeRemaining,+ timeFormat+ }+ }+</script>++<style lang="scss">+ .task-list {+ list-style: none;+ padding: 0;+ }+ .no-task {+ display: flex;+ height: 100%;+ text-align: center;+ align-items: center;+ justify-content: center;+ font-size: 14px;+ color: #555;+ }+ .no-task-inner {+ width: 100%;+ padding-top: 360px;+ background: transparent url('~@/assets/no-task.svg') top center no-repeat;+ }+</style>diff --git a/src/renderer/components/Task/TaskProgress.vue b/src/renderer/components/Task/TaskProgress.vuenew file mode 100644index 00000000..6541e162--- /dev/null+++ b/src/renderer/components/Task/TaskProgress.vue@@ -0,0 +1,49 @@+<template>+ <el-progress+ v-if="status === 'active'"+ :percentage="percent"+ :show-text="false"+ status="text"+ :color="color">+ </el-progress>+ <el-progress+ v-else+ :percentage="percent"+ :show-text="false"+ :color="color">+ </el-progress>+</template>++<script>+ import { calcProgress } from '@shared/utils'+ import colors from '@shared/colors'++ export default {+ name: 'mo-task-progress',+ props: {+ total: {+ type: Number+ },+ completed: {+ type: Number+ },+ status: {+ type: String,+ default: 'active'+ }+ },+ computed: {+ percent: function () {+ return calcProgress(this.total, this.completed)+ },+ color: function () {+ return colors[this.status]+ }+ },+ methods: {+ }+ }+</script>++<style lang="scss">+</style>diff --git a/src/renderer/components/Theme/About.scss b/src/renderer/components/Theme/About.scssnew file mode 100644index 00000000..f80d7c3b--- /dev/null+++ b/src/renderer/components/Theme/About.scss@@ -0,0 +1,13 @@+@import '~normalize.css/normalize.css';+@import './Variables.scss';+@import "~element-ui/packages/theme-chalk/src/index";++@import './Base.scss';++/* Theme Capriccio+-------------------------- */+@import './Default.scss';++/* Theme Darkness+-------------------------- */+@import './Darkness.scss';diff --git a/src/renderer/components/Theme/Base.scss b/src/renderer/components/Theme/Base.scssnew file mode 100644index 00000000..13dc968d--- /dev/null+++ b/src/renderer/components/Theme/Base.scss@@ -0,0 +1,101 @@++html,+body {+ height: 100%;+ padding: 0;+}++body {+ font-family: 'Monospaced Number', 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;+ font-variant: tabular-nums;+}++img {+ width: auto;+ height: auto;+ max-width: 100%;+ max-height: 100%;+}++.clearfix {+ @include clearfix();+}++.title-bar {+ position: fixed;+ top: 0;+ width: 100%;+ height: 40px;+ user-select: none;+ -webkit-app-region: drag;+ z-index: 5000;+}++#app,+#container {+ height: 100%;+}++.aside {+ -webkit-app-region: drag;+}++.el-progress-bar__inner {+ transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s;+}++.el-progress--line.is-text {+ .el-progress-bar__inner::before {+ content: '';+ opacity: 0;+ position: absolute;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;+ background: #fff;+ border-radius: 10px;+ animation: mo-progress-active 2.4s cubic-bezier(0.23, 1, 0.32, 1) infinite;+ }+}++@keyframes mo-progress-active {+ 0% {+ opacity: 0.1;+ width: 0;+ }+ 20% {+ opacity: 0.5;+ width: 0;+ }+ 100% {+ opacity: 0;+ width: 100%;+ }+}++.el-message-box__wrapper {+ outline: none;+}++.tab-title-dialog {+ .el-dialog__header {+ padding: 0 20px;+ position: relative;+ z-index: 10;+ }+ .el-dialog__body {+ padding-top: 10px;+ padding-bottom: 10px;+ }+}++.el-form-item--mini .el-form-item__info {+ padding-top: 1px;+}+.el-form-item__info {+ font-size: 12px;+ line-height: 1;+ padding-top: 4px;+ color: $--color-info;+}diff --git a/src/renderer/components/Theme/Darkness.scss b/src/renderer/components/Theme/Darkness.scssnew file mode 100644index 00000000..d4e56da6--- /dev/null+++ b/src/renderer/components/Theme/Darkness.scss@@ -0,0 +1 @@+@import './Darkness/Variables.scss';diff --git a/src/renderer/components/Theme/Darkness/Variables.scss b/src/renderer/components/Theme/Darkness/Variables.scssnew file mode 100644index 00000000..304b336c--- /dev/null+++ b/src/renderer/components/Theme/Darkness/Variables.scss@@ -0,0 +1,35 @@+/* App+-------------------------- */+$--dk-app-background: transparent !default;++/* Aside+-------------------------- */+$--dk-aside-background: rgba(0, 0, 0, 0.75) !default;+$--dk-aside-text-color: #fff !default;++/* SubNav+-------------------------- */+$--dk-subnav-background: #F4F5F7 !default;+$--dk-subnav-title-color: $--color-primary-dark-6 !default;+$--dk-subnav-text-color: #4D515A !default;+$--dk-subnav-active-text-color: $--color-primary !default;++/* Panel+-------------------------- */+$--panel-background: $--color-white !default;+$--dk-panel-title-color: $--color-primary-dark-6 !default;+$--dk-panel-border-color: #EBECF0 !default;++/* Task+-------------------------- */+$--dk-task-item-border-color: #ccc !default;+$--dk-task-item-hover-border-color: $--color-primary !default;+$--dk-task-item-hover-background: $--color-primary !default;++/* Speedometer+-------------------------- */+$--dk-speedometer-background: $--color-white !default;+$--dk-speedometer-border-color: #ccc !default;+$--dk-speedometer-hover-border-color: #9b9b9b !default;+$--dk-speedometer-primary-color: $--color-primary !default;+$--dk-speedometer-text-color: #9b9b9b !default;diff --git a/src/renderer/components/Theme/Default.scss b/src/renderer/components/Theme/Default.scssnew file mode 100644index 00000000..1fedd068--- /dev/null+++ b/src/renderer/components/Theme/Default.scss@@ -0,0 +1,98 @@+:root {+ --app-background: '';+ --aside-background: '';+ --aside-text-color: '';+ --subnav-background: '';+ --subnav-title-color: '';+ --subnav-text-color: '';+ --subnav-active-text-color: '';+ --panel-background: '';+ --panel-title-color: '';+ --panel-border-color: '';+ --task-item-border-color: '';+ --task-item-hover-border-color: '';+ --task-item-hover-background: '';+ --speedometer-background: '';+ --speedometer-border-color: '';+ --speedometer-hover-border-color: '';+ --speedometer-primary-color: '';+ --speedometer-text-color: '';+}++#app,+#container {+ height: 100%;+ background-color: $--app-background;+}++.aside {+ background-color: $--aside-background;+ color: $--aside-text-color;+}++.subnav {+ background-color: $--subnav-background;+ color: $--subnav-text-color;+}++.subnav-inner {+ margin-top: 44px;+ padding: 0 16px;++ h3 {+ font-size: 16px;+ color: #071D43;+ font-weight: normal;+ line-height: 24px;+ margin: 0 0 28px;+ }++ ul {+ list-style: none;+ padding: 0;+ margin: 0;+ user-select: none;+ cursor: default;++ li {+ margin-bottom: 8px;+ padding: 8px 10px;+ font-size: 14px;+ line-height: 20px;+ border-radius: 3px;+ cursor: pointer;++ i,+ span {+ vertical-align: middle;+ display: inline-block;+ }++ &:hover,+ &.active {+ background-color: #EAECF0;++ i,+ span,+ svg {+ color: $--subnav-active-text-color;+ }+ }+ }+ }+}++.subnav-icon {+ padding: 2px;+ height: 16px;+ margin-right: 12px;++ svg {+ width: 16px;+ height: 16px;+ }+}++.content {+ padding: 0;+}diff --git a/src/renderer/components/Theme/Index.scss b/src/renderer/components/Theme/Index.scssnew file mode 100644index 00000000..f80d7c3b--- /dev/null+++ b/src/renderer/components/Theme/Index.scss@@ -0,0 +1,13 @@+@import '~normalize.css/normalize.css';+@import './Variables.scss';+@import "~element-ui/packages/theme-chalk/src/index";++@import './Base.scss';++/* Theme Capriccio+-------------------------- */+@import './Default.scss';++/* Theme Darkness+-------------------------- */+@import './Darkness.scss';diff --git a/src/renderer/components/Theme/Variables.scss b/src/renderer/components/Theme/Variables.scssnew file mode 100644index 00000000..c6ac41c5--- /dev/null+++ b/src/renderer/components/Theme/Variables.scss@@ -0,0 +1,776 @@+/* Element Chalk Variables */++/* Transition+-------------------------- */+$--all-transition: all .25s cubic-bezier(.645,.045,.355,1) !default;+$--fade-transition: opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) !default;+$--fade-linear-transition: opacity 200ms linear !default;+$--md-fade-transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1), opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) !default;+$--border-transition-base: border-color .25s cubic-bezier(.645,.045,.355,1) !default;+$--color-transition-base: color .25s cubic-bezier(.645,.045,.355,1) !default;++/* Colors+-------------------------- */+$--color-white: #fff !default;+$--color-black: #000 !default;++$--color-primary: #5b5bea !default;+$--color-primary-light-1: mix($--color-white, $--color-primary, 10%) !default;+$--color-primary-light-2: mix($--color-white, $--color-primary, 20%) !default;+$--color-primary-light-3: mix($--color-white, $--color-primary, 30%) !default;+$--color-primary-light-4: mix($--color-white, $--color-primary, 40%) !default;+$--color-primary-light-5: mix($--color-white, $--color-primary, 50%) !default;+$--color-primary-light-6: mix($--color-white, $--color-primary, 60%) !default;+$--color-primary-light-7: mix($--color-white, $--color-primary, 70%) !default;+$--color-primary-light-8: mix($--color-white, $--color-primary, 80%) !default;+$--color-primary-light-9: mix($--color-white, $--color-primary, 90%) !default;++$--color-primary-dark-1: mix($--color-black, $--color-primary, 10%) !default;+$--color-primary-dark-2: mix($--color-black, $--color-primary, 20%) !default;+$--color-primary-dark-3: mix($--color-black, $--color-primary, 30%) !default;+$--color-primary-dark-4: mix($--color-black, $--color-primary, 40%) !default;+$--color-primary-dark-5: mix($--color-black, $--color-primary, 50%) !default;+$--color-primary-dark-6: mix($--color-black, $--color-primary, 60%) !default;+$--color-primary-dark-7: mix($--color-black, $--color-primary, 70%) !default;+$--color-primary-dark-8: mix($--color-black, $--color-primary, 80%) !default;+$--color-primary-dark-9: mix($--color-black, $--color-primary, 90%) !default;+++$--color-success: #2ACB42 !default;+$--color-warning: #FFC12F !default;+$--color-danger: #FF6157 !default;+$--color-info: #737373 !default;++$--color-success-light: mix($--color-white, $--color-success, 80%) !default;+$--color-warning-light: mix($--color-white, $--color-warning, 80%) !default;+$--color-danger-light: mix($--color-white, $--color-danger, 80%) !default;+$--color-info-light: mix($--color-white, $--color-info, 80%) !default;++$--color-success-lighter: mix($--color-white, $--color-success, 90%) !default;+$--color-warning-lighter: mix($--color-white, $--color-warning, 90%) !default;+$--color-danger-lighter: mix($--color-white, $--color-danger, 90%) !default;+$--color-info-lighter: mix($--color-white, $--color-info, 90%) !default;++$--color-text-primary: #222222 !default;+$--color-text-regular: #4C4C4C !default;+$--color-text-secondary: #BDBDBD !default;+$--color-text-placeholder: rgba(0, 0, 0, 0.3) !default;++/* Link+-------------------------- */+$--link-color: $--color-primary-light-2 !default;+$--link-hover-color: $--color-primary !default;++/* Background+-------------------------- */+$--background-color-base: #f5f7fa !default;++/* Border+-------------------------- */+$--border-width-base: 1px !default;+$--border-style-base: solid !default;+$--border-color-base: #dcdfe6 !default;+$--border-color-light: #e4e7ed !default;+$--border-color-lighter: #ebeef5 !default;+$--border-color-extra-light: #f2f6fc !default;+$--border-color-hover: $--color-text-placeholder !default;+$--border-base: $--border-width-base $--border-style-base $--border-color-base !default;+$--border-radius-base: 4px !default;+$--border-radius-small: 2px !default;+$--border-radius-circle: 100% !default;++/* Box-shadow+-------------------------- */+$--box-shadow-base: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04) !default;+$--box-shadow-dark: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .12) !default;+$--box-shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1) !default;++/* Fill+-------------------------- */+$--fill-base: $--color-white !default;++/* Font+-------------------------- */+$--font-path: 'fonts' !default;+$--font-size-base: 14px !default;+$--font-size-small: 12px !default;+$--font-size-large: 16px !default;+$--font-color-disabled-base: #bbb !default;+$--font-weight-primary: 500 !default;+$--font-weight-secondary: 400 !default;+$--font-line-height-primary: 24px !default;++/* Size+-------------------------- */+$--size-base: 14px !default;++/* z-index+-------------------------- */+$--index-normal: 1 !default;+$--index-top: 1000 !default;+$--index-popper: 2000 !default;++/* Disable base+-------------------------- */+$--disabled-fill-base: $--background-color-base !default;+$--disabled-color-base: $--color-text-placeholder !default;+$--disabled-border-base: $--border-color-light !default;++/* Icon+-------------------------- */+$--icon-color: #666 !default;+$--icon-color-base: $--color-info !default;++/* Checkbox+-------------------------- */+$--checkbox-font-size: 14px !default;+$--checkbox-font-weight: $--font-weight-secondary !default;+$--checkbox-color: $--color-text-regular !default;+$--checkbox-input-height: 14px !default;+$--checkbox-input-width: 14px !default;+$--checkbox-input-border-radius: $--border-radius-small !default;+$--checkbox-input-fill: $--color-white !default;+$--checkbox-input-border: $--border-base !default;+$--checkbox-input-border-color: $--border-color-base !default;+$--checkbox-icon-color: $--color-white !default;++$--checkbox-disabled-input-border-color: $--border-color-base !default;+$--checkbox-disabled-input-fill: #edf2fc !default;+$--checkbox-disabled-icon-color: $--color-text-placeholder !default;++$--checkbox-disabled-checked-input-fill: $--border-color-extra-light !default;+$--checkbox-disabled-checked-input-border-color: $--border-color-base !default;+$--checkbox-disabled-checked-icon-color: $--color-text-placeholder !default;++$--checkbox-checked-text-color: $--color-primary !default;+$--checkbox-checked-input-border-color: $--color-primary !default;+$--checkbox-checked-input-fill: $--color-primary !default;+$--checkbox-checked-icon-color: $--fill-base !default;++$--checkbox-input-border-color-hover: $--color-primary !default;++$--checkbox-bordered-height: 40px !default;+$--checkbox-bordered-padding: 9px 20px 9px 10px !default;+$--checkbox-bordered-medium-padding: 7px 20px 7px 10px !default;+$--checkbox-bordered-small-padding: 5px 15px 5px 10px !default;+$--checkbox-bordered-mini-padding: 3px 15px 3px 10px !default;+$--checkbox-bordered-medium-input-height: 14px !default;+$--checkbox-bordered-medium-input-width: 14px !default;+$--checkbox-bordered-medium-height: 36px !default;+$--checkbox-bordered-small-input-height: 12px !default;+$--checkbox-bordered-small-input-width: 12px !default;+$--checkbox-bordered-small-height: 32px !default;+$--checkbox-bordered-mini-input-height: 12px !default;+$--checkbox-bordered-mini-input-width: 12px !default;+$--checkbox-bordered-mini-height: 28px !default;++$--checkbox-button-font-size: $--font-size-base !default;+$--checkbox-button-checked-fill: $--color-primary !default;+$--checkbox-button-checked-color: $--color-white !default;+$--checkbox-button-checked-border-color: $--color-primary !default;++++/* Radio+-------------------------- */+$--radio-font-size: 14px !default;+$--radio-font-weight: $--font-weight-primary !default;+$--radio-color: $--color-text-regular !default;+$--radio-input-height: 14px !default;+$--radio-input-width: 14px !default;+$--radio-input-border-radius: $--border-radius-circle !default;+$--radio-input-fill: $--color-white !default;+$--radio-input-border: $--border-base !default;+$--radio-input-border-color: $--border-color-base !default;+$--radio-icon-color: $--color-white !default;++$--radio-disabled-input-border-color: $--disabled-border-base !default;+$--radio-disabled-input-fill: $--disabled-fill-base !default;+$--radio-disabled-icon-color: $--disabled-fill-base !default;++$--radio-disabled-checked-input-border-color: $--disabled-border-base !default;+$--radio-disabled-checked-input-fill: $--disabled-fill-base !default;+$--radio-disabled-checked-icon-color: $--color-text-placeholder !default;++$--radio-checked-text-color: $--color-primary !default;+$--radio-checked-input-border-color: $--color-primary !default;+$--radio-checked-input-fill: $--color-white !default;+$--radio-checked-icon-color: $--color-primary !default;++$--radio-input-border-color-hover: $--color-primary !default;++$--radio-bordered-height: 40px !default;+$--radio-bordered-padding: 12px 20px 0 10px !default;+$--radio-bordered-medium-padding: 10px 20px 0 10px !default;+$--radio-bordered-small-padding: 8px 15px 0 10px !default;+$--radio-bordered-mini-padding: 6px 15px 0 10px !default;+$--radio-bordered-medium-input-height: 14px !default;+$--radio-bordered-medium-input-width: 14px !default;+$--radio-bordered-medium-height: 36px !default;+$--radio-bordered-small-input-height: 12px !default;+$--radio-bordered-small-input-width: 12px !default;+$--radio-bordered-small-height: 32px !default;+$--radio-bordered-mini-input-height: 12px !default;+$--radio-bordered-mini-input-width: 12px !default;+$--radio-bordered-mini-height: 28px !default;++$--radio-button-font-size: $--font-size-base !default;+$--radio-button-checked-fill: $--color-primary !default;+$--radio-button-checked-color: $--color-white !default;+$--radio-button-checked-border-color: $--color-primary !default;+$--radio-button-disabled-checked-fill: $--border-color-extra-light !default;++/* Select+-------------------------- */+$--select-border-color-hover: $--border-color-hover !default;+$--select-disabled-border: $--disabled-border-base !default;+$--select-font-size: $--font-size-base !default;+$--select-close-hover-color: $--color-text-secondary !default;++$--select-input-color: $--color-text-placeholder !default;+$--select-multiple-input-color: #666 !default;+$--select-input-focus-background: $--color-primary !default;+$--select-input-font-size: 14px !default;++$--select-option-color: $--color-text-regular !default;+$--select-option-disabled-color: $--color-text-placeholder !default;+$--select-option-disabled-background: $--color-white !default;+$--select-option-height: 34px !default;+$--select-option-hover-background: $--background-color-base !default;+$--select-option-selected: $--color-primary !default;+$--select-option-selected-hover: $--background-color-base !default;++$--select-group-color: $--color-info !default;+$--select-group-height: 30px !default;+$--select-group-font-size: 12px !default;++$--select-dropdown-background: $--color-white !default;+$--select-dropdown-shadow: $--box-shadow-light !default;+$--select-dropdown-empty-color: #999 !default;+$--select-dropdown-max-height: 274px !default;+$--select-dropdown-padding: 6px 0 !default;+$--select-dropdown-empty-padding: 10px 0 !default;+$--select-dropdown-border: solid 1px $--border-color-light !default;++/* Alert+-------------------------- */+$--alert-padding: 8px 16px !default;+$--alert-border-radius: $--border-radius-base !default;+$--alert-title-font-size: 13px !default;+$--alert-description-font-size: 12px !default;+$--alert-close-font-size: 12px !default;+$--alert-close-customed-font-size: 13px !default;++$--alert-success-color: $--color-success-lighter !default;+$--alert-info-color: $--color-info-lighter !default;+$--alert-warning-color: $--color-warning-lighter !default;+$--alert-danger-color: $--color-danger-lighter !default;++$--alert-icon-size: 16px !default;+$--alert-icon-large-size: 28px !default;++/* Message Box+-------------------------- */+$--msgbox-width: 420px !default;+$--msgbox-border-radius: 4px !default;+$--msgbox-font-size: $--font-size-large !default;+$--msgbox-content-font-size: $--font-size-base !default;+$--msgbox-content-color: $--color-text-regular !default;+$--msgbox-error-font-size: 12px !default;+$--msgbox-padding-primary: 15px !default;++$--msgbox-success-color: $--color-success !default;+$--msgbox-info-color: $--color-info !default;+$--msgbox-warning-color: $--color-warning !default;+$--msgbox-danger-color: $--color-danger !default;++/* Message+-------------------------- */+$--message-shadow: $--box-shadow-base !default;+$--message-min-width: 380px !default;+$--message-background-color: #edf2fc !default;+$--message-padding: 15px 15px 15px 20px !default;+$--message-content-color: $--color-text-regular !default;+$--message-close-color: $--color-text-placeholder !default;+$--message-close-size: 16px !default;+$--message-close-hover-color: $--color-text-secondary !default;++$--message-success-color: $--color-success !default;+$--message-info-color: $--color-info !default;+$--message-warning-color: $--color-warning !default;+$--message-danger-color: $--color-danger !default;++/* Notification+-------------------------- */+$--notification-width: 330px !default;+$--notification-padding: 14px 26px 14px 13px !default;+$--notification-radius: 8px !default;+$--notification-shadow: $--box-shadow-light !default;+$--notification-border-color: $--border-color-lighter !default;+$--notification-icon-size: 24px !default;+$--notification-close-font-size: $--message-close-size !default;+$--notification-group-margin: 13px !default;+$--notification-font-size: $--font-size-base !default;+$--notification-color: $--color-text-regular !default;+$--notification-title-font-size: 16px !default;+$--notification-title-color: $--color-text-primary !default;++$--notification-close-color: $--color-text-secondary !default;+$--notification-close-hover-color: $--color-text-regular !default;++$--notification-success-color: $--color-success !default;+$--notification-info-color: $--color-info !default;+$--notification-warning-color: $--color-warning !default;+$--notification-danger-color: $--color-danger !default;++/* Input+-------------------------- */+$--input-font-size: $--font-size-base !default;+$--input-color: $--color-text-regular !default;+$--input-width: 140px !default;+$--input-height: 40px !default;+$--input-border: $--border-base !default;+$--input-border-color: $--border-color-base !default;+$--input-border-radius: $--border-radius-base !default;+$--input-border-color-hover: $--border-color-hover !default;+$--input-fill: $--color-white !default;+$--input-fill-disabled: $--disabled-fill-base !default;+$--input-color-disabled: $--font-color-disabled-base !default;+$--input-icon-color: $--color-text-placeholder !default;+$--input-placeholder-color: $--color-text-placeholder !default;+$--input-max-width: 314px !default;++$--input-hover-border: $--border-color-hover !default;+$--input-clear-hover-color: $--color-text-secondary !default;++$--input-focus-border: $--color-primary !default;+$--input-focus-fill: $--color-white !default;++$--input-disabled-fill: $--disabled-fill-base !default;+$--input-disabled-border: $--disabled-border-base !default;+$--input-disabled-color: $--disabled-color-base !default;+$--input-disabled-placeholder-color: $--color-text-placeholder !default;++$--input-medium-font-size: 14px !default;+$--input-medium-height: 36px !default;++$--input-small-font-size: 13px !default;+$--input-small-height: 32px !default;++$--input-mini-font-size: 12px !default;+$--input-mini-height: 28px !default;++/* Cascader+-------------------------- */+$--cascader-menu-fill: $--fill-base !default;+$--cascader-menu-font-size: $--font-size-base !default;+$--cascader-menu-radius: $--border-radius-base !default;+$--cascader-menu-border: $--border-base !default;+$--cascader-menu-border-color: $--border-color-base !default;+$--cascader-menu-border-width: $--border-width-base !default;+$--cascader-menu-color: $--color-text-regular !default;+$--cascader-menu-option-color-active: $--color-text-secondary !default;+$--cascader-menu-option-fill-active: rgba($--color-text-secondary, 0.12) !default;+$--cascader-menu-option-color-hover: $--color-text-regular !default;+$--cascader-menu-option-fill-hover: rgba($--color-text-primary, 0.06) !default;+$--cascader-menu-option-color-disabled: #999 !default;+$--cascader-menu-option-fill-disabled: rgba($--color-black, 0.06) !default;+$--cascader-menu-option-empty-color: #666 !default;+$--cascader-menu-group-color: #999 !default;+$--cascader-menu-shadow: 0 1px 2px rgba($--color-black, 0.14), 0 0 3px rgba($--color-black, 0.14) !default;+$--cascader-menu-option-pinyin-color: #999 !default;+$--cascader-menu-submenu-shadow: 1px 1px 2px rgba($--color-black, 0.14), 1px 0 2px rgba($--color-black, 0.14) !default;++/* Group+-------------------------- */+$--group-option-flex: 0 0 (1/5) * 100% !default;+$--group-option-offset-bottom: 12px !default;+$--group-option-fill-hover: rgba($--color-black, 0.06) !default;+$--group-title-color: $--color-black !default;+$--group-title-font-size: $--font-size-base !default;+$--group-title-width: 66px !default;++/* Tab+-------------------------- */+$--tab-font-size: $--font-size-base !default;+$--tab-border-line: 1px solid #e4e4e4 !default;+$--tab-header-color-active: $--color-text-secondary !default;+$--tab-header-color-hover: $--color-text-regular !default;+$--tab-header-color: $--color-text-regular !default;+$--tab-header-fill-active: rgba($--color-black, 0.06) !default;+$--tab-header-fill-hover: rgba($--color-black, 0.06) !default;+$--tab-vertical-header-width: 90px !default;+$--tab-vertical-header-count-color: $--color-white !default;+$--tab-vertical-header-count-fill: $--color-text-secondary !default;++/* Button+-------------------------- */+$--button-font-size: 14px !default;+$--button-font-weight: $--font-weight-primary !default;+$--button-border-radius: $--border-radius-base !default;+$--button-padding-vertical: 12px !default;+$--button-padding-horizontal: 20px !default;++$--button-medium-font-size: 14px !default;+$--button-medium-border-radius: $--border-radius-base !default;+$--button-medium-padding-vertical: 10px !default;+$--button-medium-padding-horizontal: 20px !default;++$--button-small-font-size: 12px !default;+$--button-small-border-radius: #{$--border-radius-base - 1} !default;+$--button-small-padding-vertical: 9px !default;+$--button-small-padding-horizontal: 15px !default;++$--button-mini-font-size: 12px !default;+$--button-mini-border-radius: #{$--border-radius-base - 1} !default;+$--button-mini-padding-vertical: 7px !default;+$--button-mini-padding-horizontal: 15px !default;++$--button-default-color: $--color-text-regular !default;+$--button-default-fill: $--color-white !default;+$--button-default-border: $--border-color-base !default;++$--button-disabled-color: $--color-text-placeholder !default;+$--button-disabled-fill: $--color-white !default;+$--button-disabled-border: $--border-color-lighter !default;++$--button-primary-border: $--color-primary !default;+$--button-primary-color: $--color-white !default;+$--button-primary-fill: $--color-primary !default;++$--button-success-border: $--color-success !default;+$--button-success-color: $--color-white !default;+$--button-success-fill: $--color-success !default;++$--button-warning-border: $--color-warning !default;+$--button-warning-color: $--color-white !default;+$--button-warning-fill: $--color-warning !default;++$--button-danger-border: $--color-danger !default;+$--button-danger-color: $--color-white !default;+$--button-danger-fill: $--color-danger !default;++$--button-info-border: $--color-info !default;+$--button-info-color: $--color-white !default;+$--button-info-fill: $--color-info !default;++$--button-hover-tint-percent: 20% !default;+$--button-active-shade-percent: 10% !default;+++/* cascader+-------------------------- */+$--cascader-height: 200px !default;++/* Switch+-------------------------- */+$--switch-on-color: $--color-primary !default;+$--switch-off-color: $--border-color-base !default;+$--switch-disabled-color: $--border-color-lighter !default;+$--switch-disabled-text-color: $--color-text-placeholder !default;++$--switch-font-size: $--font-size-base !default;+$--switch-core-border-radius: 10px !default;+$--switch-width: 40px !default;+$--switch-height: 20px !default;+$--switch-button-size: 16px !default;++/* Dialog+-------------------------- */+$--dialog-background-color: $--color-primary-light-4 !default;+$--dialog-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !default;+$--dialog-close-hover-color: $--color-primary !default;+$--dialog-title-font-size: $--font-size-large !default;+$--dialog-font-size: 14px !default;+$--dialog-line-height: $--font-line-height-primary !default;+$--dialog-padding-primary: 20px !default;++/* Table+-------------------------- */+$--table-border-color: $--border-color-lighter !default;+$--table-border: 1px solid $--table-border-color !default;+$--table-text-color: $--color-text-regular !default;+$--table-header-color: $--color-text-secondary !default;+$--table-row-hover-background: $--background-color-base !default;+$--table-current-row-background: $--color-primary-light-9 !default;+$--table-header-background: $--color-white !default;+$--table-footer-background: $--color-text-placeholder !default;+$--table-fixed-box-shadow: 0 0 10px rgba(0, 0, 0, .12) !default;++/* Pagination+-------------------------- */+$--pagination-font-size: 13px !default;+$--pagination-fill: $--color-white !default;+$--pagination-color: $--color-text-primary !default;+$--pagination-border-radius: 3px !default;+$--pagination-button-color: $--color-text-primary !default;+$--pagination-button-width: 35.5px !default;+$--pagination-button-height: 28px !default;+$--pagination-button-disabled-color: $--color-text-placeholder !default;+$--pagination-button-disabled-fill: $--color-white !default;+$--pagination-hover-fill: $--color-primary !default;+$--pagination-hover-color: $--color-white !default;++/* Popover+-------------------------- */+$--popover-fill: $--color-white !default;+$--popover-font-size: $--font-size-base !default;+$--popover-border-color: $--border-color-lighter !default;+$--popover-arrow-size: 6px !default;+$--popover-padding: 12px !default;+$--popover-padding-large: 18px 20px !default;+$--popover-title-font-size: 16px !default;+$--popover-title-color: $--color-text-primary !default;++/* Tooltip+-------------------------- */+$--tooltip-fill: $--color-text-primary !default;+$--tooltip-color: $--color-white !default;+$--tooltip-font-size: 12px !default;+$--tooltip-border-color: $--color-text-primary !default;+$--tooltip-arrow-size: 6px !default;+$--tooltip-padding: 10px !default;++/* Tag+-------------------------- */+$--tag-padding: 0 10px !default;+$--tag-fill: rgba($--color-primary, 0.10) !default;+$--tag-color: $--color-primary !default;+$--tag-border: rgba($--color-primary, 0.20) !default;+$--tag-font-size: 12px !default;+$--tag-border-radius: 4px !default;++$--tag-info-fill: rgba($--color-info, 0.10) !default;+$--tag-info-border: rgba($--color-info, 0.20) !default;+$--tag-info-color: $--color-info !default;++$--tag-primary-fill: rgba($--color-primary, 0.10) !default;+$--tag-primary-border: rgba($--color-primary, 0.20) !default;+$--tag-primary-color: $--color-primary !default;++$--tag-success-fill: rgba($--color-success, 0.10) !default;+$--tag-success-border: rgba($--color-success, 0.20) !default;+$--tag-success-color: $--color-success !default;++$--tag-warning-fill: rgba($--color-warning, 0.10) !default;+$--tag-warning-border: rgba($--color-warning, 0.20) !default;+$--tag-warning-color: $--color-warning !default;++$--tag-danger-fill: rgba($--color-danger, 0.10) !default;+$--tag-danger-border: rgba($--color-danger, 0.20) !default;+$--tag-danger-color: $--color-danger !default;++/* Tree+-------------------------- */+$--tree-node-hover-color: $--background-color-base !default;+$--tree-text-color: $--color-text-regular !default;+$--tree-expand-icon-color: $--color-text-placeholder !default;++/* Dropdown+-------------------------- */+$--dropdown-menu-box-shadow: $--box-shadow-light !default;+$--dropdown-menuItem-hover-fill: $--color-primary-light-9 !default;+$--dropdown-menuItem-hover-color: $--link-color !default;++/* Badge+-------------------------- */+$--badge-fill: $--color-danger !default;+$--badge-radius: 10px !default;+$--badge-font-size: 12px !default;+$--badge-padding: 6px !default;+$--badge-size: 18px !default;++/* Card+--------------------------*/+$--card-border-color: $--border-color-lighter !default;+$--card-border-radius: 4px !default;+$--card-padding: 20px !default;++/* Slider+--------------------------*/+$--slider-main-background-color: $--color-primary !default;+$--slider-runway-background-color: $--border-color-light !default;+$--slider-button-hover-color: mix($--color-primary, black, 97%) !default;+$--slider-stop-background-color: $--color-white !default;+$--slider-disable-color: $--color-text-placeholder !default;++$--slider-margin: 16px 0 !default;+$--slider-border-radius: 3px !default;+$--slider-height: 6px !default;+$--slider-button-size: 16px !default;+$--slider-button-wrapper-size: 36px !default;+$--slider-button-wrapper-offset: -15px !default;++/* Steps+--------------------------*/+$--steps-border-color: $--disabled-border-base !default;+$--steps-border-radius: 4px !default;+$--steps-padding: 20px !default;++/* Menu+--------------------------*/+$--menu-item-font-size: $--font-size-base !default;+$--menu-item-color: $--color-text-primary !default;+$--menu-item-fill: $--color-white !default;+$--menu-item-hover-fill: $--color-primary-light-9 !default;++/* Rate+--------------------------*/+$--rate-height: 20px !default;+$--rate-font-size: $--font-size-base !default;+$--rate-icon-size: 18px !default;+$--rate-icon-margin: 6px !default;+$--rate-icon-color: $--color-text-placeholder !default;++/* DatePicker+--------------------------*/+$--datepicker-color: $--color-text-regular !default;+$--datepicker-off-color: $--color-text-placeholder !default;+$--datepicker-header-color: $--color-text-regular !default;+$--datepicker-icon-color: $--color-text-primary !default;+$--datepicker-border-color: $--disabled-border-base !default;+$--datepicker-inner-border-color: #e4e4e4 !default;+$--datepicker-inrange-color: $--border-color-extra-light !default;+$--datepicker-inrange-hover-color: $--border-color-extra-light !default;+$--datepicker-active-color: $--color-primary !default;+$--datepicker-text-hover-color: $--color-primary !default;+$--datepicker-cell-hover-color: #fff !default;++/* Loading+--------------------------*/+$--loading-spinner-size: 42px !default;+$--loading-fullscreen-spinner-size: 50px !default;++/* Scrollbar+--------------------------*/+$--scrollbar-background-color: rgba($--color-text-secondary, .3) !default;+$--scrollbar-hover-background-color: rgba($--color-text-secondary, .5) !default;++/* Carousel+--------------------------*/+$--carousel-arrow-font-size: 12px !default;+$--carousel-arrow-size: 36px !default;+$--carousel-arrow-background: rgba(31, 45, 61, 0.11) !default;+$--carousel-arrow-hover-background: rgba(31, 45, 61, 0.23) !default;+$--carousel-indicator-width: 30px !default;+$--carousel-indicator-height: 2px !default;+$--carousel-indicator-padding-horizontal: 4px !default;+$--carousel-indicator-padding-vertical: 12px !default;+$--carousel-indicator-out-color: $--border-color-hover !default;++/* Collapse+--------------------------*/+$--collapse-border-color: $--border-color-lighter !default;+$--collapse-header-height: 48px !default;+$--collapse-header-padding: 20px !default;+$--collapse-header-fill: $--color-white !default;+$--collapse-header-color: $--color-text-primary !default;+$--collapse-header-size: 13px !default;+$--collapse-content-fill: $--color-white !default;+$--collapse-content-size: 13px !default;+$--collapse-content-color: $--color-text-primary !default;++/* Transfer+--------------------------*/+$--transfer-border-color: $--border-color-lighter !default;+$--transfer-border-radius: $--border-radius-base !default;+$--transfer-panel-width: 200px !default;+$--transfer-panel-header-height: 40px !default;+$--transfer-panel-header-background: $--background-color-base !default;+$--transfer-panel-footer-height: 40px !default;+$--transfer-panel-body-height: 246px !default;+$--transfer-item-height: 30px !default;+$--transfer-item-hover-background: $--color-text-secondary !default;+$--transfer-filter-height: 32px !default;++/* Header+ --------------------------*/+$--header-padding: 0 20px !default;++/* Footer+--------------------------*/+$--footer-padding: 0 20px !default;++/* Main+--------------------------*/+$--main-padding: 20px !default;++/* Break-point+--------------------------*/+$--sm: 768px !default;+$--md: 992px !default;+$--lg: 1200px !default;+$--xl: 1920px !default;++$--breakpoints: (+ 'xs' : (max-width: $--sm),+ 'sm' : (min-width: $--sm),+ 'md' : (min-width: $--md),+ 'lg' : (min-width: $--lg),+ 'xl' : (min-width: $--xl)+);++$--breakpoints-spec: (+ 'xs-only' : (max-width: $--sm - 1),+ 'sm-and-up' : (min-width: $--sm),+ 'sm-only': "(min-width: #{$--sm}) and (max-width: #{$--md} - 1)",+ 'sm-and-down': (max-width: $--md - 1),+ 'md-and-up' : (min-width: $--md),+ 'md-only': "(min-width: #{$--md}) and (max-width: #{$--lg } - 1)",+ 'md-and-down': (max-width: $--lg - 1),+ 'lg-and-up' : (min-width: $--lg),+ 'lg-only': "(min-width: #{$--lg}) and (max-width: #{$--xl } - 1)",+ 'lg-and-down': (max-width: $--xl - 1),+ 'xl-only' : (min-width: $--xl),+);++/* 改变 icon 字体路径变量,必需 */+$--font-path: '~element-ui/lib/theme-chalk/fonts';++/* App+-------------------------- */+$--app-background: transparent !default;+// $--app-background: #fff !default;++/* Aside+-------------------------- */+$--aside-background: rgba(0, 0, 0, 0.8) !default;+$--aside-text-color: #fff !default;++/* SubNav+-------------------------- */+$--subnav-background: #F4F5F7 !default;+$--subnav-title-color: $--color-text-primary !default;+$--subnav-text-color: #4D515A !default;+$--subnav-active-text-color: $--color-primary !default;++/* Panel+-------------------------- */+$--panel-background: $--color-white !default;+$--panel-title-color: $--color-text-primary !default;+$--panel-border-color: #EBECF0 !default;++/* Task+-------------------------- */+$--task-item-border-color: #ccc !default;+$--task-item-hover-border-color: $--color-primary !default;+$--task-item-hover-background: $--color-primary !default;++/* Speedometer+-------------------------- */+$--speedometer-background: $--color-white !default;+$--speedometer-border-color: #ccc !default;+$--speedometer-hover-border-color: #9b9b9b !default;+$--speedometer-primary-color: $--color-primary !default;+$--speedometer-stopped-color: #9b9b9b !default;+$--speedometer-text-color: #9b9b9b !default;++/* Mixin+-------------------------- */+@mixin clearfix {+ &:after {+ content: "";+ display: table;+ clear: both;+ }+}diff --git a/src/renderer/pages/index/App.vue b/src/renderer/pages/index/App.vuenew file mode 100644index 00000000..5d75b074--- /dev/null+++ b/src/renderer/pages/index/App.vue@@ -0,0 +1,36 @@+<template>+ <div id="app">+ <div class="title-bar"></div>+ <router-view></router-view>+ <mo-engine-client+ :secret="rpcSecret"+ />+ <mo-ipc v-if="isRenderer()" />+ </div>+</template>++<script>+ import is from 'electron-is'+ import EngineClient from '@/components/Native/EngineClient'+ import Ipc from '@/components/Native/Ipc'+ import { mapState } from 'vuex'++ export default {+ name: 'Motrix',+ components: {+ [EngineClient.name]: EngineClient,+ [Ipc.name]: Ipc+ },+ computed: {+ ...mapState('preference', {+ rpcSecret: state => state.rpcSecret+ })+ },+ methods: {+ isRenderer: is.renderer+ }+ }+</script>++<style>+</style>diff --git a/src/renderer/pages/index/main.js b/src/renderer/pages/index/main.jsnew file mode 100644index 00000000..ecacbc1f--- /dev/null+++ b/src/renderer/pages/index/main.js@@ -0,0 +1,48 @@+import Vue from 'vue'+import axios from 'axios'++import App from './App'+import { sync } from 'vuex-router-sync'+import router from '@/router'+import store from '@/store'++import Element, { Loading } from 'element-ui'+import '../../components/Theme/Index.scss'++import Icon from '../../components/Icons/Icon'+import 'svg-innerhtml'++import is from 'electron-is'+if (is.renderer()) {+ Vue.use(require('vue-electron'))+}++Vue.http = Vue.prototype.$http = axios+Vue.config.productionTip = false++Vue.use(Element, { size: 'mini' })+Vue.component('mo-icon', Icon)++sync(store, router)++const loading = Loading.service({+ fullscreen: true,+ background: 'rgba(0, 0, 0, 0.1)'+})++store.dispatch('preference/fetchPreference')+ .then(() => {+ /* eslint-disable no-new */+ window.app = new Vue({+ components: { App },+ router,+ store,+ template: '<App/>'+ }).$mount('#app')+ setTimeout(() => {+ loading.close()+ }, 400)+ })+ .catch((err) => {+ alert(err)+ })diff --git a/src/renderer/router/index.js b/src/renderer/router/index.jsnew file mode 100644index 00000000..1bcd7345--- /dev/null+++ b/src/renderer/router/index.js@@ -0,0 +1,73 @@+import Vue from 'vue'+import Router from 'vue-router'++Vue.use(Router)++export default new Router({+ routes: [+ {+ path: '/',+ name: 'main',+ component: require('@/components/Main').default,+ children: [+ {+ path: '/task',+ alias: '/',+ component: require('@/components/Task/Index').default,+ props: {+ status: 'active'+ }+ },+ {+ path: '/task/:status',+ name: 'task',+ component: require('@/components/Task/Index').default,+ props: true+ },+ {+ path: '/preference',+ name: 'preference',+ component: require('@/components/Preference/Index').default,+ props: true,+ children: [+ {+ path: 'basic',+ alias: '',+ components: {+ subnav: require('@/components/Subnav/PreferenceSubnav').default,+ form: require('@/components/Preference/Basic').default+ },+ props: {+ subnav: { current: 'basic' }+ }+ },+ {+ path: 'advanced',+ components: {+ subnav: require('@/components/Subnav/PreferenceSubnav').default,+ form: require('@/components/Preference/Advanced').default+ },+ props: {+ subnav: { current: 'advanced' }+ }+ },+ {+ path: 'lab',+ components: {+ subnav: require('@/components/Subnav/PreferenceSubnav').default,+ form: require('@/components/Preference/Lab').default+ },+ props: {+ subnav: { current: 'lab' }+ }+ }+ ]+ }+ ]+ },+ {+ path: '*',+ redirect: '/'+ }+ ]+})diff --git a/src/renderer/store/index.js b/src/renderer/store/index.jsnew file mode 100644index 00000000..913f0a2f--- /dev/null+++ b/src/renderer/store/index.js@@ -0,0 +1,11 @@+import Vue from 'vue'+import Vuex from 'vuex'++import modules from './modules'++Vue.use(Vuex)++export default new Vuex.Store({+ modules,+ strict: process.env.NODE_ENV !== 'production'+})diff --git a/src/renderer/store/modules/app.js b/src/renderer/store/modules/app.jsnew file mode 100644index 00000000..fa776339--- /dev/null+++ b/src/renderer/store/modules/app.js@@ -0,0 +1,161 @@+import is from 'electron-is'+import api from '@/api'++const BASE_INTERVAL = 1000+const PER_INTERVAL = 100+const MIN_INTERVAL = 500+const MAX_INTERVAL = 6000++const state = {+ aboutPanelVisible: false,+ engineInfo: {+ version: '',+ enabledFeatures: []+ },+ engineStatus: '',+ interval: BASE_INTERVAL,+ stat: {+ downloadSpeed: 0,+ uploadSpeed: 0,+ numActive: 0,+ numStopped: 0,+ numWaiting: 0+ },+ currentPage: 'task',+ addTaskVisible: false,+ addTaskType: 'uri',+ i18n: 'zh_CN'+}++const pageTitles = {+ 'task': '任务列表',+ 'preference': '偏好设置',+ 'about': '关于'+}++const getters = {+ currentPageTitle: (state, getters) => {+ return pageTitles[state.currentPage] ? pageTitles[state.currentPage] : ''+ }+}++const mutations = {+ CHANGE_ABOUT_PANEL_VISIBLE (state, visible) {+ state.aboutPanelVisible = visible+ },+ UPDATE_ENGINE_INFO (state, engineInfo) {+ state.engineInfo = { ...state.engineInfo, ...engineInfo }+ },+ UPDATE_GLOBAL_STAT (state, stat) {+ state.stat = stat+ },+ CHANGE_CURRENT_PAGE (state, currentPage) {+ state.currentPage = currentPage+ },+ CHANGE_ADD_TASK_VISIBLE (state, visible) {+ state.addTaskVisible = visible+ },+ CHANGE_ADD_TASK_TYPE (state, taskType) {+ state.addTaskType = taskType+ },+ UPDATE_INTERVAL (state, millisecond) {+ let interval = millisecond+ if (millisecond > MAX_INTERVAL) {+ interval = MAX_INTERVAL+ }+ if (millisecond < MIN_INTERVAL) {+ interval = MIN_INTERVAL+ }+ if (state.interval === interval) {+ return+ }+ state.interval = interval+ console.log('current interval===>', state.interval)+ },+ INCREASE_INTERVAL (state, millisecond) {+ if (state.interval < MAX_INTERVAL) {+ state.interval += millisecond+ }+ console.log('current interval===>', state.interval)+ },+ DECREASE_INTERVAL (state, millisecond) {+ if (state.interval > MIN_INTERVAL) {+ state.interval -= millisecond+ }+ console.log('current interval===>', state.interval)+ }+}++const actions = {+ showAboutPanel ({ commit }) {+ commit('CHANGE_ABOUT_PANEL_VISIBLE', true)+ },+ hideAboutPanel ({ commit }) {+ commit('CHANGE_ABOUT_PANEL_VISIBLE', false)+ },+ fetchEngineInfo ({ commit }) {+ api.getVersion()+ .then((data) => {+ commit('UPDATE_ENGINE_INFO', data)+ })+ },+ fetchGlobalStat ({ commit, dispatch }) {+ api.getGlobalStat()+ .then((data) => {+ const stat = {}+ Object.keys(data).forEach((key) => {+ stat[key] = Number(data[key])+ })++ if (stat.numActive > 0) {+ const interval = BASE_INTERVAL - PER_INTERVAL * stat.numActive+ dispatch('updateInterval', interval)+ } else {+ // fix downloadSpeed when numActive = 0+ stat.downloadSpeed = 0+ dispatch('increaseInterval')+ }+ commit('UPDATE_GLOBAL_STAT', stat)++ // @4ET+ if (!is.renderer()) {+ return+ }+ if (stat.numActive > 0) {+ api.startPowerSaveBlocker()+ } else {+ api.stopPowerSaveBlocker()+ }+ })+ },+ increaseInterval ({ commit }, millisecond = 100) {+ commit('INCREASE_INTERVAL', millisecond)+ },+ changeCurrentPage ({ commit }, currentPage) {+ commit('CHANGE_CURRENT_PAGE', currentPage)+ },+ showAddTaskDialog ({ commit }, taskType) {+ commit('CHANGE_ADD_TASK_TYPE', taskType)+ commit('CHANGE_ADD_TASK_VISIBLE', true)+ },+ hideAddTaskDialog ({ commit }) {+ commit('CHANGE_ADD_TASK_VISIBLE', false)+ },+ changeAddTaskType ({ commit }, taskType) {+ commit('CHANGE_ADD_TASK_TYPE', taskType)+ },+ updateInterval ({ commit }, millisecond) {+ commit('UPDATE_INTERVAL', millisecond)+ },+ resetInterval ({ commit }) {+ commit('UPDATE_INTERVAL', BASE_INTERVAL)+ }+}++export default {+ namespaced: true,+ state,+ getters,+ mutations,+ actions+}diff --git a/src/renderer/store/modules/index.js b/src/renderer/store/modules/index.jsnew file mode 100644index 00000000..428c6be2--- /dev/null+++ b/src/renderer/store/modules/index.js@@ -0,0 +1,14 @@+/**+ * The file enables `@/store/index.js` to import all vuex modules+ * in a one-shot manner. There should not be any reason to edit this file.+ */++const files = require.context('.', false, /\.js$/)+const modules = {}++files.keys().forEach(key => {+ if (key === './index.js') return+ modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default+})++export default modulesdiff --git a/src/renderer/store/modules/preference.js b/src/renderer/store/modules/preference.jsnew file mode 100644index 00000000..9b889478--- /dev/null+++ b/src/renderer/store/modules/preference.js@@ -0,0 +1,55 @@+import api from '@/api'++const state = {+ currentForm: 'basic',+ engineMode: 'MAX',+ config: {}+}++const formTitles = {+ 'basic': '基础设置',+ 'advanced': '进阶设置',+ 'lab': '实验室'+}++const getters = {+ currentFormTitle: (state, getters) => {+ return formTitles[state.currentForm] ? formTitles[state.currentForm] : ''+ }+}++const mutations = {+ UPDATE_PREFERENCE_DATA (state, config) {+ state.config = { ...state.config, ...config }+ },+ CHANGE_CURRENT_FORM (state, currentForm) {+ state.currentForm = currentForm+ }+}++const actions = {+ changeCurrentForm ({ commit }, currentForm) {+ commit('CHANGE_CURRENT_FORM', currentForm)+ },+ fetchPreference ({ commit }) {+ return api.fetchPreference()+ .then((config) => {+ commit('UPDATE_PREFERENCE_DATA', config)+ })+ },+ save ({ commit }, config) {+ commit('UPDATE_PREFERENCE_DATA', config)+ return api.savePreference(config)+ },+ toggleEngineMode () {++ }+}++export default {+ namespaced: true,+ state,+ getters,+ mutations,+ actions+}diff --git a/src/renderer/store/modules/task.js b/src/renderer/store/modules/task.jsnew file mode 100644index 00000000..60ed62d4--- /dev/null+++ b/src/renderer/store/modules/task.js@@ -0,0 +1,170 @@+import api from '@/api'++const state = {+ currentList: 'active',+ taskItemInfoVisible: false,+ currentTaskItem: null,+ taskList: []+}++const listTitles = {+ 'active': '下载中',+ 'waiting': '已暂停',+ 'stopped': '已完成'+}++const getters = {+ currentListTitle: (state, getters) => {+ return listTitles[state.currentList] ? listTitles[state.currentList] : ''+ }+}++const mutations = {+ UPDATE_TASK_LIST (state, taskList) {+ state.taskList = taskList+ },+ CHANGE_CURRENT_LIST (state, currentList) {+ state.currentList = currentList+ },+ CHANGE_TASK_ITEM_INFO_VISIBLE (state, visible) {+ state.taskItemInfoVisible = visible+ },+ UPDATE_CURRENT_TASK_ITEM (state, task) {+ state.currentTaskItem = task+ }+}++const actions = {+ changeCurrentList ({ commit, dispatch }, currentList) {+ commit('CHANGE_CURRENT_LIST', currentList)+ dispatch('fetchList')+ },+ fetchList ({ state, commit }) {+ console.log('fetchList===>')+ api.fetchTaskList({ type: state.currentList })+ .then((data) => {+ console.log('data===>', data)+ commit('UPDATE_TASK_LIST', data)+ })+ },+ fetchItem ({ dispatch }, gid) {+ api.fetchTaskItem({ gid })+ .then((data) => {+ console.log('data===>', data)+ dispatch('updateCurrentTaskItem', data)+ })+ },+ showTaskItemInfoDialog ({ commit, dispatch }, task) {+ dispatch('updateCurrentTaskItem', task)+ commit('CHANGE_TASK_ITEM_INFO_VISIBLE', true)+ },+ hideTaskItemInfoDialog ({ commit }) {+ commit('CHANGE_TASK_ITEM_INFO_VISIBLE', false)+ },+ updateCurrentTaskItem ({ commit }, task) {+ commit('UPDATE_CURRENT_TASK_ITEM', task)+ },+ addUri ({ dispatch }, data) {+ const { uris, options } = data+ return api.addUri({ uris, options })+ .then(() => {+ dispatch('fetchList')+ })+ },+ addTorrent ({ dispatch }, data) {+ const { torrent, options } = data+ return api.addTorrent({ torrent, options })+ .then(() => {+ dispatch('fetchList')+ })+ },+ addMetalink ({ dispatch }, data) {+ const { metalink, options } = data+ return api.addMetalink({ metalink, options })+ .then(() => {+ dispatch('fetchList')+ })+ },+ removeTask ({ dispatch }, task) {+ const { gid } = task+ console.log('removeTask', gid)+ return api.removeTask({ gid })+ .catch(() => {+ return api.forceRemoveTask({ gid })+ })+ .finally(() => {+ dispatch('fetchList')+ dispatch('saveSession')+ })+ },+ pauseTask ({ dispatch }, task) {+ const { gid } = task+ console.log('pauseTask', gid)+ return api.pauseTask({ gid })+ .catch(() => {+ return api.forcePauseTask({ gid })+ })+ .finally(() => {+ dispatch('fetchList')+ dispatch('saveSession')+ })+ },+ resumeTask ({ dispatch }, task) {+ const { gid } = task+ console.log('resumeTask', gid)+ return api.resumeTask({ gid })+ .finally(() => {+ dispatch('fetchList')+ dispatch('saveSession')+ })+ },+ pauseAllTask ({ dispatch }) {+ console.log('pauseAllTask===>')+ return api.pauseAllTask()+ .catch(() => {+ return api.forcePauseAllTask()+ })+ .finally(() => {+ dispatch('fetchList')+ dispatch('saveSession')+ })+ },+ resumeAllTask ({ dispatch }) {+ console.log('resumeAllTask===>')+ return api.resumeAllTask()+ .finally(() => {+ dispatch('fetchList')+ dispatch('saveSession')+ })+ },+ removeTaskRecord ({ dispatch }, task) {+ const { gid } = task+ console.log('removeTaskRecord', gid)+ return api.removeTaskRecord({ gid })+ .finally(() => dispatch('fetchList'))+ },+ saveSession () {+ api.saveSession()+ },+ purgeTaskRecord ({ dispatch }) {+ return api.purgeTaskRecord()+ .finally(() => dispatch('fetchList'))+ },+ toggleTask ({ dispatch }, task) {+ console.log('切换任务状态===>', task)+ const { status } = task+ if (status === 'active') {+ return dispatch('pauseTask', task)+ } else if (status === 'waiting' || status === 'paused') {+ return dispatch('resumeTask', task)+ }+ }+}++export default {+ namespaced: true,+ state,+ getters,+ mutations,+ actions+}diff --git a/src/shared/colors.json b/src/shared/colors.jsonnew file mode 100644index 00000000..c537af33--- /dev/null+++ b/src/shared/colors.json@@ -0,0 +1,8 @@+{+ "active": "#5b5bea",+ "waiting": "#737373",+ "paused": "#737373",+ "error": "#FF6157",+ "complete": "#2ACB42",+ "removed": "#737373"+}diff --git a/src/shared/configKeys.js b/src/shared/configKeys.jsnew file mode 100644index 00000000..e498bfb7--- /dev/null+++ b/src/shared/configKeys.js@@ -0,0 +1,130 @@+const userKeys = [+ 'cookie',+ 'resume-all-when-app-launched',+ 'task-notification',+ 'new-task-show-downloading',+ 'use-proxy',+ 'all-proxy-backup',+ 'log-path',+ 'session-path',+ 'enable-egg-features'+]++const systemKeys = [+ 'max-concurrent-downloads',+ 'all-proxy',+ 'all-proxy-passwd',+ 'all-proxy-user',+ 'allow-overwrite',+ 'allow-piece-length-change',+ 'always-resume',+ 'async-dns',+ 'auto-file-renaming',+ 'bt-enable-hook-after-hash-check',+ 'bt-enable-lpd',+ 'bt-exclude-tracker',+ 'bt-external-ip',+ 'bt-force-encryption',+ 'bt-hash-check-seed',+ 'bt-load-saved-metadata',+ 'bt-max-peers',+ 'bt-metadata-only',+ 'bt-min-crypto-level',+ 'bt-prioritize-piece',+ 'bt-remove-unselected-file',+ 'bt-request-peer-speed-limit',+ 'bt-require-crypto',+ 'bt-save-metadata',+ 'bt-seed-unverified',+ 'bt-stop-timeout',+ 'bt-tracker',+ 'bt-tracker-connect-timeout',+ 'bt-tracker-interval',+ 'bt-tracker-timeout',+ 'check-integrity',+ 'checksum',+ 'conditional-get',+ 'connect-timeout',+ 'content-disposition-default-utf8',+ 'continue',+ 'dir',+ 'dry-run',+ 'enable-http-keep-alive',+ 'enable-http-pipelining',+ 'enable-mmap',+ 'enable-peer-exchange',+ 'file-allocation',+ 'follow-metalink',+ 'follow-torrent',+ 'force-save',+ 'ftp-passwd',+ 'ftp-pasv',+ 'ftp-proxy',+ 'ftp-proxy-passwd',+ 'ftp-proxy-user',+ 'ftp-reuse-connection',+ 'ftp-type',+ 'ftp-user',+ 'gid',+ 'hash-check-only',+ 'header',+ 'http-accept-gzip',+ 'http-auth-challenge',+ 'http-no-cache',+ 'http-passwd',+ 'http-proxy',+ 'http-proxy-passwd',+ 'http-proxy-user',+ 'http-user',+ 'https-proxy',+ 'https-proxy-passwd',+ 'https-proxy-user',+ 'index-out',+ 'lowest-speed-limit',+ 'max-connection-per-server',+ 'max-download-limit',+ 'max-file-not-found',+ 'max-mmap-limit',+ 'max-resume-failure-tries',+ 'max-tries',+ 'max-upload-limit',+ 'metalink-base-uri',+ 'metalink-enable-unique-protocol',+ 'metalink-language',+ 'metalink-location',+ 'metalink-os',+ 'metalink-preferred-protocol',+ 'metalink-version',+ 'min-split-size',+ 'no-file-allocation-limit',+ 'no-netrc',+ 'no-proxy',+ 'out',+ 'parameterized-uri',+ 'pause',+ 'pause-metadata',+ 'piece-length',+ 'proxy-method',+ 'realtime-chunk-checksum',+ 'referer',+ 'remote-time',+ 'remove-control-file',+ 'retry-wait',+ 'reuse-uri',+ 'rpc-save-upload-metadata',+ 'seed-ratio',+ 'seed-time',+ 'select-file',+ 'split',+ 'ssh-host-key-md',+ 'stream-piece-selector',+ 'timeout',+ 'uri-selector',+ 'use-head',+ 'user-agent'+]++export {+ userKeys,+ systemKeys+}diff --git a/src/shared/keymap.json b/src/shared/keymap.jsonnew file mode 100644index 00000000..3ba50579--- /dev/null+++ b/src/shared/keymap.json@@ -0,0 +1,7 @@+{+ "cmd-n": "application:new-task",+ "cmd-shift-n": "application:new-bt-task",+ "cmd-,": "application:preferences",+ "cmd-shift-p": "application:pause-all-task",+ "cmd-shift-r": "application:resume-all-task"+}diff --git a/src/shared/ua.js b/src/shared/ua.jsnew file mode 100644index 00000000..2edb9502--- /dev/null+++ b/src/shared/ua.js@@ -0,0 +1,5 @@+export default {+ 'transmission': 'Transmission/2.94',+ 'chrome': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36',+ 'du': 'netdisk;6.0.0.12;PC;PC-Windows;10.0.16299;WindowsBaiduYunGuanJia'+}diff --git a/src/shared/utils.js b/src/shared/utils.jsnew file mode 100644index 00000000..fa8b95b0--- /dev/null+++ b/src/shared/utils.js@@ -0,0 +1,277 @@+import {+ isEmpty,+ isNaN,+ parseInt,+ isFunction,+ camelCase,+ kebabCase+} from 'lodash'+import { userKeys, systemKeys } from './configKeys'++export function bytesToSize (bytes) {+ const b = parseInt(bytes, 10)+ const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']+ if (b === 0) { return '0 KB' }+ const i = parseInt(Math.floor(Math.log(b) / Math.log(1024)), 10)+ if (i === 0) { return `${b} ${sizes[i]}` }+ return `${(b / (1024 ** i)).toFixed(1)} ${sizes[i]}`+}++export function calcProgress (totalLength, completedLength) {+ const total = parseInt(totalLength, 10)+ const completed = parseInt(completedLength, 10)+ if (total === 0 || completed === 0) {+ return 0+ }+ const percentage = completed / total * 100+ const result = parseFloat(percentage.toFixed(2))+ return result+}++export function timeRemaining (totalLength, completedLength, downloadSpeed) {+ const remainingLength = totalLength - completedLength+ return Math.ceil(remainingLength / downloadSpeed)+}++export function timeFormat (seconds, prefix = '', suffix = '') {+ let result = ''+ let hours = ''+ let minutes = ''+ let secs = seconds || 0++ if (secs <= 0) {+ return ''+ }+ if (secs > 86400) {+ return `${prefix} 超过一天 ${suffix}`+ }+ if (secs > 3600) {+ hours = `${Math.floor(secs / 3600)}时 `+ secs %= 3600+ }+ if (secs > 60) {+ minutes = `${Math.floor(secs / 60)}分 `+ secs %= 60+ }+ secs += '秒'+ result = hours + minutes + secs+ return result ? `${prefix} ${result} ${suffix}` : result+}++export function getTaskName (task, defaultName = '') {+ let result = defaultName+ if (!task) {+ return result+ }++ const { files, bittorrent } = task++ if (bittorrent && bittorrent.info && bittorrent.info.name) {+ result = bittorrent.info.name+ return result+ }++ if (files && files.length === 1) {+ result = getFileName(files[0])+ }++ if (files.length > 1) {+ let cnt = 0+ for (let i = 0; i < files.length; i += 1) {+ if (files[i].selected === 'true') {+ cnt += 1+ }+ }+ if (cnt > 1) {+ result += ` (${cnt} 文件...)`+ }+ }++ return result+}++export function getFileName (file) {+ if (!file) {+ return ''+ }++ let { path } = file+ if (!path && file.uris && file.uris.length > 0) {+ path = decodeURI(file.uris[0].uri)+ }++ const index = path.lastIndexOf('/')++ if (index <= 0 || index === path.length) {+ return path+ }++ return path.substring(index + 1)+}++export function getTaskFullPath (task) {+ const { dir, files, bittorrent } = task+ let result = ''++ if (bittorrent && bittorrent.info && bittorrent.info.name) {+ result = `${dir}/${bittorrent.info.name}`+ return result+ }++ const [file] = files+ const { path } = file+ result = path++ if (!path && files && files.length === 1) {+ result = `${dir}/${getFileName(file)}`+ }++ return result+}++export function getTaskUri (task) {+ const { files } = task+ let result = ''+ if (checkTaskIsBT(task)) {+ result = '种子任务'+ return result+ }++ if (files && files.length === 1) {+ const { uris } = files[0]+ result = uris[0].uri+ }++ return result+}++export function checkTaskTitleIsEmpty (task) {+ const { files, bittorrent } = task+ const [file] = files+ const { path } = file+ let result = path+ if (bittorrent && bittorrent.info && bittorrent.info.name) {+ result = bittorrent.info.name+ }+ return result === ''+}++export function checkTaskIsBT (task) {+ const { bittorrent } = task+ return !!bittorrent+}++export function isTorrent (file) {+ const { name, type } = file+ return name.endsWith('.torrent') || type === 'application/x-bittorrent'+}++export function getAsBase64 (file, callback) {+ const reader = new FileReader()+ reader.addEventListener('load', () => {+ const result = reader.result.replace('data:;base64,', '')+ callback(result)+ })+ reader.readAsDataURL(file)+}++export function mergeTaskResult (response = []) {+ let result = []+ for (const res of response) {+ result = result.concat(...res)+ }+ return result+}++export function changeKeysCase (obj, caseConverter) {+ const result = {}+ if (isEmpty(obj) || !isFunction(caseConverter)) {+ return result+ }++ for (const [k, value] of Object.entries(obj)) {+ const key = caseConverter(k)+ result[key] = value+ }++ return result+}++export function changeKeysToCamelCase (obj) {+ return changeKeysCase(obj, camelCase)+}++export function changeKeysToKebabCase (obj) {+ return changeKeysCase(obj, kebabCase)+}++export function validateNumber (n) {+ return !isNaN(parseFloat(n)) && isFinite(n) && Number(n) === n+}++export function fixValue (obj) {+ const result = {}+ for (const [k, v] of Object.entries(obj)) {+ if (v === 'true') {+ result[k] = true+ } else if (v === 'false') {+ result[k] = false+ } else if (validateNumber(v)) {+ result[k] = Number(v)+ } else {+ result[k] = v+ }+ }+ return result+}++export function separateConfig (options) {+ // user+ const user = {}+ // system+ const system = {}+ // others+ const others = {}+ for (const [k, v] of Object.entries(options)) {+ if (userKeys.indexOf(k) !== -1) {+ user[k] = v+ } else if (systemKeys.indexOf(k) !== -1) {+ system[k] = v+ } else {+ others[k] = v+ }+ }+ return {+ user, system, others+ }+}++export function compactUndefined (arr = []) {+ return arr.filter((item) => {+ return item !== undefined+ })+}++export function splitTextRows (text = '') {+ return text.replace(/\r\n/g, '\n').split('\n') || []+}++const audioSuffix = ['.aac', '.mp3', '.ogg', '.ape', '.flac', '.m4a', '.wav', '.wma', '.flav']+const videoSuffix = ['.avi', '.mkv', '.rmvb', '.wmv', '.mp4', '.m4a', '.vob', '.mov', '.mpg']+export function isAudioOrVideo (uri = '') {+ const suffixs = [...audioSuffix, ...videoSuffix]+ const result = suffixs.some((suffix) => {+ return uri.includes(suffix)+ })+ console.warn('isAudioOrVideo===>', result)+ return result+}++export function needCheckCopyright (uris) {+ const avs = uris.filter(uri => {+ return isAudioOrVideo(uri)+ })++ const result = avs.length > 0+ return result+}diff --git a/static/.gitkeep b/static/.gitkeepnew file mode 100644index 00000000..e69de29bdiff --git a/static/icons/about.png b/static/icons/about.pngnew file mode 100644index 00000000..836b6616Binary files /dev/null and b/static/icons/about.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..4147cdb6Binary files /dev/null and b/static/icons/[email protected] differdiff --git a/static/icons/new-task.png b/static/icons/new-task.pngnew file mode 100644index 00000000..2af98f7aBinary files /dev/null and b/static/icons/new-task.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..7a5f2d33Binary files /dev/null and b/static/icons/[email protected] differdiff --git a/static/icons/preferences.png b/static/icons/preferences.pngnew file mode 100644index 00000000..47e07f27Binary files /dev/null and b/static/icons/preferences.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..250c95a9Binary files /dev/null and b/static/icons/[email protected] differdiff --git a/static/icons/task-active.png b/static/icons/task-active.pngnew file mode 100644index 00000000..7a42af3cBinary files /dev/null and b/static/icons/task-active.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..a655d153Binary files /dev/null and b/static/icons/[email protected] differdiff --git a/static/icons/task-stopped.png b/static/icons/task-stopped.pngnew file mode 100644index 00000000..bc360505Binary files /dev/null and b/static/icons/task-stopped.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..e9448003Binary files /dev/null and b/static/icons/[email protected] differdiff --git a/static/icons/task-waiting.png b/static/icons/task-waiting.pngnew file mode 100644index 00000000..97c708b4Binary files /dev/null and b/static/icons/task-waiting.png differdiff --git a/static/icons/[email protected] b/static/icons/[email protected]new file mode 100644index 00000000..8ee0f978Binary files /dev/null and b/static/icons/[email protected] differ