@yh-ui/nuxt 0.1.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/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/module.cjs +204 -0
- package/dist/module.d.cts +50 -0
- package/dist/module.d.mts +50 -0
- package/dist/module.d.ts +50 -0
- package/dist/module.mjs +197 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present YH-UI Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# @yh-ui/nuxt
|
|
2
|
+
|
|
3
|
+
YH-UI 的 Nuxt 模块,提供开箱即用的 SSR 支持和组件自动导入。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
✅ **完整的 SSR 支持** - 解决了 Hydration Mismatch 问题
|
|
8
|
+
✅ **组件自动导入** - 无需手动注册组件
|
|
9
|
+
✅ **Composables 自动导入** - 直接使用 `useNamespace`、`useId` 等
|
|
10
|
+
✅ **样式自动注入** - 自动加载主题样式
|
|
11
|
+
✅ **TypeScript 支持** - 完整的类型提示
|
|
12
|
+
✅ **Nuxt 3 & 4 兼容** - 支持最新的 Nuxt 4.x
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @yh-ui/nuxt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 快速开始
|
|
21
|
+
|
|
22
|
+
### 1. 注册模块
|
|
23
|
+
|
|
24
|
+
在 `nuxt.config.ts` 中添加模块:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
export default defineNuxtConfig({
|
|
28
|
+
modules: [
|
|
29
|
+
'@yh-ui/nuxt'
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
// 可选配置
|
|
33
|
+
yhUI: {
|
|
34
|
+
importStyle: true // 是否自动导入样式,默认为 true
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. 直接使用组件
|
|
40
|
+
|
|
41
|
+
组件会自动导入,无需手动注册:
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<template>
|
|
45
|
+
<div>
|
|
46
|
+
<YhButton type="primary">Click Me</YhButton>
|
|
47
|
+
<YhInput v-model="value" placeholder="Enter text" />
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup>
|
|
52
|
+
const value = ref('')
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 3. 使用 Composables
|
|
57
|
+
|
|
58
|
+
Hooks 也会自动导入:
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<script setup>
|
|
62
|
+
// 直接使用,无需导入
|
|
63
|
+
const ns = useNamespace('my-component')
|
|
64
|
+
const id = useId()
|
|
65
|
+
const { nextZIndex } = useZIndex()
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 4. 使用全局方法
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<script setup>
|
|
73
|
+
// Message 和 Notification 自动导入
|
|
74
|
+
const showMessage = () => {
|
|
75
|
+
YhMessage.success('操作成功!')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const showNotification = () => {
|
|
79
|
+
YhNotification({
|
|
80
|
+
title: '提示',
|
|
81
|
+
message: '这是一条通知消息'
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## SSR 注意事项
|
|
88
|
+
|
|
89
|
+
本模块已经处理了以下 SSR 相关问题:
|
|
90
|
+
|
|
91
|
+
1. **ID 生成** - 使用 Vue 3.5 原生 `useId()`,确保服务端和客户端生成的 ID 一致
|
|
92
|
+
2. **Z-Index 管理** - 通过 provide/inject 为每个请求提供独立的计数器
|
|
93
|
+
3. **DOM 访问** - 所有 DOM 操作都已经用 `isClient` 保护
|
|
94
|
+
|
|
95
|
+
## 自动导入的组件
|
|
96
|
+
|
|
97
|
+
以下组件可以直接使用,无需导入:
|
|
98
|
+
|
|
99
|
+
- `YhButton`
|
|
100
|
+
- `YhInput` / `YhInputNumber` / `YhInputTag`
|
|
101
|
+
- `YhCheckbox` / `YhCheckboxGroup`
|
|
102
|
+
- `YhRadio` / `YhRadioGroup` / `YhRadioButton`
|
|
103
|
+
- `YhSelect` / `YhOption`
|
|
104
|
+
- `YhCascader` / `YhCascaderPanel`
|
|
105
|
+
- `YhSwitch` / `YhRate` / `YhSlider`
|
|
106
|
+
- `YhTimeSelect` / `YhTransfer` / `YhTreeSelect`
|
|
107
|
+
- `YhForm` / `YhFormItem` / `YhFormSchema`
|
|
108
|
+
- `YhRow` / `YhCol`
|
|
109
|
+
- `YhCard` / `YhBadge` / `YhDivider` / `YhTag`
|
|
110
|
+
- `YhIcon`
|
|
111
|
+
- `YhConfigProvider`
|
|
112
|
+
|
|
113
|
+
## 自动导入的 Composables
|
|
114
|
+
|
|
115
|
+
- `useNamespace` - BEM 类名生成
|
|
116
|
+
- `useId` - 唯一 ID 生成
|
|
117
|
+
- `useZIndex` - Z-Index 管理
|
|
118
|
+
- `useLocale` - 国际化
|
|
119
|
+
- `useFormItem` - 表单项集成
|
|
120
|
+
- `useGlobalNamespace` - 全局命名空间
|
|
121
|
+
|
|
122
|
+
## 配置选项
|
|
123
|
+
|
|
124
|
+
| 选项 | 类型 | 默认值 | 说明 |
|
|
125
|
+
|------|------|--------|------|
|
|
126
|
+
| `importStyle` | `boolean` | `true` | 是否自动导入样式文件 |
|
|
127
|
+
|
|
128
|
+
## 兼容性
|
|
129
|
+
|
|
130
|
+
- Nuxt: `^3.0.0` 或 `^4.0.0-rc.1`
|
|
131
|
+
- Vue: `^3.5.0`
|
|
132
|
+
- Node.js: `>=18.0.0`
|
|
133
|
+
|
|
134
|
+
## 示例项目
|
|
135
|
+
|
|
136
|
+
查看 [playground](../../playground-nuxt) 目录获取完整示例。
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crypto = require('node:crypto');
|
|
4
|
+
const kit = require('@nuxt/kit');
|
|
5
|
+
|
|
6
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
|
+
|
|
9
|
+
const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
10
|
+
|
|
11
|
+
if (typeof crypto__default.hash !== "function") {
|
|
12
|
+
crypto__default.hash = (algorithm, data, outputEncoding = "hex") => {
|
|
13
|
+
return crypto__default.createHash(algorithm).update(data).digest(outputEncoding);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const yhNuxtModule = kit.defineNuxtModule({
|
|
17
|
+
meta: {
|
|
18
|
+
name: "@yh-ui/nuxt",
|
|
19
|
+
configKey: "yhUI",
|
|
20
|
+
compatibility: {
|
|
21
|
+
nuxt: "^3.11.0 || ^4.0.0-rc.1"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
defaults: {
|
|
25
|
+
importStyle: true,
|
|
26
|
+
buildTranspile: true,
|
|
27
|
+
prefix: "Yh",
|
|
28
|
+
ssrOptimization: {
|
|
29
|
+
componentCache: true
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setup(options, nuxt) {
|
|
33
|
+
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)));
|
|
34
|
+
kit.addPlugin(resolve("./runtime/plugin"));
|
|
35
|
+
if (options.importStyle) {
|
|
36
|
+
nuxt.options.css.push("@yh-ui/theme/src/styles/index.scss");
|
|
37
|
+
}
|
|
38
|
+
if (options.buildTranspile) {
|
|
39
|
+
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
40
|
+
const transpileList = ["@yh-ui/components", "@yh-ui/hooks", "@yh-ui/utils", "@yh-ui/theme"];
|
|
41
|
+
transpileList.forEach((pkg) => {
|
|
42
|
+
if (!nuxt.options.build.transpile.includes(pkg)) {
|
|
43
|
+
nuxt.options.build.transpile.push(pkg);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const components = [
|
|
48
|
+
"Button",
|
|
49
|
+
"Input",
|
|
50
|
+
"InputNumber",
|
|
51
|
+
"InputTag",
|
|
52
|
+
"Autocomplete",
|
|
53
|
+
"Checkbox",
|
|
54
|
+
"CheckboxGroup",
|
|
55
|
+
"Radio",
|
|
56
|
+
"RadioGroup",
|
|
57
|
+
"RadioButton",
|
|
58
|
+
"Switch",
|
|
59
|
+
"Rate",
|
|
60
|
+
"Select",
|
|
61
|
+
"Option",
|
|
62
|
+
"Cascader",
|
|
63
|
+
"CascaderPanel",
|
|
64
|
+
"Slider",
|
|
65
|
+
"TimePicker",
|
|
66
|
+
"TimeSelect",
|
|
67
|
+
"DatePicker",
|
|
68
|
+
"Transfer",
|
|
69
|
+
"TransferPanel",
|
|
70
|
+
"TreeSelect",
|
|
71
|
+
"Divider",
|
|
72
|
+
"Badge",
|
|
73
|
+
"Card",
|
|
74
|
+
"Marquee",
|
|
75
|
+
"Row",
|
|
76
|
+
"Col",
|
|
77
|
+
"ConfigProvider",
|
|
78
|
+
"Form",
|
|
79
|
+
"FormItem",
|
|
80
|
+
"FormSchema",
|
|
81
|
+
"Tag",
|
|
82
|
+
"Icon",
|
|
83
|
+
"ColorPicker",
|
|
84
|
+
"Breadcrumb",
|
|
85
|
+
"BreadcrumbItem",
|
|
86
|
+
"BackTop",
|
|
87
|
+
"Alert",
|
|
88
|
+
"Skeleton",
|
|
89
|
+
"SkeletonItem",
|
|
90
|
+
"Progress",
|
|
91
|
+
"Tooltip",
|
|
92
|
+
"Popconfirm",
|
|
93
|
+
"Popover",
|
|
94
|
+
"Dialog",
|
|
95
|
+
"Drawer",
|
|
96
|
+
"Watermark",
|
|
97
|
+
"Upload",
|
|
98
|
+
"Spin",
|
|
99
|
+
"Pagination",
|
|
100
|
+
"Image",
|
|
101
|
+
"ImageViewer",
|
|
102
|
+
"Descriptions",
|
|
103
|
+
"DescriptionsItem",
|
|
104
|
+
"Tabs",
|
|
105
|
+
"TabPane",
|
|
106
|
+
"Steps",
|
|
107
|
+
"Step",
|
|
108
|
+
"Affix",
|
|
109
|
+
"InfiniteScroll",
|
|
110
|
+
"Dropdown",
|
|
111
|
+
"DropdownItem",
|
|
112
|
+
"DropdownMenu",
|
|
113
|
+
"Menu",
|
|
114
|
+
"MenuItem",
|
|
115
|
+
"MenuItemGroup",
|
|
116
|
+
"SubMenu",
|
|
117
|
+
"Waterfall",
|
|
118
|
+
"Tree",
|
|
119
|
+
"TreeNode",
|
|
120
|
+
"Calendar",
|
|
121
|
+
"Countdown",
|
|
122
|
+
"Table",
|
|
123
|
+
"TableColumn",
|
|
124
|
+
// 新增组件
|
|
125
|
+
"Space",
|
|
126
|
+
"Avatar",
|
|
127
|
+
"Empty",
|
|
128
|
+
// Typography
|
|
129
|
+
"TypographyTitle",
|
|
130
|
+
"TypographyText",
|
|
131
|
+
"TypographyParagraph",
|
|
132
|
+
"TypographyLink",
|
|
133
|
+
// Container
|
|
134
|
+
"Container",
|
|
135
|
+
"Header",
|
|
136
|
+
"Aside",
|
|
137
|
+
"Main",
|
|
138
|
+
"Footer",
|
|
139
|
+
// Result
|
|
140
|
+
"Result",
|
|
141
|
+
// Grid
|
|
142
|
+
"Grid",
|
|
143
|
+
"GridItem",
|
|
144
|
+
// Mention
|
|
145
|
+
"Mention"
|
|
146
|
+
];
|
|
147
|
+
components.forEach((name) => {
|
|
148
|
+
kit.addComponent({
|
|
149
|
+
name: `${options.prefix}${name}`,
|
|
150
|
+
export: `Yh${name}`,
|
|
151
|
+
filePath: "@yh-ui/components"
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
const hooks = [
|
|
155
|
+
"useNamespace",
|
|
156
|
+
"useZIndex",
|
|
157
|
+
"useLocale",
|
|
158
|
+
"useFormItem",
|
|
159
|
+
"createZIndexCounter",
|
|
160
|
+
"useGlobalNamespace",
|
|
161
|
+
"useId",
|
|
162
|
+
"useVirtualScroll",
|
|
163
|
+
"useCache",
|
|
164
|
+
"useEventListener",
|
|
165
|
+
"useScrollLock",
|
|
166
|
+
"useClickOutside",
|
|
167
|
+
"useConfig"
|
|
168
|
+
];
|
|
169
|
+
hooks.forEach((name) => {
|
|
170
|
+
kit.addImports({
|
|
171
|
+
name,
|
|
172
|
+
as: name,
|
|
173
|
+
from: "@yh-ui/hooks"
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
const globalMethods = [
|
|
177
|
+
"YhMessage",
|
|
178
|
+
"YhNotification",
|
|
179
|
+
"YhMessageBox",
|
|
180
|
+
"YhDialogMethod",
|
|
181
|
+
"YhLoading"
|
|
182
|
+
];
|
|
183
|
+
globalMethods.forEach((name) => {
|
|
184
|
+
kit.addImports({
|
|
185
|
+
name,
|
|
186
|
+
as: name,
|
|
187
|
+
from: "@yh-ui/components"
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
kit.extendViteConfig((config) => {
|
|
191
|
+
config.optimizeDeps ||= {};
|
|
192
|
+
config.optimizeDeps.include ||= [];
|
|
193
|
+
const include = config.optimizeDeps.include;
|
|
194
|
+
const dependencies = ["@yh-ui/components", "@yh-ui/hooks", "@yh-ui/utils", "dayjs"];
|
|
195
|
+
dependencies.forEach((dep) => {
|
|
196
|
+
if (!include.includes(dep)) {
|
|
197
|
+
include.push(dep);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
module.exports = yhNuxtModule;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to automatically import styles.
|
|
6
|
+
* If true, it will import `@yh-ui/theme/src/styles/index.scss`.
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
importStyle?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to transpile dependencies.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
buildTranspile?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Prefix for components.
|
|
17
|
+
* @default 'Yh'
|
|
18
|
+
*/
|
|
19
|
+
prefix?: string;
|
|
20
|
+
/**
|
|
21
|
+
* SSR optimization configurations.
|
|
22
|
+
*/
|
|
23
|
+
ssrOptimization?: {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to enable component cache hints.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
componentCache?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare const yhNuxtModule: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
32
|
+
declare module '@nuxt/schema' {
|
|
33
|
+
interface NuxtConfig {
|
|
34
|
+
yhUI?: ModuleOptions;
|
|
35
|
+
}
|
|
36
|
+
interface NuxtOptions {
|
|
37
|
+
yhUI?: ModuleOptions;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare module 'nuxt/schema' {
|
|
41
|
+
interface NuxtConfig {
|
|
42
|
+
yhUI?: ModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
interface NuxtOptions {
|
|
45
|
+
yhUI?: ModuleOptions;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export = yhNuxtModule;
|
|
50
|
+
export type { ModuleOptions };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to automatically import styles.
|
|
6
|
+
* If true, it will import `@yh-ui/theme/src/styles/index.scss`.
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
importStyle?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to transpile dependencies.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
buildTranspile?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Prefix for components.
|
|
17
|
+
* @default 'Yh'
|
|
18
|
+
*/
|
|
19
|
+
prefix?: string;
|
|
20
|
+
/**
|
|
21
|
+
* SSR optimization configurations.
|
|
22
|
+
*/
|
|
23
|
+
ssrOptimization?: {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to enable component cache hints.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
componentCache?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare const yhNuxtModule: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
32
|
+
declare module '@nuxt/schema' {
|
|
33
|
+
interface NuxtConfig {
|
|
34
|
+
yhUI?: ModuleOptions;
|
|
35
|
+
}
|
|
36
|
+
interface NuxtOptions {
|
|
37
|
+
yhUI?: ModuleOptions;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare module 'nuxt/schema' {
|
|
41
|
+
interface NuxtConfig {
|
|
42
|
+
yhUI?: ModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
interface NuxtOptions {
|
|
45
|
+
yhUI?: ModuleOptions;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { yhNuxtModule as default };
|
|
50
|
+
export type { ModuleOptions };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to automatically import styles.
|
|
6
|
+
* If true, it will import `@yh-ui/theme/src/styles/index.scss`.
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
importStyle?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to transpile dependencies.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
buildTranspile?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Prefix for components.
|
|
17
|
+
* @default 'Yh'
|
|
18
|
+
*/
|
|
19
|
+
prefix?: string;
|
|
20
|
+
/**
|
|
21
|
+
* SSR optimization configurations.
|
|
22
|
+
*/
|
|
23
|
+
ssrOptimization?: {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to enable component cache hints.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
componentCache?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare const yhNuxtModule: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
32
|
+
declare module '@nuxt/schema' {
|
|
33
|
+
interface NuxtConfig {
|
|
34
|
+
yhUI?: ModuleOptions;
|
|
35
|
+
}
|
|
36
|
+
interface NuxtOptions {
|
|
37
|
+
yhUI?: ModuleOptions;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare module 'nuxt/schema' {
|
|
41
|
+
interface NuxtConfig {
|
|
42
|
+
yhUI?: ModuleOptions;
|
|
43
|
+
}
|
|
44
|
+
interface NuxtOptions {
|
|
45
|
+
yhUI?: ModuleOptions;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export = yhNuxtModule;
|
|
50
|
+
export type { ModuleOptions };
|
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponent, addImports, extendViteConfig } from '@nuxt/kit';
|
|
3
|
+
|
|
4
|
+
if (typeof crypto.hash !== "function") {
|
|
5
|
+
crypto.hash = (algorithm, data, outputEncoding = "hex") => {
|
|
6
|
+
return crypto.createHash(algorithm).update(data).digest(outputEncoding);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const yhNuxtModule = defineNuxtModule({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "@yh-ui/nuxt",
|
|
12
|
+
configKey: "yhUI",
|
|
13
|
+
compatibility: {
|
|
14
|
+
nuxt: "^3.11.0 || ^4.0.0-rc.1"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
defaults: {
|
|
18
|
+
importStyle: true,
|
|
19
|
+
buildTranspile: true,
|
|
20
|
+
prefix: "Yh",
|
|
21
|
+
ssrOptimization: {
|
|
22
|
+
componentCache: true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setup(options, nuxt) {
|
|
26
|
+
const { resolve } = createResolver(import.meta.url);
|
|
27
|
+
addPlugin(resolve("./runtime/plugin"));
|
|
28
|
+
if (options.importStyle) {
|
|
29
|
+
nuxt.options.css.push("@yh-ui/theme/src/styles/index.scss");
|
|
30
|
+
}
|
|
31
|
+
if (options.buildTranspile) {
|
|
32
|
+
nuxt.options.build.transpile = nuxt.options.build.transpile || [];
|
|
33
|
+
const transpileList = ["@yh-ui/components", "@yh-ui/hooks", "@yh-ui/utils", "@yh-ui/theme"];
|
|
34
|
+
transpileList.forEach((pkg) => {
|
|
35
|
+
if (!nuxt.options.build.transpile.includes(pkg)) {
|
|
36
|
+
nuxt.options.build.transpile.push(pkg);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const components = [
|
|
41
|
+
"Button",
|
|
42
|
+
"Input",
|
|
43
|
+
"InputNumber",
|
|
44
|
+
"InputTag",
|
|
45
|
+
"Autocomplete",
|
|
46
|
+
"Checkbox",
|
|
47
|
+
"CheckboxGroup",
|
|
48
|
+
"Radio",
|
|
49
|
+
"RadioGroup",
|
|
50
|
+
"RadioButton",
|
|
51
|
+
"Switch",
|
|
52
|
+
"Rate",
|
|
53
|
+
"Select",
|
|
54
|
+
"Option",
|
|
55
|
+
"Cascader",
|
|
56
|
+
"CascaderPanel",
|
|
57
|
+
"Slider",
|
|
58
|
+
"TimePicker",
|
|
59
|
+
"TimeSelect",
|
|
60
|
+
"DatePicker",
|
|
61
|
+
"Transfer",
|
|
62
|
+
"TransferPanel",
|
|
63
|
+
"TreeSelect",
|
|
64
|
+
"Divider",
|
|
65
|
+
"Badge",
|
|
66
|
+
"Card",
|
|
67
|
+
"Marquee",
|
|
68
|
+
"Row",
|
|
69
|
+
"Col",
|
|
70
|
+
"ConfigProvider",
|
|
71
|
+
"Form",
|
|
72
|
+
"FormItem",
|
|
73
|
+
"FormSchema",
|
|
74
|
+
"Tag",
|
|
75
|
+
"Icon",
|
|
76
|
+
"ColorPicker",
|
|
77
|
+
"Breadcrumb",
|
|
78
|
+
"BreadcrumbItem",
|
|
79
|
+
"BackTop",
|
|
80
|
+
"Alert",
|
|
81
|
+
"Skeleton",
|
|
82
|
+
"SkeletonItem",
|
|
83
|
+
"Progress",
|
|
84
|
+
"Tooltip",
|
|
85
|
+
"Popconfirm",
|
|
86
|
+
"Popover",
|
|
87
|
+
"Dialog",
|
|
88
|
+
"Drawer",
|
|
89
|
+
"Watermark",
|
|
90
|
+
"Upload",
|
|
91
|
+
"Spin",
|
|
92
|
+
"Pagination",
|
|
93
|
+
"Image",
|
|
94
|
+
"ImageViewer",
|
|
95
|
+
"Descriptions",
|
|
96
|
+
"DescriptionsItem",
|
|
97
|
+
"Tabs",
|
|
98
|
+
"TabPane",
|
|
99
|
+
"Steps",
|
|
100
|
+
"Step",
|
|
101
|
+
"Affix",
|
|
102
|
+
"InfiniteScroll",
|
|
103
|
+
"Dropdown",
|
|
104
|
+
"DropdownItem",
|
|
105
|
+
"DropdownMenu",
|
|
106
|
+
"Menu",
|
|
107
|
+
"MenuItem",
|
|
108
|
+
"MenuItemGroup",
|
|
109
|
+
"SubMenu",
|
|
110
|
+
"Waterfall",
|
|
111
|
+
"Tree",
|
|
112
|
+
"TreeNode",
|
|
113
|
+
"Calendar",
|
|
114
|
+
"Countdown",
|
|
115
|
+
"Table",
|
|
116
|
+
"TableColumn",
|
|
117
|
+
// 新增组件
|
|
118
|
+
"Space",
|
|
119
|
+
"Avatar",
|
|
120
|
+
"Empty",
|
|
121
|
+
// Typography
|
|
122
|
+
"TypographyTitle",
|
|
123
|
+
"TypographyText",
|
|
124
|
+
"TypographyParagraph",
|
|
125
|
+
"TypographyLink",
|
|
126
|
+
// Container
|
|
127
|
+
"Container",
|
|
128
|
+
"Header",
|
|
129
|
+
"Aside",
|
|
130
|
+
"Main",
|
|
131
|
+
"Footer",
|
|
132
|
+
// Result
|
|
133
|
+
"Result",
|
|
134
|
+
// Grid
|
|
135
|
+
"Grid",
|
|
136
|
+
"GridItem",
|
|
137
|
+
// Mention
|
|
138
|
+
"Mention"
|
|
139
|
+
];
|
|
140
|
+
components.forEach((name) => {
|
|
141
|
+
addComponent({
|
|
142
|
+
name: `${options.prefix}${name}`,
|
|
143
|
+
export: `Yh${name}`,
|
|
144
|
+
filePath: "@yh-ui/components"
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
const hooks = [
|
|
148
|
+
"useNamespace",
|
|
149
|
+
"useZIndex",
|
|
150
|
+
"useLocale",
|
|
151
|
+
"useFormItem",
|
|
152
|
+
"createZIndexCounter",
|
|
153
|
+
"useGlobalNamespace",
|
|
154
|
+
"useId",
|
|
155
|
+
"useVirtualScroll",
|
|
156
|
+
"useCache",
|
|
157
|
+
"useEventListener",
|
|
158
|
+
"useScrollLock",
|
|
159
|
+
"useClickOutside",
|
|
160
|
+
"useConfig"
|
|
161
|
+
];
|
|
162
|
+
hooks.forEach((name) => {
|
|
163
|
+
addImports({
|
|
164
|
+
name,
|
|
165
|
+
as: name,
|
|
166
|
+
from: "@yh-ui/hooks"
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
const globalMethods = [
|
|
170
|
+
"YhMessage",
|
|
171
|
+
"YhNotification",
|
|
172
|
+
"YhMessageBox",
|
|
173
|
+
"YhDialogMethod",
|
|
174
|
+
"YhLoading"
|
|
175
|
+
];
|
|
176
|
+
globalMethods.forEach((name) => {
|
|
177
|
+
addImports({
|
|
178
|
+
name,
|
|
179
|
+
as: name,
|
|
180
|
+
from: "@yh-ui/components"
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
extendViteConfig((config) => {
|
|
184
|
+
config.optimizeDeps ||= {};
|
|
185
|
+
config.optimizeDeps.include ||= [];
|
|
186
|
+
const include = config.optimizeDeps.include;
|
|
187
|
+
const dependencies = ["@yh-ui/components", "@yh-ui/hooks", "@yh-ui/utils", "dayjs"];
|
|
188
|
+
dependencies.forEach((dep) => {
|
|
189
|
+
if (!include.includes(dep)) {
|
|
190
|
+
include.push(dep);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
export { yhNuxtModule as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yh-ui/nuxt",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Nuxt module for YH-UI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/module.cjs",
|
|
7
|
+
"module": "./dist/module.mjs",
|
|
8
|
+
"types": "./dist/module.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/module.d.ts",
|
|
12
|
+
"import": "./dist/module.mjs",
|
|
13
|
+
"require": "./dist/module.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@nuxt/kit": "^3.11.0 || ^4.0.0",
|
|
21
|
+
"@yh-ui/components": "0.1.0",
|
|
22
|
+
"@yh-ui/theme": "0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@nuxt/schema": "^3.11.0 || ^4.0.0",
|
|
26
|
+
"nuxt": "^3.11.0 || ^4.0.0-rc.1",
|
|
27
|
+
"vue": "^3.5.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"nuxt": "^3.11.0 || ^4.0.0-rc.1"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/1079161148/yh-ui.git",
|
|
38
|
+
"directory": "packages/nuxt"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"yh-ui",
|
|
42
|
+
"nuxt",
|
|
43
|
+
"module"
|
|
44
|
+
],
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "unbuild",
|
|
48
|
+
"dev": "unbuild --stub"
|
|
49
|
+
}
|
|
50
|
+
}
|