@swj_ld/ld-component-library 1.0.3

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,62 @@
1
+ # @swj_ld/ld-component-library
2
+
3
+ > 一套专为 **uni-app** 打造的轻量级 Vue 3 组件库,支持 **H5、微信小程序、支付宝小程序等全平台**,开箱即用。
4
+
5
+ [![](https://img.shields.io/npm/v/@swj_ld/ld-component-library?color=green)](https://www.npmjs.com/package/@swj_ld/ld-component-library)
6
+ [![](https://img.shields.io/npm/l/@swj_ld/ld-component-library)](LICENSE)
7
+ [![](https://img.shields.io/bundlephobia/minzip/@swj_ld/ld-component-library?label=minzipped)](https://bundlephobia.com/result?p=@swj_ld/ld-component-library)
8
+
9
+ ## ✨ 特性
10
+
11
+ - ✅ **uni-app 原生兼容**:所有组件使用 `<view>`、`<text>` 等标准标签,无 DOM 操作
12
+ - ✅ **多端一致**:H5 / 微信小程序 / 支付宝小程序 渲染效果一致
13
+ - ✅ **按需引入**:支持 Tree-shaking,不增加无用代码
14
+ - ✅ **TypeScript 友好**:自带类型提示,开发体验流畅
15
+ - ✅ **零构建依赖**:发布源码(`.vue`),由用户项目编译,避免兼容问题
16
+
17
+ ## 📦 安装
18
+
19
+ ```bash
20
+ npm install @swj_ld/ld-component-library
21
+ # 或
22
+ yarn add @swj_ld/ld-component-library
23
+
24
+
25
+ 本组件库采用 源码发布模式:
26
+
27
+ 所有组件以 .vue 源文件形式发布
28
+ 不经过任何打包或编译
29
+ 由用户的 uni-app 项目负责最终编译为各端代码
30
+ 因此,请确保:
31
+
32
+ 用户项目使用 Vite + Vue 3 + uni-app v3+
33
+ 不要对组件进行二次包装(否则可能导致小程序白屏)
34
+
35
+
36
+
37
+ 🚀 使用方式
38
+ 方式一:按需引入(推荐)——已测-正常
39
+ <template>
40
+ <SwjEmpty description="暂无数据" />
41
+ </template>
42
+
43
+ <script setup lang="ts">
44
+ import SwjEmpty from '@swj_ld/ld-component-library/SwjEmpty'
45
+ </script>
46
+
47
+ 方式二:整体引入——已测-非正常
48
+ import { SwjEmpty, SwjButton } from '@swj_ld/ld-component-library'
49
+
50
+ 方式三:全局注册(适合大量使用)——目前用file本地link的方式无法正常加载
51
+ // main.ts 或 main.js
52
+ import { createApp } from 'vue'
53
+ import App from './App.vue'
54
+ import LdComponentLibrary from '@swj_ld/ld-component-library'
55
+
56
+ const app = createApp(App)
57
+ app.use(LdComponentLibrary) // 自动注册所有组件
58
+ app.mount('#app')
59
+
60
+ <template>
61
+ <SwjEmpty />
62
+ </template>
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@swj_ld/ld-component-library",
3
+ "version": "1.0.3",
4
+ "description": "A set of custom components for uni-app",
5
+ "author": "Joy",
6
+ "license": "MIT",
7
+ "keywords": ["uni-app", "vue3", "components"],
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.ts",
11
+ "require": "./src/index.ts"
12
+ },
13
+ "./SwjEmpty": "./src/components/SwjEmpty/SwjEmpty.vue"
14
+ },
15
+ "main": "./src/index.ts",
16
+ "module": "./src/index.ts",
17
+ "types": "./src/index.ts",
18
+ "files": [
19
+ "src"
20
+ ],
21
+ "peerDependencies": {
22
+ "@dcloudio/uni-app": "3.0.0-4070620250821001",
23
+ "sard-uniapp": "^1.25.2",
24
+ "vue": "^3.4.21"
25
+ },
26
+ "peerDependenciesMeta": {
27
+ "sard-uniapp": {
28
+ "optional": false
29
+ }
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
34
+ }
@@ -0,0 +1,46 @@
1
+ <script lang="ts" setup>
2
+ interface Props {
3
+ description?: string
4
+ top?: string
5
+ }
6
+
7
+ withDefaults(defineProps<Props>(), {
8
+ description: '暂无数据',
9
+ top: '46%',
10
+ })
11
+ </script>
12
+
13
+ <template>
14
+ <view class="empty-wrap" :style="{ top }">
15
+ <sar-empty
16
+ :description="description"
17
+ :root-style="{
18
+ '--sar-empty-description-margin-top': 0,
19
+ '--sar-empty-description-font-size': '28rpx',
20
+ '--sar-empty-description-font-weight': '300',
21
+ '--sar-empty-description-color': '#151515',
22
+ '--sar-empty-extra-margin-top': 0,
23
+ }"
24
+ >
25
+ <template #icon>
26
+ <image src="../../../assets/images/nodata.png" class="image-box" />
27
+ </template>
28
+ <template #default>
29
+ <slot />
30
+ </template>
31
+ </sar-empty>
32
+ </view>
33
+ </template>
34
+
35
+ <style lang="scss" scoped>
36
+ .empty-wrap {
37
+ position: absolute;
38
+ left: 50%;
39
+ transform: translate(-50%, -50%);
40
+ .image-box {
41
+ margin-bottom: 28rpx;
42
+ width: 200rpx;
43
+ height: 200rpx;
44
+ }
45
+ }
46
+ </style>
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ export { default as SwjEmpty } from './components/SwjEmpty/SwjEmpty.vue'
2
+ // 可选:提供插件形式(用于 app.use())
3
+ import SwjEmpty from './components/SwjEmpty/SwjEmpty.vue'
4
+
5
+ const getComponent = (comp: any) => comp.default || comp
6
+
7
+ const components = {
8
+ SwjEmpty: getComponent(SwjEmpty),
9
+ }
10
+
11
+ export default {
12
+ install(app: any) {
13
+ for (const [name, component] of Object.entries(components)) {
14
+ app.component(name, component)
15
+ }
16
+ }
17
+ }
package/src/vue.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ // types/vue.d.ts
2
+ declare module '*.vue' {
3
+ import type { DefineComponent } from 'vue'
4
+ const component: DefineComponent<{}, {}, any>
5
+ export default component
6
+ }