声网错误日志
This commit is contained in:
parent
49953ddd5a
commit
6d0daf6919
@ -130,6 +130,26 @@ export interface AppHomePopupItem {
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface AppAgoraErrorLogItem {
|
||||
agoraUid?: string;
|
||||
bannedByServer?: boolean;
|
||||
clientIp?: string;
|
||||
connectionChangedReasonType?: string;
|
||||
createTime?: string;
|
||||
errorCodeType?: string;
|
||||
id?: string;
|
||||
isTimeout?: boolean;
|
||||
networkType?: string;
|
||||
rawPayload?: string;
|
||||
reqAppIntel?: string;
|
||||
reqClient?: string;
|
||||
roomId?: string;
|
||||
sysOrigin?: string;
|
||||
tokenRequestSuccess?: boolean | null;
|
||||
userAgent?: string;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export async function loginLoggerPage(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult>('/user/login/logger/page', {
|
||||
params,
|
||||
@ -250,6 +270,13 @@ export async function deleteAppHomePopup(id: number | string) {
|
||||
return requestClient.delete(`/go/app-system/home-popups/configs/${id}`);
|
||||
}
|
||||
|
||||
export async function pageAgoraErrorLogs(params: Record<string, any>) {
|
||||
return requestClient.get<LegacyPageResult<AppAgoraErrorLogItem>>(
|
||||
'/go/app-system/error-logs/agora/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
export async function getEnumConfigByGroup(group: string) {
|
||||
return requestClient.get<{ result: LegacyEnumConfigItem[] }>(
|
||||
`/sys/enum/config/list/${group}`,
|
||||
|
||||
@ -68,6 +68,10 @@ const LOCAL_RESIDENT_ACTIVITY_FALLBACK_ROUTES = new Set([
|
||||
'ResidentVoiceRoomRocket',
|
||||
]);
|
||||
|
||||
const LOCAL_APP_SYSTEM_FALLBACK_ROUTES = new Set([
|
||||
'AppSystemAgoraErrorLog',
|
||||
]);
|
||||
|
||||
function normalizeRoutePath(path?: string | null) {
|
||||
return String(path || '')
|
||||
.trim()
|
||||
@ -115,6 +119,7 @@ function buildAuthorizedMenuMatcher(menus: LegacyMenu[]) {
|
||||
const aliasSet = new Set<string>();
|
||||
const routerSet = new Set<string>();
|
||||
const titleSet = new Set<string>();
|
||||
let hasAppSystemAccess = false;
|
||||
let hasResidentActivityAccess = false;
|
||||
const queue = [...menus];
|
||||
|
||||
@ -142,6 +147,14 @@ function buildAuthorizedMenuMatcher(menus: LegacyMenu[]) {
|
||||
) {
|
||||
hasResidentActivityAccess = true;
|
||||
}
|
||||
if (
|
||||
String(item.alias || '') === 'AppSystemManager' ||
|
||||
menuName === 'App系统管理' ||
|
||||
normalizedRouter === 'app/sys/mamange' ||
|
||||
normalizedRouter.startsWith('app/sys/mamange/')
|
||||
) {
|
||||
hasAppSystemAccess = true;
|
||||
}
|
||||
if (Array.isArray(item.childrens) && item.childrens.length > 0) {
|
||||
queue.push(...item.childrens);
|
||||
}
|
||||
@ -154,6 +167,12 @@ function buildAuthorizedMenuMatcher(menus: LegacyMenu[]) {
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
hasAppSystemAccess &&
|
||||
LOCAL_APP_SYSTEM_FALLBACK_ROUTES.has(String(route.name || ''))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
for (const alias of collectRouteAliases(route)) {
|
||||
if (aliasSet.has(alias)) {
|
||||
return true;
|
||||
|
||||
@ -34,6 +34,20 @@ const routes: RouteRecordRaw[] = [
|
||||
component: () => import('#/views/app-system/request-log.vue'),
|
||||
meta: { title: '请求日志' },
|
||||
},
|
||||
{
|
||||
name: 'AppSystemErrorLog',
|
||||
path: 'error-log',
|
||||
redirect: '/app/sys/mamange/error-log/agora',
|
||||
meta: { title: '错误日志' },
|
||||
children: [
|
||||
{
|
||||
name: 'AppSystemAgoraErrorLog',
|
||||
path: 'agora',
|
||||
component: () => import('#/views/app-system/agora-error-log.vue'),
|
||||
meta: { title: '声网' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'AppSystemSpecialId',
|
||||
path: 'userSpecialId',
|
||||
|
||||
346
apps/src/views/app-system/agora-error-log.vue
Normal file
346
apps/src/views/app-system/agora-error-log.vue
Normal file
@ -0,0 +1,346 @@
|
||||
<script lang="ts" setup>
|
||||
import type { AppAgoraErrorLogItem } from '#/api/legacy/app-system';
|
||||
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
DateRangePicker,
|
||||
Input,
|
||||
Modal,
|
||||
Pagination,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
} from 'antdv-next';
|
||||
|
||||
import { pageAgoraErrorLogs } from '#/api/legacy/app-system';
|
||||
import SysOriginSelect from '#/components/sys-origin-select.vue';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { formatDate, getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
defineOptions({ name: 'AppSystemAgoraErrorLog' });
|
||||
|
||||
const categoryOptions = [{ label: '声网', value: 'AGORA' }];
|
||||
const bannedOptions = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '仅 BannedByServer', value: 'true' },
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{ dataIndex: 'createTime', key: 'createTime', title: '上报时间', width: 170 },
|
||||
{ dataIndex: 'userId', key: 'userId', title: '用户ID', width: 150 },
|
||||
{ dataIndex: 'roomId', key: 'roomId', title: '房间ID', width: 150 },
|
||||
{ dataIndex: 'agoraUid', key: 'agoraUid', title: 'Agora UID', width: 140 },
|
||||
{ dataIndex: 'errorCodeType', key: 'errorCodeType', title: 'ErrorCodeType', width: 220 },
|
||||
{
|
||||
dataIndex: 'connectionChangedReasonType',
|
||||
key: 'connectionChangedReasonType',
|
||||
title: 'ConnectionChangedReasonType',
|
||||
width: 260,
|
||||
},
|
||||
{ dataIndex: 'networkType', key: 'networkType', title: '网络', width: 110 },
|
||||
{ dataIndex: 'flags', key: 'flags', title: '状态', width: 220 },
|
||||
{ dataIndex: 'reqClient', key: 'reqClient', title: '客户端', width: 120 },
|
||||
{ dataIndex: 'actions', fixed: 'right' as const, key: 'actions', title: '操作', width: 100 },
|
||||
];
|
||||
|
||||
const accessStore = useAccessStore();
|
||||
const sysOriginOptions = computed(() => {
|
||||
const options = getAllowedSysOrigins(accessStore.accessCodes || []);
|
||||
return options.length > 0 ? options : getAllowedSysOrigins([]);
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
const detailsOpen = ref(false);
|
||||
const detailsText = ref('');
|
||||
const list = ref<AppAgoraErrorLogItem[]>([]);
|
||||
const total = ref(0);
|
||||
const rangeDate = ref<[string, string] | null>(null);
|
||||
|
||||
const query = reactive<Record<string, any>>({
|
||||
agoraUid: '',
|
||||
bannedOnly: '',
|
||||
category: 'AGORA',
|
||||
cursor: 1,
|
||||
endTime: '',
|
||||
errorCodeType: '',
|
||||
limit: 20,
|
||||
networkType: '',
|
||||
reasonType: '',
|
||||
roomId: '',
|
||||
startTime: '',
|
||||
sysOrigin: '',
|
||||
userId: '',
|
||||
});
|
||||
|
||||
watch(rangeDate, (value) => {
|
||||
query.startTime = value?.[0] || '';
|
||||
query.endTime = value?.[1] || '';
|
||||
});
|
||||
|
||||
watch(
|
||||
sysOriginOptions,
|
||||
(options) => {
|
||||
if (!query.sysOrigin) {
|
||||
query.sysOrigin = String(options[0]?.value || '');
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => query.sysOrigin,
|
||||
(value) => {
|
||||
if (value) {
|
||||
void loadData(true);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
async function loadData(reset = false) {
|
||||
if (!query.sysOrigin) {
|
||||
return;
|
||||
}
|
||||
if (reset) {
|
||||
query.cursor = 1;
|
||||
}
|
||||
loading.value = true;
|
||||
try {
|
||||
const result = await pageAgoraErrorLogs({
|
||||
agoraUid: query.agoraUid,
|
||||
bannedOnly: query.bannedOnly,
|
||||
cursor: query.cursor,
|
||||
endTime: query.endTime,
|
||||
errorCodeType: query.errorCodeType,
|
||||
limit: query.limit,
|
||||
networkType: query.networkType,
|
||||
reasonType: query.reasonType,
|
||||
roomId: query.roomId,
|
||||
startTime: query.startTime,
|
||||
sysOrigin: query.sysOrigin,
|
||||
userId: query.userId,
|
||||
});
|
||||
list.value = result.records || [];
|
||||
total.value = Number(result.total || 0);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handlePageChange(page: number, pageSize: number) {
|
||||
query.cursor = page;
|
||||
query.limit = pageSize;
|
||||
void loadData();
|
||||
}
|
||||
|
||||
function showDetails(record: AppAgoraErrorLogItem) {
|
||||
const payload = record.rawPayload || '{}';
|
||||
try {
|
||||
detailsText.value = JSON.stringify(JSON.parse(payload), null, 2);
|
||||
} catch {
|
||||
detailsText.value = payload;
|
||||
}
|
||||
detailsOpen.value = true;
|
||||
}
|
||||
|
||||
function tokenText(value: boolean | null | undefined) {
|
||||
if (value === true) {
|
||||
return 'Token成功';
|
||||
}
|
||||
if (value === false) {
|
||||
return 'Token失败';
|
||||
}
|
||||
return 'Token未知';
|
||||
}
|
||||
|
||||
function tokenColor(value: boolean | null | undefined) {
|
||||
if (value === true) {
|
||||
return 'green';
|
||||
}
|
||||
if (value === false) {
|
||||
return 'red';
|
||||
}
|
||||
return 'default';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="错误日志 - 声网">
|
||||
<Card>
|
||||
<InlineFilterToolbar class="toolbar">
|
||||
<InlineFilterField label="分类">
|
||||
<Select
|
||||
v-model:value="query.category"
|
||||
:options="categoryOptions"
|
||||
disabled
|
||||
style="width: 120px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="系统">
|
||||
<SysOriginSelect
|
||||
v-model:value="query.sysOrigin"
|
||||
:options="sysOriginOptions"
|
||||
style="width: 140px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="用户ID">
|
||||
<Input
|
||||
v-model:value="query.userId"
|
||||
allow-clear
|
||||
placeholder="用户ID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="房间ID">
|
||||
<Input
|
||||
v-model:value="query.roomId"
|
||||
allow-clear
|
||||
placeholder="房间ID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="Agora UID" :label-width="92">
|
||||
<Input
|
||||
v-model:value="query.agoraUid"
|
||||
allow-clear
|
||||
placeholder="Agora UID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="ErrorCode" :label-width="92">
|
||||
<Input
|
||||
v-model:value="query.errorCodeType"
|
||||
allow-clear
|
||||
placeholder="ErrorCodeType"
|
||||
style="width: 180px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="Reason" :label-width="76">
|
||||
<Input
|
||||
v-model:value="query.reasonType"
|
||||
allow-clear
|
||||
placeholder="ConnectionChangedReasonType"
|
||||
style="width: 220px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="踢出规则" :label-width="84">
|
||||
<Select
|
||||
v-model:value="query.bannedOnly"
|
||||
:options="bannedOptions"
|
||||
style="width: 170px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="网络">
|
||||
<Input
|
||||
v-model:value="query.networkType"
|
||||
allow-clear
|
||||
placeholder="wifi / mobile"
|
||||
style="width: 140px"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="时间范围" :control-width="360">
|
||||
<DateRangePicker
|
||||
v-model:value="rangeDate"
|
||||
show-time
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<Button :loading="loading" type="primary" @click="loadData(true)">
|
||||
搜索
|
||||
</Button>
|
||||
</InlineFilterToolbar>
|
||||
|
||||
<Table
|
||||
:columns="columns"
|
||||
:data-source="list"
|
||||
:loading="loading"
|
||||
:pagination="false"
|
||||
row-key="id"
|
||||
:scroll="{ x: 1700 }"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'createTime'">
|
||||
{{ formatDate(record.createTime) }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'connectionChangedReasonType'">
|
||||
<Space wrap>
|
||||
<span>{{ record.connectionChangedReasonType || '-' }}</span>
|
||||
<Tag v-if="record.bannedByServer" color="red">
|
||||
BannedByServer
|
||||
</Tag>
|
||||
</Space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'flags'">
|
||||
<Space wrap>
|
||||
<Tag :color="record.isTimeout ? 'orange' : 'default'">
|
||||
{{ record.isTimeout ? 'Timeout' : '非Timeout' }}
|
||||
</Tag>
|
||||
<Tag :color="tokenColor(record.tokenRequestSuccess)">
|
||||
{{ tokenText(record.tokenRequestSuccess) }}
|
||||
</Tag>
|
||||
</Space>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<Button size="small" type="link" @click="showDetails(record)">
|
||||
详情
|
||||
</Button>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
|
||||
<div class="pagination">
|
||||
<Pagination
|
||||
:current="query.cursor"
|
||||
:page-size="query.limit"
|
||||
:total="total"
|
||||
show-size-changer
|
||||
@change="handlePageChange"
|
||||
@showSizeChange="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Modal
|
||||
:open="detailsOpen"
|
||||
destroy-on-close
|
||||
title="原始上报内容"
|
||||
width="760"
|
||||
@cancel="detailsOpen = false"
|
||||
@ok="detailsOpen = false"
|
||||
>
|
||||
<pre class="json-box">{{ detailsText }}</pre>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.json-box {
|
||||
background: #0f172a;
|
||||
border-radius: 8px;
|
||||
color: #e2e8f0;
|
||||
margin: 0;
|
||||
max-height: 60vh;
|
||||
overflow: auto;
|
||||
padding: 16px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
@ -2,8 +2,20 @@
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import {
|
||||
OSS_FILE_BUCKETS,
|
||||
Button,
|
||||
Form,
|
||||
FormItem,
|
||||
Image,
|
||||
Input,
|
||||
message,
|
||||
Modal,
|
||||
Select,
|
||||
Switch,
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
getAccessImgUrl,
|
||||
OSS_FILE_BUCKETS,
|
||||
simpleUploadFile,
|
||||
} from '#/api/legacy/oss';
|
||||
import {
|
||||
@ -11,21 +23,9 @@ import {
|
||||
updatePropsSource,
|
||||
} from '#/api/legacy/props';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
FormItem,
|
||||
Image,
|
||||
Input,
|
||||
Modal,
|
||||
Select,
|
||||
Switch,
|
||||
message,
|
||||
} from 'antdv-next';
|
||||
|
||||
import {
|
||||
NOBLE_VIP_OPTIONS,
|
||||
PROPS_TYPES,
|
||||
PROPS_RESOURCE_CONFIG_TYPES,
|
||||
} from '../shared';
|
||||
|
||||
const props = defineProps<{
|
||||
@ -63,17 +63,26 @@ const form = reactive<Record<string, any>>({
|
||||
|
||||
const isUpdate = computed(() => Boolean(form.id));
|
||||
const isImageSourceType = computed(() =>
|
||||
['THEME', 'LAYOUT', 'CHAT_BUBBLE'].includes(form.type),
|
||||
['CHAT_BUBBLE', 'LAYOUT', 'THEME'].includes(form.type),
|
||||
);
|
||||
const isAmountRequired = computed(
|
||||
() => !['CUSTOMIZE', 'FRAGMENTS'].includes(form.type),
|
||||
);
|
||||
const isSourceRequired = computed(
|
||||
const showSourceUpload = computed(
|
||||
() => !['CUSTOMIZE', 'FRAGMENTS'].includes(form.type),
|
||||
);
|
||||
const isSourceRequired = computed(
|
||||
() => !['BADGE', 'CUSTOMIZE', 'FRAGMENTS'].includes(form.type),
|
||||
);
|
||||
const showExpandUpload = computed(() => form.type === 'CHAT_BUBBLE');
|
||||
const sourceUploadLabel = computed(() => {
|
||||
if (showExpandUpload.value) {
|
||||
return 'iOS资源';
|
||||
}
|
||||
return isSourceRequired.value ? '资源' : '资源(选填)';
|
||||
});
|
||||
const title = computed(() => (isUpdate.value ? '修改资源' : '新增资源'));
|
||||
const propsTypeOptions = PROPS_TYPES.map((item) => ({
|
||||
const propsTypeOptions = PROPS_RESOURCE_CONFIG_TYPES.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.value as any,
|
||||
}));
|
||||
@ -92,7 +101,7 @@ function resetForm() {
|
||||
form.name = '';
|
||||
form.sourceUrl = '';
|
||||
form.sysOrigin = props.sysOriginOptions[0]?.value ?? 'LIKEI';
|
||||
form.type = PROPS_TYPES[0]?.value ?? '';
|
||||
form.type = PROPS_RESOURCE_CONFIG_TYPES[0]?.value ?? '';
|
||||
}
|
||||
|
||||
watch(
|
||||
@ -235,11 +244,7 @@ async function handleSubmit() {
|
||||
...form,
|
||||
amount: isAmountRequired.value ? Number(form.amount) : 0,
|
||||
};
|
||||
if (isUpdate.value) {
|
||||
await updatePropsSource(payload);
|
||||
} else {
|
||||
await addPropsSource(payload);
|
||||
}
|
||||
await (isUpdate.value ? updatePropsSource(payload) : addPropsSource(payload));
|
||||
message.success('保存成功');
|
||||
emit('success');
|
||||
emit('close');
|
||||
@ -261,9 +266,10 @@ async function handleSubmit() {
|
||||
>
|
||||
<Form layout="vertical">
|
||||
<FormItem label="系统">
|
||||
<SysOriginSelect v-model:value="form.sysOrigin"
|
||||
<SysOriginSelect
|
||||
v-model:value="form.sysOrigin"
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="类型">
|
||||
<Select
|
||||
@ -290,7 +296,7 @@ async function handleSubmit() {
|
||||
</Button>
|
||||
</div>
|
||||
</FormItem>
|
||||
<FormItem v-if="isSourceRequired" :label="showExpandUpload ? 'iOS资源' : '资源'">
|
||||
<FormItem v-if="showSourceUpload" :label="sourceUploadLabel">
|
||||
<input
|
||||
ref="sourceInputRef"
|
||||
:accept="isImageSourceType ? 'image/*' : '.svga,.pag,.mp4'"
|
||||
|
||||
@ -3,9 +3,6 @@ import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import { getPropsSale } from '#/api/legacy/statistics';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import {
|
||||
DatePicker,
|
||||
Descriptions,
|
||||
@ -16,10 +13,13 @@ import {
|
||||
Table,
|
||||
} from 'antdv-next';
|
||||
|
||||
import { getPropsSale } from '#/api/legacy/statistics';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import {
|
||||
ACTIVITY_DATE_TYPE_MAP,
|
||||
ACTIVITY_DATE_TYPE_OPTIONS,
|
||||
PROPS_TYPES,
|
||||
PROPS_RESOURCE_CONFIG_TYPES,
|
||||
} from '../shared';
|
||||
|
||||
defineOptions({ name: 'PropsResourceOverviewModal' });
|
||||
@ -45,7 +45,7 @@ const summary = ref<Record<string, any>>({});
|
||||
const query = reactive({
|
||||
date: '',
|
||||
dateType: 'MONTH',
|
||||
propsType: PROPS_TYPES[0]?.value ?? 'AVATAR_FRAME',
|
||||
propsType: PROPS_RESOURCE_CONFIG_TYPES[0]?.value ?? 'AVATAR_FRAME',
|
||||
sysOrigin: '',
|
||||
});
|
||||
|
||||
@ -66,7 +66,7 @@ const dateTypeOptions = ACTIVITY_DATE_TYPE_OPTIONS.map((item) => ({
|
||||
label: item.label,
|
||||
value: item.value as any,
|
||||
}));
|
||||
const propsTypeOptions = PROPS_TYPES.map((item) => ({
|
||||
const propsTypeOptions = PROPS_RESOURCE_CONFIG_TYPES.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.value as any,
|
||||
}));
|
||||
@ -97,7 +97,7 @@ watch(
|
||||
}
|
||||
query.sysOrigin = sysOriginOptions.value[0]?.value || 'LIKEI';
|
||||
query.dateType = 'MONTH';
|
||||
query.propsType = PROPS_TYPES[0]?.value ?? 'AVATAR_FRAME';
|
||||
query.propsType = PROPS_RESOURCE_CONFIG_TYPES[0]?.value ?? 'AVATAR_FRAME';
|
||||
query.date = ACTIVITY_DATE_TYPE_MAP.MONTH.defaultDate;
|
||||
void loadData();
|
||||
},
|
||||
@ -123,9 +123,12 @@ watch(
|
||||
@cancel="emit('close')"
|
||||
>
|
||||
<Space class="toolbar" wrap>
|
||||
<SysOriginSelect v-model:value="query.sysOrigin" style="width: 140px" @change="loadData"
|
||||
<SysOriginSelect
|
||||
v-model:value="query.sysOrigin"
|
||||
style="width: 140px"
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
@change="loadData"
|
||||
/>
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.dateType"
|
||||
|
||||
@ -2,38 +2,39 @@
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref } from 'vue';
|
||||
ref,
|
||||
} from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { useAccessStore } from '@vben/stores';
|
||||
|
||||
import {
|
||||
offShelfPropsSource,
|
||||
pagePropsSource,
|
||||
} from '#/api/legacy/props';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Empty,
|
||||
Input,
|
||||
message,
|
||||
Pagination,
|
||||
Select,
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tag,
|
||||
message
|
||||
} from 'antdv-next';
|
||||
|
||||
import RewardIcon from './components/reward-icon.vue';
|
||||
import {
|
||||
offShelfPropsSource,
|
||||
pagePropsSource,
|
||||
} from '#/api/legacy/props';
|
||||
import InlineFilterField from '#/views/_shared/inline-filter-field.vue';
|
||||
import InlineFilterToolbar from '#/views/_shared/inline-filter-toolbar.vue';
|
||||
import { getAllowedSysOrigins } from '#/views/system/shared';
|
||||
|
||||
import ResourceConfigModal from './components/resource-config-modal.vue';
|
||||
import ResourceOverviewModal from './components/resource-overview-modal.vue';
|
||||
import ResourceSalesModal from './components/resource-sales-modal.vue';
|
||||
import { PROPS_DEL_OPTIONS, PROPS_TYPES } from './shared';
|
||||
import RewardIcon from './components/reward-icon.vue';
|
||||
import { PROPS_DEL_OPTIONS, PROPS_RESOURCE_CONFIG_TYPES } from './shared';
|
||||
|
||||
defineOptions({ name: 'PropsResourceConfig' });
|
||||
|
||||
@ -62,7 +63,7 @@ const list = ref<Array<Record<string, any>>>([]);
|
||||
const formOpen = ref(false);
|
||||
const salesOpen = ref(false);
|
||||
const overviewOpen = ref(false);
|
||||
const activeRow = ref<Record<string, any> | null>(null);
|
||||
const activeRow = ref<null | Record<string, any>>(null);
|
||||
|
||||
const query = reactive({
|
||||
cursor: 1,
|
||||
@ -71,7 +72,7 @@ const query = reactive({
|
||||
limit: 20,
|
||||
name: '',
|
||||
sysOrigin: sysOriginOptions.value[0]?.value ?? 'LIKEI',
|
||||
type: PROPS_TYPES[0]?.value ?? 'AVATAR_FRAME',
|
||||
type: PROPS_RESOURCE_CONFIG_TYPES[0]?.value ?? 'AVATAR_FRAME',
|
||||
});
|
||||
|
||||
const columns = [
|
||||
@ -150,24 +151,24 @@ loadData(true);
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="sysOriginOptions"
|
||||
></SysOriginSelect>
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="类型">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.type"
|
||||
style="width: 140px"
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="PROPS_TYPES.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
:options="PROPS_RESOURCE_CONFIG_TYPES.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
<InlineFilterField label="状态">
|
||||
<Select option-label-prop="label"
|
||||
<Select
|
||||
option-label-prop="label"
|
||||
v-model:value="query.del"
|
||||
allow-clear
|
||||
style="width: 120px"
|
||||
@change="loadData(true)"
|
||||
|
||||
:options="PROPS_DEL_OPTIONS.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||
/>
|
||||
</InlineFilterField>
|
||||
@ -246,7 +247,7 @@ loadData(true);
|
||||
:total="total"
|
||||
show-size-changer
|
||||
@change="handlePageChange"
|
||||
@showSizeChange="handlePageChange"
|
||||
@show-size-change="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@ -19,6 +19,11 @@ export const PROPS_TYPES: OptionItem[] = [
|
||||
{ value: 'CUSTOMIZE', name: '自定义(只读)' },
|
||||
];
|
||||
|
||||
export const PROPS_RESOURCE_CONFIG_TYPES: OptionItem[] = [
|
||||
...PROPS_TYPES,
|
||||
{ value: 'BADGE', name: '徽章' },
|
||||
];
|
||||
|
||||
export const PROPS_TICKET_TYPES: OptionItem[] = [
|
||||
{ value: 'AVATAR_FRAME', name: '头像框' },
|
||||
{ value: 'RIDE', name: '座驾' },
|
||||
@ -276,14 +281,15 @@ export function isBadgeRewardType(type?: null | string) {
|
||||
export function isPropsSourceType(type?: null | string) {
|
||||
return [
|
||||
'AVATAR_FRAME',
|
||||
'RIDE',
|
||||
'NOBLE_VIP',
|
||||
'THEME',
|
||||
'BADGE',
|
||||
'CHAT_BUBBLE',
|
||||
'CUSTOMIZE',
|
||||
'DATA_CARD',
|
||||
'FLOAT_PICTURE',
|
||||
'FRAGMENTS',
|
||||
'DATA_CARD',
|
||||
'CUSTOMIZE',
|
||||
'NOBLE_VIP',
|
||||
'RIDE',
|
||||
'THEME',
|
||||
].includes(String(type || ''));
|
||||
}
|
||||
|
||||
@ -328,8 +334,9 @@ export function createActivityRuleDraft(type = '') {
|
||||
case 'FIRST_CHARGE_REWARD': {
|
||||
return { productId: '' };
|
||||
}
|
||||
case 'SVIP_REWARD': {
|
||||
return { mark: '', quantity: '' };
|
||||
case 'GAME_FRUIT_BOX_REWARD_TIMES':
|
||||
case 'GAME_FRUIT_BOX_REWARD_WIN': {
|
||||
return { quantity: '', status: true };
|
||||
}
|
||||
case 'LUCKY_BOX': {
|
||||
return [
|
||||
@ -338,13 +345,12 @@ export function createActivityRuleDraft(type = '') {
|
||||
{ id: 3, opportunityNumber: '', quantity: '' },
|
||||
];
|
||||
}
|
||||
case 'SVIP_REWARD': {
|
||||
return { mark: '', quantity: '' };
|
||||
}
|
||||
case 'WEEKLY_GAME_TASKS': {
|
||||
return { gameConfId: '', target: '' };
|
||||
}
|
||||
case 'GAME_FRUIT_BOX_REWARD_WIN':
|
||||
case 'GAME_FRUIT_BOX_REWARD_TIMES': {
|
||||
return { quantity: '', status: true };
|
||||
}
|
||||
default: {
|
||||
return { quantity: '' };
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
@ -7,6 +9,7 @@ import { useAccessStore } from '@vben/stores';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
DatePicker,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
@ -20,6 +23,7 @@ import {
|
||||
Tabs,
|
||||
Tag,
|
||||
} from 'antdv-next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getResidentDailyTaskConfig,
|
||||
@ -175,6 +179,12 @@ const claimQuery = reactive<Record<string, any>>({
|
||||
userId: '',
|
||||
});
|
||||
|
||||
function defaultClaimDateRange(): [Dayjs, Dayjs] {
|
||||
return [dayjs().startOf('day'), dayjs().endOf('day')];
|
||||
}
|
||||
|
||||
const claimDateRange = ref<[Dayjs, Dayjs] | null>(defaultClaimDateRange());
|
||||
|
||||
const claimPage = reactive<Record<string, any>>({
|
||||
current: 1,
|
||||
records: [],
|
||||
@ -182,6 +192,12 @@ const claimPage = reactive<Record<string, any>>({
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const claimSummary = reactive<Record<string, any>>({
|
||||
selectedTaskRewardGold: 0,
|
||||
taskCode: '',
|
||||
totalRewardGold: 0,
|
||||
});
|
||||
|
||||
const statusMeta = computed(() => {
|
||||
if (!form.configured) {
|
||||
return { color: 'processing', text: '未配置' };
|
||||
@ -196,6 +212,24 @@ const activeTaskCategoryLabel = computed(() => {
|
||||
return taskCategoryOptions.find((item) => item.value === activeTaskCategory.value)?.label || '每日任务';
|
||||
});
|
||||
|
||||
const taskCodeOptions = computed(() => {
|
||||
const seen = new Set<string>();
|
||||
return ((form.tasks || []) as Array<Record<string, any>>)
|
||||
.map((item) => {
|
||||
const value = String(item.taskCode || '').trim();
|
||||
if (!value || seen.has(value)) {
|
||||
return null;
|
||||
}
|
||||
seen.add(value);
|
||||
const taskName = String(item.taskName || '').trim();
|
||||
return {
|
||||
label: taskName ? `${value} / ${taskName}` : value,
|
||||
value,
|
||||
};
|
||||
})
|
||||
.filter(Boolean) as Array<{ label: string; value: string }>;
|
||||
});
|
||||
|
||||
function normalizeConditionJumpRows(
|
||||
rows: Array<Record<string, any>>,
|
||||
tasks: Array<Record<string, any>>,
|
||||
@ -543,6 +577,20 @@ function normalizePage(target: Record<string, any>, result: Record<string, any>)
|
||||
target.total = Number(result?.total || 0);
|
||||
target.current = Number(result?.current || 1);
|
||||
target.size = Number(result?.size || 20);
|
||||
const summary = result?.summary || {};
|
||||
claimSummary.totalRewardGold = Number(summary.totalRewardGold || 0);
|
||||
claimSummary.selectedTaskRewardGold = Number(summary.selectedTaskRewardGold || 0);
|
||||
claimSummary.taskCode = String(summary.taskCode || '');
|
||||
}
|
||||
|
||||
function claimTimeParams() {
|
||||
if (!claimDateRange.value?.[0] || !claimDateRange.value?.[1]) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
endTime: String(claimDateRange.value[1].valueOf()),
|
||||
startTime: String(claimDateRange.value[0].valueOf()),
|
||||
};
|
||||
}
|
||||
|
||||
async function loadClaimRecords() {
|
||||
@ -553,6 +601,7 @@ async function loadClaimRecords() {
|
||||
try {
|
||||
const result = await pageResidentDailyTaskClaimRecords({
|
||||
...claimQuery,
|
||||
...claimTimeParams(),
|
||||
sysOrigin: selectedSysOrigin.value,
|
||||
taskCategory: activeTaskCategory.value,
|
||||
});
|
||||
@ -567,6 +616,11 @@ function searchClaimRecords() {
|
||||
void loadClaimRecords();
|
||||
}
|
||||
|
||||
function resetClaimDateRange() {
|
||||
claimDateRange.value = defaultClaimDateRange();
|
||||
searchClaimRecords();
|
||||
}
|
||||
|
||||
function handleClaimTableChange(pagination: Record<string, any>) {
|
||||
claimQuery.cursor = Number(pagination.current || 1);
|
||||
claimQuery.limit = Number(pagination.pageSize || 20);
|
||||
@ -585,12 +639,13 @@ watch(
|
||||
|
||||
watch(
|
||||
selectedSysOrigin,
|
||||
(value) => {
|
||||
if (value) {
|
||||
claimQuery.cursor = 1;
|
||||
void loadConfig();
|
||||
void loadClaimRecords();
|
||||
}
|
||||
(value) => {
|
||||
if (value) {
|
||||
claimQuery.cursor = 1;
|
||||
claimQuery.taskCode = '';
|
||||
void loadConfig();
|
||||
void loadClaimRecords();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@ -600,6 +655,7 @@ watch(activeTaskCategory, () => {
|
||||
return;
|
||||
}
|
||||
claimQuery.cursor = 1;
|
||||
claimQuery.taskCode = '';
|
||||
void loadConfig();
|
||||
void loadClaimRecords();
|
||||
});
|
||||
@ -786,11 +842,21 @@ watch(activeTaskCategory, () => {
|
||||
placeholder="用户ID"
|
||||
style="width: 160px"
|
||||
/>
|
||||
<Input
|
||||
<Select
|
||||
v-model:value="claimQuery.taskCode"
|
||||
allow-clear
|
||||
:options="taskCodeOptions"
|
||||
option-filter-prop="label"
|
||||
placeholder="任务编码"
|
||||
style="width: 220px"
|
||||
show-search
|
||||
style="width: 280px"
|
||||
/>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="claimDateRange"
|
||||
allow-clear
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
show-time
|
||||
style="width: 390px"
|
||||
/>
|
||||
<Select
|
||||
v-model:value="claimQuery.status"
|
||||
@ -805,6 +871,17 @@ watch(activeTaskCategory, () => {
|
||||
<Button :loading="claimLoading" type="primary" @click="searchClaimRecords">
|
||||
查询
|
||||
</Button>
|
||||
<Button @click="resetClaimDateRange">今天</Button>
|
||||
</div>
|
||||
<div class="claim-summary">
|
||||
<Tag color="blue">
|
||||
当前时间总发放金币:{{ claimSummary.totalRewardGold }}
|
||||
</Tag>
|
||||
<Tag v-if="claimQuery.taskCode" color="green">
|
||||
{{ claimQuery.taskCode }} 发放金币:{{
|
||||
claimSummary.selectedTaskRewardGold
|
||||
}}
|
||||
</Tag>
|
||||
</div>
|
||||
<Table
|
||||
:columns="claimColumns"
|
||||
@ -850,6 +927,10 @@ watch(activeTaskCategory, () => {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.claim-summary {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user