stellar-ui-plus 1.24.15 → 1.24.17
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/components/ste-radio/ste-radio.vue +15 -5
- package/package.json +1 -1
- package/store/color.ts +11 -3
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useSlots, computed, type CSSProperties } from 'vue';
|
|
3
3
|
import { useColorStore } from '../../store/color';
|
|
4
|
-
let { getColor } = useColorStore();
|
|
5
4
|
import utils from '../../utils/utils';
|
|
6
5
|
import propsData, { RADIO_KEY, type RadioEmits } from './props';
|
|
7
6
|
import type { RadioGroupProps } from '../ste-radio-group/props';
|
|
8
7
|
import { useInject } from '../../utils/mixin';
|
|
9
8
|
|
|
9
|
+
// 🚀 优化: 模块级别调用,所有实例共享
|
|
10
|
+
const { getColor } = useColorStore();
|
|
11
|
+
const themeColor = getColor()?.steThemeColor || '#0090FF';
|
|
12
|
+
|
|
10
13
|
const componentName = `ste-radio`;
|
|
11
14
|
defineOptions({
|
|
12
15
|
name: componentName,
|
|
@@ -22,9 +25,6 @@ const Parent = useInject<{ props: Required<RadioGroupProps>; updateValue: (value
|
|
|
22
25
|
|
|
23
26
|
const parentProps = computed(() => Parent?.parent?.props);
|
|
24
27
|
|
|
25
|
-
// 🚀 优化: 缓存 themeColor,避免每次调用 getColor()
|
|
26
|
-
const themeColor = getColor().steThemeColor;
|
|
27
|
-
|
|
28
28
|
// 🚀 优化: 只保留必要的 computed
|
|
29
29
|
const cmpChecked = computed(() => {
|
|
30
30
|
return parentProps.value ? parentProps.value.modelValue == props.name : props.modelValue == props.name;
|
|
@@ -108,6 +108,16 @@ const cmpSlotProps = computed(() => ({
|
|
|
108
108
|
readonly: getDefaultData('readonly', false),
|
|
109
109
|
}));
|
|
110
110
|
|
|
111
|
+
// 🚀 优化: 缓存 ste-icon 需要的属性,避免模板中重复调用 getDefaultData
|
|
112
|
+
const cmpIconProps = computed(() => {
|
|
113
|
+
const iconSize = getDefaultData('iconSize', 36);
|
|
114
|
+
const disabled = getDefaultData('disabled', false);
|
|
115
|
+
return {
|
|
116
|
+
size: iconSize * 0.8,
|
|
117
|
+
color: disabled ? '#bbbbbb' : '#fff',
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
|
|
111
121
|
async function click() {
|
|
112
122
|
const readonly = getDefaultData('readonly', false);
|
|
113
123
|
const disabled = getDefaultData('disabled', false);
|
|
@@ -155,7 +165,7 @@ const getDefaultData = <T,>(key: PropsKeyType, defaultValue: T): T => {
|
|
|
155
165
|
<view class="icon" :style="[cmpIconStyle]">
|
|
156
166
|
<slot name="icon" :slotProps="cmpSlotProps">
|
|
157
167
|
<view class="input-icon" :style="[cmpInputStyle]">
|
|
158
|
-
<ste-icon v-if="cmpChecked" :size="
|
|
168
|
+
<ste-icon v-if="cmpChecked" :size="cmpIconProps.size" code="" :color="cmpIconProps.color" bold></ste-icon>
|
|
159
169
|
</view>
|
|
160
170
|
</slot>
|
|
161
171
|
</view>
|
package/package.json
CHANGED
package/store/color.ts
CHANGED
|
@@ -2,19 +2,27 @@ const colorValue = {
|
|
|
2
2
|
steThemeColor: '#0090FF',
|
|
3
3
|
defaultColor: '#0090FF',
|
|
4
4
|
};
|
|
5
|
+
|
|
6
|
+
// 模块级缓存,避免重复读取 storage
|
|
7
|
+
let cachedColor: typeof colorValue | null = null;
|
|
8
|
+
|
|
5
9
|
export function useColorStore() {
|
|
6
10
|
const getColor = () => {
|
|
7
11
|
// 测试环境判断
|
|
8
12
|
if (process.env.NODE_ENV == 'test') {
|
|
9
13
|
return colorValue;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
// 使用缓存,避免重复调用 getStorageSync
|
|
16
|
+
if (cachedColor) {
|
|
17
|
+
return cachedColor;
|
|
13
18
|
}
|
|
19
|
+
cachedColor = uni.getStorageSync('steColor') || colorValue;
|
|
20
|
+
return cachedColor;
|
|
14
21
|
};
|
|
15
22
|
|
|
16
23
|
const setColor = (value: any) => {
|
|
17
|
-
|
|
24
|
+
cachedColor = Object.assign({}, colorValue, value);
|
|
25
|
+
uni.setStorageSync('steColor', cachedColor);
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
return {
|