@ruixinkeji/prism-ui 1.0.0 → 1.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/README.md +1 -1
- package/components/PrismAIAssist/PrismAIAssist.vue +98 -98
- package/components/PrismAddressInput/PrismAddressInput.vue +597 -597
- package/components/PrismCityCascadeSelect/PrismCityCascadeSelect.vue +793 -793
- package/components/PrismCityPicker/PrismCityPicker.vue +1008 -1008
- package/components/PrismCitySelect/PrismCitySelect.vue +435 -435
- package/components/PrismCode/PrismCode.vue +749 -749
- package/components/PrismCodeInput/PrismCodeInput.vue +156 -156
- package/components/PrismDateTimePicker/PrismDateTimePicker.vue +953 -953
- package/components/PrismDropdown/PrismDropdown.vue +77 -77
- package/components/PrismGroupSticky/PrismGroupSticky.vue +352 -352
- package/components/PrismIdCardInput/PrismIdCardInput.vue +253 -253
- package/components/PrismImagePicker/PrismImagePicker.vue +457 -457
- package/components/PrismIndexBar/PrismIndexBar.vue +243 -243
- package/components/PrismLicensePlateInput/PrismLicensePlateInput.vue +1100 -1100
- package/components/PrismMusicPlayer/PrismMusicPlayer.vue +530 -530
- package/components/PrismNavBar/PrismNavBar.vue +199 -199
- package/components/PrismSecureInput/PrismSecureInput.vue +360 -360
- package/components/PrismSticky/PrismSticky.vue +173 -173
- package/components/PrismSwiper/PrismSwiper.vue +338 -338
- package/components/PrismSwitch/PrismSwitch.vue +202 -202
- package/components/PrismTabBar/PrismTabBar.vue +147 -147
- package/components/PrismTabs/PrismTabs.vue +49 -49
- package/components/PrismVoiceInput/PrismVoiceInput.vue +529 -529
- package/fonts/fa-brands-400.woff2 +0 -0
- package/fonts/fa-regular-400.woff2 +0 -0
- package/fonts/fa-solid-900.woff2 +0 -0
- package/fonts/fa-v4compatibility.woff2 +0 -0
- package/fonts/font-awesome.css +913 -0
- package/fonts/iconfont.woff2 +0 -0
- package/package.json +7 -1
- package/store/app.d.ts +21 -0
- package/store/app.js +68 -0
- package/styles/base.scss +2 -2
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="prism-sticky">
|
|
3
|
-
<view class="prism-sticky__wrap" :class="[elClass]" :style="wrapStyle">
|
|
4
|
-
<view
|
|
5
|
-
class="prism-sticky__content"
|
|
6
|
-
:style="{
|
|
7
|
-
position: fixed ? 'fixed' : 'static',
|
|
8
|
-
top: stickyTop + 'px',
|
|
9
|
-
left: left + 'px',
|
|
10
|
-
width: width === 'auto' ? 'auto' : width + 'px',
|
|
11
|
-
zIndex: zIndex,
|
|
12
|
-
background: bgColor
|
|
13
|
-
}"
|
|
14
|
-
>
|
|
15
|
-
<slot></slot>
|
|
16
|
-
</view>
|
|
17
|
-
</view>
|
|
18
|
-
</view>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup>
|
|
22
|
-
import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
|
|
23
|
-
|
|
24
|
-
const props = defineProps({
|
|
25
|
-
// 吸顶时距离顶部的距离(rpx)
|
|
26
|
-
offsetTop: {
|
|
27
|
-
type: Number,
|
|
28
|
-
default: 0
|
|
29
|
-
},
|
|
30
|
-
// 自定义导航栏高度(px)
|
|
31
|
-
navHeight: {
|
|
32
|
-
type: Number,
|
|
33
|
-
default: 0
|
|
34
|
-
},
|
|
35
|
-
// 是否开启吸顶
|
|
36
|
-
enabled: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: true
|
|
39
|
-
},
|
|
40
|
-
// 背景颜色
|
|
41
|
-
bgColor: {
|
|
42
|
-
type: String,
|
|
43
|
-
default: ''
|
|
44
|
-
},
|
|
45
|
-
// z-index
|
|
46
|
-
zIndex: {
|
|
47
|
-
type: Number,
|
|
48
|
-
default: 100
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const emit = defineEmits(['fixed', 'unfixed']);
|
|
53
|
-
|
|
54
|
-
const instance = getCurrentInstance();
|
|
55
|
-
|
|
56
|
-
// 生成唯一类名
|
|
57
|
-
const elClass = ref('prism-sticky-' + Math.random().toString(36).slice(2, 10));
|
|
58
|
-
|
|
59
|
-
// 状态
|
|
60
|
-
const fixed = ref(false);
|
|
61
|
-
const height = ref('auto');
|
|
62
|
-
const width = ref('auto');
|
|
63
|
-
const left = ref(0);
|
|
64
|
-
const stickyTop = ref(0);
|
|
65
|
-
|
|
66
|
-
// 观察器
|
|
67
|
-
let observer = null;
|
|
68
|
-
|
|
69
|
-
// 包裹层样式
|
|
70
|
-
const wrapStyle = computed(() => ({
|
|
71
|
-
height: fixed.value ? height.value + 'px' : 'auto',
|
|
72
|
-
zIndex: props.zIndex
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
|
-
// 初始化观察器
|
|
76
|
-
function initObserver() {
|
|
77
|
-
if (!props.enabled) return;
|
|
78
|
-
|
|
79
|
-
// 计算吸顶位置
|
|
80
|
-
// #ifdef H5
|
|
81
|
-
stickyTop.value = props.navHeight + (props.offsetTop ? uni.upx2px(props.offsetTop) : 0);
|
|
82
|
-
// #endif
|
|
83
|
-
// #ifndef H5
|
|
84
|
-
stickyTop.value = props.navHeight + (props.offsetTop ? uni.upx2px(props.offsetTop) : 0);
|
|
85
|
-
// #endif
|
|
86
|
-
|
|
87
|
-
disconnectObserver();
|
|
88
|
-
|
|
89
|
-
// 获取元素信息
|
|
90
|
-
const query = uni.createSelectorQuery().in(instance.proxy);
|
|
91
|
-
query.select('.' + elClass.value).boundingClientRect((res) => {
|
|
92
|
-
if (res) {
|
|
93
|
-
height.value = res.height;
|
|
94
|
-
left.value = res.left;
|
|
95
|
-
width.value = res.width;
|
|
96
|
-
connectObserver();
|
|
97
|
-
}
|
|
98
|
-
}).exec();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// 连接观察器
|
|
102
|
-
function connectObserver() {
|
|
103
|
-
disconnectObserver();
|
|
104
|
-
|
|
105
|
-
observer = uni.createIntersectionObserver(instance.proxy, {
|
|
106
|
-
thresholds: [0.95, 0.98, 1]
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
observer.relativeToViewport({
|
|
110
|
-
top: -stickyTop.value
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
observer.observe('.' + elClass.value, (res) => {
|
|
114
|
-
if (!props.enabled) return;
|
|
115
|
-
setFixed(res.boundingClientRect.top);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// 设置固定状态
|
|
120
|
-
function setFixed(top) {
|
|
121
|
-
const isFixed = top < stickyTop.value;
|
|
122
|
-
if (isFixed && !fixed.value) {
|
|
123
|
-
emit('fixed');
|
|
124
|
-
} else if (!isFixed && fixed.value) {
|
|
125
|
-
emit('unfixed');
|
|
126
|
-
}
|
|
127
|
-
fixed.value = isFixed;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// 断开观察器
|
|
131
|
-
function disconnectObserver() {
|
|
132
|
-
if (observer) {
|
|
133
|
-
observer.disconnect();
|
|
134
|
-
observer = null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// 监听属性变化
|
|
139
|
-
watch(() => props.offsetTop, () => initObserver());
|
|
140
|
-
watch(() => props.navHeight, () => initObserver());
|
|
141
|
-
watch(() => props.enabled, (val) => {
|
|
142
|
-
if (!val) {
|
|
143
|
-
fixed.value = false;
|
|
144
|
-
disconnectObserver();
|
|
145
|
-
} else {
|
|
146
|
-
initObserver();
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
onMounted(() => {
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
initObserver();
|
|
153
|
-
}, 50);
|
|
154
|
-
});
|
|
155
|
-
</script>
|
|
156
|
-
|
|
157
|
-
<style lang="scss">
|
|
158
|
-
.prism-sticky {
|
|
159
|
-
position: relative;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.prism-sticky__wrap {
|
|
163
|
-
position: relative;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.prism-sticky__content {
|
|
167
|
-
background: var(--prism-bg-color-card, #FFFFFF);
|
|
168
|
-
|
|
169
|
-
.dark-mode & {
|
|
170
|
-
background: var(--prism-bg-color-card, #242424);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="prism-sticky">
|
|
3
|
+
<view class="prism-sticky__wrap" :class="[elClass]" :style="wrapStyle">
|
|
4
|
+
<view
|
|
5
|
+
class="prism-sticky__content"
|
|
6
|
+
:style="{
|
|
7
|
+
position: fixed ? 'fixed' : 'static',
|
|
8
|
+
top: stickyTop + 'px',
|
|
9
|
+
left: left + 'px',
|
|
10
|
+
width: width === 'auto' ? 'auto' : width + 'px',
|
|
11
|
+
zIndex: zIndex,
|
|
12
|
+
background: bgColor
|
|
13
|
+
}"
|
|
14
|
+
>
|
|
15
|
+
<slot></slot>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup>
|
|
22
|
+
import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
// 吸顶时距离顶部的距离(rpx)
|
|
26
|
+
offsetTop: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: 0
|
|
29
|
+
},
|
|
30
|
+
// 自定义导航栏高度(px)
|
|
31
|
+
navHeight: {
|
|
32
|
+
type: Number,
|
|
33
|
+
default: 0
|
|
34
|
+
},
|
|
35
|
+
// 是否开启吸顶
|
|
36
|
+
enabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true
|
|
39
|
+
},
|
|
40
|
+
// 背景颜色
|
|
41
|
+
bgColor: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: ''
|
|
44
|
+
},
|
|
45
|
+
// z-index
|
|
46
|
+
zIndex: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: 100
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const emit = defineEmits(['fixed', 'unfixed']);
|
|
53
|
+
|
|
54
|
+
const instance = getCurrentInstance();
|
|
55
|
+
|
|
56
|
+
// 生成唯一类名
|
|
57
|
+
const elClass = ref('prism-sticky-' + Math.random().toString(36).slice(2, 10));
|
|
58
|
+
|
|
59
|
+
// 状态
|
|
60
|
+
const fixed = ref(false);
|
|
61
|
+
const height = ref('auto');
|
|
62
|
+
const width = ref('auto');
|
|
63
|
+
const left = ref(0);
|
|
64
|
+
const stickyTop = ref(0);
|
|
65
|
+
|
|
66
|
+
// 观察器
|
|
67
|
+
let observer = null;
|
|
68
|
+
|
|
69
|
+
// 包裹层样式
|
|
70
|
+
const wrapStyle = computed(() => ({
|
|
71
|
+
height: fixed.value ? height.value + 'px' : 'auto',
|
|
72
|
+
zIndex: props.zIndex
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
// 初始化观察器
|
|
76
|
+
function initObserver() {
|
|
77
|
+
if (!props.enabled) return;
|
|
78
|
+
|
|
79
|
+
// 计算吸顶位置
|
|
80
|
+
// #ifdef H5
|
|
81
|
+
stickyTop.value = props.navHeight + (props.offsetTop ? uni.upx2px(props.offsetTop) : 0);
|
|
82
|
+
// #endif
|
|
83
|
+
// #ifndef H5
|
|
84
|
+
stickyTop.value = props.navHeight + (props.offsetTop ? uni.upx2px(props.offsetTop) : 0);
|
|
85
|
+
// #endif
|
|
86
|
+
|
|
87
|
+
disconnectObserver();
|
|
88
|
+
|
|
89
|
+
// 获取元素信息
|
|
90
|
+
const query = uni.createSelectorQuery().in(instance.proxy);
|
|
91
|
+
query.select('.' + elClass.value).boundingClientRect((res) => {
|
|
92
|
+
if (res) {
|
|
93
|
+
height.value = res.height;
|
|
94
|
+
left.value = res.left;
|
|
95
|
+
width.value = res.width;
|
|
96
|
+
connectObserver();
|
|
97
|
+
}
|
|
98
|
+
}).exec();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 连接观察器
|
|
102
|
+
function connectObserver() {
|
|
103
|
+
disconnectObserver();
|
|
104
|
+
|
|
105
|
+
observer = uni.createIntersectionObserver(instance.proxy, {
|
|
106
|
+
thresholds: [0.95, 0.98, 1]
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
observer.relativeToViewport({
|
|
110
|
+
top: -stickyTop.value
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
observer.observe('.' + elClass.value, (res) => {
|
|
114
|
+
if (!props.enabled) return;
|
|
115
|
+
setFixed(res.boundingClientRect.top);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 设置固定状态
|
|
120
|
+
function setFixed(top) {
|
|
121
|
+
const isFixed = top < stickyTop.value;
|
|
122
|
+
if (isFixed && !fixed.value) {
|
|
123
|
+
emit('fixed');
|
|
124
|
+
} else if (!isFixed && fixed.value) {
|
|
125
|
+
emit('unfixed');
|
|
126
|
+
}
|
|
127
|
+
fixed.value = isFixed;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 断开观察器
|
|
131
|
+
function disconnectObserver() {
|
|
132
|
+
if (observer) {
|
|
133
|
+
observer.disconnect();
|
|
134
|
+
observer = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 监听属性变化
|
|
139
|
+
watch(() => props.offsetTop, () => initObserver());
|
|
140
|
+
watch(() => props.navHeight, () => initObserver());
|
|
141
|
+
watch(() => props.enabled, (val) => {
|
|
142
|
+
if (!val) {
|
|
143
|
+
fixed.value = false;
|
|
144
|
+
disconnectObserver();
|
|
145
|
+
} else {
|
|
146
|
+
initObserver();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
onMounted(() => {
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
initObserver();
|
|
153
|
+
}, 50);
|
|
154
|
+
});
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<style lang="scss">
|
|
158
|
+
.prism-sticky {
|
|
159
|
+
position: relative;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.prism-sticky__wrap {
|
|
163
|
+
position: relative;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.prism-sticky__content {
|
|
167
|
+
background: var(--prism-bg-color-card, #FFFFFF);
|
|
168
|
+
|
|
169
|
+
.dark-mode & {
|
|
170
|
+
background: var(--prism-bg-color-card, #242424);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</style>
|