lxui-uni 0.0.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/index.ts +12 -0
- package/lib/lx-hello.vue +20 -0
- package/lib/lx-image.vue +82 -0
- package/package.json +13 -0
package/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import lxHello from './lib/lx-hello.vue'
|
|
3
|
+
import lxImage from './lib/lx-image.vue'
|
|
4
|
+
export { lxHello, lxImage }
|
|
5
|
+
const coms = [lxHello,lxImage]
|
|
6
|
+
export default {
|
|
7
|
+
install(app: App){
|
|
8
|
+
coms.forEach((commponent) => {
|
|
9
|
+
app.component(commponent.name as string, commponent)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
package/lib/lx-hello.vue
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
msg: string
|
|
4
|
+
}>()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="greetings">
|
|
9
|
+
<h1 class="green">{{ msg }}</h1>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style scoped>
|
|
14
|
+
h1 {
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
font-size: 2.6rem;
|
|
17
|
+
position: relative;
|
|
18
|
+
top: -10px;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
package/lib/lx-image.vue
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="images" :style="isCorrect ? correctStyle : errorStyle">
|
|
3
|
+
<image :src="url || defaultPic" @error="handleImageError" :mode="mode" />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, reactive, ref, watchEffect } from 'vue';
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* @description: 图片组件
|
|
12
|
+
* @fileName: ex-image.vue
|
|
13
|
+
* @params src : 图片路径
|
|
14
|
+
* @params mode : 图片模式 默认:aspectFill
|
|
15
|
+
* @params width : 宽 默认:80rpx
|
|
16
|
+
* @params height : 高 默认:80rpx
|
|
17
|
+
* @params type : 区分分页和icon类型 默认:list
|
|
18
|
+
* @author: ckl
|
|
19
|
+
* @date: 2023-12-18"
|
|
20
|
+
* @version: V1.0.0
|
|
21
|
+
*/
|
|
22
|
+
const props = withDefaults(
|
|
23
|
+
defineProps<{
|
|
24
|
+
src: string
|
|
25
|
+
mode?: string
|
|
26
|
+
width?: number | string
|
|
27
|
+
height?: number | string
|
|
28
|
+
type: 'list' | 'icon'
|
|
29
|
+
radius?: string
|
|
30
|
+
}>(),
|
|
31
|
+
{
|
|
32
|
+
src: '',
|
|
33
|
+
mode: 'aspectFill',
|
|
34
|
+
width: '200rpx',
|
|
35
|
+
height: '200rpx',
|
|
36
|
+
type: 'list'
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const url = ref(props.src)
|
|
41
|
+
|
|
42
|
+
const isCorrect = ref(true)
|
|
43
|
+
|
|
44
|
+
const correctStyle = reactive({
|
|
45
|
+
width: props.width,
|
|
46
|
+
height: props.height,
|
|
47
|
+
borderRadius: props.radius,
|
|
48
|
+
overflow: 'hidden'
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const errorStyle = reactive({
|
|
52
|
+
width: props.width,
|
|
53
|
+
height: props.height,
|
|
54
|
+
padding: '14rpx',
|
|
55
|
+
backgroundColor: '#dedede',
|
|
56
|
+
borderRadius: '4px'
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const defaultPic = computed(() => {
|
|
60
|
+
return `/static/${props.type === 'list' ? 'nomore' : 'defauIcon'}.png`
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const handleImageError = () => {
|
|
64
|
+
if (props.type !== 'list') {
|
|
65
|
+
isCorrect.value = false
|
|
66
|
+
}
|
|
67
|
+
url.value = defaultPic.value
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
watchEffect(() => {
|
|
71
|
+
url.value = props.src
|
|
72
|
+
})
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<style scoped lang="scss">
|
|
76
|
+
.iamges {
|
|
77
|
+
image {
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</style>
|