Add refresh rss item button

This commit is contained in:
CzBiX
2020-04-20 19:22:41 +08:00
parent f501604153
commit f6bb25ee13
4 changed files with 38 additions and 7 deletions

View File

@@ -221,6 +221,15 @@ class Api {
return this.axios.post('/rss/removeItem', data).then(Api.handleResponse);
}
public refreshRssFeed(path: string) {
const params: any = {
itemPath: path,
}
const data = new URLSearchParams(params)
return this.axios.post('/rss/refreshItem', data).then(Api.handleResponse);
}
public getRssRules(): Promise<{[key: string]: RssRule}> {
return this.axios.get('/rss/rules').then(Api.handleResponse);
}

View File

@@ -34,6 +34,15 @@
>
<v-icon>mdi-delete</v-icon>
</v-btn>
<v-divider vertical />
<v-btn
icon
:disabled="!selectNode"
@click="refreshRssItem"
:title="$t('refresh')"
>
<v-icon>mdi-refresh</v-icon>
</v-btn>
<v-spacer />
<v-divider vertical />
<v-switch
@@ -290,6 +299,16 @@ export default class RssDialog extends HasTask {
return null
}
get selectedPath() {
if (!this.selectNode) {
return null
}
return toPath(this.selectNode!).map(p => {
return p.replace('\\\'', '\'').replace('\\\\', '\\');
}).join('\\');
}
isItemLoading(row: any) {
const item = row.item.item
return item && item.isLoading
@@ -355,7 +374,7 @@ export default class RssDialog extends HasTask {
})
await api.addRssFeed(input);
this.runTask();
await this.runTask();
this.closeSnackBar();
}
@@ -376,23 +395,24 @@ export default class RssDialog extends HasTask {
text: tr('label.deleting'),
})
const path = toPath(this.selectNode!).map(p => {
return p.replace('\\\'', '\'').replace('\\\\', '\\');
}).join('\\');
try {
await api.removeRssFeed(path);
await api.removeRssFeed(this.selectedPath!);
} catch (e) {
this.showSnackBar({
text: e.response ? e.response.data : e.message,
})
return
}
this.runTask();
await this.runTask();
this.closeSnackBar();
}
async refreshRssItem() {
await api.refreshRssFeed(this.selectedPath!);
await this.runTask();
}
async changePreference(key: string, value: any) {
await api.setPreferences({
[key]: value,

View File

@@ -19,6 +19,7 @@ export default {
reset: 'Reset',
login: 'Login',
search: 'Search',
refresh: 'Refresh',
location: 'Location',
reannounce: 'Reannounce',

View File

@@ -19,6 +19,7 @@ export default {
reset: '重置',
login: '登录',
search: '搜索',
refresh: '刷新',
location: '位置',
reannounce: '重新通告',