@movk/nuxt 1.2.0 → 1.3.0
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 +114 -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 +89 -30
- 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 -16
- 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 +41 -0
- package/dist/runtime/{auto-form → domains/auto-form}/controls.js +27 -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 +6 -3
- 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} +2 -2
- package/dist/runtime/{auto-form/schema-introspector.js → domains/auto-form/schema.js} +1 -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 +164 -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 +67 -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 -36
- 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,96 +0,0 @@
|
|
|
1
|
-
import type { FetchContext, FetchResponse } from 'ofetch';
|
|
2
|
-
import type { ApiInstance, MovkApiPublicConfig, EndpointPrivateConfig, MovkApiFullConfig } from './api.js';
|
|
3
|
-
interface MovkFontProviderConfig {
|
|
4
|
-
/**
|
|
5
|
-
* CDN 基础 URL
|
|
6
|
-
* @see 'https://fonts.nuxt.com/get-started/providers#custom-providers'
|
|
7
|
-
* @example 'https://cdn.org/fonts'
|
|
8
|
-
*/
|
|
9
|
-
cdn: string;
|
|
10
|
-
/**
|
|
11
|
-
* 需要加载的字重,默认全部加载
|
|
12
|
-
* @example [300, 400, 500, 700]
|
|
13
|
-
*/
|
|
14
|
-
weights?: number[];
|
|
15
|
-
}
|
|
16
|
-
export interface ModuleOptions {
|
|
17
|
-
/**
|
|
18
|
-
* 组件前缀
|
|
19
|
-
* @defaultValue 'M'
|
|
20
|
-
*/
|
|
21
|
-
prefix?: string;
|
|
22
|
-
/** API 模块配置 */
|
|
23
|
-
api?: MovkApiFullConfig;
|
|
24
|
-
/** 主题系统配置 */
|
|
25
|
-
theme?: {
|
|
26
|
-
/**
|
|
27
|
-
* 是否启用主题模块(appConfig 默认值、theme plugin、ThemePicker 组件)
|
|
28
|
-
* @defaultValue true
|
|
29
|
-
*/
|
|
30
|
-
enabled?: boolean;
|
|
31
|
-
};
|
|
32
|
-
/** 字体提供器配置 */
|
|
33
|
-
fonts?: {
|
|
34
|
-
/**
|
|
35
|
-
* 是否启用字体模块
|
|
36
|
-
* @defaultValue true
|
|
37
|
-
*/
|
|
38
|
-
enabled?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* 阿里巴巴普惠体字体
|
|
41
|
-
* @defaultValue 'https://cdn.mhaibaraai.cn/fonts'
|
|
42
|
-
*/
|
|
43
|
-
alibabaPuhuiti?: MovkFontProviderConfig;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
declare module 'nuxt/app' {
|
|
47
|
-
interface NuxtApp {
|
|
48
|
-
$api: ApiInstance;
|
|
49
|
-
}
|
|
50
|
-
interface RuntimeNuxtHooks {
|
|
51
|
-
/** 请求发送前(认证注入后) */
|
|
52
|
-
'movk:api:request': (context: FetchContext) => void | Promise<void>;
|
|
53
|
-
/** 响应成功(业务检查 + 解包后) */
|
|
54
|
-
'movk:api:response': (context: FetchContext & {
|
|
55
|
-
response: FetchResponse<any>;
|
|
56
|
-
}) => void | Promise<void>;
|
|
57
|
-
/** 任何错误(业务错误 + HTTP 错误) */
|
|
58
|
-
'movk:api:error': (context: FetchContext & {
|
|
59
|
-
response: FetchResponse<any>;
|
|
60
|
-
}) => void | Promise<void>;
|
|
61
|
-
/** 401 专用(支持 handled 标记跳过默认行为) */
|
|
62
|
-
'movk:api:unauthorized': (context: FetchContext & {
|
|
63
|
-
response: FetchResponse<any>;
|
|
64
|
-
}, result: {
|
|
65
|
-
handled: boolean;
|
|
66
|
-
}) => void | Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
declare module 'nuxt/schema' {
|
|
70
|
-
interface NuxtConfig {
|
|
71
|
-
movk?: ModuleOptions;
|
|
72
|
-
}
|
|
73
|
-
interface NuxtOptions {
|
|
74
|
-
movk: ModuleOptions;
|
|
75
|
-
}
|
|
76
|
-
interface PublicRuntimeConfig {
|
|
77
|
-
movkApi: MovkApiPublicConfig;
|
|
78
|
-
}
|
|
79
|
-
interface RuntimeConfig {
|
|
80
|
-
movkApi: {
|
|
81
|
-
endpoints?: Record<string, EndpointPrivateConfig>;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
interface AppConfig {
|
|
85
|
-
ui: {
|
|
86
|
-
colors: {
|
|
87
|
-
primary: string;
|
|
88
|
-
neutral: string;
|
|
89
|
-
[key: string]: string;
|
|
90
|
-
};
|
|
91
|
-
icons: Record<string, string>;
|
|
92
|
-
};
|
|
93
|
-
toaster?: import('@nuxt/ui').ToasterProps | null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { ApiResponse, ApiError, ApiResponseConfig, ApiToastConfig, RequestToastOptions, ResolvedEndpointConfig, MovkApiPublicConfig } from '../types/api.js';
|
|
2
|
-
/**
|
|
3
|
-
* 判断 API 响应是否业务成功
|
|
4
|
-
* @param response - API 响应对象
|
|
5
|
-
* @param config - 响应配置(包含 codeKey 和 successCodes)
|
|
6
|
-
* @returns 是否业务成功
|
|
7
|
-
*/
|
|
8
|
-
export declare function isBusinessSuccess(response: ApiResponse, config?: Partial<ApiResponseConfig>): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* 从 API 响应中提取消息内容
|
|
11
|
-
* @param response - API 响应对象
|
|
12
|
-
* @param config - 响应配置(包含 messageKey)
|
|
13
|
-
* @returns 消息字符串或 undefined
|
|
14
|
-
*/
|
|
15
|
-
export declare function extractMessage(response: ApiResponse, config?: Partial<ApiResponseConfig>): string | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* 从 API 响应中提取业务数据
|
|
18
|
-
* @param response - API 响应对象
|
|
19
|
-
* @param config - 响应配置(包含 dataKey)
|
|
20
|
-
* @returns 业务数据
|
|
21
|
-
*/
|
|
22
|
-
export declare function extractData(response: ApiResponse, config?: Partial<ApiResponseConfig>): unknown;
|
|
23
|
-
/**
|
|
24
|
-
* 创建业务错误对象
|
|
25
|
-
* @param response - API 响应对象
|
|
26
|
-
* @param message - 错误消息(可选)
|
|
27
|
-
* @returns 业务错误对象
|
|
28
|
-
*/
|
|
29
|
-
export declare function createApiError(response: ApiResponse, message?: string): ApiError;
|
|
30
|
-
/**
|
|
31
|
-
* 提取 Toast 消息内容
|
|
32
|
-
* @param toast - Toast 配置选项
|
|
33
|
-
* @param type - 消息类型
|
|
34
|
-
* @param fallback - 默认消息
|
|
35
|
-
* @returns 最终显示的消息内容
|
|
36
|
-
*/
|
|
37
|
-
export declare function extractToastMessage(toast: RequestToastOptions | false | undefined, type: 'success' | 'error', fallback: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* 显示 Toast 提示
|
|
40
|
-
* @param type - 提示类型
|
|
41
|
-
* @param message - 提示消息
|
|
42
|
-
* @param requestOptions - 请求级别的 Toast 配置
|
|
43
|
-
* @param globalConfig - 全局 Toast 配置
|
|
44
|
-
*/
|
|
45
|
-
export declare function showToast(type: 'success' | 'error', message: string | undefined, requestOptions: RequestToastOptions | false | undefined, globalConfig: Partial<ApiToastConfig>): void;
|
|
46
|
-
/**
|
|
47
|
-
* 获取认证请求头
|
|
48
|
-
* @param config - 已解析的端点配置(或至少包含 auth 字段)
|
|
49
|
-
* @returns 认证请求头对象
|
|
50
|
-
*/
|
|
51
|
-
export declare function getAuthHeaders(config: Pick<ResolvedEndpointConfig, 'auth'>): Record<string, string>;
|
|
52
|
-
/**
|
|
53
|
-
* 从 publicConfig 解析端点配置(合并全局默认值)
|
|
54
|
-
* @param publicConfig - 模块公共配置
|
|
55
|
-
* @param endpoint - 端点名称(可选,默认使用 defaultEndpoint)
|
|
56
|
-
* @returns 已解析的端点配置(含 baseURL、auth、toast、response)
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolveEndpointConfig(publicConfig: MovkApiPublicConfig, endpoint?: string): Pick<ResolvedEndpointConfig, 'baseURL' | 'auth' | 'toast' | 'response'>;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { getPath } from "@movk/core";
|
|
2
|
-
import defu from "defu";
|
|
3
|
-
import { useNuxtApp, useToast, useUserSession } from "#imports";
|
|
4
|
-
export function isBusinessSuccess(response, config = {}) {
|
|
5
|
-
const codeKey = config.codeKey || "code";
|
|
6
|
-
const successCodes = config.successCodes || [200, 0];
|
|
7
|
-
const code = response[codeKey];
|
|
8
|
-
return successCodes.includes(code);
|
|
9
|
-
}
|
|
10
|
-
export function extractMessage(response, config = {}) {
|
|
11
|
-
const messageKey = config.messageKey || "message";
|
|
12
|
-
return response[messageKey] || response.message || response.msg;
|
|
13
|
-
}
|
|
14
|
-
export function extractData(response, config = {}) {
|
|
15
|
-
const dataKey = config.dataKey || "data";
|
|
16
|
-
return response[dataKey] ?? response;
|
|
17
|
-
}
|
|
18
|
-
export function createApiError(response, message) {
|
|
19
|
-
const error = new Error(message || "\u8BF7\u6C42\u5931\u8D25");
|
|
20
|
-
error.statusCode = Number(response.code || response.status || 500);
|
|
21
|
-
error.response = response;
|
|
22
|
-
error.isBusinessError = true;
|
|
23
|
-
return error;
|
|
24
|
-
}
|
|
25
|
-
function getToast() {
|
|
26
|
-
try {
|
|
27
|
-
const nuxtApp = useNuxtApp();
|
|
28
|
-
return nuxtApp.vueApp.runWithContext(() => useToast());
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function extractToastMessage(toast, type, fallback) {
|
|
34
|
-
if (toast === false) return fallback;
|
|
35
|
-
return (typeof toast === "object" ? toast?.[`${type}Message`] : void 0) || fallback;
|
|
36
|
-
}
|
|
37
|
-
export function showToast(type, message, requestOptions, globalConfig) {
|
|
38
|
-
if (globalConfig.enabled === false || requestOptions === false) return;
|
|
39
|
-
if (!message) return;
|
|
40
|
-
const typeConfig = globalConfig[type];
|
|
41
|
-
if (typeConfig?.show === false) return;
|
|
42
|
-
if (requestOptions?.[type] === false) return;
|
|
43
|
-
const toast = getToast();
|
|
44
|
-
if (!toast) return;
|
|
45
|
-
const requestTypeConfig = typeof requestOptions?.[type] === "object" ? requestOptions[type] : {};
|
|
46
|
-
toast.add({
|
|
47
|
-
icon: type === "success" ? "i-lucide-circle-check" : "i-lucide-circle-x",
|
|
48
|
-
title: message,
|
|
49
|
-
color: type === "success" ? "success" : "error",
|
|
50
|
-
duration: 3e3,
|
|
51
|
-
...typeConfig && { ...typeConfig, show: void 0 },
|
|
52
|
-
...requestTypeConfig
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function getUserSession() {
|
|
56
|
-
try {
|
|
57
|
-
const nuxtApp = useNuxtApp();
|
|
58
|
-
return nuxtApp.vueApp.runWithContext(() => useUserSession());
|
|
59
|
-
} catch {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function getTokenFromSession(tokenPath) {
|
|
64
|
-
const userSession = getUserSession();
|
|
65
|
-
if (!userSession?.session?.value) return null;
|
|
66
|
-
const sessionData = userSession.session.value;
|
|
67
|
-
return getPath(sessionData, tokenPath) || null;
|
|
68
|
-
}
|
|
69
|
-
function buildAuthHeaderValue(token, config) {
|
|
70
|
-
const tokenType = config.tokenType === "Custom" ? config.customTokenType || "" : config.tokenType || "Bearer";
|
|
71
|
-
return tokenType ? `${tokenType} ${token}` : token;
|
|
72
|
-
}
|
|
73
|
-
export function getAuthHeaders(config) {
|
|
74
|
-
const headers = {};
|
|
75
|
-
const authConfig = config.auth;
|
|
76
|
-
if (!authConfig.enabled) return headers;
|
|
77
|
-
const tokenPath = authConfig.sessionTokenPath || "token";
|
|
78
|
-
const token = getTokenFromSession(tokenPath);
|
|
79
|
-
if (token) {
|
|
80
|
-
const headerName = authConfig.headerName || "Authorization";
|
|
81
|
-
headers[headerName] = buildAuthHeaderValue(token, authConfig);
|
|
82
|
-
}
|
|
83
|
-
return headers;
|
|
84
|
-
}
|
|
85
|
-
export function resolveEndpointConfig(publicConfig, endpoint) {
|
|
86
|
-
const endpointName = endpoint || publicConfig.defaultEndpoint || "default";
|
|
87
|
-
const endpointConfig = publicConfig.endpoints[endpointName];
|
|
88
|
-
if (!endpointConfig) {
|
|
89
|
-
console.warn(`[Movk API] Endpoint "${endpointName}" not found, using default`);
|
|
90
|
-
return resolveEndpointConfig(publicConfig, publicConfig.defaultEndpoint || "default");
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
baseURL: endpointConfig.baseURL || "",
|
|
94
|
-
auth: defu(endpointConfig.auth, publicConfig.auth),
|
|
95
|
-
toast: defu(endpointConfig.toast, publicConfig.toast),
|
|
96
|
-
response: defu(endpointConfig.response, publicConfig.response)
|
|
97
|
-
};
|
|
98
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|