@movk/nuxt 1.8.1 → 1.8.3
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 +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +8 -4
- package/dist/runtime/components/SlideVerify.d.vue.ts +2 -2
- package/dist/runtime/components/SlideVerify.vue.d.ts +2 -2
- package/dist/runtime/domains/api/auth.js +6 -9
- package/dist/runtime/domains/api/interceptors/error.js +2 -25
- package/dist/runtime/domains/api/interceptors/response.d.ts +2 -0
- package/dist/runtime/domains/api/interceptors/response.js +7 -2
- package/dist/runtime/domains/api/interceptors/unauthorized.d.ts +12 -0
- package/dist/runtime/domains/api/interceptors/unauthorized.js +34 -0
- package/dist/runtime/domains/api/session.d.ts +12 -0
- package/dist/runtime/domains/api/session.js +9 -0
- package/dist/runtime/domains/api/transfer.js +8 -3
- package/dist/runtime/domains/auto-form/controls.d.ts +12 -12
- package/dist/runtime/types/api/fetch.d.ts +5 -2
- package/dist/shared/{nuxt.BT5mXYjs.mjs → nuxt.DfVF6ZZv.mjs} +15 -9
- package/dist/unplugin.mjs +63 -3
- package/dist/vite.mjs +1 -1
- package/package.json +29 -28
package/.nuxt/movk-ui.css
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveAlias, useLogger, addPlugin, defineNuxtModule, createResolver, addComponentsDir, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
import defu, { defu as defu$1 } from 'defu';
|
|
3
|
-
import { U as UI_COMPONENTS, r as resolveMovkIcons, f as formatMissingCollections, a as addTemplates } from './shared/nuxt.
|
|
3
|
+
import { U as UI_COMPONENTS, r as resolveMovkIcons, f as formatMissingCollections, a as addTemplates } from './shared/nuxt.DfVF6ZZv.mjs';
|
|
4
4
|
import { getPackageJsonMetadata } from '../dist/runtime/utils/meta.js';
|
|
5
5
|
import { kebabCase } from 'scule';
|
|
6
6
|
import { updateSiteConfig } from 'nuxt-site-config/kit';
|
|
@@ -15,7 +15,7 @@ import 'pathe';
|
|
|
15
15
|
import 'tinyglobby';
|
|
16
16
|
|
|
17
17
|
const name = "@movk/nuxt";
|
|
18
|
-
const version = "1.8.
|
|
18
|
+
const version = "1.8.3";
|
|
19
19
|
|
|
20
20
|
const MOVK_CSS_IMPORT = /@import\s+["']@movk\/nuxt["']/;
|
|
21
21
|
async function checkMovkCss(nuxt) {
|
|
@@ -149,16 +149,20 @@ function addFontLinks(nuxt, font) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
function resolveModuleDependencies(nuxt) {
|
|
152
|
-
const
|
|
152
|
+
const { options } = nuxt;
|
|
153
|
+
const ui = options.ui ??= {};
|
|
153
154
|
ui.fonts ??= false;
|
|
154
155
|
return {
|
|
155
156
|
"@nuxt/image": { version: ">=2.0.0" },
|
|
156
157
|
"@nuxt/ui": { version: ">=4.6.0" },
|
|
157
158
|
"@vueuse/nuxt": { version: ">=14.2.1" },
|
|
158
|
-
"nuxt-auth-utils": { version: ">=0.5.29" },
|
|
159
|
+
...usesSessionAuth(options.movk?.api) && { "nuxt-auth-utils": { version: ">=0.5.29" } },
|
|
159
160
|
"nuxt-site-config": { version: ">=4.0.8" }
|
|
160
161
|
};
|
|
161
162
|
}
|
|
163
|
+
function usesSessionAuth(api) {
|
|
164
|
+
return api?.enabled !== false && api?.auth?.enabled === true && (api.auth.tokenSource ?? "session") === "session";
|
|
165
|
+
}
|
|
162
166
|
const movkModule = defineNuxtModule({
|
|
163
167
|
meta: {
|
|
164
168
|
name,
|
|
@@ -25,10 +25,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
25
25
|
onDragStart?: (() => any) | undefined;
|
|
26
26
|
onDragEnd?: ((success: boolean) => any) | undefined;
|
|
27
27
|
}>, {
|
|
28
|
-
icon:
|
|
28
|
+
icon: any;
|
|
29
29
|
text: string;
|
|
30
30
|
successText: string;
|
|
31
|
-
successIcon:
|
|
31
|
+
successIcon: any;
|
|
32
32
|
threshold: number;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -25,10 +25,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
25
25
|
onDragStart?: (() => any) | undefined;
|
|
26
26
|
onDragEnd?: ((success: boolean) => any) | undefined;
|
|
27
27
|
}>, {
|
|
28
|
-
icon:
|
|
28
|
+
icon: any;
|
|
29
29
|
text: string;
|
|
30
30
|
successText: string;
|
|
31
|
-
successIcon:
|
|
31
|
+
successIcon: any;
|
|
32
32
|
threshold: number;
|
|
33
33
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
34
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { getPath } from "@movk/core";
|
|
2
|
-
import { useNuxtApp, useRuntimeConfig
|
|
3
|
-
|
|
2
|
+
import { useNuxtApp, useRuntimeConfig } from "#imports";
|
|
3
|
+
import { getUserSession } from "./session.js";
|
|
4
|
+
function getTokenFromSession(tokenPath) {
|
|
5
|
+
let sessionData;
|
|
4
6
|
try {
|
|
5
|
-
|
|
6
|
-
return nuxtApp.vueApp.runWithContext(() => useUserSession());
|
|
7
|
+
sessionData = getUserSession(useNuxtApp())?.session?.value;
|
|
7
8
|
} catch {
|
|
8
9
|
return null;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
function getTokenFromSession(tokenPath) {
|
|
12
|
-
const userSession = getUserSession();
|
|
13
|
-
if (!userSession?.session?.value) return null;
|
|
14
|
-
const sessionData = userSession.session.value;
|
|
11
|
+
if (!sessionData) return null;
|
|
15
12
|
return getPath(sessionData, tokenPath) || null;
|
|
16
13
|
}
|
|
17
14
|
function getTokenFromPublicRuntimeConfig(tokenPath) {
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
import { navigateTo, useUserSession } from "#imports";
|
|
2
1
|
import { showToast } from "../toast.js";
|
|
2
|
+
import { dispatchUnauthorized } from "./unauthorized.js";
|
|
3
3
|
function readApiContext(options) {
|
|
4
4
|
return options.context || {};
|
|
5
5
|
}
|
|
6
|
-
async function handleUnauthorized(authConfig, nuxtApp) {
|
|
7
|
-
const unauthorizedConfig = authConfig.unauthorized;
|
|
8
|
-
if (!unauthorizedConfig) return;
|
|
9
|
-
if (unauthorizedConfig.clearSession) {
|
|
10
|
-
try {
|
|
11
|
-
const userSession = nuxtApp.vueApp.runWithContext(() => useUserSession());
|
|
12
|
-
if (userSession?.clear) {
|
|
13
|
-
await userSession.clear();
|
|
14
|
-
await userSession.fetch();
|
|
15
|
-
}
|
|
16
|
-
} catch {
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (unauthorizedConfig.redirect) {
|
|
20
|
-
const loginPath = unauthorizedConfig.loginPath || "/login";
|
|
21
|
-
await nuxtApp.runWithContext(() => navigateTo(loginPath));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
6
|
export function createOnResponseError(resolvedConfig, publicConfig, nuxtApp) {
|
|
25
7
|
const { auth: authConfig, toast: toastConfig, response: responseConfig } = resolvedConfig;
|
|
26
8
|
return async function onResponseError(context) {
|
|
@@ -29,12 +11,7 @@ export function createOnResponseError(resolvedConfig, publicConfig, nuxtApp) {
|
|
|
29
11
|
const { toast } = readApiContext(context.options);
|
|
30
12
|
let unauthorizedHandled = false;
|
|
31
13
|
if (response.status === 401) {
|
|
32
|
-
|
|
33
|
-
await nuxtApp.callHook("movk:api:unauthorized", context, result);
|
|
34
|
-
unauthorizedHandled = result.handled;
|
|
35
|
-
if (!unauthorizedHandled) {
|
|
36
|
-
await handleUnauthorized(authConfig, nuxtApp);
|
|
37
|
-
}
|
|
14
|
+
unauthorizedHandled = await dispatchUnauthorized(context, authConfig, nuxtApp);
|
|
38
15
|
}
|
|
39
16
|
if (!unauthorizedHandled) {
|
|
40
17
|
await nuxtApp.callHook("movk:api:error", context);
|
|
@@ -9,6 +9,8 @@ type NuxtApp = ReturnType<typeof useNuxtApp>;
|
|
|
9
9
|
* @description 业务校验链路:
|
|
10
10
|
* - 校验通过(或 skipBusinessCheck)→ 按 skipUnwrap 决定是否解包 _data → 派发 movk:api:response hook → 触发成功 toast
|
|
11
11
|
* - 校验失败 → 派发 movk:api:error hook → 触发错误 toast → 抛 createApiError
|
|
12
|
+
* - 业务码为 401 → 先走与 HTTP 401 相同的未授权处理;业务侧接管时不再派发 movk:api:error
|
|
13
|
+
* - HTTP 4xx/5xx 直接返回:ofetch 先调 onResponse 再调 onResponseError,在此抛错会让后者(含 401 处理)失效
|
|
12
14
|
*
|
|
13
15
|
* **契约**:拦截器输出 = 业务数据。`movk:api:response` hook 收到的 `context.response._data` 已解包;
|
|
14
16
|
* 调用方设置 `skipUnwrap: true` 时不重写 `_data`,保留原始响应。
|
|
@@ -2,12 +2,14 @@ import { extractData, extractMessage, isBusinessSuccess } from "../response.js";
|
|
|
2
2
|
import { isReadableStream } from "../stream.js";
|
|
3
3
|
import { createApiError } from "../errors.js";
|
|
4
4
|
import { showToast } from "../toast.js";
|
|
5
|
+
import { dispatchUnauthorized, isUnauthorized } from "./unauthorized.js";
|
|
5
6
|
function readApiContext(options) {
|
|
6
7
|
return options.context || {};
|
|
7
8
|
}
|
|
8
9
|
export function createOnResponse(resolvedConfig, publicConfig, nuxtApp) {
|
|
9
|
-
const { toast: toastConfig, response: responseConfig } = resolvedConfig;
|
|
10
|
+
const { auth: authConfig, toast: toastConfig, response: responseConfig } = resolvedConfig;
|
|
10
11
|
return async function onResponse(context) {
|
|
12
|
+
if (context.response && context.response.status >= 400) return;
|
|
11
13
|
const raw = context.response?._data;
|
|
12
14
|
const { toast, skipBusinessCheck, skipUnwrap } = readApiContext(context.options);
|
|
13
15
|
if (isReadableStream(raw)) {
|
|
@@ -28,7 +30,10 @@ export function createOnResponse(resolvedConfig, publicConfig, nuxtApp) {
|
|
|
28
30
|
showToast("success", raw, toast, toastConfig, responseConfig, context.options.method);
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
|
-
await
|
|
33
|
+
const unauthorizedHandled = isUnauthorized(void 0, raw, responseConfig) && await dispatchUnauthorized(context, authConfig, nuxtApp);
|
|
34
|
+
if (!unauthorizedHandled) {
|
|
35
|
+
await nuxtApp.callHook("movk:api:error", context);
|
|
36
|
+
}
|
|
32
37
|
showToast("error", raw, toast, toastConfig, responseConfig, context.options.method);
|
|
33
38
|
throw createApiError(raw, extractMessage(raw, responseConfig));
|
|
34
39
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchContext } from 'ofetch';
|
|
2
|
+
import type { ApiAuthConfig, ApiResponse, ApiResponseConfig } from '../../../types/api';
|
|
3
|
+
import type { useNuxtApp } from '#imports';
|
|
4
|
+
type NuxtApp = ReturnType<typeof useNuxtApp>;
|
|
5
|
+
/** HTTP 状态码或业务码(按 codeKey 读取,兼容字符串)为 401 */
|
|
6
|
+
export declare function isUnauthorized(status: number | undefined, raw: ApiResponse | null | undefined, responseConfig?: Partial<ApiResponseConfig>): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 派发 `movk:api:unauthorized`,业务未接管时执行默认的清理会话与重定向
|
|
9
|
+
* @returns 业务侧是否已接管(`result.handled`)
|
|
10
|
+
*/
|
|
11
|
+
export declare function dispatchUnauthorized(context: FetchContext, authConfig: ApiAuthConfig, nuxtApp: NuxtApp): Promise<boolean>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { navigateTo } from "#imports";
|
|
2
|
+
import { getUserSession } from "../session.js";
|
|
3
|
+
const UNAUTHORIZED_CODE = 401;
|
|
4
|
+
export function isUnauthorized(status, raw, responseConfig = {}) {
|
|
5
|
+
if (status === UNAUTHORIZED_CODE) return true;
|
|
6
|
+
const code = raw?.[responseConfig.codeKey || "code"];
|
|
7
|
+
return code !== void 0 && code !== null && Number(code) === UNAUTHORIZED_CODE;
|
|
8
|
+
}
|
|
9
|
+
async function handleUnauthorized(authConfig, nuxtApp) {
|
|
10
|
+
const unauthorizedConfig = authConfig.unauthorized;
|
|
11
|
+
if (!unauthorizedConfig) return;
|
|
12
|
+
if (unauthorizedConfig.clearSession) {
|
|
13
|
+
const userSession = getUserSession(nuxtApp);
|
|
14
|
+
if (userSession?.clear) {
|
|
15
|
+
try {
|
|
16
|
+
await userSession.clear();
|
|
17
|
+
await userSession.fetch?.();
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (unauthorizedConfig.redirect) {
|
|
23
|
+
const loginPath = unauthorizedConfig.loginPath || "/login";
|
|
24
|
+
await nuxtApp.runWithContext(() => navigateTo(loginPath));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function dispatchUnauthorized(context, authConfig, nuxtApp) {
|
|
28
|
+
const result = { handled: false };
|
|
29
|
+
await nuxtApp.callHook("movk:api:unauthorized", context, result);
|
|
30
|
+
if (!result.handled) {
|
|
31
|
+
await handleUnauthorized(authConfig, nuxtApp);
|
|
32
|
+
}
|
|
33
|
+
return result.handled;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { useNuxtApp } from '#imports';
|
|
2
|
+
/** movk 用到的 nuxt-auth-utils 会话能力子集 */
|
|
3
|
+
interface UserSessionLike {
|
|
4
|
+
session?: {
|
|
5
|
+
value?: unknown;
|
|
6
|
+
};
|
|
7
|
+
clear?: () => Promise<void>;
|
|
8
|
+
fetch?: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** 未安装 nuxt-auth-utils 或不在可用上下文中时返回 null */
|
|
11
|
+
export declare function getUserSession(nuxtApp: ReturnType<typeof useNuxtApp>): UserSessionLike | null;
|
|
12
|
+
export {};
|
|
@@ -4,6 +4,7 @@ import { resolveEndpointConfig } from "./endpoint-config.js";
|
|
|
4
4
|
import { createApiError } from "./errors.js";
|
|
5
5
|
import { extractData, extractMessage, isBusinessSuccess } from "./response.js";
|
|
6
6
|
import { showToast } from "./toast.js";
|
|
7
|
+
import { dispatchUnauthorized, isUnauthorized } from "./interceptors/unauthorized.js";
|
|
7
8
|
export function prepareTransfer(publicConfig, url, options) {
|
|
8
9
|
const config = resolveEndpointConfig(publicConfig, options.endpoint);
|
|
9
10
|
const fullUrl = `${config.baseURL || ""}${url}`;
|
|
@@ -47,13 +48,14 @@ export function parseXhrHeaders(raw) {
|
|
|
47
48
|
}
|
|
48
49
|
export async function finalizeTransfer(nuxtApp, ctx) {
|
|
49
50
|
const { raw, fallback, config, publicConfig, requestToast, skipBusinessCheck, fetchContext } = ctx;
|
|
50
|
-
const { response: responseConfig, toast: toastConfig } = config;
|
|
51
|
+
const { auth: authConfig, response: responseConfig, toast: toastConfig } = config;
|
|
52
|
+
const status = fetchContext.response?.status;
|
|
51
53
|
const method = fetchContext.options?.method;
|
|
52
54
|
if (publicConfig.debug) {
|
|
53
55
|
console.info("[@movk/nuxt] Transfer response:", raw ?? fallback);
|
|
54
56
|
}
|
|
55
57
|
const hasRaw = raw !== null;
|
|
56
|
-
const isSuccess = hasRaw ? skipBusinessCheck || isBusinessSuccess(raw, responseConfig) : fallback?.isSuccess ?? false;
|
|
58
|
+
const isSuccess = !(status !== void 0 && status >= 400) && (hasRaw ? skipBusinessCheck || isBusinessSuccess(raw, responseConfig) : fallback?.isSuccess ?? false);
|
|
57
59
|
if (isSuccess) {
|
|
58
60
|
const data = hasRaw ? skipBusinessCheck ? raw : extractData(raw, responseConfig) : fallback?.data ?? null;
|
|
59
61
|
if (fetchContext.response) {
|
|
@@ -69,7 +71,10 @@ export async function finalizeTransfer(nuxtApp, ctx) {
|
|
|
69
71
|
fetchContext.response._data = raw ?? void 0;
|
|
70
72
|
}
|
|
71
73
|
fetchContext.error = apiError;
|
|
72
|
-
await
|
|
74
|
+
const unauthorizedHandled = isUnauthorized(status, raw, responseConfig) && await dispatchUnauthorized(fetchContext, authConfig, nuxtApp);
|
|
75
|
+
if (!unauthorizedHandled) {
|
|
76
|
+
await nuxtApp.callHook("movk:api:error", fetchContext);
|
|
77
|
+
}
|
|
73
78
|
showToast("error", raw ?? message, requestToast, toastConfig, responseConfig, method);
|
|
74
79
|
return { data: null, error: apiError, aborted: false };
|
|
75
80
|
}
|
|
@@ -474,8 +474,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
474
474
|
};
|
|
475
475
|
readonly slideVerify: {
|
|
476
476
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("../../types").SlideVerifyProps & {
|
|
477
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
478
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
477
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
478
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
479
479
|
} & {
|
|
480
480
|
modelValue?: boolean;
|
|
481
481
|
}> & Readonly<{
|
|
@@ -491,10 +491,10 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
491
491
|
dragStart: () => any;
|
|
492
492
|
dragEnd: (success: boolean) => any;
|
|
493
493
|
}, import("vue").PublicProps, {
|
|
494
|
-
icon:
|
|
494
|
+
icon: any;
|
|
495
495
|
text: string;
|
|
496
496
|
successText: string;
|
|
497
|
-
successIcon:
|
|
497
|
+
successIcon: any;
|
|
498
498
|
threshold: number;
|
|
499
499
|
}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
500
500
|
P: {};
|
|
@@ -504,8 +504,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
504
504
|
M: {};
|
|
505
505
|
Defaults: {};
|
|
506
506
|
}, Readonly<import("../../types").SlideVerifyProps & {
|
|
507
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
508
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
507
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
508
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
509
509
|
} & {
|
|
510
510
|
modelValue?: boolean;
|
|
511
511
|
}> & Readonly<{
|
|
@@ -516,18 +516,18 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
516
516
|
}>, {
|
|
517
517
|
reset: () => void;
|
|
518
518
|
}, {}, {}, {}, {
|
|
519
|
-
icon:
|
|
519
|
+
icon: any;
|
|
520
520
|
text: string;
|
|
521
521
|
successText: string;
|
|
522
|
-
successIcon:
|
|
522
|
+
successIcon: any;
|
|
523
523
|
threshold: number;
|
|
524
524
|
}>;
|
|
525
525
|
__isFragment?: never;
|
|
526
526
|
__isTeleport?: never;
|
|
527
527
|
__isSuspense?: never;
|
|
528
528
|
} & import("vue").ComponentOptionsBase<Readonly<import("../../types").SlideVerifyProps & {
|
|
529
|
-
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
530
|
-
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
529
|
+
size?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["variants"]["size"];
|
|
530
|
+
ui?: import("@nuxt/ui").ComponentConfig<typeof UInput, import("@nuxt/schema").AppConfig, "slideVerify">["slots"];
|
|
531
531
|
} & {
|
|
532
532
|
modelValue?: boolean;
|
|
533
533
|
}> & Readonly<{
|
|
@@ -543,10 +543,10 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
543
543
|
dragStart: () => any;
|
|
544
544
|
dragEnd: (success: boolean) => any;
|
|
545
545
|
}, string, {
|
|
546
|
-
icon:
|
|
546
|
+
icon: any;
|
|
547
547
|
text: string;
|
|
548
548
|
successText: string;
|
|
549
|
-
successIcon:
|
|
549
|
+
successIcon: any;
|
|
550
550
|
threshold: number;
|
|
551
551
|
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
|
|
552
552
|
$slots: import("../../types").SlideVerifySlots;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { $Fetch } from 'nitropack/types';
|
|
1
|
+
import type { $Fetch, AvailableRouterMethod } from 'nitropack/types';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
2
3
|
import type { FetchError } from 'ofetch';
|
|
3
4
|
import type { UseFetchOptions as NuxtUseFetchOptions, AsyncData } from 'nuxt/app';
|
|
4
5
|
import type { RequestToastOptions, ApiError } from './response';
|
|
@@ -33,7 +34,9 @@ export type ApiInstance = $Fetch & {
|
|
|
33
34
|
* @template T - 业务数据类型(已解包)
|
|
34
35
|
* @template DataT - transform 转换后的类型(默认等于 T)
|
|
35
36
|
*/
|
|
36
|
-
export type UseApiFetchOptions<T = unknown, DataT = T> = Omit<NuxtUseFetchOptions<T, DataT>, '$fetch' | 'context'> & {
|
|
37
|
+
export type UseApiFetchOptions<T = unknown, DataT = T> = Omit<NuxtUseFetchOptions<T, DataT>, '$fetch' | 'context' | 'method'> & {
|
|
38
|
+
/** 请求方法;请求经端点 baseURL 发往外部服务,不按本地 Nitro 路由收窄 */
|
|
39
|
+
method?: MaybeRefOrGetter<AvailableRouterMethod<string> | Uppercase<AvailableRouterMethod<string>>>;
|
|
37
40
|
/** 使用的端点名称(默认使用 defaultEndpoint) */
|
|
38
41
|
endpoint?: MovkApiEndpointName;
|
|
39
42
|
/** Toast 提示配置,设置为 false 禁用提示 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'node:url';
|
|
2
2
|
import { kebabCase } from 'scule';
|
|
3
|
-
import { addTypeTemplate, addTemplate, getLayerDirectories } from '@nuxt/kit';
|
|
3
|
+
import { addTypeTemplate, addTemplate, hasNuxtModule, getLayerDirectories } from '@nuxt/kit';
|
|
4
4
|
import { resolveFontSource, resolveFontFamily } from '../../dist/runtime/domains/theme/theme-font.js';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
@@ -612,14 +612,6 @@ declare module 'nuxt/schema' {
|
|
|
612
612
|
['movk']: ModuleOptions
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
interface AppConfig {
|
|
616
|
-
/**
|
|
617
|
-
* Movk UI theme configuration
|
|
618
|
-
* @see https://nuxt.mhaibaraai.cn/docs/getting-started/theme
|
|
619
|
-
*/
|
|
620
|
-
movk?: AppConfigUI
|
|
621
|
-
}
|
|
622
|
-
|
|
623
615
|
interface PublicRuntimeConfig {
|
|
624
616
|
movkApi: MovkApiPublicConfig
|
|
625
617
|
}
|
|
@@ -641,12 +633,26 @@ declare module '@nuxt/schema' {
|
|
|
641
633
|
*/
|
|
642
634
|
movk?: AppConfigUI
|
|
643
635
|
}
|
|
636
|
+
|
|
637
|
+
interface CustomAppConfig {
|
|
638
|
+
movk?: AppConfigUI
|
|
639
|
+
}
|
|
644
640
|
}
|
|
645
641
|
|
|
646
642
|
export {}
|
|
647
643
|
`;
|
|
648
644
|
}
|
|
649
645
|
});
|
|
646
|
+
templates.push({
|
|
647
|
+
filename: "movk-session.ts",
|
|
648
|
+
write: true,
|
|
649
|
+
// meta.name 为 'auth-utils';经 modules 数组手动注册时按包名匹配
|
|
650
|
+
getContents: () => nuxt && (hasNuxtModule("auth-utils", nuxt) || hasNuxtModule("nuxt-auth-utils", nuxt)) ? `import { useUserSession as _useUserSession } from '#imports'
|
|
651
|
+
|
|
652
|
+
export const useUserSession: (() => unknown) | undefined = _useUserSession
|
|
653
|
+
` : `export const useUserSession: (() => unknown) | undefined = undefined
|
|
654
|
+
`
|
|
655
|
+
});
|
|
650
656
|
templates.push({
|
|
651
657
|
filename: "types/movk-api-endpoints.d.ts",
|
|
652
658
|
getContents: () => {
|
package/dist/unplugin.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import MagicString from 'magic-string';
|
|
|
8
8
|
import { resolvePathSync } from 'mlly';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
|
-
import { U as UI_COMPONENTS, g as getTemplates, r as resolveMovkIcons, f as formatMissingCollections } from './shared/nuxt.
|
|
11
|
+
import { U as UI_COMPONENTS, g as getTemplates, r as resolveMovkIcons, f as formatMissingCollections } from './shared/nuxt.DfVF6ZZv.mjs';
|
|
12
12
|
import { kebabCase } from 'scule';
|
|
13
13
|
import { getDefaultConfig } from '../dist/runtime/utils/theme-defaults.js';
|
|
14
14
|
import { getPackageJsonMetadata } from '../dist/runtime/utils/meta.js';
|
|
@@ -142,6 +142,7 @@ const UI_COLOR_DEFAULTS = {
|
|
|
142
142
|
neutral: "slate"
|
|
143
143
|
};
|
|
144
144
|
function MovkAppConfigPlugin(options) {
|
|
145
|
+
const defuPath = resolvePathSync("defu", { url: import.meta.url });
|
|
145
146
|
const movkDefault = JSON.stringify(getDefaultConfig(options.theme));
|
|
146
147
|
const colorDefaults = JSON.stringify(UI_COLOR_DEFAULTS);
|
|
147
148
|
let movkSite = JSON.stringify(options.site ?? {});
|
|
@@ -160,7 +161,7 @@ function MovkAppConfigPlugin(options) {
|
|
|
160
161
|
if (!id.includes("nuxt-ui-app-config")) return;
|
|
161
162
|
if (!code.includes("export default")) return;
|
|
162
163
|
const injected = [
|
|
163
|
-
`import { defu as __movkDefu } from
|
|
164
|
+
`import { defu as __movkDefu } from ${JSON.stringify(defuPath)}`,
|
|
164
165
|
code.replace("export default", "const __movkUiAppConfig ="),
|
|
165
166
|
`export default __movkDefu({`,
|
|
166
167
|
` movk: ${movkDefault},`,
|
|
@@ -216,6 +217,64 @@ function MovkFontPlugin(options) {
|
|
|
216
217
|
};
|
|
217
218
|
}
|
|
218
219
|
|
|
220
|
+
const DOCS_URL = "https://nuxt.mhaibaraai.cn/docs/getting-started/vue";
|
|
221
|
+
const RESET_SELECTOR_RE = /(?:^|[}\s])(?:\*\s*,\s*::?(?:before|after)|button\s*,\s*input)\b/;
|
|
222
|
+
function stripLayerBlocks(css) {
|
|
223
|
+
let out = "";
|
|
224
|
+
let i = 0;
|
|
225
|
+
while (i < css.length) {
|
|
226
|
+
const start = css.indexOf("@layer", i);
|
|
227
|
+
if (start === -1) {
|
|
228
|
+
out += css.slice(i);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
out += css.slice(i, start);
|
|
232
|
+
const open = css.indexOf("{", start);
|
|
233
|
+
const semi = css.indexOf(";", start);
|
|
234
|
+
if (open === -1 || semi !== -1 && semi < open) {
|
|
235
|
+
i = semi === -1 ? css.length : semi + 1;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
let depth = 1;
|
|
239
|
+
let j = open + 1;
|
|
240
|
+
while (j < css.length && depth > 0) {
|
|
241
|
+
if (css[j] === "{") depth++;
|
|
242
|
+
else if (css[j] === "}") depth--;
|
|
243
|
+
j++;
|
|
244
|
+
}
|
|
245
|
+
i = j;
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
function hasUnlayeredReset(css) {
|
|
250
|
+
return RESET_SELECTOR_RE.test(stripLayerBlocks(css));
|
|
251
|
+
}
|
|
252
|
+
const WARNING = [
|
|
253
|
+
"UnoCSS \u8F93\u51FA\u4E86\u672A\u5206\u5C42\u7684 reset\uFF08preflights\uFF09\uFF0C\u4F1A\u8986\u76D6 Nuxt UI \u4F4D\u4E8E @layer utilities \u7684\u6837\u5F0F\uFF08\u80CC\u666F\u3001\u5185\u8FB9\u8DDD\u3001\u5706\u89D2\u7B49\u5931\u6548\uFF09\u3002",
|
|
254
|
+
"\u8BF7\u5728 uno.config \u4E2D\u5173\u95ED\uFF1ApresetWind4({ preflights: { reset: false } })\uFF0CTailwind \u7684 @layer base \u5DF2\u63D0\u4F9B\u7B49\u4EF7 reset\u3002",
|
|
255
|
+
`\u8BE6\u89C1 ${DOCS_URL}`
|
|
256
|
+
].join("\n");
|
|
257
|
+
function MovkCompatPlugin() {
|
|
258
|
+
return {
|
|
259
|
+
name: "movk:compat",
|
|
260
|
+
vite: {
|
|
261
|
+
apply: "serve",
|
|
262
|
+
async configResolved(config) {
|
|
263
|
+
const unoApi = config.plugins.find((p) => p.name === "unocss:api")?.api;
|
|
264
|
+
if (!unoApi) return;
|
|
265
|
+
try {
|
|
266
|
+
const ctx = unoApi.getContext();
|
|
267
|
+
await ctx.ready;
|
|
268
|
+
if (ctx.uno.config.outputToCssLayers) return;
|
|
269
|
+
const { css } = await ctx.uno.generate("", { preflights: true });
|
|
270
|
+
if (hasUnlayeredReset(css)) console.warn(`[movk] ${WARNING}`);
|
|
271
|
+
} catch {
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
219
278
|
const runtimeDir = normalize(fileURLToPath(new URL("./runtime", import.meta.url)));
|
|
220
279
|
const MOVK_COMPOSABLES = {
|
|
221
280
|
useAutoForm: ["useAutoForm", "defineControl", "DEFAULT_CONTROLS", "getAutoFormMetadata"],
|
|
@@ -280,7 +339,8 @@ const MovkPlugin = createUnplugin((_options = {}, meta) => {
|
|
|
280
339
|
...Array.isArray(uiPlugins) ? uiPlugins : [uiPlugins],
|
|
281
340
|
MovkTemplatePlugin(options),
|
|
282
341
|
MovkFontPlugin(options),
|
|
283
|
-
MovkPluginsPlugin(options)
|
|
342
|
+
MovkPluginsPlugin(options),
|
|
343
|
+
MovkCompatPlugin()
|
|
284
344
|
].flat(1);
|
|
285
345
|
});
|
|
286
346
|
|
package/dist/vite.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.8.
|
|
5
|
-
"packageManager": "pnpm@11.
|
|
4
|
+
"version": "1.8.3",
|
|
5
|
+
"packageManager": "pnpm@12.11.2",
|
|
6
6
|
"description": "An engineering suite built on Nuxt UI: schema-driven AutoForm (Zod v4), a full-featured DataTable, standalone UI components and composables. Get the full capabilities — including API integration with auth & progress — in Nuxt 4, and use its UI, forms, tables and theming in plain Vue + Vite via the Vite plugin.",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playgrounds/play && nuxt prepare docs && pnpm dev:vue:build",
|
|
129
129
|
"docs": "nuxt dev docs --uiDev",
|
|
130
130
|
"docs:build": "nuxt build docs",
|
|
131
|
-
"release": "release-it
|
|
131
|
+
"release": "release-it",
|
|
132
132
|
"lint": "eslint .",
|
|
133
133
|
"lint:fix": "eslint . --fix",
|
|
134
134
|
"typecheck": "vue-tsc --noEmit && nuxt typecheck playgrounds/play && nuxt typecheck docs && cd playgrounds/vue && vue-tsc --noEmit",
|
|
@@ -137,50 +137,51 @@
|
|
|
137
137
|
"test:vue": "vitest --project vue"
|
|
138
138
|
},
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@internationalized/date": "^3.12.
|
|
141
|
-
"@movk/core": "^1.
|
|
140
|
+
"@internationalized/date": "^3.12.4",
|
|
141
|
+
"@movk/core": "^1.5.0",
|
|
142
142
|
"@nuxt/image": "^2.1.0",
|
|
143
|
-
"@nuxt/ui": "^4.
|
|
143
|
+
"@nuxt/ui": "^4.11.3",
|
|
144
144
|
"@tanstack/vue-table": "^8.21.3",
|
|
145
|
-
"@vueuse/core": "^
|
|
146
|
-
"@vueuse/nuxt": "^
|
|
145
|
+
"@vueuse/core": "^15.0.0",
|
|
146
|
+
"@vueuse/nuxt": "^15.0.0",
|
|
147
147
|
"colortranslator": "^6.1.1",
|
|
148
148
|
"defu": "^6.1.7",
|
|
149
|
-
"eventsource-parser": "^4.
|
|
150
|
-
"magic-string": "^1.
|
|
151
|
-
"maska": "^3.2.
|
|
149
|
+
"eventsource-parser": "^4.1.1",
|
|
150
|
+
"magic-string": "^1.4.3",
|
|
151
|
+
"maska": "^3.2.2",
|
|
152
152
|
"mlly": "^1.8.2",
|
|
153
|
-
"nuxt-auth-utils": "^0.5.
|
|
153
|
+
"nuxt-auth-utils": "^0.5.31",
|
|
154
154
|
"nuxt-site-config": "^4.2.3",
|
|
155
155
|
"pathe": "^2.0.3",
|
|
156
|
-
"reka-ui": "2.10.
|
|
156
|
+
"reka-ui": "2.10.5",
|
|
157
157
|
"scule": "^1.3.0",
|
|
158
158
|
"tailwind-variants": "^3.3.1",
|
|
159
159
|
"tailwindcss": "^4.3.3",
|
|
160
160
|
"tinyglobby": "^0.2.17",
|
|
161
|
-
"unplugin": "^3.
|
|
162
|
-
"zod": "^4.
|
|
161
|
+
"unplugin": "^3.4.0",
|
|
162
|
+
"zod": "^4.6.5"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
|
-
"@iconify-json/lucide": "^1.2.
|
|
165
|
+
"@iconify-json/lucide": "^1.2.142",
|
|
166
166
|
"@iconify-json/ph": "^1.2.2",
|
|
167
|
-
"@iconify-json/tabler": "^1.2.
|
|
167
|
+
"@iconify-json/tabler": "^1.2.42",
|
|
168
168
|
"@nuxt/eslint-config": "^1.17.0",
|
|
169
|
-
"@nuxt/kit": "^4.
|
|
169
|
+
"@nuxt/kit": "^4.6.1",
|
|
170
170
|
"@nuxt/module-builder": "^1.0.3",
|
|
171
|
-
"@nuxt/schema": "^4.
|
|
172
|
-
"@release-it/conventional-changelog": "^12.0.
|
|
173
|
-
"ai": "^7.0.
|
|
174
|
-
"eslint": "^10.
|
|
175
|
-
"happy-dom": "^20.
|
|
176
|
-
"nuxt": "^4.
|
|
177
|
-
"
|
|
171
|
+
"@nuxt/schema": "^4.6.1",
|
|
172
|
+
"@release-it/conventional-changelog": "^12.0.2",
|
|
173
|
+
"ai": "^7.0.137",
|
|
174
|
+
"eslint": "^10.12.0",
|
|
175
|
+
"happy-dom": "^20.14.6",
|
|
176
|
+
"nuxt": "^4.6.1",
|
|
177
|
+
"ofetch": "^1.5.1",
|
|
178
|
+
"release-it": "^21.1.1",
|
|
178
179
|
"typescript": "^6.0.3",
|
|
179
180
|
"unbuild": "^3.6.1",
|
|
180
181
|
"unplugin-auto-import": "^21.1.0",
|
|
181
182
|
"unplugin-vue-components": "^32.1.0",
|
|
182
|
-
"vitest": "^
|
|
183
|
-
"vue": "^3.5.
|
|
184
|
-
"vue-tsc": "^3.3.
|
|
183
|
+
"vitest": "^5.0.3",
|
|
184
|
+
"vue": "^3.5.43",
|
|
185
|
+
"vue-tsc": "^3.3.13"
|
|
185
186
|
}
|
|
186
187
|
}
|