转盘
This commit is contained in:
parent
045a8af46f
commit
6375b45f3a
@ -20,14 +20,21 @@ import {
|
|||||||
|
|
||||||
defineOptions({ name: 'OperatePropsSourceSelectDrawer' });
|
defineOptions({ name: 'OperatePropsSourceSelectDrawer' });
|
||||||
|
|
||||||
|
type SourceTypeOption = {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
};
|
||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
defaultType?: string;
|
defaultType?: string;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
sysOrigin: string;
|
sysOrigin: string;
|
||||||
|
typeOptions?: SourceTypeOption[];
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
defaultType: 'AVATAR_FRAME',
|
defaultType: 'AVATAR_FRAME',
|
||||||
|
typeOptions: undefined,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -36,11 +43,6 @@ const emit = defineEmits<{
|
|||||||
select: [item: SourceItem];
|
select: [item: SourceItem];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
type SourceTypeOption = {
|
|
||||||
label: string;
|
|
||||||
value: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type SourceItem = {
|
type SourceItem = {
|
||||||
amount?: number | string;
|
amount?: number | string;
|
||||||
cover?: string;
|
cover?: string;
|
||||||
@ -62,12 +64,21 @@ const TYPE_OPTIONS: SourceTypeOption[] = [
|
|||||||
{ label: '聊天气泡', value: 'CHAT_BUBBLE' },
|
{ label: '聊天气泡', value: 'CHAT_BUBBLE' },
|
||||||
{ label: '飘窗', value: 'FLOAT_PICTURE' },
|
{ label: '飘窗', value: 'FLOAT_PICTURE' },
|
||||||
{ label: '碎片', value: 'FRAGMENTS' },
|
{ label: '碎片', value: 'FRAGMENTS' },
|
||||||
|
{ label: '资料卡', value: 'DATA_CARD' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const typeSelectOptions = TYPE_OPTIONS.map((item) => ({
|
const effectiveTypeOptions = computed(() =>
|
||||||
label: item.label,
|
(props.typeOptions && props.typeOptions.length > 0 ? props.typeOptions : TYPE_OPTIONS).map(
|
||||||
value: item.value as any,
|
(item) => ({
|
||||||
}));
|
label: item.label,
|
||||||
|
value: item.value as any,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const allowedTypeSet = computed(
|
||||||
|
() => new Set(effectiveTypeOptions.value.map((item) => String(item.value))),
|
||||||
|
);
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const keyword = ref('');
|
const keyword = ref('');
|
||||||
@ -197,13 +208,21 @@ function formatSourcePrice(amount: number | string | undefined) {
|
|||||||
return `${amount} 金币`;
|
return `${amount} 金币`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveSourceType(type?: string) {
|
||||||
|
const value = String(type || '').trim();
|
||||||
|
if (value && allowedTypeSet.value.has(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return String(effectiveTypeOptions.value[0]?.value || 'AVATAR_FRAME');
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.open,
|
() => props.open,
|
||||||
(open) => {
|
(open) => {
|
||||||
if (!open) {
|
if (!open) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
query.propsType = props.defaultType || 'AVATAR_FRAME';
|
query.propsType = resolveSourceType(props.defaultType);
|
||||||
keyword.value = '';
|
keyword.value = '';
|
||||||
void loadSource(query.propsType);
|
void loadSource(query.propsType);
|
||||||
},
|
},
|
||||||
@ -213,14 +232,26 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.defaultType,
|
() => props.defaultType,
|
||||||
(value) => {
|
(value) => {
|
||||||
if (!props.open || !value) {
|
if (!props.open) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
query.propsType = value;
|
query.propsType = resolveSourceType(value);
|
||||||
void loadSource(value);
|
void loadSource(query.propsType);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.typeOptions,
|
||||||
|
() => {
|
||||||
|
if (!props.open) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
query.propsType = resolveSourceType(query.propsType || props.defaultType);
|
||||||
|
void loadSource(query.propsType);
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.sysOrigin,
|
() => props.sysOrigin,
|
||||||
() => {
|
() => {
|
||||||
@ -327,7 +358,7 @@ function handleSelect(item: SourceItem) {
|
|||||||
<Space class="toolbar" wrap>
|
<Space class="toolbar" wrap>
|
||||||
<Select
|
<Select
|
||||||
v-model:value="query.propsType"
|
v-model:value="query.propsType"
|
||||||
:options="typeSelectOptions"
|
:options="effectiveTypeOptions"
|
||||||
option-label-prop="label"
|
option-label-prop="label"
|
||||||
placeholder="请选择道具类型"
|
placeholder="请选择道具类型"
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
|
|||||||
@ -70,6 +70,18 @@ const REWARD_TYPE_OPTIONS = [
|
|||||||
{ label: '金币', value: 'GOLD' },
|
{ label: '金币', value: 'GOLD' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const WHEEL_RESOURCE_TYPE_OPTIONS = [
|
||||||
|
{ label: '头像框', value: 'AVATAR_FRAME' },
|
||||||
|
{ label: '座驾', value: 'RIDE' },
|
||||||
|
{ label: '礼物', value: 'GIFT' },
|
||||||
|
{ label: '用户徽章', value: 'BADGE' },
|
||||||
|
{ label: '房间徽章', value: 'ROOM_BADGE' },
|
||||||
|
{ label: '表情包', value: 'EMOJI' },
|
||||||
|
{ label: '聊天气泡', value: 'CHAT_BUBBLE' },
|
||||||
|
{ label: '飘窗', value: 'FLOAT_PICTURE' },
|
||||||
|
{ label: '资料卡', value: 'DATA_CARD' },
|
||||||
|
];
|
||||||
|
|
||||||
let localRowId = 0;
|
let localRowId = 0;
|
||||||
|
|
||||||
function normalizeRewardTypeValue(value: any) {
|
function normalizeRewardTypeValue(value: any) {
|
||||||
@ -646,7 +658,7 @@ function validateCategory(category: Record<string, any>) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (categoryProbability(category) !== PROBABILITY_TOTAL) {
|
if (categoryProbability(category) !== PROBABILITY_TOTAL) {
|
||||||
message.warning(`${category.label} 启用时概率总和必须等于 10000`);
|
message.warning(`${category.label} 启用时概率总和必须等于 ${PROBABILITY_TOTAL}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1166,6 +1178,7 @@ watch(activePageTab, (value) => {
|
|||||||
"
|
"
|
||||||
:open="resourcePickerOpen"
|
:open="resourcePickerOpen"
|
||||||
:sys-origin="selectedSysOrigin"
|
:sys-origin="selectedSysOrigin"
|
||||||
|
:type-options="WHEEL_RESOURCE_TYPE_OPTIONS"
|
||||||
@close="closeResourcePicker"
|
@close="closeResourcePicker"
|
||||||
@select="handleResourceSelect"
|
@select="handleResourceSelect"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user