diff --git a/webui/.npmrc b/webui/.npmrc index 13e14bcc..dbed7938 100644 --- a/webui/.npmrc +++ b/webui/.npmrc @@ -1 +1,3 @@ public-hoist-pattern[]=@vue/runtime-core +public-hoist-pattern[]=*eslint* +public-hoist-pattern[]=*prettier* diff --git a/webui/src/api/bangumi.ts b/webui/src/api/bangumi.ts index 07432309..a5498ef6 100644 --- a/webui/src/api/bangumi.ts +++ b/webui/src/api/bangumi.ts @@ -32,9 +32,11 @@ export const apiBangumi = { * @returns axios 请求返回的数据 */ async updateRule(bangumiId: number, bangumiRule: BangumiRule) { + const rule = omit(bangumiRule, ['id']); + const { data } = await axios.patch( `api/v1/bangumi/update/${bangumiId}`, - bangumiRule + rule ); return data; }, diff --git a/webui/src/api/download.ts b/webui/src/api/download.ts index 51b7028b..52f25310 100644 --- a/webui/src/api/download.ts +++ b/webui/src/api/download.ts @@ -4,35 +4,25 @@ interface Status { status: 'Success'; } -interface AnalysisError { - status: 'Failed to parse link'; -} - export const apiDownload = { /** * 解析 RSS 链接 * @param rss_link - RSS 链接 */ async analysis(rss_link: string) { - const fetchResult = createEventHook(); - const fetchError = createEventHook(); - - axios - .post('api/v1/download/analysis', { + const { data } = await 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, - }; + // 解析失败抛出错误 + if (data.status) { + throw data; + } + + return data; }, /** diff --git a/webui/src/components/ab-add-bangumi.vue b/webui/src/components/ab-add-bangumi.vue index 77a73ebb..9a0e57f7 100644 --- a/webui/src/components/ab-add-bangumi.vue +++ b/webui/src/components/ab-add-bangumi.vue @@ -1,38 +1,21 @@