stellar-ui-plus 1.16.19 → 1.17.0
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-button/ste-button.vue +3 -3
- package/components/ste-calendar/ste-calendar.vue +6 -6
- package/components/ste-checkbox/ste-checkbox.vue +3 -3
- package/components/ste-date-picker/ste-date-picker.vue +3 -3
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +3 -3
- package/components/ste-index-list/ste-index-list.vue +3 -3
- package/components/ste-message-box/ste-message-box.vue +4 -3
- package/components/ste-number-keyboard/useData.ts +116 -128
- package/components/ste-progress/ste-progress.vue +3 -3
- package/components/ste-qrcode/ste-qrcode.vue +50 -31
- package/components/ste-radio/ste-radio.vue +3 -3
- package/components/ste-rate/ste-rate.vue +3 -3
- package/components/ste-select/useData.ts +438 -465
- package/components/ste-slider/ste-slider.vue +4 -4
- package/components/ste-step/ste-step.vue +9 -9
- package/components/ste-stepper/ste-stepper.vue +3 -3
- package/components/ste-switch/ste-switch.vue +3 -3
- package/components/ste-table/ste-table.vue +1 -3
- package/components/ste-tabs/useData.ts +336 -357
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineOptions, type CSSProperties } from 'vue';
|
|
3
|
-
import
|
|
4
|
-
let
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import propsData from './props';
|
|
6
6
|
import utils from '../../utils/utils';
|
|
7
7
|
import type {
|
|
@@ -109,7 +109,7 @@ const cmpBtnStyle = computed(() => {
|
|
|
109
109
|
break;
|
|
110
110
|
}
|
|
111
111
|
// 背景色 & 字体色
|
|
112
|
-
style = { ...style, ...utils.bg2style(props.background ? props.background :
|
|
112
|
+
style = { ...style, ...utils.bg2style(props.background ? props.background : getColor().steThemeColor) };
|
|
113
113
|
style.color = props.color;
|
|
114
114
|
|
|
115
115
|
// 禁用 disabled | 加载 loading
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { watch, onMounted, computed } from 'vue';
|
|
3
|
-
import
|
|
4
|
-
let
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import { formatDate, type WeekType } from './date';
|
|
6
6
|
import utils from '../../utils/utils';
|
|
7
7
|
import useData from './useData';
|
|
@@ -13,10 +13,10 @@ const props = defineProps(propsData);
|
|
|
13
13
|
const cmpRootStyle = computed(() => ({
|
|
14
14
|
'--calendar-width': utils.formatPx(props.width),
|
|
15
15
|
'--calendar-height': utils.formatPx(props.height),
|
|
16
|
-
'--calendar-color': props.color ? props.color :
|
|
17
|
-
'--calendar-bg-color': utils.Color.formatColor(props.color ? props.color :
|
|
18
|
-
'--calendar-range-color': utils.Color.formatColor(props.color ? props.color :
|
|
19
|
-
'--calendar-disabled-color': utils.Color.formatColor(props.color ? props.color :
|
|
16
|
+
'--calendar-color': props.color ? props.color : getColor().steThemeColor,
|
|
17
|
+
'--calendar-bg-color': utils.Color.formatColor(props.color ? props.color : getColor().steThemeColor, 0.1),
|
|
18
|
+
'--calendar-range-color': utils.Color.formatColor(props.color ? props.color : getColor().steThemeColor, 0.2),
|
|
19
|
+
'--calendar-disabled-color': utils.Color.formatColor(props.color ? props.color : getColor().steThemeColor, 0.3),
|
|
20
20
|
'--calendar-start-text': `"${props.startText}"`,
|
|
21
21
|
'--calendar-end-text': `"${props.endText}"`,
|
|
22
22
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useSlots, computed, ref, type CSSProperties } from 'vue';
|
|
3
|
-
import
|
|
4
|
-
let
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import utils from '../../utils/utils';
|
|
6
6
|
import propsData, { CHECKBOX_KEY, type CheckboxEmits } from './props';
|
|
7
7
|
import type { CheckboxGroupProps } from '../ste-checkbox-group/props';
|
|
@@ -23,7 +23,7 @@ const parentProps = computed(() => Parent?.parent?.props);
|
|
|
23
23
|
const cmpReadonly = computed(() => getDefaultData('readonly', false));
|
|
24
24
|
const cmpShape = computed(() => getDefaultData('shape', 'circle'));
|
|
25
25
|
const cmpIconSize = computed(() => getDefaultData('iconSize', 36));
|
|
26
|
-
const cmpCheckedColor = computed(() => getDefaultData('checkedColor',
|
|
26
|
+
const cmpCheckedColor = computed(() => getDefaultData('checkedColor', getColor().steThemeColor));
|
|
27
27
|
const cmpTextPosition = computed(() => getDefaultData('textPosition', 'right'));
|
|
28
28
|
const cmpTextSize = computed(() => getDefaultData('textSize', 28));
|
|
29
29
|
const cmpTextInactiveColor = computed(() => getDefaultData('textInactiveColor', '#000000'));
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
|
|
23
23
|
<script lang="ts" setup>
|
|
24
24
|
import { ref, onMounted, nextTick, defineOptions, computed } from 'vue';
|
|
25
|
-
import
|
|
26
|
-
let
|
|
25
|
+
import { useColorStore } from '../../store/color';
|
|
26
|
+
let { getColor } = useColorStore();
|
|
27
27
|
import propsData from './props';
|
|
28
28
|
import type { CloumnType } from './types';
|
|
29
29
|
import utils from '../../utils/utils';
|
|
@@ -37,7 +37,7 @@ defineOptions({
|
|
|
37
37
|
const props = defineProps(propsData);
|
|
38
38
|
|
|
39
39
|
let cmpConfirmColor = computed(() => {
|
|
40
|
-
return props.confirmColor ? props.confirmColor :
|
|
40
|
+
return props.confirmColor ? props.confirmColor : getColor().steThemeColor;
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const DEFAULT_DATE = dayjs(new Date(1970, 1, 1, 0, 0, 0));
|
|
@@ -7,8 +7,8 @@ import type { DropdownItem } from '../ste-dropdown-menu-item/type';
|
|
|
7
7
|
import { type DropdownMenuItemProps } from '../ste-dropdown-menu-item/props';
|
|
8
8
|
import utils from '../../utils/utils';
|
|
9
9
|
import System from '../../utils/System.js';
|
|
10
|
-
import
|
|
11
|
-
let
|
|
10
|
+
import { useColorStore } from '../../store/color';
|
|
11
|
+
let { getColor } = useColorStore();
|
|
12
12
|
|
|
13
13
|
const props = defineProps(propsData);
|
|
14
14
|
const emits = defineEmits(dropDownMenuEmits);
|
|
@@ -44,7 +44,7 @@ const cmpRootClass = computed(() => {
|
|
|
44
44
|
|
|
45
45
|
const cmpRootStyle = computed(() => ({
|
|
46
46
|
'--duration': cmpDuration.value + 's',
|
|
47
|
-
'--active-color': props.activeColor ? props.activeColor :
|
|
47
|
+
'--active-color': props.activeColor ? props.activeColor : getColor().steThemeColor,
|
|
48
48
|
'--inactive-color': props.inactiveColor,
|
|
49
49
|
'--menu-z-index': props.zIndex,
|
|
50
50
|
}));
|
|
@@ -3,8 +3,8 @@ import { ref, computed, watch, nextTick, getCurrentInstance, defineOptions, onMo
|
|
|
3
3
|
import propsData, { INDEX_LIST_KEY } from './props';
|
|
4
4
|
import useData from '../ste-scroll-to/useData';
|
|
5
5
|
import { useProvide } from '../../utils/mixin';
|
|
6
|
-
import
|
|
7
|
-
let
|
|
6
|
+
import { useColorStore } from '../../store/color';
|
|
7
|
+
let { getColor } = useColorStore();
|
|
8
8
|
|
|
9
9
|
defineOptions({
|
|
10
10
|
name: 'ste-index-list',
|
|
@@ -38,7 +38,7 @@ const { dataActive, setDataActive, scrollTop, cmpRootStyle, onScroll, initChildr
|
|
|
38
38
|
|
|
39
39
|
const cmpIndexRootStyle = computed(() => ({
|
|
40
40
|
'--ste-index-list-inactive-color': props.inactiveColor,
|
|
41
|
-
'--ste-index-list-active-color': props.activeColor ? props.activeColor :
|
|
41
|
+
'--ste-index-list-active-color': props.activeColor ? props.activeColor : getColor().steThemeColor,
|
|
42
42
|
}));
|
|
43
43
|
const cmpTitles = computed(() => internalChildren.map(c => c?.props?.title));
|
|
44
44
|
|
|
@@ -7,8 +7,9 @@ import { ICON_OBJ, ANIMATION_PROP, DURATION } from './constants';
|
|
|
7
7
|
import type { MessageBoxOptions } from '../../types';
|
|
8
8
|
import { STE_MESSAGE_BOX_KEY } from './use-message-box';
|
|
9
9
|
import { useMsgBoxStore } from '../../store';
|
|
10
|
-
import
|
|
11
|
-
let
|
|
10
|
+
import { useColorStore } from '../../store/color';
|
|
11
|
+
let { getColor } = useColorStore();
|
|
12
|
+
|
|
12
13
|
defineOptions({
|
|
13
14
|
name: 'ste-message-box',
|
|
14
15
|
});
|
|
@@ -58,7 +59,7 @@ const cmpRootStyle = computed(() => {
|
|
|
58
59
|
return {
|
|
59
60
|
opacity: 0,
|
|
60
61
|
'--cancel-color': cancelColor.value,
|
|
61
|
-
'--confirm-color': confirmColor.value ? confirmColor.value :
|
|
62
|
+
'--confirm-color': confirmColor.value ? confirmColor.value : getColor().steThemeColor,
|
|
62
63
|
};
|
|
63
64
|
});
|
|
64
65
|
|
|
@@ -1,144 +1,132 @@
|
|
|
1
|
-
import { computed, ref, watch } from 'vue'
|
|
2
|
-
import utils from '../../utils/utils'
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const color = useColor()
|
|
1
|
+
import { computed, ref, watch } from 'vue';
|
|
2
|
+
import utils from '../../utils/utils';
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
|
+
import type { NumberKeyboardProps } from './props';
|
|
7
6
|
export default function useData({
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
props,
|
|
8
|
+
emits,
|
|
10
9
|
}: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
props: NumberKeyboardProps;
|
|
11
|
+
emits: {
|
|
12
|
+
(e: 'change', value: string): void;
|
|
13
|
+
(e: 'input', value: string): void;
|
|
14
|
+
(e: 'update:modelValue', value: string): void;
|
|
15
|
+
(e: 'clear'): void;
|
|
16
|
+
(e: 'backspace'): void;
|
|
17
|
+
(e: 'confirm', value: string): void;
|
|
18
|
+
(e: 'click', key: string): void;
|
|
19
|
+
(e: 'beforeinput', key: string, suspend: () => void, next: () => void, stop: () => void): void;
|
|
20
|
+
(e: 'close'): void;
|
|
21
|
+
(e: 'update:show', show: boolean): void;
|
|
22
|
+
(e: 'open'): void;
|
|
23
|
+
};
|
|
25
24
|
}) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
dataValue.value = value
|
|
34
|
-
else dataValue.value = String(value)
|
|
35
|
-
}
|
|
25
|
+
const dataValue = ref('');
|
|
26
|
+
const setDataValue = (value: string) => {
|
|
27
|
+
if (value === dataValue.value) return;
|
|
28
|
+
if (value === null || value === undefined) dataValue.value = '';
|
|
29
|
+
else if (typeof value === 'string') dataValue.value = value;
|
|
30
|
+
else dataValue.value = String(value);
|
|
31
|
+
};
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
33
|
+
const dataShow = ref(false);
|
|
34
|
+
const setDataShow = (value: boolean) => {
|
|
35
|
+
if (value === dataShow.value) return;
|
|
36
|
+
dataShow.value = value;
|
|
37
|
+
};
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
keys = utils.randomArray(keys)
|
|
39
|
+
const cmpNumbers = computed(() => {
|
|
40
|
+
let keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
|
|
41
|
+
if (props.randomKeys) keys = utils.randomArray(keys);
|
|
48
42
|
|
|
49
|
-
|
|
50
|
-
keys.push(...props.customKeys)
|
|
43
|
+
if (Array.isArray(props.customKeys)) keys.push(...props.customKeys);
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
45
|
+
if (!props.rightKeys) {
|
|
46
|
+
if (!props.showClear) {
|
|
47
|
+
keys.push('backspace');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const d = keys.length % 3;
|
|
51
|
+
if (d === 1) {
|
|
52
|
+
const end = keys.pop();
|
|
53
|
+
keys.push('clear', end || '', 'backspace');
|
|
54
|
+
} else {
|
|
55
|
+
keys.push('clear', 'backspace');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return keys;
|
|
59
|
+
});
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
const cmpRootStyle = computed(() => {
|
|
62
|
+
return {
|
|
63
|
+
'--ste-number-keyboard-text-color': props.textColor,
|
|
64
|
+
'--ste-number-keyboard-text-size': `var(--font-size-${props.textSize},${utils.formatPx(props.textSize)})`,
|
|
65
|
+
'--ste-number-keyboard-clear-text-size': `var(--font-size-${props.textSize},${utils.formatPx(Number(props.textSize) - 8)})`,
|
|
66
|
+
'--ste-number-keyboard-confirm-text-size': `var(--font-size-${props.textSize},${utils.formatPx(Number(props.textSize) - 3)})`,
|
|
67
|
+
'--ste-number-keyboard-confirm-bg': props.confirmBg ? props.confirmBg : getColor().steThemeColor,
|
|
68
|
+
'--ste-number-keyboard-confirm-bg-active': utils.Color.formatColor(props.confirmBg, 0.8),
|
|
69
|
+
'--ste-number-keyboard-confirm-color': props.confirmColor,
|
|
70
|
+
};
|
|
71
|
+
});
|
|
80
72
|
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
watch(() => props.modelValue, setDataValue, { immediate: true });
|
|
74
|
+
watch(() => props.show, setDataShow, { immediate: true });
|
|
83
75
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
const onClose = () => {
|
|
77
|
+
setDataShow(false);
|
|
78
|
+
emits('update:show', false);
|
|
79
|
+
emits('close');
|
|
80
|
+
};
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await stop
|
|
82
|
+
const beforInput = async (value: string) => {
|
|
83
|
+
let next = true;
|
|
84
|
+
const stop = new Promise((resolve, reject) => {
|
|
85
|
+
emits(
|
|
86
|
+
'beforeinput',
|
|
87
|
+
value,
|
|
88
|
+
() => (next = false),
|
|
89
|
+
() => resolve('next'),
|
|
90
|
+
() => reject(new Error('beforInput stop'))
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
if (!next) await stop;
|
|
103
94
|
|
|
104
|
-
|
|
105
|
-
|
|
95
|
+
/* eslint prefer-promise-reject-errors: "error" */
|
|
96
|
+
};
|
|
106
97
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
console.error(e)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
98
|
+
const onChange = async (value: string) => {
|
|
99
|
+
try {
|
|
100
|
+
if (value === 'confirm') {
|
|
101
|
+
emits('confirm', dataValue.value);
|
|
102
|
+
onClose();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
switch (value) {
|
|
106
|
+
case 'backspace':
|
|
107
|
+
setDataValue(dataValue.value.slice(0, dataValue.value.length - 1));
|
|
108
|
+
emits('backspace');
|
|
109
|
+
break;
|
|
110
|
+
case 'clear':
|
|
111
|
+
setDataValue('');
|
|
112
|
+
emits('clear');
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
await beforInput(value);
|
|
116
|
+
emits('click', value);
|
|
117
|
+
if (props.maxlength && dataValue.value.length >= Number(props.maxlength)) return;
|
|
118
|
+
dataValue.value += value;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
emits('input', dataValue.value);
|
|
122
|
+
emits('change', dataValue.value);
|
|
123
|
+
emits('update:modelValue', dataValue.value);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (e) console.error(e);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
140
128
|
|
|
141
|
-
|
|
129
|
+
const onOpen = () => emits('open');
|
|
142
130
|
|
|
143
|
-
|
|
131
|
+
return { cmpNumbers, cmpRootStyle, dataShow, onClose, onChange, onOpen };
|
|
144
132
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { computed, ref, watch, useSlots, onMounted, type CSSProperties } from 'vue';
|
|
3
3
|
import propsData from './props';
|
|
4
4
|
import utils from '../../utils/utils';
|
|
5
|
-
import
|
|
6
|
-
let
|
|
5
|
+
import { useColorStore } from '../../store/color';
|
|
6
|
+
let { getColor } = useColorStore();
|
|
7
7
|
|
|
8
8
|
const slots = useSlots();
|
|
9
9
|
const props = defineProps(propsData);
|
|
@@ -70,7 +70,7 @@ const cmpActiveStyle = computed(() => {
|
|
|
70
70
|
if (props.disabled) {
|
|
71
71
|
style.backgroundColor = '#cccccc';
|
|
72
72
|
} else {
|
|
73
|
-
const bg = utils.bg2style(props.activeBg ? props.activeBg :
|
|
73
|
+
const bg = utils.bg2style(props.activeBg ? props.activeBg : getColor().steThemeColor);
|
|
74
74
|
style = { ...style, ...bg };
|
|
75
75
|
}
|
|
76
76
|
return style;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import utils from '../../utils/utils';
|
|
3
|
-
import { nextTick, onMounted, watch, defineOptions, getCurrentInstance, type ComponentPublicInstance } from 'vue';
|
|
3
|
+
import { nextTick, onMounted, watch, defineOptions, getCurrentInstance, ref, computed, type ComponentPublicInstance } from 'vue';
|
|
4
4
|
import propsData from './props';
|
|
5
5
|
|
|
6
6
|
import UQRCode, { type URCodeCanvasContext } from './uqrcode';
|
|
@@ -15,6 +15,16 @@ defineOptions({
|
|
|
15
15
|
const instance = getCurrentInstance() as unknown as ComponentPublicInstance;
|
|
16
16
|
const props = defineProps(propsData);
|
|
17
17
|
const canvasId = 'ste-qrcode-' + utils.guid(8);
|
|
18
|
+
const canvasWidth = ref(props.size);
|
|
19
|
+
const canvasHeight = ref(props.size);
|
|
20
|
+
|
|
21
|
+
const compCanvasStyle = computed(() => {
|
|
22
|
+
return {
|
|
23
|
+
width: canvasWidth.value + 'px',
|
|
24
|
+
height: canvasHeight.value + 'px',
|
|
25
|
+
transform: `scale(${props.size / canvasWidth.value}, ${props.size / canvasHeight.value})`,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
18
28
|
|
|
19
29
|
onMounted(() => {
|
|
20
30
|
initCanvas();
|
|
@@ -42,10 +52,6 @@ const initCanvas = () => {
|
|
|
42
52
|
.select(`#${canvasId}`)
|
|
43
53
|
.node(res => {
|
|
44
54
|
const context = res.node.getContext('2d');
|
|
45
|
-
const dpr = utils.System.getWindowInfo().pixelRatio;
|
|
46
|
-
res.node.width = props.size * dpr;
|
|
47
|
-
res.node.height = props.size * dpr;
|
|
48
|
-
context.scale(dpr, dpr);
|
|
49
55
|
draw(context, res.node);
|
|
50
56
|
})
|
|
51
57
|
.exec();
|
|
@@ -55,7 +61,26 @@ const initCanvas = () => {
|
|
|
55
61
|
|
|
56
62
|
const draw = (ctx: URCodeCanvasContext, canvas: any = null) => {
|
|
57
63
|
const qr = new UQRCode();
|
|
64
|
+
qr.useDynamicSize = true;
|
|
65
|
+
|
|
66
|
+
qr.backgroundColor = props.background;
|
|
67
|
+
qr.foregroundColor = props.foreground;
|
|
68
|
+
qr.foregroundImageSrc = props.foregroundImageSrc;
|
|
69
|
+
props.foregroundImageWidth ? (qr.foregroundImageWidth = props.foregroundImageWidth) : '';
|
|
70
|
+
props.foregroundImageHeight ? (qr.foregroundImageHeight = props.foregroundImageHeight) : '';
|
|
71
|
+
// 设置二维码内容
|
|
72
|
+
qr.data = props.content;
|
|
73
|
+
// 设置二维码大小,必须与canvas设置的宽高一致
|
|
74
|
+
qr.size = props.size;
|
|
75
|
+
// 调用制作二维码方法
|
|
76
|
+
qr.make();
|
|
77
|
+
|
|
58
78
|
// #ifdef MP-WEIXIN || MP-ALIPAY
|
|
79
|
+
const context = canvas.getContext('2d');
|
|
80
|
+
const dpr = utils.System.getWindowInfo().pixelRatio;
|
|
81
|
+
canvas.width = qr.dynamicSize * dpr;
|
|
82
|
+
canvas.height = qr.dynamicSize * dpr;
|
|
83
|
+
context.scale(dpr, dpr);
|
|
59
84
|
qr.loadImage = src => {
|
|
60
85
|
// 需要返回Promise对象,小程序下获取网络图片信息需先配置download域名白名单才能生效
|
|
61
86
|
return new Promise((resolve, reject) => {
|
|
@@ -75,6 +100,8 @@ const draw = (ctx: URCodeCanvasContext, canvas: any = null) => {
|
|
|
75
100
|
// #endif
|
|
76
101
|
|
|
77
102
|
// #ifdef H5
|
|
103
|
+
canvasWidth.value = qr.dynamicSize;
|
|
104
|
+
canvasHeight.value = qr.dynamicSize;
|
|
78
105
|
qr.loadImage = src => {
|
|
79
106
|
// 需要返回Promise对象
|
|
80
107
|
return new Promise((resolve, reject) => {
|
|
@@ -93,42 +120,34 @@ const draw = (ctx: URCodeCanvasContext, canvas: any = null) => {
|
|
|
93
120
|
|
|
94
121
|
// #endif
|
|
95
122
|
|
|
96
|
-
qr.backgroundColor = props.background;
|
|
97
|
-
qr.foregroundColor = props.foreground;
|
|
98
|
-
qr.foregroundImageSrc = props.foregroundImageSrc;
|
|
99
|
-
props.foregroundImageWidth ? (qr.foregroundImageWidth = props.foregroundImageWidth) : '';
|
|
100
|
-
props.foregroundImageHeight ? (qr.foregroundImageHeight = props.foregroundImageHeight) : '';
|
|
101
|
-
// 设置二维码内容
|
|
102
|
-
qr.data = props.content;
|
|
103
|
-
// 设置二维码大小,必须与canvas设置的宽高一致
|
|
104
|
-
qr.size = props.size;
|
|
105
|
-
// 调用制作二维码方法
|
|
106
|
-
qr.make();
|
|
107
|
-
|
|
108
123
|
// 设置uQRCode实例的canvas上下文
|
|
109
124
|
qr.canvasContext = ctx;
|
|
110
125
|
// 调用绘制方法将二维码图案绘制到canvas上
|
|
111
|
-
|
|
126
|
+
setTimeout(() => {
|
|
127
|
+
qr.drawCanvas().then(() => {});
|
|
128
|
+
}, 300);
|
|
112
129
|
};
|
|
113
130
|
</script>
|
|
114
131
|
|
|
115
132
|
<template>
|
|
116
|
-
<view class="ste-qrcode-root">
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
<view class="ste-qrcode-root" :style="{ width: `${size}px`, height: `${size}px` }">
|
|
134
|
+
<view class="canvas-wrapper">
|
|
135
|
+
<!-- #ifdef H5 || APP -->
|
|
136
|
+
<canvas :style="[compCanvasStyle]" :canvas-id="canvasId" :id="canvasId" class="h5-canvas"></canvas>
|
|
137
|
+
<!-- #endif -->
|
|
138
|
+
|
|
139
|
+
<!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
|
|
140
|
+
<canvas type="2d" :id="canvasId" :style="[compCanvasStyle]" class="mp-canvas"></canvas>
|
|
141
|
+
<!-- #endif -->
|
|
142
|
+
</view>
|
|
124
143
|
</view>
|
|
125
144
|
</template>
|
|
126
145
|
|
|
127
146
|
<style lang="scss" scoped>
|
|
128
|
-
.ste-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
.ste-qrcode-root {
|
|
148
|
+
position: relative;
|
|
149
|
+
.h5-canvas {
|
|
150
|
+
transform-origin: top left;
|
|
151
|
+
}
|
|
133
152
|
}
|
|
134
153
|
</style>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { useSlots, computed, type CSSProperties } from 'vue';
|
|
3
|
-
import
|
|
4
|
-
let
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import utils from '../../utils/utils';
|
|
6
6
|
import propsData, { RADIO_KEY, type RadioEmits } from './props';
|
|
7
7
|
import type { RadioGroupProps } from '../ste-radio-group/props';
|
|
@@ -24,7 +24,7 @@ const parentProps = computed(() => Parent?.parent?.props);
|
|
|
24
24
|
const cmpReadonly = computed(() => getDefaultData('readonly', false));
|
|
25
25
|
const cmpShape = computed(() => getDefaultData('shape', 'circle'));
|
|
26
26
|
const cmpIconSize = computed(() => getDefaultData('iconSize', 36));
|
|
27
|
-
const cmpCheckedColor = computed(() => getDefaultData('checkedColor',
|
|
27
|
+
const cmpCheckedColor = computed(() => getDefaultData('checkedColor', getColor().steThemeColor));
|
|
28
28
|
const cmpTextPosition = computed(() => getDefaultData('textPosition', 'right'));
|
|
29
29
|
const cmpTextSize = computed(() => getDefaultData('textSize', 28));
|
|
30
30
|
const cmpTextInactiveColor = computed(() => getDefaultData('textInactiveColor', '#000000'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import utils from '../../utils/utils.js';
|
|
3
|
-
import
|
|
4
|
-
let
|
|
3
|
+
import { useColorStore } from '../../store/color';
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import propsData from './props';
|
|
6
6
|
import { computed, defineOptions, type CSSProperties } from 'vue';
|
|
7
7
|
|
|
@@ -47,7 +47,7 @@ const cmpInactiveCode = computed(() => {
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
let cmpActiveColor = computed(() => {
|
|
50
|
-
return props.activeColor ? props.activeColor :
|
|
50
|
+
return props.activeColor ? props.activeColor : getColor().steThemeColor;
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// 根据iconData来算出每个分值对应的iconCode
|