@jctrans-materials/nuxt 1.0.1 → 1.0.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/package.json +5 -4
- package/src/module.ts +40 -25
- package/src/runtime/plugin.ts +12 -7
package/package.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jctrans-materials/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Nuxt module for JCtrans UI components",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/module.ts"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"nuxt": "^3.0.0",
|
|
11
10
|
"@nuxt/kit": "^3.0.0",
|
|
11
|
+
"defu": "6.1.2",
|
|
12
|
+
"nuxt": "^3.0.0",
|
|
12
13
|
"vue": "^3.5.26",
|
|
13
14
|
"vue-router": "^4.6.4",
|
|
14
|
-
"@jctrans-materials/comps-vue3": "1.0.
|
|
15
|
+
"@jctrans-materials/comps-vue3": "1.0.3"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
17
18
|
"nuxt": "^3.0.0",
|
|
18
|
-
"@jctrans-materials/comps-vue3": "1.0.
|
|
19
|
+
"@jctrans-materials/comps-vue3": "1.0.3"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@nuxt/module-builder": "latest"
|
package/src/module.ts
CHANGED
|
@@ -4,54 +4,69 @@ import {
|
|
|
4
4
|
addPlugin,
|
|
5
5
|
createResolver,
|
|
6
6
|
} from "nuxt/kit";
|
|
7
|
+
import { defu } from "defu";
|
|
8
|
+
import type { SharedConfig } from "@jctrans-materials/comps-vue3";
|
|
7
9
|
|
|
8
|
-
// 定义模块配置项(如果以后需要传参,比如 jctrans: { prefix: 'JC' })
|
|
9
10
|
export interface ModuleOptions {
|
|
10
|
-
/**
|
|
11
|
-
* 是否自动引入样式
|
|
12
|
-
* @default true
|
|
13
|
-
*/
|
|
14
11
|
addStyle?: boolean;
|
|
12
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export default defineNuxtModule<ModuleOptions>({
|
|
18
16
|
meta: {
|
|
19
17
|
name: "@jctrans-materials/nuxt",
|
|
20
|
-
configKey: "jctrans",
|
|
18
|
+
configKey: "jctrans",
|
|
21
19
|
compatibility: {
|
|
22
20
|
nuxt: "^3.0.0",
|
|
23
21
|
},
|
|
24
22
|
},
|
|
23
|
+
|
|
25
24
|
defaults: {
|
|
26
25
|
addStyle: true,
|
|
26
|
+
sharedConfig: {},
|
|
27
27
|
},
|
|
28
|
+
|
|
28
29
|
setup(options, nuxt) {
|
|
29
30
|
const { resolve } = createResolver(import.meta.url);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
|
|
33
40
|
if (options.addStyle) {
|
|
34
41
|
nuxt.options.css.push("@jctrans-materials/comps-vue3/index.css");
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
});
|
|
44
|
+
["JcSearch", "ApplyDataDialog", "MSearch", "GlobalModal"].forEach(
|
|
45
|
+
(name) => {
|
|
46
|
+
addComponent({
|
|
47
|
+
name,
|
|
48
|
+
export: name,
|
|
49
|
+
filePath: "@jctrans-materials/comps-vue3",
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
);
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
nuxt.options.build.transpile.push(
|
|
55
|
+
"@jctrans-materials/comps-vue3",
|
|
56
|
+
"element-plus",
|
|
57
|
+
);
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
addPlugin({
|
|
60
|
+
src: resolve("./runtime/plugin"),
|
|
61
|
+
mode: "all",
|
|
62
|
+
});
|
|
56
63
|
},
|
|
57
64
|
});
|
|
65
|
+
|
|
66
|
+
declare module "@nuxt/schema" {
|
|
67
|
+
interface PublicRuntimeConfig {
|
|
68
|
+
jctrans?: {
|
|
69
|
+
sharedConfig?: Partial<SharedConfig>;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/runtime/plugin.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { defineNuxtPlugin } from
|
|
2
|
-
import
|
|
1
|
+
import { defineNuxtPlugin, useRuntimeConfig } from '#app'
|
|
2
|
+
import { initSharedConfig } from '@jctrans-materials/comps-vue3'
|
|
3
3
|
|
|
4
|
-
export default defineNuxtPlugin((
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default defineNuxtPlugin(() => {
|
|
5
|
+
const runtimeConfig = useRuntimeConfig()
|
|
6
|
+
|
|
7
|
+
const sharedConfig =
|
|
8
|
+
runtimeConfig.public?.jctrans?.sharedConfig
|
|
9
|
+
|
|
10
|
+
if (sharedConfig) {
|
|
11
|
+
initSharedConfig(sharedConfig)
|
|
12
|
+
}
|
|
13
|
+
})
|