diff --git a/src/App.vue b/src/App.vue index 55d85331..3cf32b3c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,12 +1,24 @@ diff --git a/src/api/download.ts b/src/api/download.ts index 0b937de1..51b7028b 100644 --- a/src/api/download.ts +++ b/src/api/download.ts @@ -1,7 +1,11 @@ import type { BangumiRule } from '#/bangumi'; interface Status { - status: 'Success' | 'Failed to parse link'; + status: 'Success'; +} + +interface AnalysisError { + status: 'Failed to parse link'; } export const apiDownload = { @@ -10,10 +14,25 @@ export const apiDownload = { * @param rss_link - RSS 链接 */ async analysis(rss_link: string) { - const { data } = await axios.post('api/v1/download/analysis', { - rss_link, - }); - return data; + const fetchResult = createEventHook(); + const fetchError = createEventHook(); + + axios + .post('api/v1/download/analysis', { + rss_link, + }) + .then(({ data }) => { + if (data.status) { + fetchError.trigger(data as AnalysisError); + } else { + fetchResult.trigger(data as BangumiRule); + } + }); + + return { + onResult: fetchResult.on, + onError: fetchError.on, + }; }, /** diff --git a/src/basic/ab-button.vue b/src/basic/ab-button.vue index 9cfa3e17..2891caeb 100644 --- a/src/basic/ab-button.vue +++ b/src/basic/ab-button.vue @@ -1,14 +1,18 @@ diff --git a/src/components.d.ts b/src/components.d.ts index 32678b43..415117f1 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -10,6 +10,7 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { AbAdd: typeof import('./basic/ab-add.vue')['default'] + AbAddBangumi: typeof import('./components/ab-add-bangumi.vue')['default'] AbBangumiCard: typeof import('./components/ab-bangumi-card.vue')['default'] AbButton: typeof import('./basic/ab-button.vue')['default'] AbChangeAccount: typeof import('./components/ab-change-account.vue')['default'] @@ -21,6 +22,7 @@ declare module '@vue/runtime-core' { AbLabel: typeof import('./components/ab-label.vue')['default'] AbPageTitle: typeof import('./basic/ab-page-title.vue')['default'] AbPopup: typeof import('./components/ab-popup.vue')['default'] + AbRule: typeof import('./components/ab-rule.vue')['default'] AbSearch: typeof import('./basic/ab-search.vue')['default'] AbSelect: typeof import('./basic/ab-select.vue')['default'] AbSetting: typeof import('./components/ab-setting.vue')['default'] diff --git a/src/components/ab-add-bangumi.vue b/src/components/ab-add-bangumi.vue new file mode 100644 index 00000000..68924da4 --- /dev/null +++ b/src/components/ab-add-bangumi.vue @@ -0,0 +1,126 @@ + + + diff --git a/src/components/ab-edit-rule.vue b/src/components/ab-edit-rule.vue index f278f1ac..fb97f37a 100644 --- a/src/components/ab-edit-rule.vue +++ b/src/components/ab-edit-rule.vue @@ -1,23 +1,14 @@