@movk/nuxt 1.1.2 → 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 +75 -104
- package/dist/module.d.mts +59 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +136 -56
- package/dist/runtime/components/AutoForm.d.vue.ts +10 -31
- package/dist/runtime/components/AutoForm.vue +114 -148
- package/dist/runtime/components/AutoForm.vue.d.ts +10 -31
- package/dist/runtime/components/ColorChooser.d.vue.ts +20 -17
- package/dist/runtime/components/ColorChooser.vue +305 -31
- package/dist/runtime/components/ColorChooser.vue.d.ts +20 -17
- 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 +15 -22
- package/dist/runtime/components/DatePicker.vue +173 -65
- package/dist/runtime/components/DatePicker.vue.d.ts +15 -22
- 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 +43 -0
- package/dist/runtime/components/SearchForm.vue +274 -0
- package/dist/runtime/components/SearchForm.vue.d.ts +43 -0
- package/dist/runtime/components/SlideVerify.d.vue.ts +13 -79
- package/dist/runtime/components/SlideVerify.vue +117 -90
- package/dist/runtime/components/SlideVerify.vue.d.ts +13 -79
- package/dist/runtime/components/StarRating.d.vue.ts +25 -82
- package/dist/runtime/components/StarRating.vue +128 -99
- package/dist/runtime/components/StarRating.vue.d.ts +25 -82
- package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +32 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue +48 -0
- package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +32 -0
- package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCharacterLimit.vue +27 -15
- package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithClear.d.vue.ts +11 -5
- package/dist/runtime/components/input/WithClear.vue +29 -10
- package/dist/runtime/components/input/WithClear.vue.d.ts +11 -5
- package/dist/runtime/components/input/WithCopy.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithCopy.vue +28 -11
- package/dist/runtime/components/input/WithCopy.vue.d.ts +13 -7
- package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +33 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue +75 -0
- package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +33 -0
- package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +13 -7
- package/dist/runtime/components/input/WithPasswordToggle.vue +27 -10
- package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +13 -7
- package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePicker.vue +37 -28
- package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +8 -1
- package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +5 -6
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue +4 -0
- package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +5 -6
- package/dist/runtime/composables/index.d.ts +9 -8
- package/dist/runtime/composables/index.js +2 -1
- package/dist/runtime/composables/useApiFetch.d.ts +23 -15
- package/dist/runtime/composables/useApiFetch.js +21 -28
- package/dist/runtime/composables/useAutoForm.d.ts +14 -98
- package/dist/runtime/composables/useAutoForm.js +55 -161
- package/dist/runtime/composables/useClientApiFetch.d.ts +7 -7
- 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 +143 -42
- package/dist/runtime/composables/useLazyApiFetch.d.ts +19 -0
- package/dist/runtime/composables/useLazyApiFetch.js +4 -0
- package/dist/runtime/composables/useMessageBox.d.ts +6 -0
- package/dist/runtime/composables/useMessageBox.js +16 -0
- package/dist/runtime/composables/useTheme.d.ts +21 -8
- package/dist/runtime/composables/useTheme.js +109 -86
- package/dist/runtime/composables/useUploadWithProgress.d.ts +22 -28
- package/dist/runtime/composables/useUploadWithProgress.js +79 -68
- 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} +37 -48
- 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/domains/auto-form/components/Children.vue +50 -0
- 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/domains/auto-form/components/Layout.vue +89 -0
- 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/domains/auto-form/components/Nested.vue +47 -0
- package/dist/runtime/domains/auto-form/components/Nested.vue.d.ts +11 -0
- package/dist/runtime/{constants/auto-form.d.ts → domains/auto-form/constants.d.ts} +0 -2
- package/dist/runtime/{constants/auto-form.js → domains/auto-form/constants.js} +0 -25
- package/dist/runtime/domains/auto-form/controls.d.ts +41 -0
- package/dist/runtime/domains/auto-form/controls.js +73 -0
- package/dist/runtime/{utils/field-utils.d.ts → domains/auto-form/fields.d.ts} +7 -21
- package/dist/runtime/{utils/field-utils.js → domains/auto-form/fields.js} +19 -4
- package/dist/runtime/domains/auto-form/metadata.d.ts +22 -0
- package/dist/runtime/domains/auto-form/metadata.js +53 -0
- package/dist/runtime/domains/auto-form/provider.d.ts +62 -0
- package/dist/runtime/{internal/useAutoFormProvider.js → domains/auto-form/provider.js} +6 -3
- package/dist/runtime/domains/auto-form/reactive.d.ts +12 -0
- package/dist/runtime/{utils/reactive-utils.js → domains/auto-form/reactive.js} +1 -1
- package/dist/runtime/domains/auto-form/schema.d.ts +7 -0
- package/dist/runtime/{utils/schema-introspector.js → domains/auto-form/schema.js} +12 -10
- 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 +28 -171
- package/dist/runtime/plugins/theme.js +72 -70
- 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/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 +19 -17
- 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 +4 -0
- package/dist/runtime/utils/meta.js +14 -0
- 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 +82 -42
- package/vue-plugin.d.ts +5 -0
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +0 -55
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +0 -125
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +0 -20
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +0 -105
- package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +0 -20
- package/dist/runtime/composables/useApiAuth.d.ts +0 -47
- package/dist/runtime/composables/useApiAuth.js +0 -66
- package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
- package/dist/runtime/schemas/api.d.ts +0 -590
- package/dist/runtime/schemas/api.js +0 -228
- package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
- package/dist/runtime/server/api/_movk/session.post.js +0 -18
- package/dist/runtime/style.css +0 -1
- package/dist/runtime/types/api.d.ts +0 -218
- package/dist/runtime/types/auth.d.ts +0 -34
- package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
- package/dist/runtime/types/auto-form.d.ts +0 -548
- package/dist/runtime/types/components.d.ts +0 -43
- package/dist/runtime/types/module.d.ts +0 -39
- package/dist/runtime/utils/api-utils.d.ts +0 -79
- package/dist/runtime/utils/api-utils.js +0 -127
- package/dist/runtime/utils/auto-form.d.ts +0 -3
- package/dist/runtime/utils/auto-form.js +0 -18
- package/dist/runtime/utils/reactive-utils.d.ts +0 -30
- package/dist/runtime/utils/schema-introspector.d.ts +0 -13
- /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-renderer.js → api/fetch.js} +0 -0
- /package/dist/runtime/types/{auto-form.js → api/index.js} +0 -0
- /package/dist/runtime/types/{module.js → api/module.js} +0 -0
- /package/dist/runtime/types/{components.js → api/response.js} +0 -0
|
@@ -1,42 +1,135 @@
|
|
|
1
|
-
import { ref, useNuxtApp } 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
|
-
const
|
|
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
|
-
|
|
20
|
-
|
|
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
|
+
});
|
|
21
43
|
progress.value = 0;
|
|
22
|
-
|
|
44
|
+
status.value = "pending";
|
|
45
|
+
data.value = null;
|
|
23
46
|
error.value = null;
|
|
24
|
-
|
|
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
|
+
}
|
|
25
64
|
try {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
headers:
|
|
30
|
-
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
|
|
31
69
|
});
|
|
70
|
+
const contentType = response.headers.get("content-type") || "";
|
|
71
|
+
const isJson = contentType.toLowerCase().includes("application/json");
|
|
32
72
|
if (!response.ok) {
|
|
33
|
-
|
|
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;
|
|
34
126
|
}
|
|
35
127
|
const contentLength = response.headers.get("content-length");
|
|
36
128
|
const total = contentLength ? Number.parseInt(contentLength, 10) : 0;
|
|
37
|
-
const finalFilename =
|
|
129
|
+
const finalFilename = resolveFilename(response.headers, urlStr, filename);
|
|
38
130
|
const reader = response.body?.getReader();
|
|
39
131
|
if (!reader) throw new Error("\u65E0\u6CD5\u8BFB\u53D6\u54CD\u5E94\u6D41");
|
|
132
|
+
if (total <= 0) progress.value = null;
|
|
40
133
|
const chunks = [];
|
|
41
134
|
let received = 0;
|
|
42
135
|
while (true) {
|
|
@@ -46,35 +139,43 @@ export function useDownloadWithProgress() {
|
|
|
46
139
|
received += value.length;
|
|
47
140
|
if (total > 0) progress.value = Math.round(received / total * 100);
|
|
48
141
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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;
|
|
52
154
|
progress.value = 100;
|
|
53
|
-
|
|
54
|
-
const message = extractToastMessage(toast, "success", `\u4E0B\u8F7D\u6210\u529F: ${finalFilename}`);
|
|
55
|
-
showToast("success", message, toast, config.toast);
|
|
56
|
-
}
|
|
155
|
+
controller = null;
|
|
57
156
|
onSuccess?.(finalFilename);
|
|
58
|
-
return
|
|
157
|
+
return result;
|
|
59
158
|
} catch (err) {
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
}
|
|
62
165
|
const downloadError = err instanceof Error ? err : new Error("\u4E0B\u8F7D\u5931\u8D25");
|
|
166
|
+
status.value = "error";
|
|
63
167
|
error.value = downloadError;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const message = extractToastMessage(toast, "error", downloadError.message || "\u4E0B\u8F7D\u5931\u8D25");
|
|
67
|
-
showToast("error", message, toast, config.toast);
|
|
68
|
-
}
|
|
69
|
-
if (!isAborted) onError?.(downloadError);
|
|
70
|
-
return { success: false, error: downloadError };
|
|
168
|
+
onError?.(downloadError);
|
|
169
|
+
return { data: null, error: downloadError, aborted: false };
|
|
71
170
|
}
|
|
72
171
|
};
|
|
73
172
|
return {
|
|
74
|
-
/** 下载进度
|
|
173
|
+
/** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
|
|
75
174
|
progress,
|
|
76
|
-
/**
|
|
77
|
-
|
|
175
|
+
/** 传输状态 */
|
|
176
|
+
status,
|
|
177
|
+
/** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
|
|
178
|
+
data,
|
|
78
179
|
/** 错误信息 */
|
|
79
180
|
error,
|
|
80
181
|
/** 执行下载 */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
+
import type { UseApiFetchOptions, UseApiFetchReturn } from '../types/api';
|
|
3
|
+
/**
|
|
4
|
+
* 懒加载版 useApiFetch
|
|
5
|
+
*
|
|
6
|
+
* 等价于 `useApiFetch(url, { lazy: true, ...options })`
|
|
7
|
+
* 不阻塞客户端导航,页面立即显示,数据在后台加载
|
|
8
|
+
*
|
|
9
|
+
* @typeParam T - 业务数据类型(已由 $api 自动解包)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { data, status } = useLazyApiFetch<Post[]>('/posts')
|
|
14
|
+
*
|
|
15
|
+
* // 需要手动处理 loading 状态
|
|
16
|
+
* // <div v-if="status === 'pending'">Loading...</div>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
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,12 +1,24 @@
|
|
|
1
1
|
export declare function useTheme(): {
|
|
2
|
-
|
|
2
|
+
color: import("vue").ComputedRef<any>;
|
|
3
|
+
style: {
|
|
4
|
+
innerHTML: import("vue").ComputedRef<string>;
|
|
5
|
+
id: string;
|
|
6
|
+
tagPriority: number;
|
|
7
|
+
}[];
|
|
8
|
+
link: import("vue").ComputedRef<{
|
|
9
|
+
rel: "stylesheet";
|
|
10
|
+
href: any;
|
|
11
|
+
id: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
neutralColors: any;
|
|
3
14
|
neutral: import("vue").WritableComputedRef<any, any>;
|
|
4
15
|
primaryColors: string[];
|
|
5
16
|
primary: import("vue").WritableComputedRef<any, any>;
|
|
17
|
+
blackAsPrimary: import("vue").ComputedRef<boolean>;
|
|
6
18
|
setBlackAsPrimary: (value: boolean) => void;
|
|
7
|
-
radiuses:
|
|
19
|
+
radiuses: any;
|
|
8
20
|
radius: import("vue").WritableComputedRef<any, any>;
|
|
9
|
-
fonts:
|
|
21
|
+
fonts: any;
|
|
10
22
|
font: import("vue").WritableComputedRef<any, any>;
|
|
11
23
|
icon: import("vue").WritableComputedRef<any, any>;
|
|
12
24
|
icons: {
|
|
@@ -14,14 +26,15 @@ export declare function useTheme(): {
|
|
|
14
26
|
icon: string;
|
|
15
27
|
value: string;
|
|
16
28
|
}[];
|
|
17
|
-
modes: {
|
|
29
|
+
modes: import("vue").ComputedRef<{
|
|
18
30
|
label: string;
|
|
19
31
|
icon: any;
|
|
20
|
-
}[]
|
|
32
|
+
}[]>;
|
|
21
33
|
mode: import("vue").WritableComputedRef<any, any>;
|
|
22
|
-
hasCSSChanges: import("vue").ComputedRef<
|
|
23
|
-
|
|
34
|
+
hasCSSChanges: import("vue").ComputedRef<boolean>;
|
|
35
|
+
hasConfigChanges: import("vue").ComputedRef<boolean>;
|
|
36
|
+
configLabel: string;
|
|
24
37
|
exportCSS: () => string;
|
|
25
|
-
|
|
38
|
+
exportConfig: () => string;
|
|
26
39
|
resetTheme: () => void;
|
|
27
40
|
};
|
|
@@ -1,86 +1,80 @@
|
|
|
1
1
|
import { useAppConfig, useColorMode, useSiteConfig } from "#imports";
|
|
2
|
-
import {
|
|
2
|
+
import { themeIcons } from "../domains/theme/theme-icons.js";
|
|
3
|
+
import { omit, kebabCase } from "@movk/core";
|
|
4
|
+
import { useLocalStorage } from "@vueuse/core";
|
|
3
5
|
import colors from "tailwindcss/colors";
|
|
4
6
|
import { computed } from "vue";
|
|
5
|
-
import {
|
|
7
|
+
import { getDefaultConfig } from "../utils/theme-defaults.js";
|
|
6
8
|
export function useTheme() {
|
|
7
|
-
const
|
|
9
|
+
const { movk, ui } = useAppConfig();
|
|
8
10
|
const colorMode = useColorMode();
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const name = kebabCase(useSiteConfig().name);
|
|
12
|
+
const color = computed(() => colorMode.value === "dark" ? colors[ui.colors.neutral][900] : "white");
|
|
13
|
+
const defaultConfig = getDefaultConfig();
|
|
14
|
+
const _radius = useLocalStorage(`${name}-ui-radius`, movk?.radius ?? defaultConfig.radius);
|
|
15
|
+
const _font = useLocalStorage(`${name}-ui-font`, movk?.font ?? defaultConfig.font);
|
|
16
|
+
const _iconSet = useLocalStorage(`${name}-ui-icons`, movk?.icons ?? defaultConfig.icons);
|
|
17
|
+
const _blackAsPrimary = useLocalStorage(`${name}-ui-black-as-primary`, defaultConfig.blackAsPrimary);
|
|
18
|
+
const pickerFonts = movk?.picker?.fonts ?? [];
|
|
19
|
+
const neutralColors = movk?.picker?.neutralColors ?? [];
|
|
11
20
|
const neutral = computed({
|
|
12
21
|
get() {
|
|
13
|
-
return
|
|
22
|
+
return ui.colors.neutral;
|
|
14
23
|
},
|
|
15
24
|
set(option) {
|
|
16
|
-
|
|
17
|
-
window.localStorage.setItem(`${
|
|
25
|
+
ui.colors.neutral = option;
|
|
26
|
+
window.localStorage.setItem(`${name}-ui-neutral`, ui.colors.neutral);
|
|
18
27
|
}
|
|
19
28
|
});
|
|
20
29
|
const colorsToOmit = ["inherit", "current", "transparent", "black", "white", ...neutralColors];
|
|
21
|
-
const primaryColors = Object.keys(omit(colors,
|
|
30
|
+
const primaryColors = Object.keys(omit(colors, colorsToOmit));
|
|
22
31
|
const primary = computed({
|
|
23
32
|
get() {
|
|
24
|
-
return
|
|
33
|
+
return ui.colors.primary;
|
|
25
34
|
},
|
|
26
35
|
set(option) {
|
|
27
|
-
|
|
28
|
-
window.localStorage.setItem(`${
|
|
36
|
+
ui.colors.primary = option;
|
|
37
|
+
window.localStorage.setItem(`${name}-ui-primary`, ui.colors.primary);
|
|
29
38
|
setBlackAsPrimary(false);
|
|
30
39
|
}
|
|
31
40
|
});
|
|
32
|
-
const radiuses =
|
|
41
|
+
const radiuses = movk?.picker?.radiuses ?? [];
|
|
33
42
|
const radius = computed({
|
|
34
43
|
get() {
|
|
35
|
-
return
|
|
44
|
+
return _radius.value;
|
|
36
45
|
},
|
|
37
46
|
set(option) {
|
|
38
|
-
|
|
39
|
-
window.localStorage.setItem(`${site.name}-ui-radius`, String(appConfig.theme.radius));
|
|
47
|
+
_radius.value = option;
|
|
40
48
|
}
|
|
41
49
|
});
|
|
42
|
-
const fonts =
|
|
50
|
+
const fonts = pickerFonts.map((f) => f.name);
|
|
43
51
|
const font = computed({
|
|
44
52
|
get() {
|
|
45
|
-
return
|
|
53
|
+
return _font.value;
|
|
46
54
|
},
|
|
47
55
|
set(option) {
|
|
48
|
-
|
|
49
|
-
if (appConfig.theme.font) {
|
|
50
|
-
window.localStorage.setItem(`${site.name}-ui-font`, appConfig.theme.font);
|
|
51
|
-
}
|
|
56
|
+
_font.value = option;
|
|
52
57
|
}
|
|
53
58
|
});
|
|
54
|
-
const icons = [
|
|
55
|
-
label: "Lucide",
|
|
56
|
-
icon: "i-
|
|
57
|
-
value: "
|
|
58
|
-
|
|
59
|
-
label: "Phosphor",
|
|
60
|
-
icon: "i-ph-phosphor-logo",
|
|
61
|
-
value: "phosphor"
|
|
62
|
-
}, {
|
|
63
|
-
label: "Tabler",
|
|
64
|
-
icon: "i-tabler-brand-tabler",
|
|
65
|
-
value: "tabler"
|
|
66
|
-
}];
|
|
59
|
+
const icons = [
|
|
60
|
+
{ label: "Lucide", icon: "i-lucide-feather", value: "lucide" },
|
|
61
|
+
{ label: "Phosphor", icon: "i-ph-phosphor-logo", value: "phosphor" },
|
|
62
|
+
{ label: "Tabler", icon: "i-tabler-brand-tabler", value: "tabler" }
|
|
63
|
+
];
|
|
67
64
|
const icon = computed({
|
|
68
65
|
get() {
|
|
69
|
-
return
|
|
66
|
+
return _iconSet.value;
|
|
70
67
|
},
|
|
71
68
|
set(option) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (appConfig.theme.icons) {
|
|
75
|
-
window.localStorage.setItem(`${site.name}-ui-icons`, appConfig.theme.icons);
|
|
76
|
-
}
|
|
69
|
+
_iconSet.value = option;
|
|
70
|
+
ui.icons = themeIcons[option];
|
|
77
71
|
}
|
|
78
72
|
});
|
|
79
|
-
const modes = [
|
|
80
|
-
{ label: "light", icon:
|
|
81
|
-
{ label: "dark", icon:
|
|
82
|
-
{ label: "system", icon:
|
|
83
|
-
];
|
|
73
|
+
const modes = computed(() => [
|
|
74
|
+
{ label: "light", icon: ui.icons.light },
|
|
75
|
+
{ label: "dark", icon: ui.icons.dark },
|
|
76
|
+
{ label: "system", icon: ui.icons.system }
|
|
77
|
+
]);
|
|
84
78
|
const mode = computed({
|
|
85
79
|
get() {
|
|
86
80
|
return colorMode.value;
|
|
@@ -89,79 +83,107 @@ export function useTheme() {
|
|
|
89
83
|
colorMode.preference = option;
|
|
90
84
|
}
|
|
91
85
|
});
|
|
86
|
+
const blackAsPrimary = computed(() => _blackAsPrimary.value);
|
|
92
87
|
function setBlackAsPrimary(value) {
|
|
93
|
-
|
|
94
|
-
window.localStorage.setItem(`${site.name}-ui-black-as-primary`, String(value));
|
|
88
|
+
_blackAsPrimary.value = value;
|
|
95
89
|
}
|
|
90
|
+
const radiusStyle = computed(() => `:root { --ui-radius: ${_radius.value}rem; }`);
|
|
91
|
+
const blackAsPrimaryStyle = computed(() => _blackAsPrimary.value ? `:root { --ui-primary: black; } .dark { --ui-primary: white; }` : ":root {}");
|
|
92
|
+
const fontStyle = computed(() => `:root { --font-sans: '${_font.value}', sans-serif; }`);
|
|
93
|
+
const link = computed(() => {
|
|
94
|
+
const fontName = _font.value;
|
|
95
|
+
const fontConfig = pickerFonts.find((f) => f.name === fontName);
|
|
96
|
+
const href = fontConfig?.href ?? `https://fonts.googleapis.com/css2?family=${encodeURIComponent(fontName)}:wght@400;500;600;700&display=swap`;
|
|
97
|
+
return [{
|
|
98
|
+
rel: "stylesheet",
|
|
99
|
+
href,
|
|
100
|
+
id: `font-${fontName.toLowerCase().replace(/\s+/g, "-")}`
|
|
101
|
+
}];
|
|
102
|
+
});
|
|
103
|
+
const style = [
|
|
104
|
+
{ innerHTML: radiusStyle, id: `nuxt-ui-radius`, tagPriority: -2 },
|
|
105
|
+
{ innerHTML: blackAsPrimaryStyle, id: `nuxt-ui-black-as-primary`, tagPriority: -2 },
|
|
106
|
+
{ innerHTML: fontStyle, id: `nuxt-ui-font`, tagPriority: -2 }
|
|
107
|
+
];
|
|
96
108
|
const hasCSSChanges = computed(() => {
|
|
97
|
-
return
|
|
109
|
+
return _radius.value !== (movk?.radius ?? defaultConfig.radius) || _blackAsPrimary.value || _font.value !== (movk?.font ?? defaultConfig.font);
|
|
98
110
|
});
|
|
99
|
-
const
|
|
100
|
-
return
|
|
111
|
+
const hasConfigChanges = computed(() => {
|
|
112
|
+
return ui.colors.primary !== "blue" || ui.colors.neutral !== "slate" || _iconSet.value !== (movk?.icons ?? defaultConfig.icons);
|
|
101
113
|
});
|
|
102
114
|
function exportCSS() {
|
|
103
115
|
const lines = [
|
|
104
116
|
'@import "tailwindcss";',
|
|
105
117
|
'@import "@nuxt/ui";'
|
|
106
118
|
];
|
|
107
|
-
if (
|
|
108
|
-
lines.push("", "@theme {", ` --font-sans: '${
|
|
119
|
+
if (_font.value !== defaultConfig.font) {
|
|
120
|
+
lines.push("", "@theme {", ` --font-sans: '${_font.value}', sans-serif;`, "}");
|
|
109
121
|
}
|
|
110
122
|
const rootLines = [];
|
|
111
|
-
if (
|
|
112
|
-
rootLines.push(` --ui-radius: ${
|
|
123
|
+
if (_radius.value !== defaultConfig.radius) {
|
|
124
|
+
rootLines.push(` --ui-radius: ${_radius.value}rem;`);
|
|
113
125
|
}
|
|
114
|
-
if (
|
|
126
|
+
if (_blackAsPrimary.value) {
|
|
115
127
|
rootLines.push(" --ui-primary: black;");
|
|
116
128
|
}
|
|
117
129
|
if (rootLines.length) {
|
|
118
130
|
lines.push("", ":root {", ...rootLines, "}");
|
|
119
131
|
}
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
const darkLines = [];
|
|
133
|
+
if (_blackAsPrimary.value) {
|
|
134
|
+
darkLines.push(" --ui-primary: white;");
|
|
135
|
+
}
|
|
136
|
+
if (darkLines.length) {
|
|
137
|
+
lines.push("", ".dark {", ...darkLines, "}");
|
|
122
138
|
}
|
|
123
139
|
return lines.join("\n");
|
|
124
140
|
}
|
|
125
|
-
function
|
|
141
|
+
function exportConfig() {
|
|
126
142
|
const config = {};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
const defaultColors = {
|
|
144
|
+
primary: "blue",
|
|
145
|
+
neutral: "slate",
|
|
146
|
+
secondary: "blue",
|
|
147
|
+
success: "green",
|
|
148
|
+
info: "blue",
|
|
149
|
+
warning: "yellow",
|
|
150
|
+
error: "red"
|
|
151
|
+
};
|
|
152
|
+
const colorEntries = Object.entries(defaultColors).filter(([key, def]) => ui.colors[key] !== def);
|
|
153
|
+
if (colorEntries.length) {
|
|
154
|
+
config.ui = { colors: Object.fromEntries(colorEntries.map(([key]) => [key, ui.colors[key]])) };
|
|
135
155
|
}
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
const icons2 = themeIcons[iconSet];
|
|
156
|
+
if (_iconSet.value !== defaultConfig.icons) {
|
|
157
|
+
const iconMapping = themeIcons[_iconSet.value];
|
|
139
158
|
config.ui = config.ui || {};
|
|
140
|
-
config.ui.icons =
|
|
159
|
+
config.ui.icons = iconMapping;
|
|
141
160
|
}
|
|
142
161
|
const configString = JSON.stringify(config, null, 2).replace(/"([^"]+)":/g, "$1:").replace(/"/g, "'");
|
|
143
162
|
return `export default defineAppConfig(${configString})`;
|
|
144
163
|
}
|
|
145
164
|
function resetTheme() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
window.localStorage.removeItem(`${site.name}-ui-black-as-primary`);
|
|
165
|
+
const defaultPrimary = "blue";
|
|
166
|
+
const defaultNeutral = "slate";
|
|
167
|
+
const defaultIcon = movk?.icons ?? defaultConfig.icons;
|
|
168
|
+
ui.colors.primary = defaultPrimary;
|
|
169
|
+
window.localStorage.removeItem(`${name}-ui-primary`);
|
|
170
|
+
ui.colors.neutral = defaultNeutral;
|
|
171
|
+
window.localStorage.removeItem(`${name}-ui-neutral`);
|
|
172
|
+
_radius.value = movk?.radius ?? defaultConfig.radius;
|
|
173
|
+
_font.value = movk?.font ?? defaultConfig.font;
|
|
174
|
+
_iconSet.value = defaultIcon;
|
|
175
|
+
ui.icons = themeIcons[defaultIcon];
|
|
176
|
+
_blackAsPrimary.value = movk?.blackAsPrimary ?? defaultConfig.blackAsPrimary;
|
|
159
177
|
}
|
|
160
178
|
return {
|
|
179
|
+
color,
|
|
180
|
+
style,
|
|
181
|
+
link,
|
|
161
182
|
neutralColors,
|
|
162
183
|
neutral,
|
|
163
184
|
primaryColors,
|
|
164
185
|
primary,
|
|
186
|
+
blackAsPrimary,
|
|
165
187
|
setBlackAsPrimary,
|
|
166
188
|
radiuses,
|
|
167
189
|
radius,
|
|
@@ -172,9 +194,10 @@ export function useTheme() {
|
|
|
172
194
|
modes,
|
|
173
195
|
mode,
|
|
174
196
|
hasCSSChanges,
|
|
175
|
-
|
|
197
|
+
hasConfigChanges,
|
|
198
|
+
configLabel: "app.config.ts",
|
|
176
199
|
exportCSS,
|
|
177
|
-
|
|
200
|
+
exportConfig,
|
|
178
201
|
resetTheme
|
|
179
202
|
};
|
|
180
203
|
}
|