@jctrans-materials/nuxt 1.0.22 → 1.0.23
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/dist/module.cjs +65 -0
- package/dist/module.d.cts +20 -0
- package/dist/module.d.mts +20 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +62 -0
- package/dist/runtime/plugin.d.ts +6 -0
- package/{src/runtime/plugin.ts → dist/runtime/plugin.js} +11 -17
- package/dist/runtime/types.d.ts +16 -0
- package/dist/types.d.mts +3 -0
- package/package.json +16 -5
- package/nuxt.config.ts +0 -5
- package/public/favicon.ico +0 -0
- package/public/robots.txt +0 -2
- package/src/module.ts +0 -79
- package/tsconfig.json +0 -11
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const kit = require('nuxt/kit');
|
|
4
|
+
const defu = require('defu');
|
|
5
|
+
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
+
const module$1 = kit.defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "@jctrans-materials/nuxt",
|
|
10
|
+
configKey: "jctrans",
|
|
11
|
+
compatibility: {
|
|
12
|
+
nuxt: "^3.0.0"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
defaults: {
|
|
16
|
+
addStyle: true,
|
|
17
|
+
sharedConfig: {}
|
|
18
|
+
},
|
|
19
|
+
async setup(options, nuxt) {
|
|
20
|
+
const { resolve } = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('module.cjs', document.baseURI).href)));
|
|
21
|
+
nuxt.options.runtimeConfig.public ||= {};
|
|
22
|
+
nuxt.options.runtimeConfig.public.jctrans = defu.defu(
|
|
23
|
+
nuxt.options.runtimeConfig.public.jctrans,
|
|
24
|
+
{
|
|
25
|
+
sharedConfig: options.sharedConfig
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
if (options.addStyle) {
|
|
29
|
+
const cssPath = await kit.resolvePath(
|
|
30
|
+
"@jctrans-materials/comps-vue3/index.css"
|
|
31
|
+
);
|
|
32
|
+
nuxt.options.css.push(cssPath);
|
|
33
|
+
}
|
|
34
|
+
[
|
|
35
|
+
"JcSearch",
|
|
36
|
+
"JcLoginDialog",
|
|
37
|
+
"ApplyDataDialog",
|
|
38
|
+
"MSearch",
|
|
39
|
+
"GlobalModal",
|
|
40
|
+
"JcVerifySlide",
|
|
41
|
+
"JcCarrierSearch"
|
|
42
|
+
].forEach((name) => {
|
|
43
|
+
kit.addComponent({
|
|
44
|
+
name,
|
|
45
|
+
export: name,
|
|
46
|
+
filePath: "@jctrans-materials/comps-vue3"
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
nuxt.options.build.transpile.push(
|
|
50
|
+
"@jctrans-materials/comps-vue3",
|
|
51
|
+
"element-plus"
|
|
52
|
+
);
|
|
53
|
+
kit.addPlugin({
|
|
54
|
+
src: resolve("./runtime/plugin"),
|
|
55
|
+
mode: "all"
|
|
56
|
+
});
|
|
57
|
+
kit.addTypeTemplate({
|
|
58
|
+
filename: "types/jctrans-materials-nuxt.d.ts",
|
|
59
|
+
// 生成在宿主 .nuxt/types 下的文件名,不重名即可
|
|
60
|
+
src: resolve("./runtime/types.d.ts")
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
module.exports = module$1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { SharedConfig } from '@jctrans-materials/comps-vue3';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
addStyle?: boolean;
|
|
6
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
9
|
+
|
|
10
|
+
declare module "@nuxt/schema" {
|
|
11
|
+
interface PublicRuntimeConfig {
|
|
12
|
+
jctrans?: {
|
|
13
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
14
|
+
appId: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export = _default;
|
|
20
|
+
export type { ModuleOptions };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { SharedConfig } from '@jctrans-materials/comps-vue3';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
addStyle?: boolean;
|
|
6
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
9
|
+
|
|
10
|
+
declare module "@nuxt/schema" {
|
|
11
|
+
interface PublicRuntimeConfig {
|
|
12
|
+
jctrans?: {
|
|
13
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
14
|
+
appId: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { _default as default };
|
|
20
|
+
export type { ModuleOptions };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { SharedConfig } from '@jctrans-materials/comps-vue3';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
addStyle?: boolean;
|
|
6
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
9
|
+
|
|
10
|
+
declare module "@nuxt/schema" {
|
|
11
|
+
interface PublicRuntimeConfig {
|
|
12
|
+
jctrans?: {
|
|
13
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
14
|
+
appId: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export = _default;
|
|
20
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, resolvePath, addComponent, addPlugin, addTypeTemplate } from 'nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
|
|
4
|
+
const module$1 = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "@jctrans-materials/nuxt",
|
|
7
|
+
configKey: "jctrans",
|
|
8
|
+
compatibility: {
|
|
9
|
+
nuxt: "^3.0.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
addStyle: true,
|
|
14
|
+
sharedConfig: {}
|
|
15
|
+
},
|
|
16
|
+
async setup(options, nuxt) {
|
|
17
|
+
const { resolve } = createResolver(import.meta.url);
|
|
18
|
+
nuxt.options.runtimeConfig.public ||= {};
|
|
19
|
+
nuxt.options.runtimeConfig.public.jctrans = defu(
|
|
20
|
+
nuxt.options.runtimeConfig.public.jctrans,
|
|
21
|
+
{
|
|
22
|
+
sharedConfig: options.sharedConfig
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
if (options.addStyle) {
|
|
26
|
+
const cssPath = await resolvePath(
|
|
27
|
+
"@jctrans-materials/comps-vue3/index.css"
|
|
28
|
+
);
|
|
29
|
+
nuxt.options.css.push(cssPath);
|
|
30
|
+
}
|
|
31
|
+
[
|
|
32
|
+
"JcSearch",
|
|
33
|
+
"JcLoginDialog",
|
|
34
|
+
"ApplyDataDialog",
|
|
35
|
+
"MSearch",
|
|
36
|
+
"GlobalModal",
|
|
37
|
+
"JcVerifySlide",
|
|
38
|
+
"JcCarrierSearch"
|
|
39
|
+
].forEach((name) => {
|
|
40
|
+
addComponent({
|
|
41
|
+
name,
|
|
42
|
+
export: name,
|
|
43
|
+
filePath: "@jctrans-materials/comps-vue3"
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
nuxt.options.build.transpile.push(
|
|
47
|
+
"@jctrans-materials/comps-vue3",
|
|
48
|
+
"element-plus"
|
|
49
|
+
);
|
|
50
|
+
addPlugin({
|
|
51
|
+
src: resolve("./runtime/plugin"),
|
|
52
|
+
mode: "all"
|
|
53
|
+
});
|
|
54
|
+
addTypeTemplate({
|
|
55
|
+
filename: "types/jctrans-materials-nuxt.d.ts",
|
|
56
|
+
// 生成在宿主 .nuxt/types 下的文件名,不重名即可
|
|
57
|
+
src: resolve("./runtime/types.d.ts")
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const _default: import("#app").Plugin<{
|
|
2
|
+
initAuthSharedConfig: (newConfig: Partial<import("@jctrans-materials/shared").SharedConfig>) => void;
|
|
3
|
+
}> & import("#app").ObjectPlugin<{
|
|
4
|
+
initAuthSharedConfig: (newConfig: Partial<import("@jctrans-materials/shared").SharedConfig>) => void;
|
|
5
|
+
}>;
|
|
6
|
+
export default _default;
|
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
// @jctrans-materials/nuxt/runtime/plugin.ts
|
|
2
1
|
import { defineNuxtPlugin, useRuntimeConfig } from "#app";
|
|
3
2
|
import {
|
|
4
3
|
initSharedConfig,
|
|
5
4
|
createRequest,
|
|
6
|
-
getAppId
|
|
5
|
+
getAppId
|
|
7
6
|
} from "@jctrans-materials/comps-vue3";
|
|
8
|
-
|
|
9
7
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
10
8
|
const runtimeConfig = useRuntimeConfig();
|
|
11
9
|
const sharedConfig = runtimeConfig.public?.jctrans?.sharedConfig;
|
|
12
|
-
|
|
13
10
|
if (sharedConfig) {
|
|
14
|
-
|
|
15
|
-
const finalBaseURL: string =
|
|
16
|
-
(runtimeConfig.public.PROD_CLIENT_PROXY_API as string) ||
|
|
17
|
-
sharedConfig.prefixPath ||
|
|
18
|
-
"";
|
|
11
|
+
const finalBaseURL = runtimeConfig.public.PROD_CLIENT_PROXY_API || sharedConfig.prefixPath || "";
|
|
19
12
|
const LOGIN_PAGE = runtimeConfig.public.APP_LOGIN_PAGE;
|
|
20
|
-
|
|
21
|
-
// 1. 初始化静态配置(建议把最新的 URL 也更新进去)
|
|
22
13
|
initSharedConfig({
|
|
23
14
|
...sharedConfig,
|
|
24
|
-
prefixPath: finalBaseURL
|
|
15
|
+
prefixPath: finalBaseURL
|
|
25
16
|
});
|
|
26
|
-
|
|
27
|
-
// 2. 🚀 使用 fetch 驱动,并注入 Nuxt 内置的 $fetch
|
|
28
17
|
createRequest("fetch", {
|
|
29
18
|
// 这里将 Nuxt 的 $fetch 注入到适配器中,
|
|
30
19
|
// 它可以享受 Nuxt 所有的 SSR 优化(如在服务器端免请求、自动带上服务器端上下文等)
|
|
31
|
-
fetch: $fetch
|
|
20
|
+
fetch: $fetch,
|
|
32
21
|
baseURL: finalBaseURL,
|
|
33
22
|
onUnauthorized: () => {
|
|
34
23
|
if (import.meta.client) {
|
|
35
24
|
const appId = sharedConfig.appId || getAppId();
|
|
36
25
|
const currentPath = encodeURIComponent(window.location.pathname);
|
|
37
|
-
// 跳转至登录
|
|
38
26
|
window.location.href = `${LOGIN_PAGE || `https://passport.jctrans.com`}/login?appId=${appId}&path=${currentPath}`;
|
|
39
27
|
}
|
|
40
|
-
}
|
|
28
|
+
}
|
|
41
29
|
});
|
|
42
30
|
}
|
|
31
|
+
return {
|
|
32
|
+
provide: {
|
|
33
|
+
// 暴露出去的方法,Nuxt 会自动变成 $initSharedConfig
|
|
34
|
+
initAuthSharedConfig: initSharedConfig
|
|
35
|
+
}
|
|
36
|
+
};
|
|
43
37
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/runtime/types.d.ts
|
|
2
|
+
import { initSharedConfig } from "@jctrans-materials/comps-vue3";
|
|
3
|
+
|
|
4
|
+
declare module "#app" {
|
|
5
|
+
interface NuxtApp {
|
|
6
|
+
$initAuthSharedConfig: typeof initSharedConfig;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module "vue" {
|
|
11
|
+
interface ComponentCustomProperties {
|
|
12
|
+
$initAuthSharedConfig: typeof initSharedConfig;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {};
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jctrans-materials/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"description": "Nuxt module for JCtrans UI components",
|
|
6
6
|
"exports": {
|
|
7
|
-
".":
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/module.d.mts",
|
|
9
|
+
"import": "./dist/module.mjs",
|
|
10
|
+
"require": "./dist/module.cjs"
|
|
11
|
+
}
|
|
8
12
|
},
|
|
13
|
+
"main": "./dist/module.cjs",
|
|
14
|
+
"module": "./dist/module.mjs",
|
|
15
|
+
"types": "./dist/module.d.mts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
9
19
|
"dependencies": {
|
|
10
20
|
"@nuxt/kit": "^3.0.0",
|
|
11
21
|
"defu": "6.1.2",
|
|
12
22
|
"nuxt": "^3.0.0",
|
|
13
23
|
"vue": "^3.5.26",
|
|
14
24
|
"vue-router": "^4.6.4",
|
|
15
|
-
"@jctrans-materials/comps-vue3": "1.0.
|
|
25
|
+
"@jctrans-materials/comps-vue3": "1.0.23"
|
|
16
26
|
},
|
|
17
27
|
"peerDependencies": {
|
|
18
28
|
"nuxt": "^3.0.0",
|
|
19
|
-
"@jctrans-materials/comps-vue3": "1.0.
|
|
29
|
+
"@jctrans-materials/comps-vue3": "1.0.23"
|
|
20
30
|
},
|
|
21
31
|
"devDependencies": {
|
|
22
|
-
"@nuxt/module-builder": "latest"
|
|
32
|
+
"@nuxt/module-builder": "latest",
|
|
33
|
+
"unbuild": "^3.6.1"
|
|
23
34
|
},
|
|
24
35
|
"scripts": {
|
|
25
36
|
"build": "nuxt-module-build",
|
package/nuxt.config.ts
DELETED
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/robots.txt
DELETED
package/src/module.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineNuxtModule,
|
|
3
|
-
addComponent,
|
|
4
|
-
addPlugin,
|
|
5
|
-
createResolver,
|
|
6
|
-
} from "nuxt/kit";
|
|
7
|
-
import { defu } from "defu";
|
|
8
|
-
import type { SharedConfig } from "@jctrans-materials/comps-vue3";
|
|
9
|
-
|
|
10
|
-
export interface ModuleOptions {
|
|
11
|
-
addStyle?: boolean;
|
|
12
|
-
sharedConfig?: Partial<SharedConfig>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default defineNuxtModule<ModuleOptions>({
|
|
16
|
-
meta: {
|
|
17
|
-
name: "@jctrans-materials/nuxt",
|
|
18
|
-
configKey: "jctrans",
|
|
19
|
-
compatibility: {
|
|
20
|
-
nuxt: "^3.0.0",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
defaults: {
|
|
25
|
-
addStyle: true,
|
|
26
|
-
sharedConfig: {},
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
setup(options, nuxt) {
|
|
30
|
-
const { resolve } = createResolver(import.meta.url);
|
|
31
|
-
|
|
32
|
-
nuxt.options.runtimeConfig.public ||= {};
|
|
33
|
-
nuxt.options.runtimeConfig.public.jctrans = defu(
|
|
34
|
-
nuxt.options.runtimeConfig.public.jctrans,
|
|
35
|
-
{
|
|
36
|
-
sharedConfig: options.sharedConfig,
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (options.addStyle) {
|
|
41
|
-
nuxt.options.css.push("@jctrans-materials/comps-vue3/index.css");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
[
|
|
45
|
-
"JcSearch",
|
|
46
|
-
"JcLoginDialog",
|
|
47
|
-
"ApplyDataDialog",
|
|
48
|
-
"MSearch",
|
|
49
|
-
"GlobalModal",
|
|
50
|
-
"JcVerifySlide",
|
|
51
|
-
"JcCarrierSearch",
|
|
52
|
-
].forEach((name) => {
|
|
53
|
-
addComponent({
|
|
54
|
-
name,
|
|
55
|
-
export: name,
|
|
56
|
-
filePath: "@jctrans-materials/comps-vue3",
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
nuxt.options.build.transpile.push(
|
|
61
|
-
"@jctrans-materials/comps-vue3",
|
|
62
|
-
"element-plus",
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
addPlugin({
|
|
66
|
-
src: resolve("./runtime/plugin"),
|
|
67
|
-
mode: "all",
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
declare module "@nuxt/schema" {
|
|
73
|
-
interface PublicRuntimeConfig {
|
|
74
|
-
jctrans?: {
|
|
75
|
-
sharedConfig?: Partial<SharedConfig>;
|
|
76
|
-
appId: string;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
package/tsconfig.json
DELETED