diff --git a/src/Api.ts b/src/Api.ts index e88321e..49da7b2 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -1,6 +1,5 @@ import Axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios'; -import { RssNode } from '@/types'; - +import { RssNode, RssRule } from '@/types'; class Api { private axios: AxiosInstance; @@ -213,6 +212,29 @@ class Api { return this.axios.post('/rss/removeItem', data).then(Api.handleResponse); } + public getRssRules(): Promise<{[key: string]: RssRule}> { + return this.axios.get('/rss/rules').then(Api.handleResponse); + } + + public setRssRule(name: string, def: any = {}) { + const params: any = { + ruleName: name, + ruleDef: JSON.stringify(def), + } + + const data = new URLSearchParams(params) + return this.axios.post('/rss/setRule', data).then(Api.handleResponse); + } + + public removeRssRule(name: string) { + const params: any = { + ruleName: name, + } + + const data = new URLSearchParams(params) + return this.axios.post('/rss/removeRule', data).then(Api.handleResponse); + } + private actionTorrents(action: string, hashes: string[], extra?: any) { const params: any = { hashes: hashes.join('|'), diff --git a/src/components/GlobalSnackBar.vue b/src/components/GlobalSnackBar.vue index a524a44..016e1f9 100644 --- a/src/components/GlobalSnackBar.vue +++ b/src/components/GlobalSnackBar.vue @@ -1,18 +1,20 @@ @@ -32,7 +34,6 @@ export default { return; } - await timeout(150); mutations.closeSnackBar(); } diff --git a/src/components/dialogs/RssDialog.vue b/src/components/dialogs/RssDialog.vue index 4bf11ec..dbb9bfa 100644 --- a/src/components/dialogs/RssDialog.vue +++ b/src/components/dialogs/RssDialog.vue @@ -4,7 +4,6 @@ @input="$emit('input', $event)" fullscreen persistent - hide-overlay > mdi-rss-box RSS - {{ $t('close') }} + + mdi-close +
@@ -30,12 +31,16 @@ :label="$t('dialog.rss.auto_refresh')" hide-details /> + + + mdi-settings +
@@ -87,10 +92,11 @@ v-if="selectItem" dense > - + @@ -125,6 +131,8 @@
+ + @@ -141,8 +149,12 @@ import { tr } from '@/locale' import { RssItem, RssNode, RssTorrent } from '@/types'; import { DialogType, DialogConfig, SnackBarConfig } from '@/store/types' import { parseDate, formatTimestamp, formatAsDuration } from '../../filters' +import RssRulesDialog from './RssRulesDialog.vue' @Component({ + components: { + RssRulesDialog, + }, computed: mapState([ 'preferences', ]), @@ -198,7 +210,8 @@ export default class RssDialog extends HasTask { rssNode: RssNode | null = null selectNode: string | null = null - selectArticleIndex: number | null = null + selectArticle: RssTorrent | null = null + showRulesDialog = false preferences!: any asyncShowDialog!: (_: DialogConfig) => Promise @@ -225,13 +238,6 @@ export default class RssDialog extends HasTask { // Folder return null } - get selectArticle() { - if (!this.selectItem || this.selectArticleIndex == null || this.selectArticleIndex < 0) { - return null - } - - return this.selectItem!.articles[this.selectArticleIndex] - } isItemLoading(row: any) { const item = row.item.item @@ -345,15 +351,16 @@ export default class RssDialog extends HasTask { @Watch('selectNode') onSelectNodeChanged() { - this.selectArticleIndex = null + this.selectArticle = null } created() { - this.setTaskAndRun(this.fetchRssItems) + this.setTaskAndRun(this.fetchRssItems, 5000) } + @Emit('input') closeDialog() { - this.$emit('input', false); + return false } } @@ -382,11 +389,12 @@ export default class RssDialog extends HasTask { display: flex; flex-wrap: wrap; width: 100%; - padding: 0 2em; + padding: 0 20px; + align-items: center; .v-input--switch { - margin-left: 1em; - margin-top: 0; + margin: 0 0.5em; + padding: 0; } } diff --git a/src/components/dialogs/RssRulesDialog.vue b/src/components/dialogs/RssRulesDialog.vue new file mode 100644 index 0000000..068f9ae --- /dev/null +++ b/src/components/dialogs/RssRulesDialog.vue @@ -0,0 +1,371 @@ + + + + + \ No newline at end of file diff --git a/src/locale/en.ts b/src/locale/en.ts index 1e2423f..1d13619 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -101,6 +101,22 @@ export default { delete_feeds: 'Are you sure to delete selected feeds?', date_format: '%{date} (%{duration} ago)', }, + rss_rule: { + add_rule: 'Add Rule', + new_rule_name: 'The name of the new rule', + delete_rule: 'Are you sure to delete selected rule?', + title: 'RSS Downloader', + rule_settings: 'Rule Settings', + + use_regex: 'Use Regex', + must_contain: 'Must Contain', + must_not_contain: 'Must Not Contain', + episode_filter: 'Episode Filter', + smart_episode: 'Use Smart Episode Filter', + assign_category: 'Assign Category', + + apply_to_feeds: 'Apply Rule to Feeds', + }, }, state: { diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 83676bd..05d176a 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -101,6 +101,22 @@ export default { delete_feeds: '确定要删除选中的订阅吗?', date_format: '%{date}(%{duration} 之前)', }, + rss_rule: { + add_rule: '添加规则', + new_rule_name: '新规则的名称', + delete_rule: '确定要删除选中的规则吗?', + title: 'RSS 自动下载', + rule_settings: '规则设置', + + use_regex: '使用正则', + must_contain: '必须包含', + must_not_contain: '必须排除', + episode_filter: '剧集过滤', + smart_episode: '使用智能剧集过滤', + assign_category: '分配分类', + + apply_to_feeds: '应用到订阅', + }, }, state: { diff --git a/src/types.ts b/src/types.ts index ed99189..598be51 100644 --- a/src/types.ts +++ b/src/types.ts @@ -121,9 +121,10 @@ export interface RssRule { smartFilter: boolean, previouslyMatchedEpisodes: string[], affectedFeeds: string[], + createSubfolder: boolean | null, ignoreDays: number, lastMatch: string, - addPaused: boolean, + addPaused: boolean | null, assignedCategory: string, savepath: string, }