From 3f70dd446c984568555409edc81e49f2c313bc7b Mon Sep 17 00:00:00 2001
From: Rewrite0 <49576640+Rewrite0@users.noreply.github.com>
Date: Sun, 28 May 2023 14:58:21 +0800
Subject: [PATCH] =?UTF-8?q?=E7=95=AA=E5=89=A7=E8=AE=A2=E9=98=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/App.vue | 20 ++++-
src/api/download.ts | 29 +++++--
src/basic/ab-button.vue | 19 ++++-
src/components.d.ts | 2 +
src/components/ab-add-bangumi.vue | 126 ++++++++++++++++++++++++++++++
src/components/ab-edit-rule.vue | 77 +++---------------
src/components/ab-rule.vue | 64 +++++++++++++++
src/components/ab-status-bar.vue | 11 ++-
src/pages/index/bangumi.vue | 48 ++++++------
src/style/transition.scss | 2 +-
src/views/ab-sidebar.vue | 4 +-
src/views/ab-topbar.vue | 9 ++-
types/components.ts | 9 ---
13 files changed, 305 insertions(+), 115 deletions(-)
create mode 100644 src/components/ab-add-bangumi.vue
create mode 100644 src/components/ab-rule.vue
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 @@
@@ -36,7 +51,9 @@ const buttonSize = computed(() => {
:class="[`type-${type}`, buttonSize]"
@click="$emit('click')"
>
-
+
+
+
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 @@
-
+
[] = [
-
emitDelete(true)"
>Yes
-
No
+
emitDelete(false)">No
diff --git a/src/components/ab-rule.vue b/src/components/ab-rule.vue
new file mode 100644
index 00000000..d232dbc2
--- /dev/null
+++ b/src/components/ab-rule.vue
@@ -0,0 +1,64 @@
+
+
+
+
+
diff --git a/src/components/ab-status-bar.vue b/src/components/ab-status-bar.vue
index 572faf91..efaaa08d 100644
--- a/src/components/ab-status-bar.vue
+++ b/src/components/ab-status-bar.vue
@@ -16,13 +16,22 @@ withDefaults(
running: false,
}
);
+
+defineEmits(['clickAdd']);