@jctrans-materials/nuxt 1.0.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/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # Nuxt Minimal Starter
2
+
3
+ Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4
+
5
+ ## Setup
6
+
7
+ Make sure to install dependencies:
8
+
9
+ ```bash
10
+ # npm
11
+ npm install
12
+
13
+ # pnpm
14
+ pnpm install
15
+
16
+ # yarn
17
+ yarn install
18
+
19
+ # bun
20
+ bun install
21
+ ```
22
+
23
+ ## Development Server
24
+
25
+ Start the development server on `http://localhost:3000`:
26
+
27
+ ```bash
28
+ # npm
29
+ npm run dev
30
+
31
+ # pnpm
32
+ pnpm dev
33
+
34
+ # yarn
35
+ yarn dev
36
+
37
+ # bun
38
+ bun run dev
39
+ ```
40
+
41
+ ## Production
42
+
43
+ Build the application for production:
44
+
45
+ ```bash
46
+ # npm
47
+ npm run build
48
+
49
+ # pnpm
50
+ pnpm build
51
+
52
+ # yarn
53
+ yarn build
54
+
55
+ # bun
56
+ bun run build
57
+ ```
58
+
59
+ Locally preview production build:
60
+
61
+ ```bash
62
+ # npm
63
+ npm run preview
64
+
65
+ # pnpm
66
+ pnpm preview
67
+
68
+ # yarn
69
+ yarn preview
70
+
71
+ # bun
72
+ bun run preview
73
+ ```
74
+
75
+ Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
package/nuxt.config.ts ADDED
@@ -0,0 +1,5 @@
1
+ // https://nuxt.com/docs/api/configuration/nuxt-config
2
+ export default defineNuxtConfig({
3
+ compatibilityDate: '2025-07-15',
4
+ devtools: { enabled: true }
5
+ })
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@jctrans-materials/nuxt",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "Nuxt module for JCtrans UI components",
6
+ "exports": {
7
+ ".": "./src/module.ts"
8
+ },
9
+ "dependencies": {
10
+ "nuxt": "^3.0.0",
11
+ "@nuxt/kit": "^3.0.0",
12
+ "vue": "^3.5.26",
13
+ "vue-router": "^4.6.4",
14
+ "@jctrans-materials/comps-vue3": "1.0.0"
15
+ },
16
+ "peerDependencies": {
17
+ "nuxt": "^3.0.0",
18
+ "@jctrans-materials/comps-vue3": "1.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "@nuxt/module-builder": "latest"
22
+ },
23
+ "scripts": {
24
+ "build": "nuxt-module-build",
25
+ "dev": "nuxt dev",
26
+ "generate": "nuxt generate",
27
+ "preview": "nuxt preview",
28
+ "postinstall": "nuxt prepare"
29
+ }
30
+ }
Binary file
@@ -0,0 +1,2 @@
1
+ User-Agent: *
2
+ Disallow:
package/src/module.ts ADDED
@@ -0,0 +1,57 @@
1
+ import {
2
+ defineNuxtModule,
3
+ addComponent,
4
+ addPlugin,
5
+ createResolver,
6
+ } from "nuxt/kit";
7
+
8
+ // 定义模块配置项(如果以后需要传参,比如 jctrans: { prefix: 'JC' })
9
+ export interface ModuleOptions {
10
+ /**
11
+ * 是否自动引入样式
12
+ * @default true
13
+ */
14
+ addStyle?: boolean;
15
+ }
16
+
17
+ export default defineNuxtModule<ModuleOptions>({
18
+ meta: {
19
+ name: "@jctrans-materials/nuxt",
20
+ configKey: "jctrans", // 在 nuxt.config.ts 中使用的键名
21
+ compatibility: {
22
+ nuxt: "^3.0.0",
23
+ },
24
+ },
25
+ defaults: {
26
+ addStyle: true,
27
+ },
28
+ setup(options, nuxt) {
29
+ const { resolve } = createResolver(import.meta.url);
30
+
31
+ // 1. 自动注入样式文件
32
+ // 用户不再需要手动 import '@jctrans-materials/comps/style.css'
33
+ if (options.addStyle) {
34
+ nuxt.options.css.push("@jctrans-materials/comps-vue3/index.css");
35
+ }
36
+
37
+ // 2. 自动注册组件 (Auto-import)
38
+ // 这样用户在页面里直接写 <Search /> 即可,无需 import
39
+ const components = ["JcSearch", "ApplyDataDialog"];
40
+
41
+ components.forEach((name) => {
42
+ addComponent({
43
+ name: name, // 组件在模板中的标签名
44
+ export: name, // 从基础库中导出的具名对象名
45
+ filePath: "@jctrans-materials/comps-vue3", // 来源库
46
+ });
47
+ });
48
+
49
+ // 3. 处理 SSR 转译
50
+ // 确保 Nuxt 能够正确处理组件库里的 ESM 代码
51
+ nuxt.options.build.transpile.push("@jctrans-materials/comps-vue3", "element-plus");
52
+
53
+ // 4. 注册运行时插件 (用于指令等)
54
+ // 如果你的组件库在 install 里注册了全局指令,需要在这里指向一个插件文件
55
+ addPlugin(resolve("./runtime/plugin"));
56
+ },
57
+ });
@@ -0,0 +1,8 @@
1
+ import { defineNuxtPlugin } from "#app";
2
+ import JCtransComps from "@jctrans-materials/comps-vue3";
3
+
4
+ export default defineNuxtPlugin((nuxtApp) => {
5
+ // 此时组件已经被 addComponent 自动注册了,
6
+ // 我们这里主要执行基础库里的 install 函数,用于挂载指令或全局属性
7
+ nuxtApp.vueApp.use(JCtransComps);
8
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ // https://nuxt.com/docs/guide/concepts/typescript
3
+ "extends": "./.nuxt/tsconfig.json",
4
+ "compilerOptions": {
5
+ "module": "esnext",
6
+ "resolveJsonModule": true,
7
+ "esModuleInterop": true,
8
+ "allowJs": true,
9
+ "strict": false
10
+ }
11
+ }