From 962e872c23b3912bb7d248126fa101961e3447af Mon Sep 17 00:00:00 2001 From: sheepzh Date: Tue, 15 Apr 2025 21:21:00 +0800 Subject: [PATCH] refactor: refactor with provider --- src/database/memory-detector.ts | 2 +- src/pages/app/components/About/DescLink.tsx | 30 ++-- .../app/components/About/InstallationLink.tsx | 27 ++- src/pages/app/components/Analysis/common.ts | 3 - .../AnalysisFilter/TargetSelect.tsx | 142 ++++++++------- .../components/AnalysisFilter/index.tsx | 65 ++----- .../components/Summary/TargetInfo.tsx | 96 +++++----- .../Analysis/components/Trend/Filter.tsx | 46 +++-- .../Analysis/components/Trend/Total.tsx | 65 +++---- .../Analysis/components/Trend/context.ts | 145 ++++++++++++++- .../Analysis/components/Trend/index.tsx | 166 ++---------------- src/pages/app/components/Analysis/context.ts | 61 ++++++- src/pages/app/components/Analysis/index.tsx | 64 +------ .../app/components/Dashboard/ChartTitle.tsx | 19 +- .../components/Dashboard/DashboardCard.tsx | 44 +---- .../Dashboard/components/Indicator/index.tsx | 41 ++--- .../DataManage/ClearPanel/index.tsx | 47 +++-- .../app/components/DataManage/MemoryInfo.tsx | 76 ++++---- .../DataManage/Migration/ImportButton.tsx | 48 +++-- .../Migration/ImportOtherButton/Sop.tsx | 7 +- .../Migration/ImportOtherButton/index.tsx | 56 +++--- .../components/DataManage/Migration/index.tsx | 69 ++++---- .../app/components/DataManage/context.ts | 17 ++ src/pages/app/components/DataManage/index.tsx | 14 +- .../Habit/components/HabitFilter.tsx | 60 ++----- .../Habit/components/Period/Average/index.tsx | 2 +- .../Habit/components/Period/Filter.tsx | 79 ++++----- .../Habit/components/Period/Stack/index.tsx | 2 +- .../Habit/components/Period/Summary.tsx | 4 +- .../Habit/components/Period/Trend/index.tsx | 2 +- .../Habit/components/Period/context.ts | 61 ++++++- .../Habit/components/Period/index.tsx | 84 ++------- .../components/Site/DailyTrend/index.tsx | 12 +- .../components/Site/Distribution/index.tsx | 2 +- .../Habit/components/Site/Summary.tsx | 9 +- .../Habit/components/Site/TopK/index.tsx | 2 +- .../Habit/components/Site/context.ts | 24 ++- .../Habit/components/Site/index.tsx | 17 +- .../components/Habit/components/context.ts | 19 +- src/pages/app/components/Habit/index.tsx | 19 +- .../Option/components/BackupOption/Footer.tsx | 84 ++++----- src/pages/app/components/Option/index.tsx | 7 +- .../components/Report/ReportFilter/index.tsx | 2 +- .../ReportTable/columns/OperationColumn.tsx | 2 +- .../common/filter/TimeFormatFilterItem.tsx | 29 ++- src/pages/hooks/index.ts | 3 + src/pages/util/style.ts | 2 +- 47 files changed, 851 insertions(+), 1026 deletions(-) delete mode 100644 src/pages/app/components/Analysis/common.ts create mode 100644 src/pages/app/components/DataManage/context.ts diff --git a/src/database/memory-detector.ts b/src/database/memory-detector.ts index 64ef51508..5579bef5e 100644 --- a/src/database/memory-detector.ts +++ b/src/database/memory-detector.ts @@ -10,7 +10,7 @@ import StoragePromise from "./common/storage-promise" /** * User memory of this extension */ -type MemoryInfo = { +export type MemoryInfo = { /** * Used bytes */ diff --git a/src/pages/app/components/About/DescLink.tsx b/src/pages/app/components/About/DescLink.tsx index 6651884d6..26590c20e 100644 --- a/src/pages/app/components/About/DescLink.tsx +++ b/src/pages/app/components/About/DescLink.tsx @@ -1,24 +1,18 @@ import { ElLink } from "element-plus" -import { defineComponent, h, useSlots, type PropType } from "vue" +import { defineComponent, h, useSlots } from "vue" import "./desc-link.sass" -export type Icon = "github" | "element-plus" | "echarts" | "vue" +type Icon = "github" | "element-plus" | "echarts" | "vue" -const _default = defineComponent({ - props: { - href: String, - icon: String as PropType - }, - setup(props) { - const { icon, href } = props - const { default: default_ } = useSlots() - return () => ( - - {icon ?
: null} - {!!default_ && h(default_)} - - ) - } -}) +const _default = defineComponent<{ href?: string, icon?: Icon }>(props => { + const { icon, href } = props + const { default: default_ } = useSlots() + return () => ( + + {icon ?
: null} + {!!default_ && h(default_)} + + ) +}, { props: ['href', 'icon'] }) export default _default \ No newline at end of file diff --git a/src/pages/app/components/About/InstallationLink.tsx b/src/pages/app/components/About/InstallationLink.tsx index 71c82fe40..e4cb57841 100644 --- a/src/pages/app/components/About/InstallationLink.tsx +++ b/src/pages/app/components/About/InstallationLink.tsx @@ -1,23 +1,16 @@ -import { type PropType, defineComponent } from "vue" +import { defineComponent } from "vue" import "./installation-link.sass" type _Source = 'chrome' | 'firefox' | 'edge' | 'kiwi' -const _default = defineComponent({ - props: { - source: String as PropType<_Source>, - name: String, - href: String, - }, - setup({ source, name, href }) { - return () => -