Skip to content

Commit 2d23607

Browse files
docs: ✏️ 调整组件库基于vite配置自动引入组件的介绍
1 parent 325ba0b commit 2d23607

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

docs/guide/quick-use.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
:::warning 关于安装
66
`Wot Design Uni`提供了`uni_modules``npm`两种安装方式,按需选择。
77
- 使用`uni_modules`安装无需额外配置,即插即用,但是每次更新组件库需要处理代码差异(一般直接覆盖就可以)。
8-
- 使用`npm`安装需要配置`easycom`,更新组件库时无需处理代码差异。
8+
- 使用`npm`安装需要额外配置,更新组件库时无需处理代码差异。
99
:::
1010

1111
## uni_modules 安装
1212

13-
`Wot Design Uni` 支持 [uni_modules](https://uniapp.dcloud.net.cn/plugin/uni_modules.html#uni-modules) 规范,已经上架到 uni-app 的插件市场,故我们推荐使用 uni_modules 的方式引入,方便更新
13+
`Wot Design Uni` 支持 [uni_modules](https://uniapp.dcloud.net.cn/plugin/uni_modules.html#uni-modules) 规范,已经上架到 uni-app 的插件市场。
1414

1515
`uni-app插件市场`选择使用`HBuildX`导入,或者选择手动在src目录下创建uni_modules文件夹并将`Wot Design Uni`解压到uni_modules中,结构如下:
1616
```
@@ -66,6 +66,11 @@ pnpm add wot-design-uni
6666
### 基于vite配置自动引入组件<el-tag type="primary" style="vertical-align: middle;margin-left:8px;" effect="dark" >自动引入方案2</el-tag>
6767
如果不熟悉`easycom`,也可以通过[@uni-helper/vite-plugin-uni-components](https://github.com/uni-helper/vite-plugin-uni-components)实现组件的自动引入。
6868

69+
:::tip 提醒
70+
- 推荐使用@uni-helper/vite-plugin-uni-components@0.0.9及以上版本,因为在0.0.9版本开始其内置了`wot-design-uni``resolver`
71+
- 如果使用此方案时控制台打印很多`Sourcemap for points to missing source files​`,可以尝试将vite版本升级至4.5.x。
72+
:::
73+
6974
::: code-group
7075
```bash [npm]
7176
npm i @uni-helper/vite-plugin-uni-components -D
@@ -79,6 +84,8 @@ yarn add @uni-helper/vite-plugin-uni-components -D
7984
pnpm add @uni-helper/vite-plugin-uni-components -D
8085
```
8186
:::
87+
88+
***@uni-helper/vite-plugin-uni-components 0.0.8及之前版本***
8289
```ts
8390
// vite.config.ts
8491
import { defineConfig } from "vite";
@@ -87,7 +94,8 @@ import uni from "@dcloudio/vite-plugin-uni";
8794
import Components, { kebabCase } from '@uni-helper/vite-plugin-uni-components'
8895

8996
export default defineConfig({
90-
plugins: [Components({
97+
plugins: [
98+
Components({
9199
resolvers: [
92100
{
93101
type: 'component',
@@ -105,6 +113,24 @@ export default defineConfig({
105113
}), uni()],
106114
});
107115
```
116+
117+
***@uni-helper/vite-plugin-uni-components 0.0.9及以后版本***
118+
```ts
119+
// vite.config.ts
120+
import { defineConfig } from "vite";
121+
import uni from "@dcloudio/vite-plugin-uni";
122+
123+
import Components from '@uni-helper/vite-plugin-uni-components'
124+
import { WotResolver } from '@uni-helper/vite-plugin-uni-components/resolvers'
125+
126+
127+
export default defineConfig({
128+
plugins: [
129+
Components({
130+
resolvers: [WotResolver()]
131+
}), uni()],
132+
});
133+
```
108134
#### UI 组件类型提示
109135

110136
如果你使用 `pnpm` ,请在根目录下创建一个 `.npmrc` 文件,参见[issue](https://github.com/antfu/unplugin-vue-components/issues/389)

docs/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,22 @@ features:
4747

4848
footer: false
4949
---
50+
51+
<script setup lang="ts">
52+
import { onMounted } from 'vue'
53+
import { ElMessage, ElMessageBox } from 'element-plus'
54+
onMounted(()=>{
55+
if (window.location.hostname === 'localhost') {
56+
ElMessageBox.confirm('您正在访问的站点速度较慢,是否跳转至更快的 wot-design-uni.gitee.io ?', '提示', {
57+
confirmButtonText: '确定',
58+
cancelButtonText: '取消',
59+
type: 'warning'
60+
}).then(() => {
61+
window.location.href = 'https://wot-design-uni.gitee.io/';
62+
}).catch(() => {
63+
// 用户点击取消按钮时的操作
64+
});
65+
}
66+
})
67+
68+
</script>

0 commit comments

Comments
 (0)