@swj_ld/ld-component-library 1.1.0 → 1.1.2
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 +36 -35
- package/package.json +13 -11
- package/src/components/SwjButton/SwjButton.vue +13 -0
- package/src/components/SwjEmpty/SwjEmpty.vue +3 -1
- package/src/index.ts +13 -15
package/README.md
CHANGED
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
> 一套专为 **uni-app** 打造的轻量级 Vue 3 组件库,支持 **H5、微信小程序、支付宝小程序等全平台**,开箱即用。
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@swj_ld/ld-component-library)
|
|
6
|
-
[](LICENSE)
|
|
7
|
-
[](https://bundlephobia.com/result?p=@swj_ld/ld-component-library)
|
|
5
|
+
[](https://www.npmjs.com/package/@swj_ld/ld-component-library)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://bundlephobia.com/result?p=@swj_ld/ld-component-library)
|
|
8
8
|
|
|
9
9
|
## ✨ 特性
|
|
10
10
|
|
|
11
|
-
- ✅ **uni-app 原生兼容**:所有组件使用 `<view>`、`<text>` 等标准标签,无 DOM 操作
|
|
12
|
-
- ✅ **多端一致**:H5 / 微信小程序 / 支付宝小程序 渲染效果一致
|
|
13
|
-
- ✅
|
|
14
|
-
- ✅ **TypeScript 友好**:自带类型提示,开发体验流畅
|
|
15
|
-
- ✅
|
|
11
|
+
- ✅ **uni-app 原生兼容**:所有组件使用 `<view>`、`<text>` 等标准标签,无 DOM/BOM 操作
|
|
12
|
+
- ✅ **多端一致**:H5 / 微信小程序 / 支付宝小程序 渲染效果一致
|
|
13
|
+
- ✅ **源码发布**:以 `.vue` 源文件形式发布,由用户项目编译,避免打包兼容问题
|
|
14
|
+
- ✅ **TypeScript 友好**:自带类型提示,开发体验流畅
|
|
15
|
+
- ✅ **按需使用**:每个组件独立引入,天然支持 Tree-shaking
|
|
16
|
+
|
|
17
|
+
> ⚠️ **注意**:本组件库 **不提供预编译的 JS 包**,请勿尝试 `app.use()` 或解构式按需引入(如 `import { SwjEmpty } from '...'`),这些方式在 uni-app 小程序中 **无法渲染组件**。
|
|
18
|
+
|
|
19
|
+
---
|
|
16
20
|
|
|
17
21
|
## 📦 安装
|
|
18
22
|
|
|
@@ -21,42 +25,39 @@ npm install @swj_ld/ld-component-library
|
|
|
21
25
|
# 或
|
|
22
26
|
yarn add @swj_ld/ld-component-library
|
|
23
27
|
|
|
28
|
+
🚀 使用方式(推荐)
|
|
29
|
+
✅ 方式一:直接引入 .vue 文件(最稳定,全平台支持)
|
|
24
30
|
|
|
25
|
-
本组件库采用 源码发布模式:
|
|
26
|
-
|
|
27
|
-
所有组件以 .vue 源文件形式发布
|
|
28
|
-
不经过任何打包或编译
|
|
29
|
-
由用户的 uni-app 项目负责最终编译为各端代码
|
|
30
|
-
因此,请确保:
|
|
31
|
-
|
|
32
|
-
用户项目使用 Vite + Vue 3 + uni-app v3+
|
|
33
|
-
不要对组件进行二次包装(否则可能导致小程序白屏)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
🚀 使用方式
|
|
38
|
-
方式一:按需引入(推荐)——已测-正常
|
|
39
31
|
<template>
|
|
40
32
|
<SwjEmpty description="暂无数据" />
|
|
41
33
|
</template>
|
|
42
34
|
|
|
43
35
|
<script setup lang="ts">
|
|
36
|
+
// 注意:直接指定到 .vue 文件路径
|
|
44
37
|
import SwjEmpty from '@swj_ld/ld-component-library/SwjEmpty'
|
|
45
38
|
</script>
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
✅ 方式二:配置 easycom(自动按需,无需 import)
|
|
41
|
+
在项目根目录的 pages.json 中添加以下配置:
|
|
42
|
+
{
|
|
43
|
+
"easycom": {
|
|
44
|
+
"autoscan": true,
|
|
45
|
+
"custom": {
|
|
46
|
+
'^Swj(.*)$': '@swj_ld/ld-component-library/Swj$1'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"pages": [
|
|
50
|
+
// ...你的页面配置
|
|
51
|
+
]
|
|
52
|
+
}
|
|
59
53
|
|
|
60
54
|
<template>
|
|
61
|
-
<
|
|
55
|
+
<view>
|
|
56
|
+
<SwjEmpty />
|
|
57
|
+
<SwjButton type="primary">确定</SwjButton>
|
|
58
|
+
</view>
|
|
62
59
|
</template>
|
|
60
|
+
|
|
61
|
+
<script setup>
|
|
62
|
+
// ✅ 无需任何 import!
|
|
63
|
+
</script>
|
package/package.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swj_ld/ld-component-library",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "A set of custom components for uni-app",
|
|
5
|
+
"keywords": ["uni-app", "vue3", "components"],
|
|
5
6
|
"author": "Joy",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
+
"main": "./src/index.ts",
|
|
9
|
+
"module": "./src/index.ts",
|
|
10
|
+
"types": "./src/index.ts",
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"import": "./src/index.ts",
|
|
11
14
|
"require": "./src/index.ts"
|
|
12
15
|
},
|
|
13
|
-
"./SwjEmpty": "./src/components/SwjEmpty/SwjEmpty.vue"
|
|
16
|
+
"./SwjEmpty": "./src/components/SwjEmpty/SwjEmpty.vue",
|
|
17
|
+
"./SwjButton": "./src/components/SwjButton/SwjButton.vue"
|
|
14
18
|
},
|
|
15
|
-
"main": "./src/index.ts",
|
|
16
|
-
"module": "./src/index.ts",
|
|
17
|
-
"types": "./src/index.ts",
|
|
18
19
|
"files": [
|
|
20
|
+
"src",
|
|
19
21
|
"assets",
|
|
20
|
-
"
|
|
22
|
+
"dist"
|
|
21
23
|
],
|
|
22
|
-
|
|
23
|
-
"@dcloudio/uni-app": "3.0.0-4070620250821001",
|
|
24
|
+
"peerDependencies": {
|
|
24
25
|
"sard-uniapp": "^1.25.2",
|
|
25
|
-
"vue": "^3.4.21"
|
|
26
|
+
"vue": "^3.4.21",
|
|
27
|
+
"@dcloudio/uni-app": "3.0.0-4070620250821001"
|
|
26
28
|
},
|
|
27
29
|
"peerDependenciesMeta": {
|
|
28
30
|
"sard-uniapp": {
|
|
@@ -32,4 +34,4 @@
|
|
|
32
34
|
"publishConfig": {
|
|
33
35
|
"access": "public"
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
+
import nodataImage from '../../../assets/images/nodata.png'
|
|
3
|
+
defineOptions({ name: 'SwjEmpty' })
|
|
2
4
|
interface Props {
|
|
3
5
|
description?: string
|
|
4
6
|
top?: string
|
|
@@ -23,7 +25,7 @@ withDefaults(defineProps<Props>(), {
|
|
|
23
25
|
}"
|
|
24
26
|
>
|
|
25
27
|
<template #icon>
|
|
26
|
-
<image src="
|
|
28
|
+
<image :src="nodataImage" class="image-box" />
|
|
27
29
|
</template>
|
|
28
30
|
<template #default>
|
|
29
31
|
<slot />
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
// 可选:提供插件形式(用于 app.use())
|
|
1
|
+
// 引入所有组件
|
|
3
2
|
import SwjEmpty from './components/SwjEmpty/SwjEmpty.vue'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import SwjButton from './components/SwjButton/SwjButton.vue'
|
|
4
|
+
// 组件列表用于全局注册
|
|
5
|
+
const components = [SwjEmpty, SwjButton]
|
|
6
|
+
// 全局注册的install方法,vue3的app use需要这个
|
|
7
|
+
const install = (app: any) => {
|
|
8
|
+
components.forEach((component: any) => {
|
|
9
|
+
app.component(component.name, component)
|
|
10
|
+
})
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
app.component(name, component)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
12
|
+
// 命名导出,支持按需解构引入
|
|
13
|
+
export { SwjEmpty, SwjButton }
|
|
14
|
+
// 默认导出,支持全局注册app.use
|
|
15
|
+
export default {install}
|