Skip to content

Commit

Permalink
docs(sites): update official website documentation and readme (#2895)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzcr authored Feb 14, 2025
1 parent 842cece commit 441c376
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 123 deletions.
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/webdoc/develop-demo-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
'process.env': { TINY_MODE: 'pc' }
}
})
```
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/webdoc/develop-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
'process.env': { TINY_MODE: 'pc' }
}
})
```
Expand Down
154 changes: 41 additions & 113 deletions examples/sites/demos/pc/webdoc/import-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,121 +14,67 @@ npm i @opentiny/unplugin-tiny-vue -D

然后把以下代码插入到你项目的 `Vite``Webpack` 配置文件中。

Vite

```ts
// vite.config.ts

import autoImportPlugin from '@opentiny/unplugin-tiny-vue'

export default {
plugins: [autoImportPlugin('vite')]
}
```

Webpack

```js
// vue.config.js

const autoImportPlugin = require('@opentiny/unplugin-tiny-vue')

module.exports = defineConfig({
configureWebpack: {
plugins: [autoImportPlugin('webpack')]
}
})
```

这样你就能直接在项目中使用 TinyVue 的组件,这些组件都是自动按需导入的,无需手动导入,且不用担心项目体积变得太大。

你也可以只使用 TinyVueResolver,这样就可以和其他组件库一起使用。
实现效果类似于单组件引入:`TinyVueSingleResolver('TinyModal') => import TinyModal from '@opentiny/vue-modal'`

Vite

```ts
// vite.config.ts

```js
// vite.config.js
import { defineConfig } from 'vite'
import Components from 'unplugin-vue-components/vite'
import { TinyVueResolver } from '@opentiny/unplugin-tiny-vue'
import AutoImport from 'unplugin-auto-import/vite'
import { TinyVueSingleResolver } from '@opentiny/unplugin-tiny-vue'

export default {
export default defineConfig({
plugins: [
Components({
resolvers: [TinyVueResolver]
resolvers: [TinyVueSingleResolver]
}),
AutoImport({
resolvers: [TinyVueSingleResolver]
})
]
}
})
```

Webpack

```js
// vue.config.js

const Components = require('unplugin-vue-components/webpack').default
const TinyVueResolver = require('@opentiny/unplugin-tiny-vue').TinyVueResolver

module.exports = defineConfig({
configureWebpack: {
plugins: [
Components({
resolvers: [TinyVueResolver]
})
]
}
})
```

#### 关于函数式组件

TinyModal,TinyNotify,TinyLoading 可使用函数形式调用,在使用时,需使用 `unplugin-auto-import` 实现自动导入。

Vite
// webpack.config.js
const Components = require('unplugin-vue-components/webpack')
const AutoImport = require('unplugin-auto-import/webpack')
const { TinyVueSingleResolver } = require('@opentiny/unplugin-tiny-vue')

```js
// vite.config.js
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import { TinyVueResolver } from '@opentiny/unplugin-tiny-vue'

module.exports = defineConfig({
configureWebpack: {
plugins: [
Components({
resolvers: [TinyVueResolver]
}),
AutoImport({
resolvers: [TinyVueResolver]
})
]
}
})
module.exports = {
plugins: [
Components({
resolvers: [TinyVueSingleResolver]
}),
AutoImport({
resolvers: [TinyVueSingleResolver]
})
]
}
```

Webpack
#### 温馨提示

```js
// webpack.config.js
const Components = require('unplugin-vue-components/webpack').default
const AutoImport = require('unplugin-auto-import/webpack').default
const TinyVueResolver = require('@opentiny/unplugin-tiny-vue').TinyVueResolver

module.exports = defineConfig({
configureWebpack: {
plugins: [
Components({
resolvers: [TinyVueResolver]
}),
AutoImport({
resolvers: [TinyVueResolver]
})
]
因为 `pnpm` 工程的特点之一是:项目中显示引入的依赖需要提前在 `package.json` 中声明(防止幽灵依赖),所以在 `pnpm` 工程使用该插件时需要在 `package.json` 中声明项目用到的每一个 `TinyVue` 组件依赖(`TinyVue` 每个组件都是一个 `npm` 包)。依赖声明可以参考以下配置:

```json
{
"dependencies": {
"@opentiny/vue-button": "~3.x.x",
"@opentiny/vue-alert": "~3.x.x",
"@opentiny/vue-input": "~3.x.x",
...
}
})
}
```

想了解更多自动按需导入的信息,请参考:[unplugin-vue-components](https://github.com/antfu/unplugin-vue-components)[unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)
想了解更多自动按需导入的信息,请参考:
[unplugin-vue-components](https://github.com/antfu/unplugin-vue-components)
[unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)

## 多组件引入

Expand Down Expand Up @@ -197,25 +143,7 @@ export default {
],
'pc' // 此配置非必选,按需配置 (pc|mobile|mobile-first)
)
],
define: {
'process.env': { ...process.env }
}
}
```

### 温馨提示

因为 `pnpm` 工程的特点之一是:项目中显示引入的依赖需要提前在 `package.json` 中声明(防止幽灵依赖),所以在 `pnpm` 工程使用该插件时需要在 `package.json` 中声明项目用到的每一个 `TinyVue` 组件依赖(`TinyVue` 每个组件都是一个 `npm` 包)。依赖声明可以参考以下配置:

```json
{
"dependencies": {
"@opentiny/vue-button": "~3.x.x",
"@opentiny/vue-alert": "~3.x.x",
"@opentiny/vue-input": "~3.x.x",
...
}
]
}
```

Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/webdoc/installation-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
'process.env': { TINY_MODE: 'pc' }
}
})
```
Expand Down
5 changes: 2 additions & 3 deletions examples/sites/demos/pc/webdoc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
define: {
'process.env': { ...process.env }
'process.env': { TINY_MODE: 'pc' }
}
})
```

<div class="tip custom-block">
<p>为了避免<code> @opentiny/vue </code> 的月度版本 (minor) 升级带来的不确定因素,因此推荐在您的工程中的<code> package.json </code> 中依赖包的版本号前使用 ~,
比如 <code>"@opentiny/vue": "~3.12.0</code>。</p>
<p><code> @opentiny/vue </code> 支持多种模式。如果您的工程非移动端工程,可以在上面配置代码中的<code>process.env</code>中,声明<code>TINY_MODE</code>的值,以使工程在构建时,能将移动端模式的代码摇掉,优化打包产物的体积。比如 <code>'process.env': { ...process.env,TINY_MODE:'pc' }</code>。</p>
<p><code> @opentiny/vue </code> 支持多种模式。如果您的工程非移动端工程,可以在上面配置代码中的<code>process.env</code>中,声明<code>TINY_MODE</code>的值,以使工程在构建时,能将移动端模式的代码摇掉,优化打包产物的体积。比如 <code>'process.env': { TINY_MODE:'pc' }</code>。</p>
</div>

## 通过 CDN 方式引入 (v3.16.0 及之前的版本可用)
Expand Down Expand Up @@ -83,7 +83,6 @@ export default defineConfig({
| Runtime 名称 | 使用说明 |
| ------------------------- | -------------------------- |
| tiny-vue-pc.mjs | 包含所有 pc 模板的组件集合 |
| tiny-vue-mobile.mjs | 包含所有移动模板的组件集合 |
| tiny-vue-mobile-first.mjs | 包含所有多端模板的组件集合 |
| tiny-vue-simple.mjs | 包含常用组件的集合 |

Expand Down
4 changes: 2 additions & 2 deletions internals/cli/src/commands/build/build-entry-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const install = (app, opts = {}) => {
* mobile 包含素有mobile组件
* mobile-first 包含所有多端组件
*/
type RunTimeModeType = 'all' | 'pc' | 'mobile' | 'mobile-first' | 'simple'
const runtimeModeList: Array<RunTimeModeType> = ['all', 'pc', 'mobile', 'mobile-first', 'simple']
type RunTimeModeType = 'all' | 'pc' | 'mobile-first' | 'simple'
const runtimeModeList: Array<RunTimeModeType> = ['all', 'pc', 'mobile-first', 'simple']

// 简易模式下需要排除的组件列表,包括chart、业务组件、冷门组件等
const notSimpleComponents = [
Expand Down
1 change: 0 additions & 1 deletion packages/vue-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ In order to meet different business needs, `TinyVue` provides multiple forms of
| Runtime name | Instructions |
| ------------------------- | ----------------------------------------------------------------- |
| tiny-vue-pc.mjs | A collection of components including all pc templates |
| tiny-vue-mobile.mjs | A collection of components including all mobile templates |
| tiny-vue-mobile-first.mjs | A collection of components including all multi-terminal templates |
| tiny-vue-simple.mjs | A collection of commonly used components |

Expand Down
1 change: 0 additions & 1 deletion packages/vue-runtime/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
| Runtime 名称 | 使用说明 |
| ------------------------- | -------------------------- |
| tiny-vue-pc.mjs | 包含所有pc模板的组件集合 |
| tiny-vue-mobile.mjs | 包含所有移动模板的组件集合 |
| tiny-vue-mobile-first.mjs | 包含所有多端模板的组件集合 |
| tiny-vue-simple.mjs | 包含常用组件的集合 |

Expand Down

0 comments on commit 441c376

Please sign in to comment.