@movk/nuxt 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/movk-ui.css +3 -0
- package/README.md +74 -79
- package/dist/module.d.mts +57 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +120 -126
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -30
- package/dist/runtime/components/AutoForm.vue +119 -125
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -30
- package/dist/runtime/components/ColorChooser.d.vue.ts +21 -22
- package/dist/runtime/components/ColorChooser.vue +304 -27
- package/dist/runtime/components/ColorChooser.vue.d.ts +21 -22
- package/dist/runtime/components/DataTable.d.vue.ts +57 -0
- package/dist/runtime/components/DataTable.vue +584 -0
- package/dist/runtime/components/DataTable.vue.d.ts +57 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +20 -33
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +20 -33
- package/dist/runtime/components/MessageBox.d.vue.ts +36 -0
- package/dist/runtime/components/MessageBox.vue +113 -0
- package/dist/runtime/components/MessageBox.vue.d.ts +36 -0
- package/dist/runtime/components/PillGroup.d.vue.ts +33 -0
- package/dist/runtime/components/PillGroup.vue +291 -0
- package/dist/runtime/components/PillGroup.vue.d.ts +33 -0
- package/dist/runtime/components/Popconfirm.d.vue.ts +30 -0
- package/dist/runtime/components/Popconfirm.vue +143 -0
- package/dist/runtime/components/Popconfirm.vue.d.ts +30 -0
- package/dist/runtime/components/SearchForm.d.vue.ts +21 -149
- package/dist/runtime/components/SearchForm.vue +211 -153
- package/dist/runtime/components/SearchForm.vue.d.ts +21 -149
- package/dist/runtime/components/SlideVerify.d.vue.ts +31 -70
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +31 -70
- package/dist/runtime/components/StarRating.d.vue.ts +38 -87
- package/dist/runtime/components/StarRating.vue +118 -74
- package/dist/runtime/components/StarRating.vue.d.ts +38 -87
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +11 -15
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +22 -9
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +11 -15
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +11 -13
- package/dist/runtime/components/input/WithCharacterLimit.vue +23 -11
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +11 -13
- package/dist/runtime/components/input/WithClear.d.vue.ts +13 -11
- package/dist/runtime/components/input/WithClear.vue +27 -8
- package/dist/runtime/components/input/WithClear.vue.d.ts +13 -11
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -13
- package/dist/runtime/components/input/WithCopy.vue +25 -8
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -13
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +13 -16
- package/dist/runtime/components/input/WithFloatingLabel.vue +35 -27
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +13 -16
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +24 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +27 -12
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +9 -4
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +9 -4
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +10 -5
- package/dist/runtime/composables/useApiFetch.js +20 -2
- package/dist/runtime/composables/useAutoForm.d.ts +4 -4
- package/dist/runtime/composables/useAutoForm.js +23 -9
- package/dist/runtime/composables/useClientApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useDateFormatter.d.ts +16 -3
- package/dist/runtime/composables/useDateFormatter.js +96 -35
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +26 -27
- package/dist/runtime/composables/useDownloadWithProgress.js +142 -40
- package/dist/runtime/composables/useLazyApiFetch.d.ts +3 -2
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +26 -14
- package/dist/runtime/composables/useTheme.js +98 -71
- package/dist/runtime/composables/useUploadWithProgress.d.ts +23 -29
- package/dist/runtime/composables/useUploadWithProgress.js +78 -67
- package/dist/runtime/domains/api/auth.d.ts +2 -0
- package/dist/runtime/domains/api/auth.js +31 -0
- package/dist/runtime/domains/api/endpoint-config.d.ts +11 -0
- package/dist/runtime/domains/api/endpoint-config.js +17 -0
- package/dist/runtime/domains/api/errors.d.ts +2 -0
- package/dist/runtime/domains/api/errors.js +10 -0
- package/dist/runtime/domains/api/fetch-key.d.ts +20 -0
- package/dist/runtime/domains/api/fetch-key.js +23 -0
- package/dist/runtime/domains/api/interceptors/error.d.ts +13 -0
- package/dist/runtime/domains/api/interceptors/error.js +49 -0
- package/dist/runtime/domains/api/interceptors/request.d.ts +12 -0
- package/dist/runtime/domains/api/interceptors/request.js +46 -0
- package/dist/runtime/domains/api/interceptors/response.d.ts +17 -0
- package/dist/runtime/domains/api/interceptors/response.js +27 -0
- package/dist/runtime/domains/api/response.d.ts +4 -0
- package/dist/runtime/domains/api/response.js +14 -0
- package/dist/runtime/domains/api/toast.d.ts +15 -0
- package/dist/runtime/domains/api/toast.js +46 -0
- package/dist/runtime/domains/api/transfer.d.ts +69 -0
- package/dist/runtime/domains/api/transfer.js +81 -0
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -0
- package/dist/runtime/domains/auto-form/actions.js +4 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +13 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererArray.vue → domains/auto-form/components/Array.vue} +25 -29
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +13 -0
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererChildren.vue → domains/auto-form/components/Children.vue} +18 -18
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Field.vue +56 -0
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererLayout.vue → domains/auto-form/components/Layout.vue} +24 -25
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +11 -0
- package/dist/runtime/{components/auto-form-renderer/AutoFormRendererNested.vue → domains/auto-form/components/Nested.vue} +17 -21
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/domains/auto-form/controls.d.ts +681 -0
- package/dist/runtime/{auto-form → domains/auto-form}/controls.js +28 -24
- package/dist/runtime/{auto-form/field-utils.d.ts → domains/auto-form/fields.d.ts} +3 -1
- package/dist/runtime/{auto-form/field-utils.js → domains/auto-form/fields.js} +18 -2
- package/dist/runtime/{auto-form → domains/auto-form}/metadata.js +1 -1
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{auto-form → domains/auto-form}/provider.js +9 -5
- package/dist/runtime/{auto-form/reactive-utils.d.ts → domains/auto-form/reactive.d.ts} +5 -5
- package/dist/runtime/{auto-form/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/{auto-form/schema-introspector.d.ts → domains/auto-form/schema.d.ts} +7 -2
- package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +14 -1
- package/dist/runtime/domains/data-table/columns/constants.d.ts +50 -0
- package/dist/runtime/domains/data-table/columns/constants.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +59 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +9 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +196 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.d.ts +4 -0
- package/dist/runtime/domains/data-table/columns/resolve-group-column.js +19 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.d.ts +8 -0
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +232 -0
- package/dist/runtime/domains/data-table/columns/style.d.ts +11 -0
- package/dist/runtime/domains/data-table/columns/style.js +68 -0
- package/dist/runtime/domains/data-table/columns/utils.d.ts +6 -0
- package/dist/runtime/domains/data-table/columns/utils.js +16 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.d.vue.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue +39 -0
- package/dist/runtime/domains/data-table/components/ActionConfirm.vue.d.ts +10 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.d.vue.ts +11 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue +91 -0
- package/dist/runtime/domains/data-table/components/ActionsCell.vue.d.ts +11 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.d.vue.ts +9 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue +40 -0
- package/dist/runtime/domains/data-table/components/CellTooltip.vue.d.ts +9 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +26 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue +132 -0
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +26 -0
- package/dist/runtime/domains/data-table/indent.d.ts +8 -0
- package/dist/runtime/domains/data-table/indent.js +19 -0
- package/dist/runtime/domains/data-table/tree-selection.d.ts +9 -0
- package/dist/runtime/domains/data-table/tree-selection.js +76 -0
- package/dist/runtime/{utils/theme.d.ts → domains/theme/theme-icons.d.ts} +0 -1
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/plugins/api.factory.js +17 -117
- package/dist/runtime/plugins/theme.js +49 -27
- package/dist/runtime/types/api/config.d.ts +127 -0
- package/dist/runtime/types/api/fetch.d.ts +50 -0
- package/dist/runtime/types/api/index.d.ts +5 -0
- package/dist/runtime/types/api/module.d.ts +94 -0
- package/dist/runtime/types/api/response.d.ts +62 -0
- package/dist/runtime/types/api/response.js +0 -0
- package/dist/runtime/types/api/transfer.d.ts +32 -0
- package/dist/runtime/types/api/transfer.js +0 -0
- package/dist/runtime/types/app.config.d.ts +6 -0
- package/dist/runtime/types/auto-form/base.d.ts +26 -0
- package/dist/runtime/types/auto-form/base.js +0 -0
- package/dist/runtime/types/auto-form/component.d.ts +28 -0
- package/dist/runtime/types/auto-form/component.js +0 -0
- package/dist/runtime/types/auto-form/controls.d.ts +45 -0
- package/dist/runtime/types/auto-form/controls.js +0 -0
- package/dist/runtime/types/auto-form/fields.d.ts +68 -0
- package/dist/runtime/types/auto-form/fields.js +0 -0
- package/dist/runtime/types/auto-form/index.d.ts +7 -0
- package/dist/runtime/types/auto-form/index.js +0 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +84 -0
- package/dist/runtime/types/auto-form/search-form.js +0 -0
- package/dist/runtime/types/auto-form/slots.d.ts +85 -0
- package/dist/runtime/types/auto-form/slots.js +0 -0
- package/dist/runtime/types/auto-form/zod-factory.d.ts +127 -0
- package/dist/runtime/types/auto-form/zod-factory.js +0 -0
- package/dist/runtime/types/components/color-chooser.d.ts +109 -0
- package/dist/runtime/types/components/color-chooser.js +0 -0
- package/dist/runtime/types/components/date-picker.d.ts +41 -0
- package/dist/runtime/types/components/date-picker.js +0 -0
- package/dist/runtime/types/components/index.d.ts +8 -0
- package/dist/runtime/types/components/index.js +0 -0
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +17 -0
- package/dist/runtime/types/components/input/as-phone-number-input.js +0 -0
- package/dist/runtime/types/components/input/index.d.ts +6 -0
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +11 -0
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +10 -0
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +11 -0
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +12 -0
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +7 -0
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/message-box.d.ts +69 -0
- package/dist/runtime/types/components/message-box.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +103 -0
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +74 -0
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +54 -0
- package/dist/runtime/types/components/slide-verify.js +0 -0
- package/dist/runtime/types/components/star-rating.d.ts +55 -0
- package/dist/runtime/types/components/star-rating.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +236 -0
- package/dist/runtime/types/data-table/columns.js +6 -0
- package/dist/runtime/types/data-table/component.d.ts +190 -0
- package/dist/runtime/types/data-table/component.js +0 -0
- package/dist/runtime/types/data-table/contexts.d.ts +44 -0
- package/dist/runtime/types/data-table/contexts.js +0 -0
- package/dist/runtime/types/data-table/index.d.ts +6 -0
- package/dist/runtime/types/data-table/index.js +1 -0
- package/dist/runtime/types/data-table/pagination.d.ts +87 -0
- package/dist/runtime/types/data-table/pagination.js +0 -0
- package/dist/runtime/types/index.d.ts +6 -5
- package/dist/runtime/types/index.js +5 -5
- package/dist/runtime/types/shared.d.ts +5 -0
- package/dist/runtime/types/shared.js +0 -0
- package/dist/runtime/types/zod.d.ts +11 -10
- package/dist/runtime/utils/extend-theme.d.ts +19 -0
- package/dist/runtime/utils/extend-theme.js +44 -0
- package/dist/runtime/utils/form-control.d.ts +33 -0
- package/dist/runtime/utils/form-control.js +54 -0
- package/dist/runtime/utils/meta.d.ts +2 -5
- package/dist/runtime/utils/meta.js +1 -3
- package/dist/runtime/utils/theme-defaults.d.ts +27 -0
- package/dist/runtime/utils/theme-defaults.js +28 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +4 -0
- package/dist/runtime/vue/composables/useSiteConfig.d.ts +13 -0
- package/dist/runtime/vue/composables/useSiteConfig.js +11 -0
- package/dist/runtime/vue/plugins/theme.d.ts +6 -0
- package/dist/runtime/vue/plugins/theme.js +14 -0
- package/dist/runtime/vue/stubs/base.d.ts +2 -0
- package/dist/runtime/vue/stubs/base.js +2 -0
- package/dist/runtime/vue/stubs/inertia.d.ts +2 -0
- package/dist/runtime/vue/stubs/inertia.js +2 -0
- package/dist/runtime/vue/stubs/movk-extra.d.ts +2 -0
- package/dist/runtime/vue/stubs/movk-extra.js +2 -0
- package/dist/runtime/vue/stubs/none.d.ts +2 -0
- package/dist/runtime/vue/stubs/none.js +2 -0
- package/dist/runtime/vue/stubs/vue-router.d.ts +2 -0
- package/dist/runtime/vue/stubs/vue-router.js +2 -0
- package/dist/shared/nuxt.DfBEyjld.mjs +667 -0
- package/dist/types.d.mts +2 -6
- package/dist/unplugin.d.mts +28 -0
- package/dist/unplugin.mjs +292 -0
- package/dist/vite.d.mts +12 -0
- package/dist/vite.mjs +20 -0
- package/package.json +75 -37
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/auto-form/controls.d.ts +0 -221
- package/dist/runtime/auto-form/provider.d.ts +0 -27
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -28
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -26
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -26
- package/dist/runtime/constants/api-defaults.d.ts +0 -9
- package/dist/runtime/constants/api-defaults.js +0 -32
- package/dist/runtime/constants/grid-cols.d.ts +0 -7
- package/dist/runtime/constants/grid-cols.js +0 -44
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -349
- package/dist/runtime/types/auto-form.d.ts +0 -259
- package/dist/runtime/types/module.d.ts +0 -96
- package/dist/runtime/types/theme.d.ts +0 -2
- package/dist/runtime/utils/api-utils.d.ts +0 -58
- package/dist/runtime/utils/api-utils.js +0 -98
- /package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -0
- /package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -0
- /package/dist/runtime/{auto-form → domains/auto-form}/metadata.d.ts +0 -0
- /package/dist/runtime/{utils/theme.js → domains/theme/theme-icons.js} +0 -0
- /package/dist/runtime/types/{api.js → api/config.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{module.js → api/index.js} +0 -0
- /package/dist/runtime/types/{theme.js → api/module.js} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
1
2
|
import type { DateValue } from '@internationalized/date';
|
|
2
3
|
import type { DateRange } from 'reka-ui';
|
|
4
|
+
export type ValueFormat = 'date-value' | 'iso' | 'timestamp' | 'unix' | 'date';
|
|
3
5
|
/**
|
|
4
6
|
* 日期格式化器配置选项
|
|
5
7
|
*/
|
|
@@ -55,9 +57,17 @@ export declare function useDateFormatter(options?: DateFormatterOptions): {
|
|
|
55
57
|
toDate: (date: DateValue | undefined | null) => Date | null;
|
|
56
58
|
toTimestamp: (date: DateValue | undefined | null) => number | null;
|
|
57
59
|
toUnixTimestamp: (date: DateValue | undefined | null) => number | null;
|
|
58
|
-
|
|
60
|
+
toFormat: (date: DateValue | undefined | null, format: ValueFormat) => unknown;
|
|
61
|
+
fromISO: (value: string | undefined | null) => DateValue | null;
|
|
62
|
+
fromDate: (value: Date | undefined | null) => CalendarDate | null;
|
|
63
|
+
fromTimestamp: (value: number | undefined | null) => CalendarDate | null;
|
|
64
|
+
fromUnixTimestamp: (value: number | undefined | null) => CalendarDate | null;
|
|
65
|
+
fromFormat: (value: unknown, format: ValueFormat) => DateValue | null;
|
|
66
|
+
parse: (value: string) => CalendarDate | import("@internationalized/date").CalendarDateTime | import("@internationalized/date").ZonedDateTime | null;
|
|
59
67
|
convertData: <T>(data: T, converter: (value: DateValue) => unknown) => T;
|
|
60
|
-
|
|
68
|
+
convertToFormat: <T>(data: T, format: ValueFormat) => unknown;
|
|
69
|
+
convertFromFormat: <T>(data: T, format: ValueFormat) => unknown;
|
|
70
|
+
getToday: () => CalendarDate;
|
|
61
71
|
getNow: () => import("@internationalized/date").ZonedDateTime;
|
|
62
72
|
getStartOfWeek: (date: DateValue) => DateValue;
|
|
63
73
|
getEndOfWeek: (date: DateValue) => DateValue;
|
|
@@ -82,4 +92,7 @@ export declare function useDateFormatter(options?: DateFormatterOptions): {
|
|
|
82
92
|
locale: string;
|
|
83
93
|
timeZone: string;
|
|
84
94
|
};
|
|
85
|
-
export {};
|
|
95
|
+
export { CalendarDate } from '@internationalized/date';
|
|
96
|
+
export type DateFormatter = ReturnType<typeof useDateFormatter>;
|
|
97
|
+
export type { AnyCalendarDate, Calendar, CalendarDateTime, DateDuration, DateFields, DateValue, Time, ZonedDateTime } from '@internationalized/date';
|
|
98
|
+
export type { DateRange } from 'reka-ui';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CalendarDate,
|
|
3
|
+
DateFormatter as IntlDateFormatter,
|
|
3
4
|
getLocalTimeZone,
|
|
4
5
|
today,
|
|
5
6
|
now,
|
|
@@ -19,10 +20,19 @@ import {
|
|
|
19
20
|
isToday,
|
|
20
21
|
parseDate,
|
|
21
22
|
parseDateTime,
|
|
22
|
-
parseZonedDateTime
|
|
23
|
+
parseZonedDateTime,
|
|
24
|
+
parseAbsolute
|
|
23
25
|
} from "@internationalized/date";
|
|
24
26
|
const DEFAULT_LOCALE = "zh-CN";
|
|
25
27
|
const DEFAULT_FORMAT_OPTIONS = { dateStyle: "medium" };
|
|
28
|
+
const ABSOLUTE_RE = /(?:Z|[+-]\d{2}:?\d{2})$/;
|
|
29
|
+
function safe(fn, fallback) {
|
|
30
|
+
try {
|
|
31
|
+
return fn();
|
|
32
|
+
} catch {
|
|
33
|
+
return fallback;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
26
36
|
function isDateValue(value) {
|
|
27
37
|
return value !== null && value !== void 0 && typeof value === "object" && "calendar" in value && "year" in value && "month" in value && "day" in value;
|
|
28
38
|
}
|
|
@@ -33,14 +43,10 @@ export function useDateFormatter(options = {}) {
|
|
|
33
43
|
const locale = options.locale ?? DEFAULT_LOCALE;
|
|
34
44
|
const formatOptions = options.formatOptions ?? DEFAULT_FORMAT_OPTIONS;
|
|
35
45
|
const timeZone = options.timeZone ?? getLocalTimeZone();
|
|
36
|
-
const formatter = new
|
|
46
|
+
const formatter = new IntlDateFormatter(locale, { ...formatOptions, timeZone });
|
|
37
47
|
function format(date) {
|
|
38
48
|
if (!date) return "";
|
|
39
|
-
|
|
40
|
-
return formatter.format(date.toDate(timeZone));
|
|
41
|
-
} catch {
|
|
42
|
-
return "";
|
|
43
|
-
}
|
|
49
|
+
return safe(() => formatter.format(date.toDate(timeZone)), "");
|
|
44
50
|
}
|
|
45
51
|
function formatRange(start, end, separator = " - ") {
|
|
46
52
|
if (!start || !end) return "";
|
|
@@ -52,19 +58,11 @@ export function useDateFormatter(options = {}) {
|
|
|
52
58
|
}
|
|
53
59
|
function toISO(date) {
|
|
54
60
|
if (!date) return "";
|
|
55
|
-
|
|
56
|
-
return date.toString();
|
|
57
|
-
} catch {
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
61
|
+
return safe(() => date.toString(), "");
|
|
60
62
|
}
|
|
61
63
|
function toDate(date) {
|
|
62
64
|
if (!date) return null;
|
|
63
|
-
|
|
64
|
-
return new Date(Date.UTC(date.year, date.month - 1, date.day));
|
|
65
|
-
} catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
65
|
+
return safe(() => new Date(Date.UTC(date.year, date.month - 1, date.day)), null);
|
|
68
66
|
}
|
|
69
67
|
function toTimestamp(date) {
|
|
70
68
|
const jsDate = toDate(date);
|
|
@@ -72,7 +70,67 @@ export function useDateFormatter(options = {}) {
|
|
|
72
70
|
}
|
|
73
71
|
function toUnixTimestamp(date) {
|
|
74
72
|
const timestamp = toTimestamp(date);
|
|
75
|
-
return timestamp ? Math.floor(timestamp / 1e3)
|
|
73
|
+
return timestamp === null ? null : Math.floor(timestamp / 1e3);
|
|
74
|
+
}
|
|
75
|
+
function toFormat(date, format2) {
|
|
76
|
+
if (!date) return void 0;
|
|
77
|
+
switch (format2) {
|
|
78
|
+
case "date-value":
|
|
79
|
+
return date;
|
|
80
|
+
case "iso":
|
|
81
|
+
return toISO(date);
|
|
82
|
+
case "timestamp":
|
|
83
|
+
return toTimestamp(date);
|
|
84
|
+
case "unix":
|
|
85
|
+
return toUnixTimestamp(date);
|
|
86
|
+
case "date":
|
|
87
|
+
return toDate(date);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function convertToFormat(data, format2) {
|
|
91
|
+
if (format2 === "date-value") return data;
|
|
92
|
+
return convertData(data, (value) => toFormat(value, format2));
|
|
93
|
+
}
|
|
94
|
+
function fromDate(value) {
|
|
95
|
+
if (!value || Number.isNaN(value.getTime())) return null;
|
|
96
|
+
return safe(
|
|
97
|
+
() => new CalendarDate(value.getUTCFullYear(), value.getUTCMonth() + 1, value.getUTCDate()),
|
|
98
|
+
null
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function fromTimestamp(value) {
|
|
102
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return null;
|
|
103
|
+
return fromDate(new Date(value));
|
|
104
|
+
}
|
|
105
|
+
function fromUnixTimestamp(value) {
|
|
106
|
+
if (value === null || value === void 0 || Number.isNaN(value)) return null;
|
|
107
|
+
return fromTimestamp(value * 1e3);
|
|
108
|
+
}
|
|
109
|
+
function fromISO(value) {
|
|
110
|
+
if (!value) return null;
|
|
111
|
+
return parse(value);
|
|
112
|
+
}
|
|
113
|
+
function fromFormat(value, format2) {
|
|
114
|
+
if (value === null || value === void 0) return null;
|
|
115
|
+
if (format2 === "date-value") return isDateValue(value) ? value : null;
|
|
116
|
+
if (format2 === "iso") return typeof value === "string" ? fromISO(value) : null;
|
|
117
|
+
if (format2 === "timestamp") return typeof value === "number" ? fromTimestamp(value) : null;
|
|
118
|
+
if (format2 === "unix") return typeof value === "number" ? fromUnixTimestamp(value) : null;
|
|
119
|
+
if (format2 === "date") return value instanceof Date ? fromDate(value) : null;
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
function convertFromFormat(data, format2) {
|
|
123
|
+
if (data === null || data === void 0) return data;
|
|
124
|
+
if (format2 === "date-value") return data;
|
|
125
|
+
if (Array.isArray(data)) return data.map((item) => convertFromFormat(item, format2));
|
|
126
|
+
if (typeof data === "object" && "start" in data && "end" in data) {
|
|
127
|
+
const range = data;
|
|
128
|
+
return {
|
|
129
|
+
start: range.start === void 0 || range.start === null ? range.start : fromFormat(range.start, format2),
|
|
130
|
+
end: range.end === void 0 || range.end === null ? range.end : fromFormat(range.end, format2)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return fromFormat(data, format2);
|
|
76
134
|
}
|
|
77
135
|
function getToday() {
|
|
78
136
|
return today(timeZone);
|
|
@@ -82,10 +140,10 @@ export function useDateFormatter(options = {}) {
|
|
|
82
140
|
}
|
|
83
141
|
function parse(value) {
|
|
84
142
|
try {
|
|
85
|
-
if (value.includes("T"))
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return
|
|
143
|
+
if (!value.includes("T")) return parseDate(value);
|
|
144
|
+
if (value.includes("[")) return parseZonedDateTime(value);
|
|
145
|
+
if (ABSOLUTE_RE.test(value)) return parseAbsolute(value, timeZone);
|
|
146
|
+
return parseDateTime(value);
|
|
89
147
|
} catch {
|
|
90
148
|
return null;
|
|
91
149
|
}
|
|
@@ -112,12 +170,10 @@ export function useDateFormatter(options = {}) {
|
|
|
112
170
|
return getDayOfWeek(date, locale);
|
|
113
171
|
}
|
|
114
172
|
function getDayOfWeekName(date, style = "long") {
|
|
115
|
-
|
|
116
|
-
const weekdayFormatter = new
|
|
173
|
+
return safe(() => {
|
|
174
|
+
const weekdayFormatter = new IntlDateFormatter(locale, { weekday: style, timeZone });
|
|
117
175
|
return weekdayFormatter.format(date.toDate(timeZone));
|
|
118
|
-
}
|
|
119
|
-
return "";
|
|
120
|
-
}
|
|
176
|
+
}, "");
|
|
121
177
|
}
|
|
122
178
|
function getWeeksInMonthNumber(date) {
|
|
123
179
|
return getWeeksInMonth(date, locale);
|
|
@@ -156,13 +212,9 @@ export function useDateFormatter(options = {}) {
|
|
|
156
212
|
return data.map((item) => convertData(item, converter));
|
|
157
213
|
}
|
|
158
214
|
if (typeof data === "object") {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
result[key] = convertData(data[key], converter);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
215
|
+
return Object.fromEntries(
|
|
216
|
+
Object.entries(data).map(([k, v]) => [k, convertData(v, converter)])
|
|
217
|
+
);
|
|
166
218
|
}
|
|
167
219
|
return data;
|
|
168
220
|
}
|
|
@@ -183,8 +235,16 @@ export function useDateFormatter(options = {}) {
|
|
|
183
235
|
toDate,
|
|
184
236
|
toTimestamp,
|
|
185
237
|
toUnixTimestamp,
|
|
238
|
+
toFormat,
|
|
239
|
+
fromISO,
|
|
240
|
+
fromDate,
|
|
241
|
+
fromTimestamp,
|
|
242
|
+
fromUnixTimestamp,
|
|
243
|
+
fromFormat,
|
|
186
244
|
parse,
|
|
187
245
|
convertData,
|
|
246
|
+
convertToFormat,
|
|
247
|
+
convertFromFormat,
|
|
188
248
|
getToday,
|
|
189
249
|
getNow,
|
|
190
250
|
getStartOfWeek,
|
|
@@ -211,3 +271,4 @@ export function useDateFormatter(options = {}) {
|
|
|
211
271
|
timeZone
|
|
212
272
|
};
|
|
213
273
|
}
|
|
274
|
+
export { CalendarDate } from "@internationalized/date";
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
+
import type { ApiError, TransferRequestOptions, TransferResult } from '../types/api';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
+
* 下载选项(带进度监控)
|
|
4
5
|
*/
|
|
5
|
-
export interface DownloadWithProgressOptions {
|
|
6
|
-
/**
|
|
6
|
+
export interface DownloadWithProgressOptions extends TransferRequestOptions {
|
|
7
|
+
/** HTTP 方法 @defaultValue 'GET' */
|
|
8
|
+
method?: RequestInit['method'];
|
|
9
|
+
/** 请求体,非 GET 时若非 string 自动序列化为 JSON */
|
|
10
|
+
body?: RequestInit['body'] | Record<string, unknown>;
|
|
11
|
+
/** 自定义文件名,不提供时从响应头或 URL 提取 */
|
|
7
12
|
filename?: string;
|
|
8
|
-
/**
|
|
9
|
-
headers?: Record<string, string>;
|
|
10
|
-
/** Toast 配置 */
|
|
11
|
-
toast?: RequestToastOptions | false;
|
|
12
|
-
/** 端点名称 */
|
|
13
|
-
endpoint?: string;
|
|
14
|
-
/** 下载成功回调 */
|
|
13
|
+
/** 下载成功回调(文件名) */
|
|
15
14
|
onSuccess?: (filename: string) => void;
|
|
16
|
-
/**
|
|
17
|
-
onError?: (error: Error) => void;
|
|
15
|
+
/** 下载失败回调;中止时不触发 */
|
|
16
|
+
onError?: (error: ApiError | Error) => void;
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
|
-
* 带进度监控的文件下载 composable
|
|
19
|
+
* 带进度监控的文件下载 composable(仅客户端)
|
|
21
20
|
*
|
|
22
|
-
* 基于原生 fetch + ReadableStream
|
|
21
|
+
* @description 基于原生 fetch + ReadableStream 实现,复用 `@movk/nuxt` 的端点/认证/业务校验/toast/hook 体系。
|
|
22
|
+
* - 后端返回 JSON 时按业务码校验,错误不会触发文件下载
|
|
23
|
+
* - 后端无 content-length 时 progress 为 null,UI 据此切 indeterminate
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
26
|
* ```ts
|
|
26
|
-
* const { progress,
|
|
27
|
+
* const { progress, status, error, download, abort } = useDownloadWithProgress()
|
|
27
28
|
*
|
|
28
|
-
* await download('/api/export', {
|
|
29
|
-
* filename: 'report.pdf'
|
|
30
|
-
* onSuccess: (name) => console.log('下载成功:', name)
|
|
29
|
+
* const { data, error: err, aborted } = await download('/api/export', {
|
|
30
|
+
* filename: 'report.pdf'
|
|
31
31
|
* })
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function useDownloadWithProgress(): {
|
|
35
|
-
/** 下载进度
|
|
34
|
+
export declare function useDownloadWithProgress<T = Blob>(): {
|
|
35
|
+
/** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
|
|
36
36
|
progress: any;
|
|
37
|
-
/**
|
|
38
|
-
|
|
37
|
+
/** 传输状态 */
|
|
38
|
+
status: any;
|
|
39
|
+
/** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
|
|
40
|
+
data: any;
|
|
39
41
|
/** 错误信息 */
|
|
40
42
|
error: any;
|
|
41
43
|
/** 执行下载 */
|
|
42
|
-
download: (url:
|
|
43
|
-
success: boolean;
|
|
44
|
-
error: Error | null;
|
|
45
|
-
}>;
|
|
44
|
+
download: (url: NitroFetchRequest, options?: DownloadWithProgressOptions) => Promise<TransferResult<T>>;
|
|
46
45
|
/** 中止下载 */
|
|
47
46
|
abort: () => void;
|
|
48
47
|
};
|
|
@@ -1,41 +1,135 @@
|
|
|
1
|
-
import { ref, useRuntimeConfig } from "#imports";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ref, useNuxtApp, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { triggerDownload } from "@movk/core";
|
|
3
|
+
import {
|
|
4
|
+
buildFetchContext,
|
|
5
|
+
finalizeTransfer,
|
|
6
|
+
prepareTransfer,
|
|
7
|
+
resolveFilename,
|
|
8
|
+
tryParseJsonResponse
|
|
9
|
+
} from "../domains/api/transfer.js";
|
|
4
10
|
export function useDownloadWithProgress() {
|
|
5
11
|
const publicConfig = useRuntimeConfig().public.movkApi;
|
|
12
|
+
const nuxtApp = useNuxtApp();
|
|
6
13
|
const progress = ref(0);
|
|
7
|
-
const
|
|
14
|
+
const status = ref("idle");
|
|
15
|
+
const data = ref(null);
|
|
8
16
|
const error = ref(null);
|
|
9
|
-
let
|
|
17
|
+
let controller = null;
|
|
10
18
|
const abort = () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
controller?.abort();
|
|
20
|
+
controller = null;
|
|
21
|
+
status.value = "aborted";
|
|
14
22
|
progress.value = 0;
|
|
15
23
|
};
|
|
16
24
|
const download = async (url, options = {}) => {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
const {
|
|
26
|
+
method = "GET",
|
|
27
|
+
body,
|
|
28
|
+
filename,
|
|
29
|
+
headers: userHeaders,
|
|
30
|
+
toast,
|
|
31
|
+
endpoint,
|
|
32
|
+
skipBusinessCheck,
|
|
33
|
+
onSuccess,
|
|
34
|
+
onError
|
|
35
|
+
} = options;
|
|
36
|
+
const urlStr = typeof url === "string" ? url : url.url;
|
|
37
|
+
const { fullUrl, headers, config } = prepareTransfer(publicConfig, urlStr, {
|
|
38
|
+
endpoint,
|
|
39
|
+
headers: userHeaders,
|
|
40
|
+
toast,
|
|
41
|
+
skipBusinessCheck
|
|
42
|
+
});
|
|
20
43
|
progress.value = 0;
|
|
21
|
-
|
|
44
|
+
status.value = "pending";
|
|
45
|
+
data.value = null;
|
|
22
46
|
error.value = null;
|
|
23
|
-
|
|
47
|
+
controller = new AbortController();
|
|
48
|
+
const fetchInit = {
|
|
49
|
+
method,
|
|
50
|
+
headers,
|
|
51
|
+
signal: controller.signal
|
|
52
|
+
};
|
|
53
|
+
if (method && method !== "GET" && body !== void 0 && body !== null) {
|
|
54
|
+
const isBodyInit = typeof body === "string" || body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams || body instanceof ArrayBuffer || body instanceof ReadableStream || ArrayBuffer.isView(body);
|
|
55
|
+
if (isBodyInit) {
|
|
56
|
+
fetchInit.body = body;
|
|
57
|
+
} else {
|
|
58
|
+
fetchInit.body = JSON.stringify(body);
|
|
59
|
+
if (!("content-type" in headers) && !("Content-Type" in headers)) {
|
|
60
|
+
fetchInit.headers["Content-Type"] = "application/json";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
24
64
|
try {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
headers:
|
|
29
|
-
signal: abortController.signal
|
|
65
|
+
const response = await fetch(fullUrl, fetchInit);
|
|
66
|
+
const fetchContext = buildFetchContext(fullUrl, { context: { toast, skipBusinessCheck } }, {
|
|
67
|
+
status: response.status,
|
|
68
|
+
headers: response.headers
|
|
30
69
|
});
|
|
70
|
+
const contentType = response.headers.get("content-type") || "";
|
|
71
|
+
const isJson = contentType.toLowerCase().includes("application/json");
|
|
31
72
|
if (!response.ok) {
|
|
32
|
-
|
|
73
|
+
if (isJson) {
|
|
74
|
+
const text = await response.text();
|
|
75
|
+
const raw = tryParseJsonResponse(response.headers, text);
|
|
76
|
+
const result3 = await finalizeTransfer(nuxtApp, {
|
|
77
|
+
raw,
|
|
78
|
+
fallback: { isSuccess: false, data: null, message: `HTTP ${response.status}` },
|
|
79
|
+
config,
|
|
80
|
+
publicConfig,
|
|
81
|
+
requestToast: toast,
|
|
82
|
+
skipBusinessCheck,
|
|
83
|
+
fetchContext
|
|
84
|
+
});
|
|
85
|
+
status.value = "error";
|
|
86
|
+
error.value = result3.error;
|
|
87
|
+
onError?.(result3.error);
|
|
88
|
+
return result3;
|
|
89
|
+
}
|
|
90
|
+
const result2 = await finalizeTransfer(nuxtApp, {
|
|
91
|
+
raw: null,
|
|
92
|
+
fallback: { isSuccess: false, data: null, message: `HTTP ${response.status} ${response.statusText}` },
|
|
93
|
+
config,
|
|
94
|
+
publicConfig,
|
|
95
|
+
requestToast: toast,
|
|
96
|
+
fetchContext
|
|
97
|
+
});
|
|
98
|
+
status.value = "error";
|
|
99
|
+
error.value = result2.error;
|
|
100
|
+
onError?.(result2.error);
|
|
101
|
+
return result2;
|
|
102
|
+
}
|
|
103
|
+
if (isJson) {
|
|
104
|
+
const text = await response.text();
|
|
105
|
+
const raw = tryParseJsonResponse(response.headers, text);
|
|
106
|
+
const result2 = await finalizeTransfer(nuxtApp, {
|
|
107
|
+
raw,
|
|
108
|
+
fallback: { isSuccess: false, data: null, message: "\u54CD\u5E94\u89E3\u6790\u5931\u8D25" },
|
|
109
|
+
config,
|
|
110
|
+
publicConfig,
|
|
111
|
+
requestToast: toast,
|
|
112
|
+
skipBusinessCheck,
|
|
113
|
+
fetchContext
|
|
114
|
+
});
|
|
115
|
+
if (result2.error) {
|
|
116
|
+
status.value = "error";
|
|
117
|
+
error.value = result2.error;
|
|
118
|
+
onError?.(result2.error);
|
|
119
|
+
} else {
|
|
120
|
+
status.value = "success";
|
|
121
|
+
data.value = result2.data;
|
|
122
|
+
progress.value = 100;
|
|
123
|
+
}
|
|
124
|
+
controller = null;
|
|
125
|
+
return result2;
|
|
33
126
|
}
|
|
34
127
|
const contentLength = response.headers.get("content-length");
|
|
35
128
|
const total = contentLength ? Number.parseInt(contentLength, 10) : 0;
|
|
36
|
-
const finalFilename =
|
|
129
|
+
const finalFilename = resolveFilename(response.headers, urlStr, filename);
|
|
37
130
|
const reader = response.body?.getReader();
|
|
38
131
|
if (!reader) throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u6D41");
|
|
132
|
+
if (total <= 0) progress.value = null;
|
|
39
133
|
const chunks = [];
|
|
40
134
|
let received = 0;
|
|
41
135
|
while (true) {
|
|
@@ -45,35 +139,43 @@ export function useDownloadWithProgress() {
|
|
|
45
139
|
received += value.length;
|
|
46
140
|
if (total > 0) progress.value = Math.round(received / total * 100);
|
|
47
141
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
142
|
+
const blob = new Blob(chunks);
|
|
143
|
+
triggerDownload(blob, finalFilename);
|
|
144
|
+
const result = await finalizeTransfer(nuxtApp, {
|
|
145
|
+
raw: null,
|
|
146
|
+
fallback: { isSuccess: true, data: blob, message: `\u4E0B\u8F7D\u6210\u529F: ${finalFilename}` },
|
|
147
|
+
config,
|
|
148
|
+
publicConfig,
|
|
149
|
+
requestToast: toast,
|
|
150
|
+
fetchContext
|
|
151
|
+
});
|
|
152
|
+
status.value = "success";
|
|
153
|
+
data.value = result.data;
|
|
51
154
|
progress.value = 100;
|
|
52
|
-
|
|
53
|
-
const message = extractToastMessage(toast, "success", `\u4E0B\u8F7D\u6210\u529F: ${finalFilename}`);
|
|
54
|
-
showToast("success", message, toast, config.toast);
|
|
55
|
-
}
|
|
155
|
+
controller = null;
|
|
56
156
|
onSuccess?.(finalFilename);
|
|
57
|
-
return
|
|
157
|
+
return result;
|
|
58
158
|
} catch (err) {
|
|
59
|
-
|
|
60
|
-
|
|
159
|
+
controller = null;
|
|
160
|
+
const isAborted = err instanceof DOMException && err.name === "AbortError";
|
|
161
|
+
if (isAborted) {
|
|
162
|
+
status.value = "aborted";
|
|
163
|
+
return { data: null, error: null, aborted: true };
|
|
164
|
+
}
|
|
61
165
|
const downloadError = err instanceof Error ? err : new Error("\u4E0B\u8F7D\u5931\u8D25");
|
|
166
|
+
status.value = "error";
|
|
62
167
|
error.value = downloadError;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const message = extractToastMessage(toast, "error", downloadError.message || "\u4E0B\u8F7D\u5931\u8D25");
|
|
66
|
-
showToast("error", message, toast, config.toast);
|
|
67
|
-
}
|
|
68
|
-
if (!isAborted) onError?.(downloadError);
|
|
69
|
-
return { success: false, error: downloadError };
|
|
168
|
+
onError?.(downloadError);
|
|
169
|
+
return { data: null, error: downloadError, aborted: false };
|
|
70
170
|
}
|
|
71
171
|
};
|
|
72
172
|
return {
|
|
73
|
-
/** 下载进度
|
|
173
|
+
/** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
|
|
74
174
|
progress,
|
|
75
|
-
/**
|
|
76
|
-
|
|
175
|
+
/** 传输状态 */
|
|
176
|
+
status,
|
|
177
|
+
/** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
|
|
178
|
+
data,
|
|
77
179
|
/** 错误信息 */
|
|
78
180
|
error,
|
|
79
181
|
/** 执行下载 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
+
import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
|
|
2
3
|
/**
|
|
3
4
|
* 懒加载版 useApiFetch
|
|
4
5
|
*
|
|
@@ -15,4 +16,4 @@ import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api.js';
|
|
|
15
16
|
* // <div v-if="status === 'pending'">Loading...</div>
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
|
-
export declare function useLazyApiFetch<T = unknown, DataT = T>(url:
|
|
19
|
+
export declare function useLazyApiFetch<T = unknown, DataT = T>(url: NitroFetchRequest | (() => NitroFetchRequest), options?: UseApiFetchOptions<T, DataT>): UseApiFetchReturn<DataT>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MessageBoxProps } from '../types/components/message-box';
|
|
2
|
+
import type { OmitByKey } from '@movk/core';
|
|
3
|
+
export declare function useMessageBox(): {
|
|
4
|
+
alert: (options: OmitByKey<MessageBoxProps, "mode">) => Promise<void>;
|
|
5
|
+
confirm: (options: OmitByKey<MessageBoxProps, "mode">) => Promise<boolean>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useOverlay } from "#imports";
|
|
2
|
+
import { LazyMMessageBox } from "#components";
|
|
3
|
+
export function useMessageBox() {
|
|
4
|
+
const overlay = useOverlay();
|
|
5
|
+
function createInstance() {
|
|
6
|
+
return overlay.create(LazyMMessageBox, { destroyOnClose: true });
|
|
7
|
+
}
|
|
8
|
+
async function alert(options) {
|
|
9
|
+
await createInstance().open({ ...options, mode: "alert" });
|
|
10
|
+
}
|
|
11
|
+
async function confirm(options) {
|
|
12
|
+
const result = await createInstance().open({ ...options, mode: "confirm" });
|
|
13
|
+
return result ?? false;
|
|
14
|
+
}
|
|
15
|
+
return { alert, confirm };
|
|
16
|
+
}
|
|
@@ -1,30 +1,42 @@
|
|
|
1
|
+
type IconSet = 'lucide' | 'phosphor' | 'tabler';
|
|
1
2
|
export declare function useTheme(): {
|
|
3
|
+
color: import("vue").ComputedRef<string>;
|
|
2
4
|
style: {
|
|
3
|
-
innerHTML:
|
|
5
|
+
innerHTML: import("vue").ComputedRef<string>;
|
|
4
6
|
id: string;
|
|
5
7
|
tagPriority: number;
|
|
6
8
|
}[];
|
|
7
|
-
link:
|
|
9
|
+
link: import("vue").ComputedRef<{
|
|
10
|
+
rel: "stylesheet";
|
|
11
|
+
href: string;
|
|
12
|
+
id: string;
|
|
13
|
+
}[]>;
|
|
8
14
|
neutralColors: string[];
|
|
9
|
-
neutral:
|
|
15
|
+
neutral: import("vue").WritableComputedRef<string, string>;
|
|
10
16
|
primaryColors: string[];
|
|
11
|
-
primary:
|
|
12
|
-
blackAsPrimary: import("
|
|
17
|
+
primary: import("vue").WritableComputedRef<string, string>;
|
|
18
|
+
blackAsPrimary: import("vue").ComputedRef<boolean>;
|
|
19
|
+
setBlackAsPrimary: (value: boolean) => void;
|
|
13
20
|
radiuses: number[];
|
|
14
|
-
radius: import("
|
|
21
|
+
radius: import("vue").WritableComputedRef<number, number>;
|
|
15
22
|
fonts: string[];
|
|
16
|
-
font: import("
|
|
17
|
-
icon:
|
|
23
|
+
font: import("vue").WritableComputedRef<string, string>;
|
|
24
|
+
icon: import("vue").WritableComputedRef<IconSet, IconSet>;
|
|
18
25
|
icons: {
|
|
19
26
|
label: string;
|
|
20
27
|
icon: string;
|
|
21
|
-
value:
|
|
28
|
+
value: IconSet;
|
|
22
29
|
}[];
|
|
23
|
-
modes:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
modes: import("vue").ComputedRef<{
|
|
31
|
+
label: string;
|
|
32
|
+
icon: any;
|
|
33
|
+
}[]>;
|
|
34
|
+
mode: import("vue").WritableComputedRef<string, string>;
|
|
35
|
+
hasCSSChanges: import("vue").ComputedRef<boolean>;
|
|
36
|
+
hasConfigChanges: import("vue").ComputedRef<boolean>;
|
|
37
|
+
configLabel: string;
|
|
27
38
|
exportCSS: () => string;
|
|
28
|
-
|
|
39
|
+
exportConfig: () => string;
|
|
29
40
|
resetTheme: () => void;
|
|
30
41
|
};
|
|
42
|
+
export {};
|