Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new task detail panel #921

Merged
merged 22 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 🌍 翻译指南

首先你要确定一个语言的英文简写作为 **locale**,如 en-US,这个 locale 值请严格参考 [Electron 的 Locales 文档](https://electronjs.org/docs/api/locales)
首先你要确定一个语言的英文简写作为 **locale**,如 en-US,这个 locale 值请严格参考 [Electron 的 Locales 文档](https://www.electronjs.org/docs/api/app#appgetlocale)

Motrix 的国际化分两部分:

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Before you start contributing, make sure you already understand [GitHub flow](ht

## 🌍 Translation Guide

First you need to determine the English abbreviation of a language as **locale**, such as en-US, this locale value should strictly refer to the [electron's documentation](https://electronjs.org/docs/api/locales).
First you need to determine the English abbreviation of a language as **locale**, such as en-US, this locale value should strictly refer to the [electron's documentation](https://www.electronjs.org/docs/api/app#appgetlocale).

The internationalization of Motrix is divided into two parts:

Expand Down
3 changes: 2 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Motrix 在 Linux 中首次启动可能需要使用 `sudo` 运行,因为可能
- 🔔 下载完成后通知
- 💻 支持触控栏快捷键 (Mac 专享)
- 🤖 常驻系统托盘,操作更加便捷
- 📟 系统托盘速度仪表显示实时速度 (Mac 专享)
- 🌑 深色模式
- 🗑 移除任务时可同时删除相关文件
- 🌍 国际化,[查看已可选的语言](#-国际化)
Expand Down Expand Up @@ -165,7 +166,7 @@ yarn run build

| Key | Name | Status |
|-------|:--------------------|:-------------|
| ar | Arabic | [@hadialqattan](https://github.com/hadialqattan), [AhmedElTabarani](https://github.com/AhmedElTabarani) |
| ar | Arabic | [@hadialqattan](https://github.com/hadialqattan), [@AhmedElTabarani](https://github.com/AhmedElTabarani) |
| bg | Българският език | ✔️ [@null-none](https://github.com/null-none) |
| ca | Català | ✔️ [@marcizhu](https://github.com/marcizhu) |
| de | Deutsch | ✔️ [@Schloemicher](https://github.com/Schloemicher) |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Motrix may need to run with `sudo` for the first time in Linux because there is
- 🔔 Download completed Notification
- 💻 Ready for Touch Bar (Mac only)
- 🤖 Resident system tray for quick operation
- 📟 Tray speed meter displays real-time speed (Mac only)
- 🌑 Dark mode
- 🗑 Delete related files when removing tasks (optional)
- 🌍 I18n, [View supported languages](#-internationalization).
Expand Down Expand Up @@ -158,7 +159,7 @@ Translations into versions for other languages are welcome 🧐! Please read the

| Key | Name | Status |
|-------|:--------------------|:-------------|
| ar | Arabic | [@hadialqattan](https://github.com/hadialqattan), [AhmedElTabarani](https://github.com/AhmedElTabarani) |
| ar | Arabic | [@hadialqattan](https://github.com/hadialqattan), [@AhmedElTabarani](https://github.com/AhmedElTabarani) |
| bg | Българският език | ✔️ [@null-none](https://github.com/null-none) |
| ca | Català | ✔️ [@marcizhu](https://github.com/marcizhu) |
| de | Deutsch | ✔️ [@Schloemicher](https://github.com/Schloemicher) |
Expand Down
4 changes: 2 additions & 2 deletions src/main/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export default class Engine {

if (is.dev()) {
this.instance.stdout.on('data', function (data) {
console.log('[Motrix] engine stdout===>', data.toString())
logger.log('[Motrix] engine stdout===>', data.toString())
})

this.instance.stderr.on('data', function (data) {
console.log('[Motrix] engine stderr===>', data.toString())
logger.log('[Motrix] engine stderr===>', data.toString())
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/menus/darwin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{ "id": "app.hide-others", "role": "hideothers" },
{ "id": "app.unhide", "role": "unhide" },
{ "type": "separator" },
{ "id": "app.quit", "command": "application:quit" }
{ "id": "app.quit", "role": "quit" }
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/menus/linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{ "id": "app.check-for-updates", "command": "application:check-for-updates" },
{ "id": "app.show", "command": "application:show", "command-arg": { "page": "index" } },
{ "type": "separator" },
{ "id": "app.quit", "command": "application:quit" }
{ "id": "app.quit", "role": "quit" }
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/menus/win32.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{ "id": "app.check-for-updates", "command": "application:check-for-updates" },
{ "id": "app.show", "command": "application:show", "command-arg": { "page": "index" } },
{ "type": "separator" },
{ "id": "app.quit", "command": "application:quit" }
{ "id": "app.quit", "role": "quit" }
]
},
{
Expand Down
24 changes: 24 additions & 0 deletions src/renderer/api/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,30 @@ export default class Api {
return this.client.call('tellStatus', ...args)
}

fetchTaskItemWithPeers (params = {}) {
const { gid, keys } = params
const statusArgs = compactUndefined([gid, keys])
const peersArgs = compactUndefined([gid])
return new Promise((resolve, reject) => {
this.client.multicall([
['aria2.tellStatus', ...statusArgs],
['aria2.getPeers', ...peersArgs]
]).then((data) => {
console.log('[Motrix] fetchTaskItemWithPeers:', data)
const result = data[0] && data[0][0]
const peers = data[1] && data[1][0]
result.peers = peers || []
console.log('[Motrix] fetchTaskItemWithPeers.result:', result)
console.log('[Motrix] fetchTaskItemWithPeers.peers:', peers)

resolve(result)
}).catch((err) => {
console.log('[Motrix] fetch downloading task list fail:', err)
reject(err)
})
})
}

fetchTaskItemPeers (params = {}) {
const { gid, keys } = params
const args = compactUndefined([gid, keys])
Expand Down
19 changes: 14 additions & 5 deletions src/renderer/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<mo-speedometer />
<mo-add-task :visible="addTaskVisible" :type="addTaskType" />
<mo-about-panel :visible="aboutPanelVisible" />
<mo-task-item-info :visible="taskItemInfoVisible" :task="currentTaskItem" />
<mo-task-detail
:visible="taskDetailVisible"
:gid="currentTaskGid"
:task="currentTaskItem"
:files="currentTaskFiles"
:peers="currentTaskPeers"
/>
<mo-dragger />
</el-container>
</template>
Expand All @@ -16,7 +22,7 @@
import Aside from '@/components/Aside/Index'
import Speedometer from '@/components/Speedometer/Speedometer'
import AddTask from '@/components/Task/AddTask'
import TaskItemInfo from '@/components/Task/TaskItemInfo'
import TaskDetail from '@/components/TaskDetail/Index'
import Dragger from '@/components/Dragger/Index'
export default {
Expand All @@ -26,7 +32,7 @@
[Aside.name]: Aside,
[Speedometer.name]: Speedometer,
[AddTask.name]: AddTask,
[TaskItemInfo.name]: TaskItemInfo,
[TaskDetail.name]: TaskDetail,
[Dragger.name]: Dragger
},
computed: {
Expand All @@ -36,8 +42,11 @@
addTaskType: state => state.addTaskType
}),
...mapState('task', {
taskItemInfoVisible: state => state.taskItemInfoVisible,
currentTaskItem: state => state.currentTaskItem
taskDetailVisible: state => state.taskDetailVisible,
currentTaskGid: state => state.currentTaskGid,
currentTaskItem: state => state.currentTaskItem,
currentTaskFiles: state => state.currentTaskFiles,
currentTaskPeers: state => state.currentTaskPeers
})
},
methods: {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/Native/DynamicTray.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
scale,
iconKey
} = this
console.log('currentTheme====>', theme, iconKey)
const icon = await this.getIcon(iconKey)
Expand Down
24 changes: 14 additions & 10 deletions src/renderer/components/Native/EngineClient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
getTaskFullPath,
showItemInFolder
} from '@/utils/native'
import { getTaskName } from '@shared/utils'
import { checkTaskIsBT, getTaskName } from '@shared/utils'
export default {
name: 'mo-engine-client',
Expand All @@ -26,12 +26,17 @@
...mapState('task', {
messages: state => state.messages,
seedingList: state => state.seedingList,
taskItemInfoVisible: state => state.taskItemInfoVisible,
taskDetailVisible: state => state.taskDetailVisible,
enabledFetchPeers: state => state.enabledFetchPeers,
currentTaskGid: state => state.currentTaskGid,
currentTaskItem: state => state.currentTaskItem
}),
...mapState('preference', {
taskNotification: state => state.config.taskNotification
})
}),
currentTaskIsBT () {
return checkTaskIsBT(this.currentTaskItem)
}
},
watch: {
speed (val) {
Expand All @@ -58,7 +63,6 @@
this.$store.dispatch('task/fetchList')
this.$store.dispatch('app/resetInterval')
this.$store.dispatch('task/saveSession')
console.log('aria2 onDownloadStart', event)
const [{ gid }] = event
const { seedingList } = this
if (seedingList.includes(gid)) {
Expand All @@ -73,7 +77,6 @@
})
},
onDownloadPause (event) {
console.log('aria2 onDownloadPause')
const [{ gid }] = event
const { seedingList } = this
if (seedingList.includes(gid)) {
Expand All @@ -88,7 +91,6 @@
})
},
onDownloadStop (event) {
console.log('aria2 onDownloadStop')
const [{ gid }] = event
this.fetchTaskItem({ gid })
.then((task) => {
Expand Down Expand Up @@ -116,7 +118,6 @@
})
},
onDownloadComplete (event) {
console.log('aria2 onDownloadComplete')
this.$store.dispatch('task/fetchList')
const [{ gid }] = event
this.$store.dispatch('task/removeFromSeedingList', gid)
Expand All @@ -127,7 +128,6 @@
})
},
onBtDownloadComplete (event) {
console.log('aria2 onBtDownloadComplete')
this.$store.dispatch('task/fetchList')
const [{ gid }] = event
const { seedingList } = this
Expand Down Expand Up @@ -219,8 +219,12 @@
this.$store.dispatch('app/fetchGlobalStat')
this.$store.dispatch('task/fetchList')
if (this.taskItemInfoVisible && this.currentTaskItem) {
this.$store.dispatch('task/fetchItem', this.currentTaskItem.gid)
if (this.taskDetailVisible && this.currentTaskGid) {
if (this.currentTaskIsBT && this.enabledFetchPeers) {
this.$store.dispatch('task/fetchItemWithPeers', this.currentTaskGid)
} else {
this.$store.dispatch('task/fetchItem', this.currentTaskGid)
}
}
},
stopPolling () {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Preference/Advanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
submitForm (formName) {
this.$refs[formName].validate((valid) => {
if (!valid) {
console.log('[Motrix] preference form valid:', valid)
console.error('[Motrix] preference form valid:', valid)
return false
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Preference/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@
submitForm (formName) {
this.$refs[formName].validate((valid) => {
if (!valid) {
console.log('[Motrix] preference form valid:', valid)
console.error('[Motrix] preference form valid:', valid)
return false
}
Expand Down
48 changes: 23 additions & 25 deletions src/renderer/components/Task/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,35 +171,33 @@
return this.removeTaskRecordItem(task, taskName)
})
},
removeTaskItem (task, taskName) {
return this.$store.dispatch('task/removeTask', task)
.then(() => {
this.$msg.success(this.$t('task.delete-task-success', {
async removeTaskItem (task, taskName) {
try {
await this.$store.dispatch('task/removeTask', task)
this.$msg.success(this.$t('task.delete-task-success', {
taskName
}))
} catch ({ code }) {
if (code === 1) {
this.$msg.error(this.$t('task.delete-task-fail', {
taskName
}))
})
.catch(({ code }) => {
if (code === 1) {
this.$msg.error(this.$t('task.delete-task-fail', {
taskName
}))
}
})
}
}
},
removeTaskRecordItem (task, taskName) {
return this.$store.dispatch('task/removeTaskRecord', task)
.then(() => {
this.$msg.success(this.$t('task.remove-record-success', {
async removeTaskRecordItem (task, taskName) {
try {
await this.$store.dispatch('task/removeTaskRecord', task)
this.$msg.success(this.$t('task.remove-record-success', {
taskName
}))
} catch ({ code }) {
if (code === 1) {
this.$msg.error(this.$t('task.remove-record-fail', {
taskName
}))
})
.catch(({ code }) => {
if (code === 1) {
this.$msg.error(this.$t('task.remove-record-fail', {
taskName
}))
}
})
}
}
},
removeTasks (taskList, isRemoveWithFiles = false) {
const gids = taskList.map((task) => task.gid)
Expand Down Expand Up @@ -380,7 +378,7 @@
},
handleShowTaskInfo (payload) {
const { task } = payload
this.$store.dispatch('task/showTaskItemInfoDialog', task)
this.$store.dispatch('task/showTaskDetail', task)
}
},
created () {
Expand Down
Loading