@movk/nuxt 1.8.3 → 2.0.0-beta.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/README.en.md +16 -6
- package/README.md +16 -6
- package/dist/module.d.mts +6 -0
- package/dist/module.json +3 -3
- package/dist/module.mjs +15 -22
- package/dist/runtime/components/AutoForm.d.vue.ts +15 -1
- package/dist/runtime/components/AutoForm.vue +48 -50
- package/dist/runtime/components/AutoForm.vue.d.ts +15 -1
- package/dist/runtime/components/DataTable.d.vue.ts +4 -2
- package/dist/runtime/components/DataTable.vue +166 -174
- package/dist/runtime/components/DataTable.vue.d.ts +4 -2
- package/dist/runtime/components/DatePicker.d.vue.ts +6 -5
- package/dist/runtime/components/DatePicker.vue +96 -43
- package/dist/runtime/components/DatePicker.vue.d.ts +6 -5
- package/dist/runtime/components/MessageBox.d.vue.ts +1 -5
- package/dist/runtime/components/MessageBox.vue +9 -7
- package/dist/runtime/components/MessageBox.vue.d.ts +1 -5
- package/dist/runtime/components/SearchForm.d.vue.ts +12 -4
- package/dist/runtime/components/SearchForm.vue +130 -120
- package/dist/runtime/components/SearchForm.vue.d.ts +12 -4
- package/dist/runtime/components/Tree.d.vue.ts +3 -1
- package/dist/runtime/components/Tree.vue +102 -140
- package/dist/runtime/components/Tree.vue.d.ts +3 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +5 -3
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +15 -6
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useApiFetch.d.ts +7 -7
- package/dist/runtime/composables/useApiFetch.js +5 -23
- package/dist/runtime/composables/useAutoForm.js +2 -2
- package/dist/runtime/composables/useClientApiFetch.d.ts +5 -5
- package/dist/runtime/composables/useDateFormatter.d.ts +32 -34
- package/dist/runtime/composables/useDateFormatter.js +75 -232
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +11 -8
- package/dist/runtime/composables/useDownloadWithProgress.js +49 -132
- package/dist/runtime/composables/useMessageBox.js +3 -2
- package/dist/runtime/composables/useMovkLocale.d.ts +16 -0
- package/dist/runtime/composables/useMovkLocale.js +20 -0
- package/dist/runtime/composables/useTheme.js +8 -18
- package/dist/runtime/composables/useUploadWithProgress.d.ts +9 -6
- package/dist/runtime/composables/useUploadWithProgress.js +50 -84
- package/dist/runtime/domains/ai/chat-transport.js +1 -0
- package/dist/runtime/domains/api/adapters/xhr.d.ts +17 -0
- package/dist/runtime/domains/api/adapters/xhr.js +55 -0
- package/dist/runtime/domains/api/auth.d.ts +4 -1
- package/dist/runtime/domains/api/auth.js +6 -7
- package/dist/runtime/domains/api/client.d.ts +13 -0
- package/dist/runtime/domains/api/client.js +35 -0
- package/dist/runtime/domains/api/download.d.ts +10 -0
- package/dist/runtime/domains/api/download.js +28 -0
- package/dist/runtime/domains/api/errors.d.ts +20 -2
- package/dist/runtime/domains/api/errors.js +61 -8
- package/dist/runtime/domains/api/fetch-key.d.ts +2 -2
- package/dist/runtime/domains/api/fetch-key.js +4 -4
- package/dist/runtime/domains/api/interceptors/request.d.ts +2 -6
- package/dist/runtime/domains/api/interceptors/request.js +3 -2
- package/dist/runtime/domains/api/interceptors/response.d.ts +8 -14
- package/dist/runtime/domains/api/interceptors/response.js +34 -25
- package/dist/runtime/domains/api/report.d.ts +25 -0
- package/dist/runtime/domains/api/report.js +51 -0
- package/dist/runtime/domains/api/response.d.ts +29 -4
- package/dist/runtime/domains/api/response.js +27 -6
- package/dist/runtime/domains/api/session.d.ts +1 -1
- package/dist/runtime/domains/api/session.js +1 -1
- package/dist/runtime/domains/api/stream.d.ts +2 -1
- package/dist/runtime/domains/api/stream.js +2 -1
- package/dist/runtime/domains/api/toast.d.ts +6 -3
- package/dist/runtime/domains/api/toast.js +7 -7
- package/dist/runtime/domains/auto-form/actions.d.ts +2 -1
- package/dist/runtime/domains/auto-form/actions.js +6 -4
- package/dist/runtime/domains/auto-form/array-ops.d.ts +3 -0
- package/dist/runtime/domains/auto-form/array-ops.js +9 -0
- package/dist/runtime/domains/auto-form/async-items.d.ts +10 -0
- package/dist/runtime/domains/auto-form/async-items.js +42 -0
- package/dist/runtime/domains/auto-form/components/Array.d.vue.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Array.vue +81 -73
- package/dist/runtime/domains/auto-form/components/Array.vue.d.ts +0 -4
- package/dist/runtime/domains/auto-form/components/Children.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Children.vue +0 -5
- package/dist/runtime/domains/auto-form/components/Children.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Field.vue +9 -2
- package/dist/runtime/domains/auto-form/components/Field.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Layout.vue +3 -6
- package/dist/runtime/domains/auto-form/components/Layout.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.d.vue.ts +0 -2
- package/dist/runtime/domains/auto-form/components/Nested.vue +5 -9
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +0 -2
- package/dist/runtime/domains/auto-form/controls.d.ts +5 -572
- package/dist/runtime/domains/auto-form/controls.js +7 -20
- package/dist/runtime/domains/auto-form/fields.d.ts +21 -4
- package/dist/runtime/domains/auto-form/fields.js +52 -40
- package/dist/runtime/domains/auto-form/provider.d.ts +15 -6
- package/dist/runtime/domains/auto-form/provider.js +24 -10
- package/dist/runtime/domains/auto-form/schema.d.ts +9 -4
- package/dist/runtime/domains/auto-form/schema.js +91 -50
- package/dist/runtime/domains/auto-form/search-query.d.ts +10 -0
- package/dist/runtime/domains/auto-form/search-query.js +57 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.d.ts +62 -0
- package/dist/runtime/domains/auto-form/useAutoFormCore.js +108 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.d.ts +11 -0
- package/dist/runtime/domains/auto-form/useSearchQuerySync.js +64 -0
- package/dist/runtime/domains/data-table/columns/constants.d.ts +2 -0
- package/dist/runtime/domains/data-table/columns/constants.js +1 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.d.ts +2 -1
- package/dist/runtime/domains/data-table/columns/resolve-columns.js +3 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.d.ts +7 -2
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +10 -5
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +14 -8
- package/dist/runtime/domains/data-table/components/ColumnSettings.d.vue.ts +20 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue +63 -0
- package/dist/runtime/domains/data-table/components/ColumnSettings.vue.d.ts +20 -0
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +2 -8
- package/dist/runtime/domains/data-table/components/Pagination.vue +34 -36
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +2 -8
- package/dist/runtime/domains/data-table/export.d.ts +23 -0
- package/dist/runtime/domains/data-table/export.js +43 -0
- package/dist/runtime/domains/data-table/load-more.d.ts +8 -0
- package/dist/runtime/domains/data-table/load-more.js +14 -0
- package/dist/runtime/domains/data-table/pagination.d.ts +29 -0
- package/dist/runtime/domains/data-table/pagination.js +42 -0
- package/dist/runtime/domains/data-table/persist.d.ts +12 -0
- package/dist/runtime/domains/data-table/persist.js +41 -0
- package/dist/runtime/domains/data-table/state/keys.d.ts +11 -0
- package/dist/runtime/domains/data-table/state/keys.js +44 -0
- package/dist/runtime/domains/data-table/state/models.d.ts +5 -0
- package/dist/runtime/domains/data-table/state/models.js +38 -0
- package/dist/runtime/domains/data-table/tree-layout.d.ts +13 -0
- package/dist/runtime/domains/data-table/tree-layout.js +30 -0
- package/dist/runtime/domains/theme/theme-color.d.ts +3 -0
- package/dist/runtime/domains/theme/theme-color.js +16 -0
- package/dist/runtime/domains/theme/theme-fouc.d.ts +5 -0
- package/dist/runtime/domains/theme/theme-fouc.js +43 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +7 -5
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +6 -4
- package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +7 -5
- package/dist/runtime/domains/tree/tree-disabled.d.ts +5 -0
- package/dist/runtime/domains/tree/tree-disabled.js +15 -0
- package/dist/runtime/domains/tree/tree-lazy.d.ts +8 -0
- package/dist/runtime/domains/tree/tree-lazy.js +19 -1
- package/dist/runtime/domains/tree/tree-search.d.ts +3 -1
- package/dist/runtime/domains/tree/tree-search.js +4 -0
- package/dist/runtime/domains/tree/useTreeLazy.d.ts +22 -0
- package/dist/runtime/domains/tree/useTreeLazy.js +57 -0
- package/dist/runtime/domains/tree/useTreeSearch.d.ts +27 -0
- package/dist/runtime/domains/tree/useTreeSearch.js +59 -0
- package/dist/runtime/domains/tree/useTreeSelection.d.ts +31 -0
- package/dist/runtime/domains/tree/useTreeSelection.js +89 -0
- package/dist/runtime/domains/zod/apply.d.ts +23 -0
- package/dist/runtime/domains/zod/apply.js +26 -0
- package/dist/runtime/domains/zod/error-map.d.ts +13 -0
- package/dist/runtime/domains/zod/error-map.js +19 -0
- package/dist/runtime/domains/zod/locale-map.d.ts +5 -0
- package/dist/runtime/domains/zod/locale-map.js +17 -0
- package/dist/runtime/domains/zod/sync.d.ts +12 -0
- package/dist/runtime/domains/zod/sync.js +30 -0
- package/dist/runtime/locale/en.d.ts +74 -0
- package/dist/runtime/locale/en.js +73 -0
- package/dist/runtime/locale/index.d.ts +8 -0
- package/dist/runtime/locale/index.js +15 -0
- package/dist/runtime/locale/zh_cn.d.ts +74 -0
- package/dist/runtime/locale/zh_cn.js +73 -0
- package/dist/runtime/plugins/api.factory.js +5 -22
- package/dist/runtime/plugins/theme.js +4 -42
- package/dist/runtime/plugins/zod.d.ts +2 -0
- package/dist/runtime/plugins/zod.js +16 -0
- package/dist/runtime/types/api/config.d.ts +12 -0
- package/dist/runtime/types/api/fetch.d.ts +3 -16
- package/dist/runtime/types/api/index.d.ts +1 -1
- package/dist/runtime/types/api/response.d.ts +33 -19
- package/dist/runtime/types/api/stream.d.ts +2 -3
- package/dist/runtime/types/api/transfer.d.ts +3 -7
- package/dist/runtime/types/auto-form/base.d.ts +9 -1
- package/dist/runtime/types/auto-form/component.d.ts +31 -3
- package/dist/runtime/types/auto-form/fields.d.ts +15 -1
- package/dist/runtime/types/auto-form/index.d.ts +3 -3
- package/dist/runtime/types/auto-form/search-form.d.ts +26 -12
- package/dist/runtime/types/auto-form/zod-factory.d.ts +2 -2
- package/dist/runtime/types/components/date-picker.d.ts +14 -3
- package/dist/runtime/types/components/index.d.ts +1 -6
- package/dist/runtime/types/components/message-box.d.ts +5 -18
- package/dist/runtime/types/components/tree.d.ts +17 -14
- package/dist/runtime/types/data-table/columns.d.ts +6 -14
- package/dist/runtime/types/data-table/component.d.ts +42 -1
- package/dist/runtime/types/data-table/index.d.ts +1 -1
- package/dist/runtime/types/data-table/pagination.d.ts +7 -8
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/locale.d.ts +82 -0
- package/dist/runtime/types/shared.d.ts +13 -0
- package/dist/runtime/types/zod-config.d.ts +38 -0
- package/dist/runtime/types/zod.d.ts +9 -1
- package/dist/runtime/utils/date/convert.d.ts +29 -0
- package/dist/runtime/utils/date/convert.js +93 -0
- package/dist/runtime/utils/date/guards.d.ts +10 -0
- package/dist/runtime/utils/date/guards.js +18 -0
- package/dist/runtime/utils/extend-theme.js +2 -1
- package/dist/runtime/utils/form-control.d.ts +0 -12
- package/dist/runtime/utils/form-control.js +3 -39
- package/dist/runtime/utils/interpolate.d.ts +2 -0
- package/dist/runtime/utils/interpolate.js +4 -0
- package/dist/runtime/utils/theme-defaults.d.ts +10 -0
- package/dist/runtime/utils/theme-defaults.js +9 -0
- package/dist/runtime/utils/tree-selection.d.ts +2 -15
- package/dist/runtime/utils/tv.d.ts +1 -1
- package/dist/runtime/vue/plugins/zod.d.ts +7 -0
- package/dist/runtime/vue/plugins/zod.js +12 -0
- package/dist/shared/{nuxt.DfVF6ZZv.mjs → nuxt.CbmfnBRt.mjs} +82 -236
- package/dist/unplugin.d.mts +3 -2
- package/dist/unplugin.mjs +22 -22
- package/dist/vite.d.mts +1 -0
- package/dist/vite.mjs +2 -1
- package/package.json +39 -34
- package/vue-plugin.d.ts +7 -1
- package/dist/runtime/components/ColorChooser.d.vue.ts +0 -36
- package/dist/runtime/components/ColorChooser.vue +0 -328
- package/dist/runtime/components/ColorChooser.vue.d.ts +0 -36
- package/dist/runtime/components/PillGroup.d.vue.ts +0 -33
- package/dist/runtime/components/PillGroup.vue +0 -291
- package/dist/runtime/components/PillGroup.vue.d.ts +0 -33
- package/dist/runtime/components/Popconfirm.d.vue.ts +0 -30
- package/dist/runtime/components/Popconfirm.vue +0 -143
- package/dist/runtime/components/Popconfirm.vue.d.ts +0 -30
- package/dist/runtime/components/SlideVerify.d.vue.ts +0 -41
- package/dist/runtime/components/SlideVerify.vue +0 -174
- package/dist/runtime/components/SlideVerify.vue.d.ts +0 -41
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +0 -32
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +0 -48
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithCharacterLimit.vue +0 -54
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +0 -32
- package/dist/runtime/components/input/WithClear.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithClear.vue +0 -60
- package/dist/runtime/components/input/WithClear.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithCopy.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithCopy.vue +0 -66
- package/dist/runtime/components/input/WithCopy.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +0 -33
- package/dist/runtime/components/input/WithFloatingLabel.vue +0 -75
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +0 -33
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +0 -32
- package/dist/runtime/components/input/WithPasswordToggle.vue +0 -61
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +0 -32
- package/dist/runtime/domains/api/interceptors/compose.d.ts +0 -24
- package/dist/runtime/domains/api/interceptors/compose.js +0 -18
- package/dist/runtime/domains/api/interceptors/error.d.ts +0 -13
- package/dist/runtime/domains/api/interceptors/error.js +0 -26
- package/dist/runtime/domains/api/interceptors/unauthorized.d.ts +0 -12
- package/dist/runtime/domains/api/interceptors/unauthorized.js +0 -34
- package/dist/runtime/domains/api/transfer.d.ts +0 -69
- package/dist/runtime/domains/api/transfer.js +0 -87
- package/dist/runtime/types/components/color-chooser.d.ts +0 -109
- package/dist/runtime/types/components/input/as-phone-number-input.d.ts +0 -17
- package/dist/runtime/types/components/input/index.d.ts +0 -6
- package/dist/runtime/types/components/input/index.js +0 -0
- package/dist/runtime/types/components/input/with-character-limit.d.ts +0 -11
- package/dist/runtime/types/components/input/with-character-limit.js +0 -0
- package/dist/runtime/types/components/input/with-clear.d.ts +0 -10
- package/dist/runtime/types/components/input/with-clear.js +0 -0
- package/dist/runtime/types/components/input/with-copy.d.ts +0 -11
- package/dist/runtime/types/components/input/with-copy.js +0 -0
- package/dist/runtime/types/components/input/with-floating-label.d.ts +0 -12
- package/dist/runtime/types/components/input/with-floating-label.js +0 -0
- package/dist/runtime/types/components/input/with-password-toggle.d.ts +0 -7
- package/dist/runtime/types/components/input/with-password-toggle.js +0 -0
- package/dist/runtime/types/components/pill-group.d.ts +0 -103
- package/dist/runtime/types/components/pill-group.js +0 -0
- package/dist/runtime/types/components/popconfirm.d.ts +0 -74
- package/dist/runtime/types/components/popconfirm.js +0 -0
- package/dist/runtime/types/components/slide-verify.d.ts +0 -54
- package/dist/runtime/types/components/slide-verify.js +0 -0
- /package/dist/runtime/types/{components/color-chooser.js → locale.js} +0 -0
- /package/dist/runtime/types/{components/input/as-phone-number-input.js → zod-config.js} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
autoForm: {
|
|
3
|
+
submit: "Submit",
|
|
4
|
+
add: "Add",
|
|
5
|
+
moveUp: "Move up",
|
|
6
|
+
moveDown: "Move down",
|
|
7
|
+
duplicate: "Duplicate",
|
|
8
|
+
remove: "Remove"
|
|
9
|
+
},
|
|
10
|
+
searchForm: {
|
|
11
|
+
search: "Search",
|
|
12
|
+
reset: "Reset",
|
|
13
|
+
expand: "Expand",
|
|
14
|
+
collapse: "Collapse"
|
|
15
|
+
},
|
|
16
|
+
dataTable: {
|
|
17
|
+
actions: "Actions",
|
|
18
|
+
selectAll: "Select all rows",
|
|
19
|
+
selectRow: "Select row",
|
|
20
|
+
selectParentRow: "Select parent row",
|
|
21
|
+
expandAll: "Expand all rows",
|
|
22
|
+
collapseAll: "Collapse all rows",
|
|
23
|
+
pinRow: "Pin row",
|
|
24
|
+
unpinRow: "Unpin row",
|
|
25
|
+
pinColumn: "Pin column",
|
|
26
|
+
unpinColumn: "Unpin column",
|
|
27
|
+
columnSettings: "Columns",
|
|
28
|
+
resetColumns: "Reset columns"
|
|
29
|
+
},
|
|
30
|
+
pagination: {
|
|
31
|
+
empty: "Showing 0",
|
|
32
|
+
total: "{total} items",
|
|
33
|
+
range: "Showing {from}-{to} of {total}",
|
|
34
|
+
rangeUnknown: "Showing {from}-{to}, page {page} of {pageCount}",
|
|
35
|
+
selected: "{count} selected",
|
|
36
|
+
pageSize: "{size} / page"
|
|
37
|
+
},
|
|
38
|
+
tree: {
|
|
39
|
+
empty: "No results",
|
|
40
|
+
loading: "Loading",
|
|
41
|
+
selected: "{count} selected",
|
|
42
|
+
selectAll: "Select all",
|
|
43
|
+
expandAll: "Expand all",
|
|
44
|
+
collapseAll: "Collapse all",
|
|
45
|
+
search: "Search nodes",
|
|
46
|
+
clearSearch: "Clear search",
|
|
47
|
+
loadError: "Failed to load",
|
|
48
|
+
searchError: "Search failed",
|
|
49
|
+
searchLoading: "Searching\u2026",
|
|
50
|
+
retry: "Retry"
|
|
51
|
+
},
|
|
52
|
+
datePicker: {
|
|
53
|
+
placeholder: "Select date",
|
|
54
|
+
clear: "Clear",
|
|
55
|
+
today: "Today",
|
|
56
|
+
yesterday: "Yesterday",
|
|
57
|
+
tomorrow: "Tomorrow",
|
|
58
|
+
thisWeek: "This week",
|
|
59
|
+
thisMonth: "This month",
|
|
60
|
+
last7Days: "Last 7 days",
|
|
61
|
+
last30Days: "Last 30 days"
|
|
62
|
+
},
|
|
63
|
+
messageBox: {
|
|
64
|
+
title: "Notice",
|
|
65
|
+
acknowledge: "OK",
|
|
66
|
+
confirm: "Confirm",
|
|
67
|
+
cancel: "Cancel"
|
|
68
|
+
},
|
|
69
|
+
validation: {
|
|
70
|
+
required: "This field is required",
|
|
71
|
+
requiredWithLabel: "{label} is required"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MovkMessageKey, MovkMessages } from '../types/locale';
|
|
2
|
+
import en from './en';
|
|
3
|
+
import zh_cn from './zh_cn';
|
|
4
|
+
export { en, zh_cn };
|
|
5
|
+
export type MovkTranslator = (key: MovkMessageKey, vars?: Record<string, string | number>) => string;
|
|
6
|
+
/** 按 Nuxt UI locale code 索引的内置字典 */
|
|
7
|
+
export declare const movkLocales: Record<string, MovkMessages>;
|
|
8
|
+
export declare function createTranslator(getMessages: () => MovkMessages): MovkTranslator;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { interpolate } from "../utils/interpolate.js";
|
|
2
|
+
import en from "./en.js";
|
|
3
|
+
import zh_cn from "./zh_cn.js";
|
|
4
|
+
export { en, zh_cn };
|
|
5
|
+
export const movkLocales = {
|
|
6
|
+
"en": en,
|
|
7
|
+
"zh-CN": zh_cn
|
|
8
|
+
};
|
|
9
|
+
export function createTranslator(getMessages) {
|
|
10
|
+
return (key, vars) => {
|
|
11
|
+
const [group, name] = key.split(".");
|
|
12
|
+
const message = getMessages()[group]?.[name];
|
|
13
|
+
return typeof message === "string" ? interpolate(message, vars) : key;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
autoForm: {
|
|
3
|
+
submit: string;
|
|
4
|
+
add: string;
|
|
5
|
+
moveUp: string;
|
|
6
|
+
moveDown: string;
|
|
7
|
+
duplicate: string;
|
|
8
|
+
remove: string;
|
|
9
|
+
};
|
|
10
|
+
searchForm: {
|
|
11
|
+
search: string;
|
|
12
|
+
reset: string;
|
|
13
|
+
expand: string;
|
|
14
|
+
collapse: string;
|
|
15
|
+
};
|
|
16
|
+
dataTable: {
|
|
17
|
+
actions: string;
|
|
18
|
+
selectAll: string;
|
|
19
|
+
selectRow: string;
|
|
20
|
+
selectParentRow: string;
|
|
21
|
+
expandAll: string;
|
|
22
|
+
collapseAll: string;
|
|
23
|
+
pinRow: string;
|
|
24
|
+
unpinRow: string;
|
|
25
|
+
pinColumn: string;
|
|
26
|
+
unpinColumn: string;
|
|
27
|
+
columnSettings: string;
|
|
28
|
+
resetColumns: string;
|
|
29
|
+
};
|
|
30
|
+
pagination: {
|
|
31
|
+
empty: string;
|
|
32
|
+
total: string;
|
|
33
|
+
range: string;
|
|
34
|
+
rangeUnknown: string;
|
|
35
|
+
selected: string;
|
|
36
|
+
pageSize: string;
|
|
37
|
+
};
|
|
38
|
+
tree: {
|
|
39
|
+
empty: string;
|
|
40
|
+
loading: string;
|
|
41
|
+
selected: string;
|
|
42
|
+
selectAll: string;
|
|
43
|
+
expandAll: string;
|
|
44
|
+
collapseAll: string;
|
|
45
|
+
search: string;
|
|
46
|
+
clearSearch: string;
|
|
47
|
+
loadError: string;
|
|
48
|
+
searchError: string;
|
|
49
|
+
searchLoading: string;
|
|
50
|
+
retry: string;
|
|
51
|
+
};
|
|
52
|
+
datePicker: {
|
|
53
|
+
placeholder: string;
|
|
54
|
+
clear: string;
|
|
55
|
+
today: string;
|
|
56
|
+
yesterday: string;
|
|
57
|
+
tomorrow: string;
|
|
58
|
+
thisWeek: string;
|
|
59
|
+
thisMonth: string;
|
|
60
|
+
last7Days: string;
|
|
61
|
+
last30Days: string;
|
|
62
|
+
};
|
|
63
|
+
messageBox: {
|
|
64
|
+
title: string;
|
|
65
|
+
acknowledge: string;
|
|
66
|
+
confirm: string;
|
|
67
|
+
cancel: string;
|
|
68
|
+
};
|
|
69
|
+
validation: {
|
|
70
|
+
required: string;
|
|
71
|
+
requiredWithLabel: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export default _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
autoForm: {
|
|
3
|
+
submit: "\u63D0\u4EA4",
|
|
4
|
+
add: "\u6DFB\u52A0",
|
|
5
|
+
moveUp: "\u4E0A\u79FB",
|
|
6
|
+
moveDown: "\u4E0B\u79FB",
|
|
7
|
+
duplicate: "\u590D\u5236",
|
|
8
|
+
remove: "\u5220\u9664"
|
|
9
|
+
},
|
|
10
|
+
searchForm: {
|
|
11
|
+
search: "\u641C\u7D22",
|
|
12
|
+
reset: "\u91CD\u7F6E",
|
|
13
|
+
expand: "\u5C55\u5F00",
|
|
14
|
+
collapse: "\u6536\u8D77"
|
|
15
|
+
},
|
|
16
|
+
dataTable: {
|
|
17
|
+
actions: "\u64CD\u4F5C",
|
|
18
|
+
selectAll: "\u5168\u9009",
|
|
19
|
+
selectRow: "\u9009\u62E9\u884C",
|
|
20
|
+
selectParentRow: "\u9009\u62E9\u7236\u884C",
|
|
21
|
+
expandAll: "\u5C55\u5F00\u5168\u90E8",
|
|
22
|
+
collapseAll: "\u6298\u53E0\u5168\u90E8",
|
|
23
|
+
pinRow: "\u56FA\u5B9A\u884C",
|
|
24
|
+
unpinRow: "\u53D6\u6D88\u56FA\u5B9A\u884C",
|
|
25
|
+
pinColumn: "\u56FA\u5B9A\u5217",
|
|
26
|
+
unpinColumn: "\u53D6\u6D88\u56FA\u5B9A\u5217",
|
|
27
|
+
columnSettings: "\u5217\u8BBE\u7F6E",
|
|
28
|
+
resetColumns: "\u91CD\u7F6E\u5217"
|
|
29
|
+
},
|
|
30
|
+
pagination: {
|
|
31
|
+
empty: "\u663E\u793A 0",
|
|
32
|
+
total: "\u5171 {total} \u6761",
|
|
33
|
+
range: "\u663E\u793A {from}-{to}\uFF0C\u5171 {total} \u6761",
|
|
34
|
+
rangeUnknown: "\u663E\u793A {from}-{to}\uFF0C\u7B2C {page} / {pageCount} \u9875",
|
|
35
|
+
selected: "\u5DF2\u9009 {count} \u6761",
|
|
36
|
+
pageSize: "{size} \u6761/\u9875"
|
|
37
|
+
},
|
|
38
|
+
tree: {
|
|
39
|
+
empty: "\u65E0\u5339\u914D\u7ED3\u679C",
|
|
40
|
+
loading: "\u52A0\u8F7D\u4E2D",
|
|
41
|
+
selected: "\u5DF2\u9009 {count}",
|
|
42
|
+
selectAll: "\u5168\u9009",
|
|
43
|
+
expandAll: "\u5C55\u5F00\u5168\u90E8",
|
|
44
|
+
collapseAll: "\u6298\u53E0\u5168\u90E8",
|
|
45
|
+
search: "\u641C\u7D22\u8282\u70B9",
|
|
46
|
+
clearSearch: "\u6E05\u9664\u641C\u7D22",
|
|
47
|
+
loadError: "\u52A0\u8F7D\u5931\u8D25",
|
|
48
|
+
searchError: "\u641C\u7D22\u5931\u8D25",
|
|
49
|
+
searchLoading: "\u6B63\u5728\u641C\u7D22\u2026",
|
|
50
|
+
retry: "\u91CD\u8BD5"
|
|
51
|
+
},
|
|
52
|
+
datePicker: {
|
|
53
|
+
placeholder: "\u9009\u62E9\u65E5\u671F",
|
|
54
|
+
clear: "\u6E05\u9664",
|
|
55
|
+
today: "\u4ECA\u5929",
|
|
56
|
+
yesterday: "\u6628\u5929",
|
|
57
|
+
tomorrow: "\u660E\u5929",
|
|
58
|
+
thisWeek: "\u672C\u5468",
|
|
59
|
+
thisMonth: "\u672C\u6708",
|
|
60
|
+
last7Days: "\u6700\u8FD1 7 \u5929",
|
|
61
|
+
last30Days: "\u6700\u8FD1 30 \u5929"
|
|
62
|
+
},
|
|
63
|
+
messageBox: {
|
|
64
|
+
title: "\u63D0\u793A",
|
|
65
|
+
acknowledge: "\u77E5\u9053\u4E86",
|
|
66
|
+
confirm: "\u786E\u8BA4",
|
|
67
|
+
cancel: "\u53D6\u6D88"
|
|
68
|
+
},
|
|
69
|
+
validation: {
|
|
70
|
+
required: "\u6B64\u9879\u4E3A\u5FC5\u586B",
|
|
71
|
+
requiredWithLabel: "{label}\u4E3A\u5FC5\u586B"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import { resolveEndpointConfig } from "../domains/api/endpoint-config.js";
|
|
2
|
-
import {
|
|
3
|
-
import { createOnResponse } from "../domains/api/interceptors/response.js";
|
|
4
|
-
import { createOnResponseError } from "../domains/api/interceptors/error.js";
|
|
5
|
-
import { attachInterceptors } from "../domains/api/interceptors/compose.js";
|
|
2
|
+
import { createApiClient } from "../domains/api/client.js";
|
|
6
3
|
import { openEventStream } from "../domains/api/stream.js";
|
|
7
4
|
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "#imports";
|
|
8
|
-
function createEndpointFetch(resolvedConfig, publicConfig, nuxtApp) {
|
|
9
|
-
const interceptors = {
|
|
10
|
-
onRequest: createOnRequest(resolvedConfig, publicConfig, nuxtApp),
|
|
11
|
-
onResponse: createOnResponse(resolvedConfig, publicConfig, nuxtApp),
|
|
12
|
-
onResponseError: createOnResponseError(resolvedConfig, publicConfig, nuxtApp)
|
|
13
|
-
};
|
|
14
|
-
const instance = $fetch.create({
|
|
15
|
-
baseURL: resolvedConfig.baseURL,
|
|
16
|
-
headers: resolvedConfig.headers,
|
|
17
|
-
...interceptors
|
|
18
|
-
});
|
|
19
|
-
attachInterceptors(instance, interceptors);
|
|
20
|
-
return instance;
|
|
21
|
-
}
|
|
22
5
|
export default defineNuxtPlugin(() => {
|
|
23
6
|
const nuxtApp = useNuxtApp();
|
|
24
7
|
const runtimeConfig = useRuntimeConfig();
|
|
@@ -33,11 +16,11 @@ export default defineNuxtPlugin(() => {
|
|
|
33
16
|
console.warn(`[@movk/nuxt] Endpoint "${endpointName}" not found, using default`);
|
|
34
17
|
return getOrCreateEndpoint(defaultEndpoint);
|
|
35
18
|
}
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const apiInstance = Object.assign(
|
|
19
|
+
const config = resolveEndpointConfig(publicConfig, endpointName, privateEndpoints);
|
|
20
|
+
const client = createApiClient({ endpoint: endpointName, config, publicConfig, nuxtApp });
|
|
21
|
+
const apiInstance = Object.assign(client, {
|
|
39
22
|
use: (endpoint) => getOrCreateEndpoint(endpoint),
|
|
40
|
-
stream: (url, options) => openEventStream(
|
|
23
|
+
stream: (url, options) => openEventStream(client, url, options)
|
|
41
24
|
});
|
|
42
25
|
endpointCache.set(endpointName, apiInstance);
|
|
43
26
|
return apiInstance;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { kebabCase } from "@movk/core";
|
|
2
2
|
import { defineNuxtPlugin, useAppConfig, useHead, useSiteConfig } from "#imports";
|
|
3
|
+
import { createColorSwapScript } from "../domains/theme/theme-fouc.js";
|
|
3
4
|
import { resolveThemeIcons } from "../domains/theme/theme-icons.js";
|
|
4
5
|
export default defineNuxtPlugin({
|
|
5
6
|
enforce: "post",
|
|
6
7
|
setup() {
|
|
7
8
|
const appConfig = useAppConfig();
|
|
8
9
|
const site = useSiteConfig();
|
|
9
|
-
const name = kebabCase(site.name);
|
|
10
|
+
const name = kebabCase(site.name ?? "movk");
|
|
10
11
|
if (import.meta.client) {
|
|
11
12
|
const primary = localStorage.getItem(`${name}-ui-primary`);
|
|
12
13
|
if (primary) appConfig.ui.colors.primary = primary;
|
|
@@ -18,47 +19,8 @@ export default defineNuxtPlugin({
|
|
|
18
19
|
if (import.meta.server) {
|
|
19
20
|
useHead({
|
|
20
21
|
script: [{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var primaryColor = localStorage.getItem('${name}-ui-primary');
|
|
24
|
-
var neutralColor = localStorage.getItem('${name}-ui-neutral');
|
|
25
|
-
if (!primaryColor && !neutralColor) return;
|
|
26
|
-
function swapColors(el) {
|
|
27
|
-
var html = el.innerHTML;
|
|
28
|
-
if (primaryColor && primaryColor !== 'black') {
|
|
29
|
-
html = html.replace(
|
|
30
|
-
/(--ui-color-primary-\\d{2,3}:\\s*var\\(--color-)${appConfig.ui.colors.primary}(-\\d{2,3}.*?\\))/g,
|
|
31
|
-
\`$1\${primaryColor}$2\`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
if (neutralColor) {
|
|
35
|
-
html = html.replace(
|
|
36
|
-
/(--ui-color-neutral-\\d{2,3}:\\s*var\\(--color-)${appConfig.ui.colors.neutral}(-\\d{2,3}.*?\\))/g,
|
|
37
|
-
\`$1\${neutralColor === 'neutral' ? 'old-neutral' : neutralColor}$2\`
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
el.innerHTML = html;
|
|
41
|
-
}
|
|
42
|
-
var colorsEl = document.querySelector('style#nuxt-ui-colors');
|
|
43
|
-
if (colorsEl) {
|
|
44
|
-
swapColors(colorsEl);
|
|
45
|
-
} else {
|
|
46
|
-
var obs = new MutationObserver(function(mutations) {
|
|
47
|
-
for (var i = 0; i < mutations.length; i++) {
|
|
48
|
-
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
|
|
49
|
-
var node = mutations[i].addedNodes[j];
|
|
50
|
-
if (node.id === 'nuxt-ui-colors') {
|
|
51
|
-
swapColors(node);
|
|
52
|
-
obs.disconnect();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
obs.observe(document.head, { childList: true });
|
|
59
|
-
}
|
|
60
|
-
})();
|
|
61
|
-
`.replace(/\s+/g, " "),
|
|
22
|
+
// 与 @nuxt/ui colors 插件生成色板变量时读取的 prefix 保持一致
|
|
23
|
+
innerHTML: createColorSwapScript(name, appConfig.ui.prefix),
|
|
62
24
|
type: "text/javascript",
|
|
63
25
|
tagPriority: -1
|
|
64
26
|
}, {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#imports";
|
|
2
|
+
import { zodLocales, zodOptions } from "#build/movk-zod";
|
|
3
|
+
import { installZod } from "../domains/zod/apply.js";
|
|
4
|
+
import { ZOD_FORM_CONTEXT } from "../domains/zod/sync.js";
|
|
5
|
+
export default defineNuxtPlugin({
|
|
6
|
+
name: "movk:zod",
|
|
7
|
+
setup(nuxtApp) {
|
|
8
|
+
if (!zodOptions) return;
|
|
9
|
+
const options = zodOptions;
|
|
10
|
+
const locales = zodLocales;
|
|
11
|
+
const runtime = {};
|
|
12
|
+
installZod(options, locales);
|
|
13
|
+
nuxtApp.vueApp.provide(ZOD_FORM_CONTEXT, { options, locales, runtime });
|
|
14
|
+
nuxtApp.hook("app:created", () => nuxtApp.callHook("movk:zod:config", runtime));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -25,6 +25,18 @@ export interface ApiResponseConfig {
|
|
|
25
25
|
* @defaultValue 'data'
|
|
26
26
|
*/
|
|
27
27
|
dataKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* 是否按 successCodes 校验业务状态码,关闭后任何 2xx 响应都视为成功
|
|
30
|
+
* @description 请求级 `businessCheck` 显式值优先
|
|
31
|
+
* @defaultValue true
|
|
32
|
+
*/
|
|
33
|
+
businessCheck?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 是否按 dataKey 解包业务数据,关闭后调用方拿到原始响应体
|
|
36
|
+
* @description 请求级 `unwrap` 显式值优先;裸资源端点(直接返回数组 / 对象)同时关闭 businessCheck 与 unwrap
|
|
37
|
+
* @defaultValue true
|
|
38
|
+
*/
|
|
39
|
+
unwrap?: boolean;
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* API 认证配置
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { $Fetch, AvailableRouterMethod } from 'nitropack/types';
|
|
2
2
|
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
-
import type { FetchError } from 'ofetch';
|
|
4
3
|
import type { UseFetchOptions as NuxtUseFetchOptions, AsyncData } from 'nuxt/app';
|
|
5
|
-
import type {
|
|
4
|
+
import type { ApiError, ApiRequestOptions } from './response';
|
|
6
5
|
import type { ApiStreamOptions } from './stream';
|
|
7
6
|
/**
|
|
8
7
|
* 端点名声明合并入口
|
|
@@ -34,26 +33,14 @@ export type ApiInstance = $Fetch & {
|
|
|
34
33
|
* @template T - 业务数据类型(已解包)
|
|
35
34
|
* @template DataT - transform 转换后的类型(默认等于 T)
|
|
36
35
|
*/
|
|
37
|
-
export type UseApiFetchOptions<T = unknown, DataT = T> = Omit<NuxtUseFetchOptions<T, DataT>, '$fetch' | '
|
|
36
|
+
export type UseApiFetchOptions<T = unknown, DataT = T> = Omit<NuxtUseFetchOptions<T, DataT>, '$fetch' | 'method' | keyof ApiRequestOptions> & ApiRequestOptions & {
|
|
38
37
|
/** 请求方法;请求经端点 baseURL 发往外部服务,不按本地 Nitro 路由收窄 */
|
|
39
38
|
method?: MaybeRefOrGetter<AvailableRouterMethod<string> | Uppercase<AvailableRouterMethod<string>>>;
|
|
40
39
|
/** 使用的端点名称(默认使用 defaultEndpoint) */
|
|
41
40
|
endpoint?: MovkApiEndpointName;
|
|
42
|
-
/** Toast 提示配置,设置为 false 禁用提示 */
|
|
43
|
-
toast?: RequestToastOptions | false;
|
|
44
|
-
/**
|
|
45
|
-
* 是否跳过业务状态码检查
|
|
46
|
-
* @description 仅跳过 code 校验,仍解包;与 skipUnwrap 正交。
|
|
47
|
-
*/
|
|
48
|
-
skipBusinessCheck?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* 是否跳过数据解包
|
|
51
|
-
* @description 为 true 时返回原始响应;与 skipBusinessCheck 正交。
|
|
52
|
-
*/
|
|
53
|
-
skipUnwrap?: boolean;
|
|
54
41
|
};
|
|
55
42
|
/**
|
|
56
43
|
* useApiFetch 返回值类型
|
|
57
44
|
* @template DataT - 最终数据类型
|
|
58
45
|
*/
|
|
59
|
-
export type UseApiFetchReturn<DataT> = AsyncData<DataT | null,
|
|
46
|
+
export type UseApiFetchReturn<DataT> = AsyncData<DataT | null, ApiError | null>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { ApiAuthConfig, ApiEndpointPublicConfig, ApiResponseConfig, ApiToastConfig } from './config';
|
|
2
2
|
export type { MovkApiPublicConfig } from './module';
|
|
3
|
-
export type { ApiError, ApiResponse, RequestToastOptions } from './response';
|
|
3
|
+
export type { ApiError, ApiErrorData, ApiErrorKind, ApiRequestOptions, ApiResponse, RequestToastOptions } from './response';
|
|
4
4
|
export type { ApiInstance, MovkApiEndpointName, MovkApiEndpoints, UseApiFetchOptions, UseApiFetchReturn } from './fetch';
|
|
5
5
|
export type { TransferRequestOptions, TransferResult, TransferStatus } from './transfer';
|
|
6
6
|
export type { ApiStreamOptions, ApiStreamStatus, EventStreamOptions, UseApiStreamOptions } from './stream';
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
import type { NuxtError } from 'nuxt/app';
|
|
1
2
|
import type { ApiToast } from './config';
|
|
2
3
|
declare module 'ofetch' {
|
|
3
4
|
interface FetchOptions {
|
|
4
|
-
|
|
5
|
+
toast?: ApiRequestOptions['toast'];
|
|
6
|
+
businessCheck?: ApiRequestOptions['businessCheck'];
|
|
7
|
+
unwrap?: ApiRequestOptions['unwrap'];
|
|
5
8
|
}
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
11
|
+
* 请求级选项
|
|
12
|
+
* @description `$api`、`useApiFetch`、上传下载与流式请求共用;未传的字段继承端点 / 全局 `response` 配置
|
|
10
13
|
*/
|
|
11
|
-
export interface
|
|
14
|
+
export interface ApiRequestOptions {
|
|
12
15
|
/** Toast 提示配置,设置为 false 禁用提示 */
|
|
13
16
|
toast?: RequestToastOptions | false;
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @description
|
|
18
|
+
* 是否按 successCodes 校验业务状态码
|
|
19
|
+
* @description 未传时继承端点 / 全局 `response.businessCheck`;显式值可覆盖端点配置
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
businessCheck?: boolean;
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @description
|
|
23
|
+
* 是否按 dataKey 解包业务数据
|
|
24
|
+
* @description 未传时继承端点 / 全局 `response.unwrap`;为 false 时拿到原始响应体
|
|
22
25
|
*/
|
|
23
|
-
|
|
26
|
+
unwrap?: boolean;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* 请求级别的 Toast 提示选项
|
|
@@ -49,14 +52,25 @@ export interface ApiResponse {
|
|
|
49
52
|
[key: string]: unknown;
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @description
|
|
55
|
+
* 错误分类
|
|
56
|
+
* @description business:业务码校验失败;http:HTTP 4xx/5xx;network:请求未拿到响应;timeout:超时;aborted:主动中止
|
|
54
57
|
*/
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
58
|
+
export type ApiErrorKind = 'business' | 'http' | 'network' | 'timeout' | 'aborted';
|
|
59
|
+
/**
|
|
60
|
+
* API 错误附带数据,挂在 `error.data` 上
|
|
61
|
+
*/
|
|
62
|
+
export interface ApiErrorData {
|
|
63
|
+
/** 错误分类 */
|
|
64
|
+
kind: ApiErrorKind;
|
|
65
|
+
/** 发起请求的端点名称 */
|
|
66
|
+
endpoint: string;
|
|
67
|
+
/** 业务码(business)或 HTTP 状态码(http) */
|
|
68
|
+
code?: number | string;
|
|
69
|
+
/** 原始响应体 */
|
|
70
|
+
response?: unknown;
|
|
62
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* API 错误
|
|
74
|
+
* @description 所有失败统一为 NuxtError,经 useAsyncData 时原样保留;按 `error.data.kind` 区分场景
|
|
75
|
+
*/
|
|
76
|
+
export type ApiError = NuxtError<ApiErrorData>;
|
|
@@ -14,9 +14,8 @@ export interface EventStreamOptions<T> {
|
|
|
14
14
|
/**
|
|
15
15
|
* `$api.stream()` 选项
|
|
16
16
|
*
|
|
17
|
-
* @description
|
|
18
|
-
*
|
|
19
|
-
* - 不强制 `responseType: 'stream'` 才能让 JSON 错误信封走完业务码校验;网关把流标成非 SSE 类型时再显式传
|
|
17
|
+
* @description 默认 `responseType: 'stream'`,JSON 错误信封仍由拦截器还原后走业务码校验;
|
|
18
|
+
* `Accept` 默认通配,部分网关(如 DRF)按 `Accept` 做内容协商,收到 `text/event-stream` 会直接拒掉整个请求
|
|
20
19
|
*/
|
|
21
20
|
export type ApiStreamOptions<T = unknown> = FetchOptions & EventStreamOptions<T>;
|
|
22
21
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MovkApiEndpointName } from './fetch';
|
|
2
|
-
import type { ApiError,
|
|
2
|
+
import type { ApiError, ApiRequestOptions } from './response';
|
|
3
3
|
/**
|
|
4
4
|
* 传输状态
|
|
5
5
|
* @description idle 初始;pending 进行中;success 成功;error 失败;aborted 已中止
|
|
@@ -13,20 +13,16 @@ export interface TransferResult<T = unknown> {
|
|
|
13
13
|
/** 业务数据(已按 dataKey 解包);失败或中止时为 null */
|
|
14
14
|
data: T | null;
|
|
15
15
|
/** 错误对象;成功或中止时为 null */
|
|
16
|
-
error: ApiError |
|
|
16
|
+
error: ApiError | null;
|
|
17
17
|
/** 是否因调用方主动 abort 而结束 */
|
|
18
18
|
aborted: boolean;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* 传输请求公共选项
|
|
22
22
|
*/
|
|
23
|
-
export interface TransferRequestOptions {
|
|
23
|
+
export interface TransferRequestOptions extends ApiRequestOptions {
|
|
24
24
|
/** 端点名称,未指定时使用 defaultEndpoint */
|
|
25
25
|
endpoint?: MovkApiEndpointName;
|
|
26
26
|
/** 额外的请求头(覆盖同名 auth 头) */
|
|
27
27
|
headers?: Record<string, string>;
|
|
28
|
-
/** Toast 配置,设置为 false 整体禁用 */
|
|
29
|
-
toast?: RequestToastOptions | false;
|
|
30
|
-
/** 跳过业务码校验(仍按 dataKey 解包),与 useApiFetch.skipBusinessCheck 同义 */
|
|
31
|
-
skipBusinessCheck?: boolean;
|
|
32
28
|
}
|
|
@@ -4,7 +4,7 @@ import type { OmitByKey } from '@movk/core';
|
|
|
4
4
|
import type { AutoFormControls } from './controls';
|
|
5
5
|
import type { ZodAutoFormFieldMeta } from '../zod';
|
|
6
6
|
import type { ClassNameValue } from '../shared';
|
|
7
|
-
export interface BaseAutoFormProps<S extends z.ZodObject, T extends boolean = true, N extends boolean = false> extends /** @vue-ignore */ OmitByKey<FormProps<S, T, N>, 'schema' | 'state' | 'loadingAuto' | 'validateOn' | 'ui'> {
|
|
7
|
+
export interface BaseAutoFormProps<S extends z.ZodObject, T extends boolean = true, N extends boolean = false> extends /** @vue-ignore */ OmitByKey<FormProps<S, T, N>, 'schema' | 'state' | 'loadingAuto' | 'validateOn' | 'ui' | 'onSubmit'> {
|
|
8
8
|
/** Zod 对象 schema,定义表单字段 */
|
|
9
9
|
schema: S;
|
|
10
10
|
/** 自定义控件映射 */
|
|
@@ -21,6 +21,14 @@ export interface BaseAutoFormProps<S extends z.ZodObject, T extends boolean = tr
|
|
|
21
21
|
* @defaultValue []
|
|
22
22
|
*/
|
|
23
23
|
validateOn?: FormProps<S, T, N>['validateOn'];
|
|
24
|
+
/**
|
|
25
|
+
* 字段被 `meta.if` 隐藏时如何处理其值:`keep` 保留,`clear` 置为 `undefined`;字段 meta 的 `hiddenValue` 优先。
|
|
26
|
+
* 无论哪种策略,隐藏字段都不参与校验,也不出现在提交数据中
|
|
27
|
+
* @defaultValue 'keep'
|
|
28
|
+
*/
|
|
29
|
+
hiddenValue?: 'keep' | 'clear';
|
|
30
|
+
/** 提交回调;返回 Promise 时配合 `loadingAuto` 显示加载状态 */
|
|
31
|
+
onSubmit?: FormProps<S, T, N>['onSubmit'];
|
|
24
32
|
class?: ClassNameValue;
|
|
25
33
|
ui?: Record<string, ClassNameValue>;
|
|
26
34
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type { ButtonProps, FormProps, FormSubmitEvent, FormData, FormErrorEvent } from '@nuxt/ui';
|
|
1
|
+
import type { ButtonProps, Form, FormProps, FormSubmitEvent, FormData, FormErrorEvent } from '@nuxt/ui';
|
|
2
2
|
import type { z } from 'zod';
|
|
3
3
|
import type { BaseAutoFormProps } from './base';
|
|
4
4
|
import type { AutoFormSlotProps, DynamicFormSlots } from './slots';
|
|
5
5
|
import type { VNode } from 'vue';
|
|
6
6
|
export interface AutoFormProps<S extends z.ZodObject = z.ZodObject, T extends boolean = true, N extends boolean = false> extends BaseAutoFormProps<S, T, N> {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* 表单状态对象,原地修改。
|
|
9
|
+
* @deprecated 改用 `v-model`
|
|
10
|
+
*/
|
|
8
11
|
state?: FormProps<S, T, N>['state'];
|
|
12
|
+
/** 外部 loading 状态,与 `loadingAuto` 的提交中状态合并 */
|
|
13
|
+
loading?: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* 是否显示默认提交按钮
|
|
11
16
|
* @defaultValue true
|
|
@@ -18,8 +23,31 @@ export interface AutoFormProps<S extends z.ZodObject = z.ZodObject, T extends bo
|
|
|
18
23
|
}
|
|
19
24
|
export type AutoFormSubmitHandler<S extends z.ZodObject, T extends boolean = true> = (event: FormSubmitEvent<FormData<S, T>>) => void;
|
|
20
25
|
export type AutoFormErrorHandler = (event: FormErrorEvent) => void;
|
|
21
|
-
export interface AutoFormEmits {
|
|
26
|
+
export interface AutoFormEmits<S extends z.ZodObject = z.ZodObject> {
|
|
22
27
|
error: [FormErrorEvent];
|
|
28
|
+
/** 重置后的状态快照(基线加字段默认值) */
|
|
29
|
+
reset: [state: Partial<z.input<S>>];
|
|
30
|
+
/** 清空后的状态快照(仅字段默认值) */
|
|
31
|
+
clear: [state: Partial<z.input<S>>];
|
|
32
|
+
}
|
|
33
|
+
/** AutoForm 与 SearchForm 共同的实例方法 */
|
|
34
|
+
export interface AutoFormExposed<S extends z.ZodObject = z.ZodObject> {
|
|
35
|
+
formRef: Form<S> | null;
|
|
36
|
+
/** 触发校验并提交 */
|
|
37
|
+
submit: () => Promise<void>;
|
|
38
|
+
validate: Form<S>['validate'];
|
|
39
|
+
/** 原地恢复为基线并应用字段默认值 */
|
|
40
|
+
reset: () => void;
|
|
41
|
+
/** 原地清空为仅含字段默认值的状态 */
|
|
42
|
+
clear: () => void;
|
|
43
|
+
/** 以当前状态(或传入值)作为 reset 与 dirty 比较的基线 */
|
|
44
|
+
setBaseline: (state?: Partial<z.input<S>>) => void;
|
|
45
|
+
/** 是否有字段相对基线发生变化 */
|
|
46
|
+
isDirty: boolean;
|
|
47
|
+
/** 相对基线发生变化的字段路径 */
|
|
48
|
+
dirtyFields: string[];
|
|
49
|
+
getFieldValue: (path: string) => unknown;
|
|
50
|
+
setFieldValue: (path: string, value: unknown) => void;
|
|
23
51
|
}
|
|
24
52
|
export type AutoFormSlots<T extends object> = {
|
|
25
53
|
header(props: AutoFormSlotProps<T>): VNode[];
|