diff --git a/apps/src/api/legacy/baishun-game.ts b/apps/src/api/legacy/baishun-game.ts index 1f557c2..3494bb0 100644 --- a/apps/src/api/legacy/baishun-game.ts +++ b/apps/src/api/legacy/baishun-game.ts @@ -10,6 +10,13 @@ export async function saveBaishunProviderConfig(data: Record) { return requestClient.post>('/go/operate/baishun-game/config', data); } +export async function activateBaishunProviderProfile(data: Record) { + return requestClient.post>( + '/go/operate/baishun-game/config/activate', + data, + ); +} + export async function pageBaishunGames(params: Record) { return requestClient.get>('/go/operate/baishun-game/page', { params, @@ -26,9 +33,13 @@ export async function saveBaishunGame(data: Record) { return requestClient.post>('/go/operate/baishun-game/save', data); } -export async function deleteBaishunGame(id: number | string, sysOrigin: string) { +export async function deleteBaishunGame( + id: number | string, + sysOrigin: string, + profile?: string, +) { return requestClient.delete>('/go/operate/baishun-game', { - params: { id, sysOrigin }, + params: { id, profile, sysOrigin }, }); } diff --git a/apps/src/router/routes/modules/app-user.ts b/apps/src/router/routes/modules/app-user.ts index 75311d5..fdad2cf 100644 --- a/apps/src/router/routes/modules/app-user.ts +++ b/apps/src/router/routes/modules/app-user.ts @@ -197,6 +197,13 @@ const routes: RouteRecordRaw[] = [ component: () => import('#/views/operate/gift-history.vue'), meta: { title: '礼物赠送记录' }, }, + { + name: 'OperatePush', + path: 'push', + alias: '/operate/manager/push', + component: () => import('#/views/operate/push.vue'), + meta: { title: '消息推送' }, + }, { name: 'RunningWaterUserProps', path: 'running/water/user/props', diff --git a/apps/src/router/routes/modules/operate.ts b/apps/src/router/routes/modules/operate.ts index 8b68e6f..be989a0 100644 --- a/apps/src/router/routes/modules/operate.ts +++ b/apps/src/router/routes/modules/operate.ts @@ -161,12 +161,6 @@ const routes: RouteRecordRaw[] = [ component: () => import('#/views/operate/teen-patti.vue'), meta: { title: '炸金花' }, }, - { - name: 'OperatePush', - path: 'push', - component: () => import('#/views/operate/push.vue'), - meta: { title: '消息推送' }, - }, { name: 'OperateSysCountry', path: 'sys/country', diff --git a/apps/src/views/operate/baishun-config.vue b/apps/src/views/operate/baishun-config.vue index 6aab3ac..7126666 100644 --- a/apps/src/views/operate/baishun-config.vue +++ b/apps/src/views/operate/baishun-config.vue @@ -5,6 +5,7 @@ import { Page } from '@vben/common-ui'; import { useAccessStore } from '@vben/stores'; import { + activateBaishunProviderProfile, fetchBaishunCatalog, getBaishunProviderConfig, importBaishunCatalog, @@ -22,6 +23,7 @@ import { Input, InputNumber, Pagination, + Select, Table, Tag, message, @@ -32,6 +34,7 @@ defineOptions({ name: 'OperateBaishunConfig' }); function createProviderForm(sysOrigin = '') { return { sysOrigin, + profile: 'PROD', platformBaseUrl: '', appId: undefined as any, appName: '', @@ -49,7 +52,12 @@ const sysOriginOptions = computed(() => { return options.length > 0 ? options : getAllowedSysOrigins([]); }); -const contextQuery = reactive({ sysOrigin: '' }); +const profileOptions = [ + { label: '正式环境', value: 'PROD' }, + { label: '测试环境', value: 'TEST' }, +]; + +const contextQuery = reactive({ profile: 'PROD', sysOrigin: '' }); const providerForm = reactive(createProviderForm()); const catalogQuery = reactive>({ cursor: 1, @@ -62,9 +70,20 @@ const providerSaving = ref(false); const catalogLoading = ref(false); const catalogFetching = ref(false); const catalogImporting = ref(false); +const profileActivating = ref(false); const totalCatalog = ref(0); const catalogList = ref>>([]); const selectedCatalogKeys = ref>([]); +const activeProfile = ref('PROD'); + +const isCurrentProfileActive = computed( + () => activeProfile.value === contextQuery.profile, +); +const activeProfileLabel = computed( + () => + profileOptions.find((item) => item.value === activeProfile.value)?.label || + activeProfile.value, +); const catalogColumns = [ { dataIndex: 'cover', key: 'cover', title: '封面', width: 90 }, @@ -100,12 +119,15 @@ watch( ); watch( - () => contextQuery.sysOrigin, - (value) => { - if (!value) { + () => [contextQuery.sysOrigin, contextQuery.profile], + ([sysOrigin, profile]) => { + if (!sysOrigin || !profile) { return; } - Object.assign(providerForm, createProviderForm(value)); + Object.assign(providerForm, createProviderForm(sysOrigin), { + profile, + sysOrigin, + }); selectedCatalogKeys.value = []; void Promise.all([loadProviderConfig(), loadCatalog(true)]); }, @@ -113,8 +135,10 @@ watch( ); function applyProviderForm(record: Record) { + activeProfile.value = String(record.activeProfile || activeProfile.value || 'PROD'); Object.assign(providerForm, createProviderForm(contextQuery.sysOrigin), { ...record, + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, appId: Number(record.appId || 0) || undefined, gsp: Number(record.gsp || 101) || 101, @@ -130,6 +154,7 @@ async function loadProviderConfig() { providerLoading.value = true; try { const result = await getBaishunProviderConfig({ + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, }); applyProviderForm(result || {}); @@ -153,6 +178,7 @@ async function persistProviderConfig(showSuccess = true) { try { const result = await saveBaishunProviderConfig({ ...providerForm, + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, appId: Number(providerForm.appId || 0), gsp: Number(providerForm.gsp || 101), @@ -182,6 +208,7 @@ async function loadCatalog(reset = false) { try { const result = await pageBaishunCatalog({ ...catalogQuery, + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, }); catalogList.value = Array.isArray(result.records) ? result.records : []; @@ -205,6 +232,24 @@ async function handleSaveProviderConfig() { await persistProviderConfig(true); } +async function handleActivateProfile() { + if (!(await persistProviderConfig(false))) { + return; + } + profileActivating.value = true; + try { + const result = await activateBaishunProviderProfile({ + profile: contextQuery.profile, + sysOrigin: contextQuery.sysOrigin, + }); + applyProviderForm(result || providerForm); + message.success(`已切换到${activeProfileLabel.value}`); + await loadCatalog(true); + } finally { + profileActivating.value = false; + } +} + async function handleFetchCatalog() { if (!(await persistProviderConfig(false))) { return; @@ -212,6 +257,7 @@ async function handleFetchCatalog() { catalogFetching.value = true; try { const result = await fetchBaishunCatalog({ + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, }); message.success( @@ -234,6 +280,7 @@ async function handleImportSelected() { catalogImporting.value = true; try { const result = await importBaishunCatalog({ + profile: contextQuery.profile, sysOrigin: contextQuery.sysOrigin, vendorGameIds: selectedCatalogKeys.value, }); @@ -259,6 +306,13 @@ async function handleImportSelected() { :options="sysOriginOptions" /> + +