Skip to content

A full-featured download manager.

feat: make Motrix layout more responsive (#505)

han89336dda3768
diff --git a/src/main/configs/page.js b/src/main/configs/page.js
index abd20ddb..341d3230 100644
--- a/src/main/configs/page.js
+++ b/src/main/configs/page.js
@@ -6,7 +6,7 @@ export default {
title: 'Motrix',
width: 1024,
height: 768,
- minWidth: 840,
+ minWidth: 400,
minHeight: 420,
// backgroundColor: '#FFFFFF',
transparent: !is.windows()
diff --git a/src/renderer/components/Aside/Index.vue b/src/renderer/components/Aside/Index.vue
index 4d79e227..c8fbc389 100644
--- a/src/renderer/components/Aside/Index.vue
+++ b/src/renderer/components/Aside/Index.vue
@@ -1,5 +1,5 @@
<template>
- <el-aside width="78px" :class="['aside', { 'draggable': asideDraggable }]">
+ <el-aside width="78px" :class="['aside', 'hidden-sm-and-down', { 'draggable': asideDraggable }]">
<div class="aside-inner">
<mo-logo-mini />
<ul class="menu top-menu">
diff --git a/src/renderer/components/Icons/menu-add.js b/src/renderer/components/Icons/menu-add.js
index e03bfe76..d1e80dd0 100644
--- a/src/renderer/components/Icons/menu-add.js
+++ b/src/renderer/components/Icons/menu-add.js
@@ -4,8 +4,8 @@ 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" />`,
+ 'raw': `<line fill="none" stroke-miterlimit="10" x1="12" y1="2" x2="12" y2="22" />
+ <line fill="none" stroke-miterlimit="10" x1="22" y1="12" x2="2" y2="12" />`,
'g': {
'stroke': 'currentColor',
'stroke-linecap': 'round',
diff --git a/src/renderer/components/Task/AddTask.vue b/src/renderer/components/Task/AddTask.vue
index 6bb42b45..cf7d9371 100644
--- a/src/renderer/components/Task/AddTask.vue
+++ b/src/renderer/components/Task/AddTask.vue
@@ -1,416 +1,422 @@
<template>
- <el-dialog
- custom-class="tab-title-dialog add-task-dialog"
- width="61.8vw"
- :visible.sync="visible"
- :before-close="handleClose"
- @open="handleOpen"
- @opened="handleOpened"
- @closed="handleClosed">
- <el-form
- ref="taskForm"
- label-position="left"
- :model="form"
- :rules="rules">
- <el-tabs :value="type" @tab-click="handleTabClick">
- <el-tab-pane :label="$t('task.uri-task')" name="uri">
+ <el-dialog custom-class="tab-title-dialog add-task-dialog"
+ width="64vw"
+ :visible.sync="visible"
+ :before-close="handleClose"
+ @open="handleOpen"
+ @opened="handleOpened"
+ @closed="handleClosed">
+ <el-form ref="taskForm"
+ label-position="left"
+ :model="form"
+ :rules="rules">
+ <el-tabs :value="type"
+ @tab-click="handleTabClick">
+ <el-tab-pane :label="$t('task.uri-task')"
+ name="uri">
<el-form-item>
- <el-input
- ref="uri"
- type="textarea"
- :autosize="{ minRows: 3, maxRows: 5 }"
- auto-complete="off"
- :placeholder="$t('task.uri-task-tips')"
- @change="handleUriChange"
- @paste.native="handleUriPaste"
- v-model="form.uris">
+ <el-input ref="uri"
+ type="textarea"
+ :autosize="{ minRows: 3, maxRows: 5 }"
+ auto-complete="off"
+ :placeholder="$t('task.uri-task-tips')"
+ @change="handleUriChange"
+ @paste.native="handleUriPaste"
+ v-model="form.uris">
</el-input>
</el-form-item>
</el-tab-pane>
- <el-tab-pane
- :label="$t('task.torrent-task')"
- name="torrent"
- >
+ <el-tab-pane :label="$t('task.torrent-task')"
+ name="torrent">
<el-form-item>
- <mo-select-torrent
- v-on:change="handleTorrentChange"
- />
+ <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="`${$t('task.task-out')}: `" :label-width="formLabelWidth">
- <el-input :placeholder="$t('task.task-out-tips')" v-model="form.out">
+ <el-col :span="15"
+ :xs="24">
+ <el-form-item :label="`${$t('task.task-out')}: `"
+ :label-width="formLabelWidth">
+ <el-input :placeholder="$t('task.task-out-tips')"
+ v-model="form.out">
</el-input>
</el-form-item>
</el-col>
- <el-col :span="9">
- <el-form-item :label="`${$t('task.task-split')}: `" :label-width="formLabelWidth">
- <el-input-number
- v-model="form.split"
- @change="handleSplitChange"
- controls-position="right"
- :min="1"
- :max="config.maxConnectionPerServer"
- :value="config.split"
- :label="$t('task.task-split')">
+ <el-col :span="9"
+ :xs="24">
+ <el-form-item :label="`${$t('task.task-split')}: `"
+ :label-width="formLabelWidth">
+ <el-input-number v-model="form.split"
+ @change="handleSplitChange"
+ controls-position="right"
+ :min="1"
+ :max="config.maxConnectionPerServer"
+ :value="config.split"
+ :label="$t('task.task-split')">
</el-input-number>
</el-form-item>
</el-col>
</el-row>
- <el-form-item :label="`${$t('task.task-dir')}: `" :label-width="formLabelWidth">
- <el-input placeholder="" v-model="downloadDir" :readonly="isMas()">
- <mo-select-directory
- v-if="isRenderer()"
- slot="append"
- @selected="onDirectorySelected"
- />
+ <el-form-item :label="`${$t('task.task-dir')}: `"
+ :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="`${$t('task.task-user-agent')}: `" :label-width="formLabelWidth">
- <el-input
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 3 }"
- auto-complete="off"
- :placeholder="$t('task.task-user-agent')"
- v-model="form.userAgent">
+ <el-form-item :label="`${$t('task.task-user-agent')}: `"
+ :label-width="formLabelWidth">
+ <el-input type="textarea"
+ :autosize="{ minRows: 2, maxRows: 3 }"
+ auto-complete="off"
+ :placeholder="$t('task.task-user-agent')"
+ v-model="form.userAgent">
</el-input>
</el-form-item>
- <el-form-item :label="`${$t('task.task-referer')}: `" :label-width="formLabelWidth">
- <el-input
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 3 }"
- auto-complete="off"
- :placeholder="$t('task.task-referer')"
- v-model="form.referer">
+ <el-form-item :label="`${$t('task.task-referer')}: `"
+ :label-width="formLabelWidth">
+ <el-input type="textarea"
+ :autosize="{ minRows: 2, maxRows: 3 }"
+ auto-complete="off"
+ :placeholder="$t('task.task-referer')"
+ v-model="form.referer">
</el-input>
</el-form-item>
- <el-form-item :label="`${$t('task.task-cookie')}: `" :label-width="formLabelWidth">
- <el-input
- type="textarea"
- :autosize="{ minRows: 2, maxRows: 3 }"
- auto-complete="off"
- :placeholder="$t('task.task-cookie')"
- v-model="form.cookie">
+ <el-form-item :label="`${$t('task.task-cookie')}: `"
+ :label-width="formLabelWidth">
+ <el-input type="textarea"
+ :autosize="{ minRows: 2, maxRows: 3 }"
+ auto-complete="off"
+ :placeholder="$t('task.task-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">{{$t('task.navigate-to-downloading')}}</el-checkbox>
+ <el-form-item label=""
+ :label-width="formLabelWidth">
+ <el-checkbox class="chk"
+ v-model="form.newTaskShowDownloading">{{$t('task.navigate-to-downloading')}}</el-checkbox>
</el-form-item>
</div>
</el-form>
- <div slot="footer" class="dialog-footer">
- <el-checkbox class="chk" v-model="showAdvanced">{{$t('task.show-advanced-options')}}</el-checkbox>
- <el-button @click="handleCancel('taskForm')">{{$t('app.cancel')}}</el-button>
- <el-button type="primary" @click="submitForm('taskForm')">{{$t('app.submit')}}</el-button>
+ <div slot="footer"
+ class="dialog-footer">
+ <el-row>
+ <el-col :span="9"
+ :xs="9">
+ <el-checkbox class="chk"
+ v-model="showAdvanced">{{$t('task.show-advanced-options')}}</el-checkbox>
+ </el-col>
+ <el-col :span="15"
+ :xs="15">
+ <el-button @click="handleCancel('taskForm')">{{$t('app.cancel')}}</el-button>
+ <el-button type="primary"
+ @click="submitForm('taskForm')">{{$t('app.submit')}}</el-button>
+ </el-col>
+ </el-row>
</div>
</el-dialog>
</template>
<script>
- import is from 'electron-is'
- import { mapState } from 'vuex'
- import { isEmpty } from 'lodash'
- import SelectDirectory from '@/components/Native/SelectDirectory'
- import SelectTorrent from '@/components/Task/SelectTorrent'
- import { prettifyDir } from '@/components/Native/utils'
- import {
- NONE_SELECTED_FILES,
- SELECTED_ALL_FILES
- } from '@shared/constants'
- import { buildOuts } from '@shared/rename'
- import {
- detectResource,
- splitTaskLinks
- } from '@shared/utils'
- import '@/components/Icons/inbox'
+import is from 'electron-is'
+import { mapState } from 'vuex'
+import { isEmpty } from 'lodash'
+import SelectDirectory from '@/components/Native/SelectDirectory'
+import SelectTorrent from '@/components/Task/SelectTorrent'
+import { prettifyDir } from '@/components/Native/utils'
+import { NONE_SELECTED_FILES, SELECTED_ALL_FILES } from '@shared/constants'
+import { buildOuts } from '@shared/rename'
+import { detectResource, splitTaskLinks } from '@shared/utils'
+import '@/components/Icons/inbox'
- const initialForm = (state) => {
- const { addTaskUrl, addTaskOptions } = state.app
- const { dir, split, newTaskShowDownloading } = state.preference.config
- const result = {
- uris: addTaskUrl,
- torrent: '',
- selectFile: NONE_SELECTED_FILES,
- out: '',
- userAgent: '',
- referer: '',
- cookie: '',
- dir,
- split,
- newTaskShowDownloading,
- ...addTaskOptions
- }
- return result
+const initialForm = state => {
+ const { addTaskUrl, addTaskOptions } = state.app
+ const { dir, split, newTaskShowDownloading } = state.preference.config
+ const result = {
+ uris: addTaskUrl,
+ torrent: '',
+ selectFile: NONE_SELECTED_FILES,
+ out: '',
+ userAgent: '',
+ referer: '',
+ cookie: '',
+ dir,
+ split,
+ newTaskShowDownloading,
+ ...addTaskOptions
}
+ return result
+}
- export default {
- name: 'mo-add-task',
- components: {
- [SelectDirectory.name]: SelectDirectory,
- [SelectTorrent.name]: SelectTorrent
+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: '100px',
+ showAdvanced: false,
+ form: {},
+ rules: {}
+ }
+ },
+ computed: {
+ taskType: function () {
+ return this.type
+ },
+ downloadDir: function () {
+ return prettifyDir(this.form.dir)
},
- props: {
- visible: {
- type: Boolean,
- default: false
- },
- type: {
- type: String,
- default: 'uri'
+ ...mapState('app', {
+ taskList: state => state.taskList
+ }),
+ ...mapState('preference', {
+ config: state => state.config
+ })
+ },
+ 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') {
+ this.autofillResourceLink()
+ setTimeout(() => {
+ this.$refs.uri && this.$refs.uri.focus()
+ }, 50)
}
},
- data () {
- return {
- formLabelWidth: '100px',
- showAdvanced: false,
- form: {},
- rules: {}
+ autofillResourceLink () {
+ const content = this.$electron.clipboard.readText()
+ const hasResource = detectResource(content)
+ if (!hasResource) {
+ return
+ }
+ if (isEmpty(this.form.uris)) {
+ this.form.uris = content
}
},
- 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
+ handleOpened () {
+ this.detectThunderResource(this.form.uris)
+ },
+ handleClose (done) {
+ this.$store.dispatch('app/hideAddTaskDialog')
+ this.$store.dispatch('app/updateAddTaskOptions', {})
+ },
+ handleClosed () {
+ this.reset()
+ },
+ handleTabClick (tab, event) {
+ this.$store.dispatch('app/changeAddTaskType', tab.name)
+ },
+ handleUriPaste () {
+ setImmediate(() => {
+ const uris = this.$refs.uri.value
+ this.detectThunderResource(uris)
})
},
- watch: {
- taskType: function (current, previous) {
- if (this.visible && previous === 'uri') {
- return
- }
-
- if (current === 'uri') {
- setTimeout(() => {
- this.$refs.uri && this.$refs.uri.focus()
- }, 50)
- }
+ detectThunderResource (uris = '') {
+ if (uris.includes('thunder://')) {
+ this.$msg({
+ type: 'warning',
+ message: this.$t('task.thunder-link-tips'),
+ duration: 6000
+ })
}
},
- methods: {
- isRenderer: is.renderer,
- isMas: is.mas,
- handleOpen () {
- this.form = initialForm(this.$store.state)
- if (this.taskType === 'uri') {
- this.autofillResourceLink()
- setTimeout(() => {
- this.$refs.uri && this.$refs.uri.focus()
- }, 50)
- }
- },
- autofillResourceLink () {
- const content = this.$electron.clipboard.readText()
- const hasResource = detectResource(content)
- if (!hasResource) {
- return
- }
- if (isEmpty(this.form.uris)) {
- this.form.uris = content
- }
- },
- handleOpened () {
- this.detectThunderResource(this.form.uris)
- },
- handleClose (done) {
- this.$store.dispatch('app/hideAddTaskDialog')
- this.$store.dispatch('app/updateAddTaskOptions', {})
- },
- handleClosed () {
- this.reset()
- },
- handleTabClick (tab, event) {
- this.$store.dispatch('app/changeAddTaskType', tab.name)
- },
- handleUriPaste () {
- setImmediate(() => {
- const uris = this.$refs.uri.value
- this.detectThunderResource(uris)
- })
- },
- detectThunderResource (uris = '') {
- if (uris.includes('thunder://')) {
- this.$msg({
- type: 'warning',
- message: this.$t('task.thunder-link-tips'),
- duration: 6000
- })
- }
- },
- handleUriChange () {
- console.log('handleUriChange===>', this.form.uris)
- },
- handleTorrentChange (torrent, selectedFileIndex) {
- this.form.torrent = torrent
- this.form.selectFile = selectedFileIndex
- },
- handleSplitChange (value) {
- console.log('handleSplitChange===>', value)
- },
- onDirectorySelected (dir) {
- this.form.dir = dir
- },
- reset () {
- this.showAdvanced = false
- this.form = initialForm(this.$store.state)
- },
- handleCancel (formName) {
- this.$store.dispatch('app/hideAddTaskDialog')
- },
- buildHeader (form) {
- const {
- userAgent, referer, cookie
- } = form
- const result = []
+ handleUriChange () {
+ console.log('handleUriChange===>', this.form.uris)
+ },
+ handleTorrentChange (torrent, selectedFileIndex) {
+ this.form.torrent = torrent
+ this.form.selectFile = selectedFileIndex
+ },
+ handleSplitChange (value) {
+ console.log('handleSplitChange===>', value)
+ },
+ onDirectorySelected (dir) {
+ this.form.dir = dir
+ },
+ reset () {
+ this.showAdvanced = false
+ 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 (type, form) {
- const {
- dir,
- out,
- selectFile,
- split
- } = 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 (type, form) {
+ const { dir, out, selectFile, split } = form
+ const result = {}
- if (!isEmpty(dir)) {
- result.dir = dir
- }
+ if (!isEmpty(dir)) {
+ result.dir = dir
+ }
- if (!isEmpty(out)) {
- result.out = out
- }
+ if (!isEmpty(out)) {
+ result.out = out
+ }
- if (type === 'torrent') {
- if (
- selectFile !== SELECTED_ALL_FILES &&
- selectFile !== NONE_SELECTED_FILES
- ) {
- result.selectFile = selectFile
- }
+ if (type === 'torrent') {
+ if (
+ selectFile !== SELECTED_ALL_FILES &&
+ selectFile !== NONE_SELECTED_FILES
+ ) {
+ result.selectFile = selectFile
}
+ }
- if (split > 0) {
- result.split = split
- }
+ if (split > 0) {
+ result.split = split
+ }
- const header = this.buildHeader(form)
- if (!isEmpty(header)) {
- result.header = header
- }
- return result
- },
- buildUriPayload (form) {
- let { uris, out } = form
- if (isEmpty(uris)) {
- throw new Error(this.$t('task.new-task-uris-required'))
- }
- uris = splitTaskLinks(uris)
- const outs = buildOuts(uris, out)
+ const header = this.buildHeader(form)
+ if (!isEmpty(header)) {
+ result.header = header
+ }
+ return result
+ },
+ buildUriPayload (form) {
+ let { uris, out } = form
+ if (isEmpty(uris)) {
+ throw new Error(this.$t('task.new-task-uris-required'))
+ }
+ uris = splitTaskLinks(uris)
+ const outs = buildOuts(uris, out)
- const options = this.buildOption('uri', form)
- const result = {
- uris,
- outs,
- options
- }
- return result
- },
- buildTorrentPayload (form) {
- const { torrent } = form
- if (isEmpty(torrent)) {
- throw new Error(this.$t('task.new-task-torrent-required'))
- }
- const options = this.buildOption('torrent', form)
- const result = {
- torrent,
- options
- }
- return result
- },
- addTask (type, form) {
- let payload = null
- if (type === 'uri') {
- payload = this.buildUriPayload(form)
- this.$store.dispatch('task/addUri', payload)
- .catch((err) => {
- this.$msg.error(err.message)
- })
- } else if (type === 'torrent') {
- payload = this.buildTorrentPayload(form)
- this.$store.dispatch('task/addTorrent', payload)
- .catch((err) => {
- this.$msg.error(err.message)
- })
- } else if (type === 'metalink') {
- // @TODO addMetalink
- } else {
- console.error('addTask fail', form)
+ const options = this.buildOption('uri', form)
+ const result = {
+ uris,
+ outs,
+ options
+ }
+ return result
+ },
+ buildTorrentPayload (form) {
+ const { torrent } = form
+ if (isEmpty(torrent)) {
+ throw new Error(this.$t('task.new-task-torrent-required'))
+ }
+ const options = this.buildOption('torrent', form)
+ const result = {
+ torrent,
+ options
+ }
+ return result
+ },
+ addTask (type, form) {
+ let payload = null
+ if (type === 'uri') {
+ payload = this.buildUriPayload(form)
+ this.$store.dispatch('task/addUri', payload).catch(err => {
+ this.$msg.error(err.message)
+ })
+ } else if (type === 'torrent') {
+ payload = this.buildTorrentPayload(form)
+ this.$store.dispatch('task/addTorrent', payload).catch(err => {
+ this.$msg.error(err.message)
+ })
+ } else if (type === 'metalink') {
+ // @TODO addMetalink
+ } else {
+ console.error('addTask fail', form)
+ }
+ },
+ submitForm (formName) {
+ this.$refs[formName].validate(valid => {
+ if (!valid) {
+ return false
}
- },
- submitForm (formName) {
- this.$refs[formName].validate((valid) => {
- if (!valid) {
- return false
- }
- try {
- this.addTask(this.type, this.form)
+ try {
+ this.addTask(this.type, this.form)
- this.$store.dispatch('app/hideAddTaskDialog')
- if (this.form.newTaskShowDownloading) {
- this.$router.push({
- path: '/task/active'
- })
- }
- } catch (err) {
- this.$msg.error(err.message)
+ this.$store.dispatch('app/hideAddTaskDialog')
+ if (this.form.newTaskShowDownloading) {
+ this.$router.push({
+ path: '/task/active'
+ })
}
- })
- }
+ } catch (err) {
+ this.$msg.error(err.message)
+ }
+ })
}
}
+}
</script>
<style lang="scss">
- .el-dialog.add-task-dialog {
- max-width: 632px;
- .el-tabs__header {
- user-select: none;
- }
- .el-input-number.el-input-number--mini {
- width: 100%;
- }
- .el-dialog__footer {
- padding-top: 20px;
- background-color: $--add-task-dialog-footer-background;
- border-radius: 0 0 5px 5px;
- }
- .dialog-footer {
- .chk {
- float: left;
- line-height: 28px;
+.el-dialog.add-task-dialog {
+ max-width: 632px;
+ .el-tabs__header {
+ user-select: none;
+ }
+ .el-input-number.el-input-number--mini {
+ width: 100%;
+ }
+ .el-dialog__footer {
+ padding-top: 20px;
+ background-color: $--add-task-dialog-footer-background;
+ border-radius: 0 0 5px 5px;
+ }
+ .dialog-footer {
+ .chk {
+ float: left;
+ line-height: 28px;
+ &.el-checkbox {
+ & .el-checkbox__input {
+ line-height: 19px;
+ }
+ & .el-checkbox__label {
+ padding-left: 6px;
+ }
}
}
}
+}
</style>
diff --git a/src/renderer/components/Task/Index.vue b/src/renderer/components/Task/Index.vue
index 222ad37e..b5ef178d 100644
--- a/src/renderer/components/Task/Index.vue
+++ b/src/renderer/components/Task/Index.vue
@@ -1,11 +1,18 @@
<template>
- <el-container class="content panel" direction="horizontal">
- <el-aside width="200px" class="subnav">
+ <el-container class="content panel"
+ direction="horizontal">
+ <el-aside width="200px"
+ class="subnav hidden-xs-only">
<mo-task-subnav :current="status" />
</el-aside>
- <el-container class="content panel" direction="vertical">
- <el-header class="panel-header" height="84">
- <h4>{{ title }}</h4>
+ <el-container class="content panel"
+ direction="vertical">
+ <el-header class="panel-header"
+ height="84">
+ <h4 class="task-title hidden-xs-only">{{ title }}</h4>
+ <mo-task-switcher :title="title"
+ :commands="titles"
+ class="hidden-sm-and-up" />
<mo-task-actions />
</el-header>
<el-main class="panel-content">
@@ -16,48 +23,60 @@
</template>
<script>
- import TaskSubnav from '@/components/Subnav/TaskSubnav'
- import TaskActions from '@/components/Task/TaskActions'
- import TaskList from '@/components/Task/TaskList'
+import TaskSubnav from '@/components/Subnav/TaskSubnav'
+import TaskActions from '@/components/Task/TaskActions'
+import TaskList from '@/components/Task/TaskList'
+import TaskSwitch from '@/components/Task/TaskSwitcher'
- export default {
- name: 'mo-content-task',
- components: {
- [TaskSubnav.name]: TaskSubnav,
- [TaskActions.name]: TaskActions,
- [TaskList.name]: TaskList
- },
- props: {
- status: {
- type: String,
- default: 'active'
+export default {
+ name: 'mo-content-task',
+ components: {
+ [TaskSubnav.name]: TaskSubnav,
+ [TaskActions.name]: TaskActions,
+ [TaskList.name]: TaskList,
+ [TaskSwitch.name]: TaskSwitch
+ },
+ props: {
+ status: {
+ type: String,
+ default: 'active'
+ }
+ },
+ computed: {
+ titleMap: function () {
+ return {
+ active: this.$t('task.active'),
+ waiting: this.$t('task.waiting'),
+ stopped: this.$t('task.stopped')
}
},
- computed: {
- title: function () {
- const titles = {
- 'active': this.$t('task.active'),
- 'waiting': this.$t('task.waiting'),
- 'stopped': this.$t('task.stopped')
+ titles: function () {
+ return Object.keys(this.titleMap).map(key => {
+ return {
+ key,
+ label: this.titleMap[key]
}
- return titles[this.status]
- }
- },
- watch: {
- 'status': 'onStatusChange'
+ })
},
- methods: {
- onStatusChange () {
- this.changeCurrentList()
- },
- changeCurrentList () {
- this.$store.dispatch('task/changeCurrentList', this.status)
- }
- },
- created: function () {
+ title: function () {
+ return this.titleMap[this.status]
+ }
+ },
+ watch: {
+ status: 'onStatusChange'
+ },
+ methods: {
+ onStatusChange () {
this.changeCurrentList()
+ },
+ changeCurrentList () {
+ this.$store.dispatch('task/changeCurrentList', this.status)
}
+ },
+ created: function () {
+ this.changeCurrentList()
}
+}
</script>
<style lang="scss">
diff --git a/src/renderer/components/Task/TaskActions.vue b/src/renderer/components/Task/TaskActions.vue
index cd76fbaa..25758eb7 100644
--- a/src/renderer/components/Task/TaskActions.vue
+++ b/src/renderer/components/Task/TaskActions.vue
@@ -1,5 +1,10 @@
<template>
<div class="task-actions">
+ <el-tooltip class="item hidden-md-and-up" effect="dark" :content="$t('task.new-task')" placement="bottom">
+ <i @click.stop="onAddClick">
+ <mo-icon name="menu-add" width="14" height="14" />
+ </i>
+ </el-tooltip>
<el-tooltip class="item" effect="dark" :content="$t('task.refresh-list')" placement="bottom">
<i @click="onRefreshClick">
<mo-icon name="refresh" width="14" height="14" :spin="refreshing" />
@@ -37,6 +42,7 @@
<script>
import { mapState } from 'vuex'
import TaskProgress from './TaskProgress'
+ import '@/components/Icons/menu-add'
import '@/components/Icons/refresh'
import '@/components/Icons/task-start-line'
import '@/components/Icons/task-pause-line'
@@ -113,6 +119,9 @@
this.$msg.error(this.$t('task.purge-record-fail'))
}
})
+ },
+ onAddClick: function () {
+ this.$store.dispatch('app/showAddTaskDialog', 'uri')
}
}
}
diff --git a/src/renderer/components/Task/TaskSwitcher.vue b/src/renderer/components/Task/TaskSwitcher.vue
new file mode 100644
index 00000000..2af06d88
--- /dev/null
+++ b/src/renderer/components/Task/TaskSwitcher.vue
@@ -0,0 +1,95 @@
+<template>
+ <el-dropdown @command="handleCommand"
+ class="task-switch"
+ size="medium">
+ <h4 class="task-title">
+ {{ title }}<i class="el-icon-arrow-down el-icon--right"></i>
+ </h4>
+ <el-dropdown-menu slot="dropdown"
+ class="task-switch-dropdown">
+ <el-dropdown-item :command="s.key"
+ v-for="s in commands"
+ :key="s.key">{{s.label}}</el-dropdown-item>
+ </el-dropdown-menu>
+ </el-dropdown>
+</template>
+
+<script>
+export default {
+ name: 'mo-task-switcher',
+ props: {
+ title: {
+ type: String,
+ default: function () {
+ return this.$t('task.active')
+ }
+ },
+ commands: {
+ type: Array,
+ default: function () {
+ const s = ['active', 'waiting', 'stopped']
+ return s.map(key => {
+ return {
+ key,
+ label: this.$t(`task.${key}`)
+ }
+ })
+ }
+ }
+ },
+ methods: {
+ calcIconName (key) {
+ const statusIconMap = {
+ active: 'start',
+ waiting: 'pause',
+ stopped: 'stop'
+ }
+ return `task-${statusIconMap[key]}` || ''
+ },
+ handleCommand (status) {
+ this.$router.push({
+ path: `/task/${status}`
+ })
+ }
+ }
+}
+</script>
+
+<style lang='scss'>
+ .task-switch-dropdown {
+ background: $--select-dropdown-background;
+ & .el-dropdown-menu__item {
+ font-size: 16px;
+ color: $--select-option-color;
+ }
+ }
+ .task-switch {
+ & .task-title {
+ color: $--task-action-color;
+ font-size: 16px;
+ }
+ }
+ .theme-dark {
+ .task-switch-dropdown {
+ background-color: $--dk-task-item-backgroud;
+ border-color: $--dk-task-item-border-color;
+ color: $--dk-task-item-text-color;
+ & .el-dropdown-menu__item {
+ color: $--dk-task-item-text-color;
+ &.selected {
+ color: $--color-primary;
+ }
+ &.hover,
+ &:hover {
+ background-color: $--color-primary;
+ color: $--dk-titlebar-close-active-color;
+ }
+ }
+ }
+ & .el-dropdown {
+ & .task-title {
+ color: $--dk-task-action-color;
+ }
+ }
+ }
+</style>
\ No newline at end of file
diff --git a/src/renderer/components/Theme/Default.scss b/src/renderer/components/Theme/Default.scss
index e581cd42..bb4099b7 100644
--- a/src/renderer/components/Theme/Default.scss
+++ b/src/renderer/components/Theme/Default.scss
@@ -242,3 +242,32 @@ img {
.form-actions {
background: $--form-actions-background;
}
+
+@media only screen and (max-width:567px) {
+ .hidden-xs-only {
+ display:none!important
+ }
+}
+
+@media only screen and (min-width: 568px) {
+ .hidden-sm-and-up {
+ display: none !important;
+ }
+}
+@media only screen and (min-width: 568px) and (max-width: 991px) {
+ .hidden-sm-only {
+ display: none !important;
+ }
+}
+
+@media only screen and (max-width: 791px) {
+ .hidden-sm-and-down {
+ display: none !important;
+ }
+}
+
+@media only screen and (min-width: 792px) {
+ .hidden-md-and-up {
+ display: none !important;
+ }
+}
\ No newline at end of file