feat(theme-2): sync inbox/announcements/presence/deposit from main
This commit is contained in:
@@ -1153,6 +1153,12 @@ a {
|
||||
color: var(--text) !important;
|
||||
}
|
||||
|
||||
.el-input,
|
||||
.el-select,
|
||||
.el-date-editor {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.el-input__wrapper:hover,
|
||||
.el-select__wrapper:hover,
|
||||
.el-textarea__inner:hover {
|
||||
@@ -1426,6 +1432,40 @@ input:-webkit-autofill:focus {
|
||||
color: var(--warning-text) !important;
|
||||
}
|
||||
|
||||
/* Link buttons hover in light theme - override dark legacy */
|
||||
.el-button.is-link:hover,
|
||||
.el-button.is-link:focus,
|
||||
.el-button.is-link.el-button--default:hover,
|
||||
.el-button.is-link.el-button--default:focus,
|
||||
.el-button.is-link.el-button--primary:hover,
|
||||
.el-button.is-link.el-button--primary:focus {
|
||||
color: #155b86 !important; /* Darker blue */
|
||||
background: transparent !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.el-button.is-link.el-button--success:hover,
|
||||
.el-button.is-link.el-button--success:focus {
|
||||
color: #224225 !important; /* Darker green */
|
||||
background: transparent !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.el-button.is-link.el-button--warning:hover,
|
||||
.el-button.is-link.el-button--warning:focus {
|
||||
color: #704b00 !important; /* Darker warning/gold */
|
||||
background: transparent !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.el-button.is-link.el-button--danger:hover,
|
||||
.el-button.is-link.el-button--danger:focus {
|
||||
color: #7d2321 !important; /* Darker danger/red */
|
||||
background: transparent !important;
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
|
||||
.el-button.is-disabled,
|
||||
.el-button.is-disabled:hover {
|
||||
background: #f4f0e8 !important;
|
||||
|
||||
52
apps/admin/src/components/AdminPlayerStatusCell.vue
Normal file
52
apps/admin/src/components/AdminPlayerStatusCell.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { useAdminLocale } from '../composables/useAdminLocale';
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
status: string;
|
||||
isOnline?: boolean;
|
||||
}>(),
|
||||
{ isOnline: false },
|
||||
);
|
||||
|
||||
const { t } = useAdminLocale();
|
||||
|
||||
function statusTagType(s: string) {
|
||||
return s === 'ACTIVE' ? 'success' : s === 'SUSPENDED' ? 'warning' : 'info';
|
||||
}
|
||||
|
||||
function statusLabel(s: string) {
|
||||
const key = `user.status.${s}`;
|
||||
const label = t(key);
|
||||
return label !== key ? label : s;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="player-status-with-presence">
|
||||
<el-tag :type="statusTagType(status)" size="small">{{ statusLabel(status) }}</el-tag>
|
||||
<span :class="isOnline ? 'presence-online' : 'presence-offline'">
|
||||
({{ t(isOnline ? 'user.presence_online' : 'user.presence_offline') }})
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.player-status-with-presence {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.presence-online {
|
||||
font-size: 12px;
|
||||
color: #2d8a4e;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.presence-offline {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
@@ -37,7 +37,7 @@ interface AuditRow {
|
||||
const logs = ref<AuditRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSize = ref(10);
|
||||
const filterModule = ref('');
|
||||
|
||||
onMounted(load);
|
||||
@@ -129,6 +129,7 @@ function operatorDisplay(row: AuditRow): string {
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" fixed="left" />
|
||||
<el-table-column :label="t('audit.col.time')" min-width="168" fixed="left">
|
||||
<template #default="{ row }">{{ formatTime(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
|
||||
316
apps/admin/src/components/ContentImageField.vue
Normal file
316
apps/admin/src/components/ContentImageField.vue
Normal file
@@ -0,0 +1,316 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { useAdminLocale } from '../composables/useAdminLocale';
|
||||
import api from '../api';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string;
|
||||
category?: string;
|
||||
sizeHintKey?: string;
|
||||
disabled?: boolean;
|
||||
}>(),
|
||||
{ category: 'contents', sizeHintKey: 'content.upload.cover_size_hint' },
|
||||
);
|
||||
|
||||
const emit = defineEmits<{ 'update:modelValue': [string] }>();
|
||||
|
||||
const { t } = useAdminLocale();
|
||||
|
||||
const IMAGE_ACCEPT = 'image/png,image/jpeg,image/webp,image/gif,image/svg+xml';
|
||||
const MAX_UPLOAD_SIZE = 5 * 1024 * 1024;
|
||||
|
||||
const uploading = ref(false);
|
||||
const mediaPickerVisible = ref(false);
|
||||
const mediaFiles = ref<Array<{ id: string; filename: string; url: string; mimeType: string }>>([]);
|
||||
const mediaLoading = ref(false);
|
||||
|
||||
async function uploadImage(file: File) {
|
||||
if (file.size > MAX_UPLOAD_SIZE) {
|
||||
ElMessage.error(t('content.upload.size_error'));
|
||||
return;
|
||||
}
|
||||
uploading.value = true;
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
const { data } = await api.post(`/admin/uploads?category=${props.category}`, fd, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
const url = data.data?.url as string;
|
||||
if (url) {
|
||||
emit('update:modelValue', url);
|
||||
ElMessage.success(t('content.upload.success'));
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
const e = err as { response?: { data?: { message?: string } } };
|
||||
ElMessage.error(String(e.response?.data?.message || t('content.upload.failed')));
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onFileChange(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
if (input.files?.[0]) {
|
||||
void uploadImage(input.files[0]);
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function removeImage() {
|
||||
emit('update:modelValue', '');
|
||||
}
|
||||
|
||||
async function openMediaPicker() {
|
||||
mediaPickerVisible.value = true;
|
||||
mediaLoading.value = true;
|
||||
try {
|
||||
const res = await api.get('/admin/files', {
|
||||
params: { category: props.category, pageSize: 200 },
|
||||
});
|
||||
mediaFiles.value = res.data.data.items ?? [];
|
||||
} catch {
|
||||
mediaFiles.value = [];
|
||||
} finally {
|
||||
mediaLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function pickMediaFile(url: string) {
|
||||
emit('update:modelValue', url);
|
||||
mediaPickerVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="content-image-field">
|
||||
<div class="field-main">
|
||||
<div v-if="modelValue" class="preview">
|
||||
<img :src="modelValue" alt="" class="preview-img" />
|
||||
<button
|
||||
type="button"
|
||||
class="preview-remove"
|
||||
:title="t('content.upload.remove')"
|
||||
:disabled="disabled || uploading"
|
||||
@click="removeImage"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div class="field-controls">
|
||||
<p v-if="sizeHintKey" class="size-hint">{{ t(sizeHintKey) }}</p>
|
||||
<div class="actions">
|
||||
<label class="upload-btn" :class="{ 'is-uploading': uploading, 'is-disabled': disabled }">
|
||||
<input
|
||||
type="file"
|
||||
:accept="IMAGE_ACCEPT"
|
||||
style="display: none"
|
||||
:disabled="disabled || uploading"
|
||||
@change="onFileChange"
|
||||
/>
|
||||
{{ uploading ? t('content.upload.uploading') : t('content.upload.upload_btn') }}
|
||||
</label>
|
||||
<button type="button" class="pick-btn" :disabled="disabled || uploading" @click="openMediaPicker">
|
||||
{{ t('content.upload.pick_media') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-input
|
||||
:model-value="modelValue"
|
||||
:placeholder="t('content.upload.url_placeholder')"
|
||||
size="small"
|
||||
:disabled="disabled"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="mediaPickerVisible"
|
||||
:title="t('content.upload.pick_media_title')"
|
||||
width="680px"
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
>
|
||||
<div v-if="mediaLoading" class="media-state">{{ t('common.loading') }}</div>
|
||||
<div v-else-if="mediaFiles.length === 0" class="media-state">{{ t('content.upload.no_media') }}</div>
|
||||
<div v-else class="media-grid">
|
||||
<div
|
||||
v-for="file in mediaFiles"
|
||||
:key="file.id"
|
||||
class="media-card"
|
||||
@click="pickMediaFile(file.url)"
|
||||
>
|
||||
<div class="media-thumb">
|
||||
<img v-if="file.mimeType !== 'image/svg+xml'" :src="file.url" :alt="file.filename" loading="lazy" />
|
||||
<div v-else class="media-svg">SVG</div>
|
||||
</div>
|
||||
<div class="media-name" :title="file.filename">{{ file.filename }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.content-image-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.field-main {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.field-controls {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.size-hint {
|
||||
margin: 0 0 4px;
|
||||
font-size: 11px;
|
||||
line-height: 1.35;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.preview {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
width: 120px;
|
||||
max-width: 120px;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border);
|
||||
background: #f4f0e8;
|
||||
}
|
||||
|
||||
.preview-img {
|
||||
width: 100%;
|
||||
max-height: 68px;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.preview-remove {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
background: rgba(31, 35, 32, 0.78);
|
||||
color: #fff;
|
||||
border: 1px solid rgba(255, 255, 255, 0.36);
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.preview-remove:hover {
|
||||
background: rgba(159, 47, 45, 0.92);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.upload-btn,
|
||||
.pick-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
font-family: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.upload-btn {
|
||||
border: 1px solid var(--primary);
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.upload-btn.is-uploading,
|
||||
.upload-btn.is-disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.pick-btn {
|
||||
border: 1px solid var(--border);
|
||||
background: #fff;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.pick-btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.media-state {
|
||||
text-align: center;
|
||||
padding: 40px 0;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
|
||||
gap: 12px;
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.media-card {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.media-card:hover {
|
||||
border-color: #d5cfc3;
|
||||
box-shadow: 0 8px 22px rgba(56, 49, 37, 0.08);
|
||||
}
|
||||
|
||||
.media-thumb {
|
||||
height: 80px;
|
||||
background: #f4f0e8;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.media-thumb img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.media-svg {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.media-name {
|
||||
padding: 6px 8px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
531
apps/admin/src/components/ContentRichEditor.vue
Normal file
531
apps/admin/src/components/ContentRichEditor.vue
Normal file
@@ -0,0 +1,531 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { useAdminLocale } from '../composables/useAdminLocale';
|
||||
import api from '../api';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string;
|
||||
placeholder?: string;
|
||||
uploadCategory?: string;
|
||||
disabled?: boolean;
|
||||
fill?: boolean;
|
||||
}>(),
|
||||
{ uploadCategory: 'contents', fill: false },
|
||||
);
|
||||
|
||||
const emit = defineEmits<{ 'update:modelValue': [string] }>();
|
||||
|
||||
const { t } = useAdminLocale();
|
||||
|
||||
const IMAGE_ACCEPT = 'image/png,image/jpeg,image/webp,image/gif,image/svg+xml';
|
||||
const MAX_UPLOAD_SIZE = 5 * 1024 * 1024;
|
||||
const EDITOR_IMAGE_MAX_HEIGHT = '200px';
|
||||
|
||||
const editorRef = ref<HTMLDivElement | null>(null);
|
||||
const mediaPickerVisible = ref(false);
|
||||
/** blob/object URL -> File,保存时由父组件调用 uploadPendingImages 上传 */
|
||||
const pendingFiles = new Map<string, File>();
|
||||
const mediaFiles = ref<Array<{ id: string; filename: string; url: string; mimeType: string }>>([]);
|
||||
const mediaLoading = ref(false);
|
||||
const syncing = ref(false);
|
||||
let savedRange: Range | null = null;
|
||||
|
||||
function isNodeInEditor(node: Node | null): boolean {
|
||||
const el = editorRef.value;
|
||||
if (!el || !node) return false;
|
||||
return el.contains(node.nodeType === Node.TEXT_NODE ? node.parentNode : node);
|
||||
}
|
||||
|
||||
function saveSelection() {
|
||||
const sel = window.getSelection();
|
||||
const el = editorRef.value;
|
||||
if (!sel || sel.rangeCount === 0 || !el) return;
|
||||
const range = sel.getRangeAt(0);
|
||||
if (isNodeInEditor(range.commonAncestorContainer)) {
|
||||
savedRange = range.cloneRange();
|
||||
}
|
||||
}
|
||||
|
||||
function restoreSelection(): boolean {
|
||||
const el = editorRef.value;
|
||||
if (!savedRange || !el) return false;
|
||||
try {
|
||||
if (!isNodeInEditor(savedRange.commonAncestorContainer)) return false;
|
||||
const sel = window.getSelection();
|
||||
if (!sel) return false;
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(savedRange);
|
||||
return true;
|
||||
} catch {
|
||||
savedRange = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDocumentSelectionChange() {
|
||||
if (isNodeInEditor(window.getSelection()?.anchorNode ?? null)) {
|
||||
saveSelection();
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeHtml(html: string) {
|
||||
const trimmed = html.trim();
|
||||
if (!trimmed) return '';
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function syncFromModel() {
|
||||
const el = editorRef.value;
|
||||
if (!el) return;
|
||||
syncing.value = true;
|
||||
el.innerHTML = props.modelValue || '';
|
||||
if (el.innerHTML) normalizeEditorImages(el);
|
||||
syncing.value = false;
|
||||
}
|
||||
|
||||
function emitChange() {
|
||||
if (syncing.value || !editorRef.value) return;
|
||||
const html = normalizeHtml(editorRef.value.innerHTML);
|
||||
cleanupOrphanedBlobs(html);
|
||||
emit('update:modelValue', html);
|
||||
}
|
||||
|
||||
function cleanupOrphanedBlobs(html: string) {
|
||||
const used = new Set<string>();
|
||||
for (const match of html.matchAll(/blob:[^\s"'<>]+/g)) {
|
||||
used.add(match[0]);
|
||||
}
|
||||
for (const blobUrl of pendingFiles.keys()) {
|
||||
if (!used.has(blobUrl)) {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
pendingFiles.delete(blobUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function revokeAllPendingBlobs() {
|
||||
for (const blobUrl of pendingFiles.keys()) {
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
}
|
||||
pendingFiles.clear();
|
||||
}
|
||||
|
||||
function exec(cmd: string, value?: string) {
|
||||
editorRef.value?.focus();
|
||||
document.execCommand(cmd, false, value);
|
||||
emitChange();
|
||||
}
|
||||
|
||||
function applyInlineImageStyles(img: HTMLImageElement) {
|
||||
img.removeAttribute('width');
|
||||
img.removeAttribute('height');
|
||||
img.style.maxWidth = '100%';
|
||||
img.style.width = 'auto';
|
||||
img.style.height = 'auto';
|
||||
img.style.maxHeight = EDITOR_IMAGE_MAX_HEIGHT;
|
||||
img.style.objectFit = 'contain';
|
||||
img.style.display = 'block';
|
||||
img.style.margin = '10px 0';
|
||||
img.style.borderRadius = '6px';
|
||||
}
|
||||
|
||||
function createEditorImage(url: string, pending = false) {
|
||||
const img = document.createElement('img');
|
||||
img.src = url;
|
||||
if (pending || url.startsWith('blob:')) {
|
||||
img.setAttribute('data-local-blob', '1');
|
||||
}
|
||||
applyInlineImageStyles(img);
|
||||
return img;
|
||||
}
|
||||
|
||||
function normalizeEditorImages(root: HTMLElement) {
|
||||
root.querySelectorAll('img').forEach((node) => applyInlineImageStyles(node as HTMLImageElement));
|
||||
}
|
||||
|
||||
function insertImageUrl(url: string) {
|
||||
const el = editorRef.value;
|
||||
if (!el) return;
|
||||
|
||||
el.focus();
|
||||
restoreSelection();
|
||||
|
||||
const img = createEditorImage(url, url.startsWith('blob:'));
|
||||
const sel = window.getSelection();
|
||||
|
||||
if (sel && sel.rangeCount > 0) {
|
||||
const range = sel.getRangeAt(0);
|
||||
if (isNodeInEditor(range.commonAncestorContainer)) {
|
||||
range.deleteContents();
|
||||
range.insertNode(img);
|
||||
const after = document.createRange();
|
||||
after.setStartAfter(img);
|
||||
after.collapse(true);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(after);
|
||||
savedRange = after.cloneRange();
|
||||
normalizeEditorImages(el);
|
||||
emitChange();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
el.appendChild(img);
|
||||
normalizeEditorImages(el);
|
||||
emitChange();
|
||||
}
|
||||
|
||||
function insertPendingImage(file: File) {
|
||||
if (file.size > MAX_UPLOAD_SIZE) {
|
||||
ElMessage.error(t('content.upload.size_error'));
|
||||
return;
|
||||
}
|
||||
saveSelection();
|
||||
const blobUrl = URL.createObjectURL(file);
|
||||
pendingFiles.set(blobUrl, file);
|
||||
insertImageUrl(blobUrl);
|
||||
}
|
||||
|
||||
async function uploadSingleFile(file: File): Promise<string> {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
const { data } = await api.post(`/admin/uploads?category=${props.uploadCategory}`, fd, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
const url = data.data?.url as string;
|
||||
if (!url) {
|
||||
throw new Error(t('content.upload.failed'));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/** 扫描 HTML 中的 blob: 图片,上传后替换为 /uploads/... URL */
|
||||
async function uploadPendingImages(html: string): Promise<string> {
|
||||
if (!html.includes('blob:')) return html;
|
||||
|
||||
let result = html;
|
||||
const blobUrls = [...new Set([...html.matchAll(/blob:[^\s"'<>]+/g)].map((m) => m[0]))];
|
||||
|
||||
for (const blobUrl of blobUrls) {
|
||||
const file = pendingFiles.get(blobUrl);
|
||||
if (!file) continue;
|
||||
|
||||
const serverUrl = await uploadSingleFile(file);
|
||||
result = result.replaceAll(blobUrl, serverUrl);
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
pendingFiles.delete(blobUrl);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getHtml(): string {
|
||||
if (!editorRef.value) return normalizeHtml(props.modelValue);
|
||||
return normalizeHtml(editorRef.value.innerHTML);
|
||||
}
|
||||
|
||||
defineExpose({ uploadPendingImages, getHtml });
|
||||
|
||||
function onImageFileChange(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
if (input.files?.[0]) {
|
||||
insertPendingImage(input.files[0]);
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function openMediaPicker() {
|
||||
saveSelection();
|
||||
mediaPickerVisible.value = true;
|
||||
mediaLoading.value = true;
|
||||
try {
|
||||
const res = await api.get('/admin/files', {
|
||||
params: { category: props.uploadCategory, pageSize: 200 },
|
||||
});
|
||||
mediaFiles.value = res.data.data.items ?? [];
|
||||
} catch {
|
||||
mediaFiles.value = [];
|
||||
} finally {
|
||||
mediaLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function pickMediaFile(url: string) {
|
||||
insertImageUrl(url);
|
||||
mediaPickerVisible.value = false;
|
||||
}
|
||||
|
||||
function onPaste(e: ClipboardEvent) {
|
||||
const items = e.clipboardData?.items;
|
||||
if (!items) return;
|
||||
for (const item of items) {
|
||||
if (item.type.startsWith('image/')) {
|
||||
e.preventDefault();
|
||||
saveSelection();
|
||||
const file = item.getAsFile();
|
||||
if (file) insertPendingImage(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
void nextTick(() => {
|
||||
const el = editorRef.value;
|
||||
if (!el) return;
|
||||
normalizeEditorImages(el);
|
||||
emitChange();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val, prev) => {
|
||||
if (val === prev) return;
|
||||
const el = editorRef.value;
|
||||
if (!el) return;
|
||||
if (normalizeHtml(el.innerHTML) !== normalizeHtml(val)) {
|
||||
syncFromModel();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
syncFromModel();
|
||||
document.addEventListener('selectionchange', onDocumentSelectionChange);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('selectionchange', onDocumentSelectionChange);
|
||||
revokeAllPendingBlobs();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rich-editor" :class="{ 'is-disabled': disabled, 'rich-editor--fill': fill }">
|
||||
<div class="toolbar">
|
||||
<button type="button" title="Bold" :disabled="disabled" @mousedown.prevent @click="exec('bold')">
|
||||
<strong>B</strong>
|
||||
</button>
|
||||
<button type="button" title="Italic" :disabled="disabled" @mousedown.prevent @click="exec('italic')">
|
||||
<em>I</em>
|
||||
</button>
|
||||
<button type="button" :disabled="disabled" @mousedown.prevent @click="exec('insertUnorderedList')">
|
||||
•
|
||||
</button>
|
||||
<button type="button" :disabled="disabled" @mousedown.prevent @click="exec('insertOrderedList')">
|
||||
1.
|
||||
</button>
|
||||
<label class="toolbar-upload" @mousedown.prevent="saveSelection">
|
||||
<input
|
||||
type="file"
|
||||
:accept="IMAGE_ACCEPT"
|
||||
style="display: none"
|
||||
:disabled="disabled"
|
||||
@change="onImageFileChange"
|
||||
/>
|
||||
{{ t('content.editor.insert_image') }}
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="disabled"
|
||||
@mousedown.prevent="saveSelection"
|
||||
@click="openMediaPicker"
|
||||
>
|
||||
{{ t('content.upload.pick_media') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
ref="editorRef"
|
||||
class="editor-body"
|
||||
:data-placeholder="placeholder || t('content.editor.placeholder')"
|
||||
:contenteditable="disabled ? 'false' : 'true'"
|
||||
@input="emitChange"
|
||||
@blur="emitChange"
|
||||
@paste="onPaste"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-model="mediaPickerVisible"
|
||||
:title="t('content.upload.pick_media_title')"
|
||||
width="680px"
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
>
|
||||
<div v-if="mediaLoading" class="media-state">{{ t('common.loading') }}</div>
|
||||
<div v-else-if="mediaFiles.length === 0" class="media-state">{{ t('content.upload.no_media') }}</div>
|
||||
<div v-else class="media-grid">
|
||||
<div
|
||||
v-for="file in mediaFiles"
|
||||
:key="file.id"
|
||||
class="media-card"
|
||||
@click="pickMediaFile(file.url)"
|
||||
>
|
||||
<div class="media-thumb">
|
||||
<img v-if="file.mimeType !== 'image/svg+xml'" :src="file.url" :alt="file.filename" loading="lazy" />
|
||||
<div v-else class="media-svg">SVG</div>
|
||||
</div>
|
||||
<div class="media-name" :title="file.filename">{{ file.filename }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.rich-editor {
|
||||
width: 100%;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.rich-editor--fill {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 420px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.rich-editor.is-disabled {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
padding: 5px 6px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: #fbfaf7;
|
||||
}
|
||||
|
||||
.toolbar button,
|
||||
.toolbar-upload {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 28px;
|
||||
height: 26px;
|
||||
padding: 0 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 5px;
|
||||
background: #fff;
|
||||
color: var(--text);
|
||||
font-size: 11px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar button:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.toolbar-upload {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.editor-body {
|
||||
min-height: 140px;
|
||||
max-height: 280px;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
padding: 8px 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.rich-editor--fill .editor-body {
|
||||
flex: 1;
|
||||
min-height: 400px;
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.editor-body:empty::before {
|
||||
content: attr(data-placeholder);
|
||||
color: var(--text-muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.editor-body :deep(img) {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-height: 200px;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
margin: 10px 0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.rich-editor--fill .editor-body :deep(img) {
|
||||
max-height: 200px;
|
||||
}
|
||||
|
||||
.editor-body :deep(ul),
|
||||
.editor-body :deep(ol) {
|
||||
margin: 8px 0;
|
||||
padding-left: 22px;
|
||||
}
|
||||
|
||||
.media-state {
|
||||
text-align: center;
|
||||
padding: 40px 0;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
|
||||
gap: 12px;
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.media-card {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.media-card:hover {
|
||||
border-color: #d5cfc3;
|
||||
}
|
||||
|
||||
.media-thumb {
|
||||
height: 80px;
|
||||
background: #f4f0e8;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.media-thumb img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.media-svg {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.media-name {
|
||||
padding: 6px 8px;
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
</style>
|
||||
40
apps/admin/src/composables/useDepositPendingCount.ts
Normal file
40
apps/admin/src/composables/useDepositPendingCount.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { ref } from 'vue';
|
||||
import api from '../api';
|
||||
|
||||
const pendingCount = ref(0);
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let pollConsumers = 0;
|
||||
|
||||
export async function refreshDepositPendingCount() {
|
||||
try {
|
||||
const { data } = await api.get('/admin/deposit-orders/pending-count');
|
||||
pendingCount.value = Number(data.data?.count ?? 0);
|
||||
} catch {
|
||||
pendingCount.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export function useDepositPendingCount() {
|
||||
function startDepositPendingPolling() {
|
||||
pollConsumers += 1;
|
||||
if (pollConsumers > 1) return;
|
||||
void refreshDepositPendingCount();
|
||||
pollTimer = setInterval(() => void refreshDepositPendingCount(), 30_000);
|
||||
}
|
||||
|
||||
function stopDepositPendingPolling() {
|
||||
pollConsumers = Math.max(0, pollConsumers - 1);
|
||||
if (pollConsumers > 0) return;
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
pendingCount,
|
||||
refreshDepositPendingCount,
|
||||
startDepositPendingPolling,
|
||||
stopDepositPendingPolling,
|
||||
};
|
||||
}
|
||||
@@ -35,6 +35,7 @@ const zh: Record<string, string> = {
|
||||
'staff.col.last_login': '最近登录',
|
||||
'staff.dialog.create': '创建后台账号',
|
||||
'staff.dialog.edit': '编辑后台账号',
|
||||
'staff.field.visible_menus': '菜单权限',
|
||||
'login.captcha_ph': '验证码',
|
||||
'login.captcha_refresh': '点击刷新',
|
||||
|
||||
@@ -69,6 +70,7 @@ const zh: Record<string, string> = {
|
||||
'deposit.status_approved': '已通过',
|
||||
'deposit.status_rejected': '已拒绝',
|
||||
'deposit.search_player_ph': '搜索玩家...',
|
||||
'deposit.pending_badge': '待审核 {n} 笔',
|
||||
'deposit.order_no': '订单号',
|
||||
'deposit.player': '玩家',
|
||||
'deposit.amount': '金额',
|
||||
@@ -114,7 +116,7 @@ const zh: Record<string, string> = {
|
||||
'deposit.add_method': '+ 添加',
|
||||
'deposit.display_name': '展示名称',
|
||||
'deposit.details': '详情',
|
||||
'deposit.sort': '排序',
|
||||
'deposit.sort': '排序值',
|
||||
'deposit.active': '启用',
|
||||
'deposit.show_player': '前台展示',
|
||||
'deposit.edit_method': '编辑收款方式',
|
||||
@@ -124,7 +126,7 @@ const zh: Record<string, string> = {
|
||||
'deposit.account_number': '银行账号',
|
||||
'deposit.usdt_address': 'USDT 地址',
|
||||
'deposit.qr_code': '二维码',
|
||||
'deposit.sort_order': '排序序号',
|
||||
'deposit.sort_order': '排序值',
|
||||
'deposit.show_on_player': '展示给玩家',
|
||||
'deposit.save': '保存',
|
||||
'deposit.confirm_deactivate': '确认停用此收款方式?',
|
||||
@@ -150,11 +152,12 @@ const zh: Record<string, string> = {
|
||||
'role.tier2_agent': '二级代理',
|
||||
'logout': '退出',
|
||||
'lang': '语言',
|
||||
'portal.admin': '平台后台',
|
||||
'portal.agent': '代理后台',
|
||||
'portal.admin': '平台后台管理',
|
||||
'portal.agent': '代理后台管理',
|
||||
|
||||
'common.all': '全部',
|
||||
'common.search': '查询',
|
||||
'common.refresh': '刷新',
|
||||
'common.reset': '重置',
|
||||
'common.edit': '编辑',
|
||||
'common.yes': '是',
|
||||
@@ -164,9 +167,13 @@ const zh: Record<string, string> = {
|
||||
'common.confirm': '确定',
|
||||
'common.retry': '重试',
|
||||
'common.status': '状态',
|
||||
'user.status.ACTIVE': '正常',
|
||||
'user.status.SUSPENDED': '已冻结',
|
||||
'user.status.DISABLED': '已停用',
|
||||
'common.type': '类型',
|
||||
'common.keyword': '关键词',
|
||||
'common.actions': '操作',
|
||||
'common.seq': '序号',
|
||||
'common.more': '更多',
|
||||
'common.loading': '加载中…',
|
||||
'common.no_data': '暂无数据',
|
||||
@@ -218,6 +225,9 @@ const zh: Record<string, string> = {
|
||||
'dash.match_pending_settle': '待结算',
|
||||
'dash.match_settled': '已结算',
|
||||
'dash.user_active': '正常玩家',
|
||||
'dash.user_online': '当前在线',
|
||||
'dash.players_online': '当前在线',
|
||||
'dash.players_online_hint': '约 2 分钟内活跃',
|
||||
'dash.user_suspended': '停用',
|
||||
'dash.user_direct': '直属',
|
||||
'dash.user_agents': '代理',
|
||||
@@ -334,6 +344,7 @@ const en: Record<string, string> = {
|
||||
'staff.col.last_login': 'Last login',
|
||||
'staff.dialog.create': 'Create staff account',
|
||||
'staff.dialog.edit': 'Edit staff account',
|
||||
'staff.field.visible_menus': 'Menu Permissions',
|
||||
'login.captcha_ph': 'Captcha',
|
||||
'login.captcha_refresh': 'Click to refresh',
|
||||
|
||||
@@ -370,6 +381,7 @@ const en: Record<string, string> = {
|
||||
'deposit.status_approved': 'Approved',
|
||||
'deposit.status_rejected': 'Rejected',
|
||||
'deposit.search_player_ph': 'Search player...',
|
||||
'deposit.pending_badge': '{n} pending',
|
||||
'deposit.order_no': 'Order No',
|
||||
'deposit.player': 'Player',
|
||||
'deposit.amount': 'Amount',
|
||||
@@ -449,11 +461,12 @@ const en: Record<string, string> = {
|
||||
'role.tier2_agent': 'Tier-2 Agent',
|
||||
'logout': 'Logout',
|
||||
'lang': 'Language',
|
||||
'portal.admin': 'Platform Admin',
|
||||
'portal.agent': 'Agent Portal',
|
||||
'portal.admin': 'Admin Console',
|
||||
'portal.agent': 'Agent Console',
|
||||
|
||||
'common.all': 'All',
|
||||
'common.search': 'Search',
|
||||
'common.refresh': 'Refresh',
|
||||
'common.reset': 'Reset',
|
||||
'common.edit': 'Edit',
|
||||
'common.yes': 'Yes',
|
||||
@@ -463,9 +476,13 @@ const en: Record<string, string> = {
|
||||
'common.confirm': 'OK',
|
||||
'common.retry': 'Retry',
|
||||
'common.status': 'Status',
|
||||
'user.status.ACTIVE': 'Active',
|
||||
'user.status.SUSPENDED': 'Suspended',
|
||||
'user.status.DISABLED': 'Disabled',
|
||||
'common.type': 'Type',
|
||||
'common.keyword': 'Keyword',
|
||||
'common.actions': 'Actions',
|
||||
'common.seq': 'No.',
|
||||
'common.more': 'More',
|
||||
'common.loading': 'Loading…',
|
||||
'common.no_data': 'No data',
|
||||
@@ -517,6 +534,9 @@ const en: Record<string, string> = {
|
||||
'dash.match_pending_settle': 'Pending settlement',
|
||||
'dash.match_settled': 'Settled',
|
||||
'dash.user_active': 'Active players',
|
||||
'dash.user_online': 'Online now',
|
||||
'dash.players_online': 'Online now',
|
||||
'dash.players_online_hint': 'Active within ~2 min',
|
||||
'dash.user_suspended': 'Suspended',
|
||||
'dash.user_direct': 'Direct',
|
||||
'dash.user_agents': 'Agents',
|
||||
@@ -633,6 +653,7 @@ const ms: Record<string, string> = {
|
||||
'staff.col.last_login': 'Log masuk terakhir',
|
||||
'staff.dialog.create': 'Cipta akaun kakitangan',
|
||||
'staff.dialog.edit': 'Edit akaun kakitangan',
|
||||
'staff.field.visible_menus': 'Kebenaran Menu',
|
||||
'login.captcha_ph': 'Captcha',
|
||||
'login.captcha_refresh': 'Klik untuk muat semula',
|
||||
|
||||
@@ -669,6 +690,7 @@ const ms: Record<string, string> = {
|
||||
'deposit.status_approved': 'Diluluskan',
|
||||
'deposit.status_rejected': 'Ditolak',
|
||||
'deposit.search_player_ph': 'Cari pemain...',
|
||||
'deposit.pending_badge': '{n} menunggu',
|
||||
'deposit.order_no': 'No. Pesanan',
|
||||
'deposit.player': 'Pemain',
|
||||
'deposit.amount': 'Jumlah',
|
||||
@@ -748,11 +770,12 @@ const ms: Record<string, string> = {
|
||||
'role.tier2_agent': 'Ejen Peringkat 2',
|
||||
'logout': 'Log keluar',
|
||||
'lang': 'Bahasa',
|
||||
'portal.admin': 'Admin Platform',
|
||||
'portal.agent': 'Portal Ejen',
|
||||
'portal.admin': 'Pengurusan Admin',
|
||||
'portal.agent': 'Pengurusan Ejen',
|
||||
|
||||
'common.all': 'Semua',
|
||||
'common.search': 'Cari',
|
||||
'common.refresh': 'Muat semula',
|
||||
'common.reset': 'Set semula',
|
||||
'common.edit': 'Edit',
|
||||
'common.yes': 'Ya',
|
||||
@@ -762,9 +785,13 @@ const ms: Record<string, string> = {
|
||||
'common.confirm': 'OK',
|
||||
'common.retry': 'Cuba lagi',
|
||||
'common.status': 'Status',
|
||||
'user.status.ACTIVE': 'Aktif',
|
||||
'user.status.SUSPENDED': 'Digantung',
|
||||
'user.status.DISABLED': 'Dinyahaktifkan',
|
||||
'common.type': 'Jenis',
|
||||
'common.keyword': 'Kata kunci',
|
||||
'common.actions': 'Tindakan',
|
||||
'common.seq': 'No.',
|
||||
'common.more': 'Lagi',
|
||||
'common.loading': 'Memuatkan…',
|
||||
'common.no_data': 'Tiada data',
|
||||
@@ -816,6 +843,9 @@ const ms: Record<string, string> = {
|
||||
'dash.match_pending_settle': 'Menunggu penyelesaian',
|
||||
'dash.match_settled': 'Diselesaikan',
|
||||
'dash.user_active': 'Pemain aktif',
|
||||
'dash.user_online': 'Dalam talian',
|
||||
'dash.players_online': 'Dalam talian',
|
||||
'dash.players_online_hint': 'Aktif dalam ~2 min',
|
||||
'dash.user_suspended': 'Digantung',
|
||||
'dash.user_direct': 'Terus',
|
||||
'dash.user_agents': 'Ejen',
|
||||
|
||||
@@ -28,6 +28,10 @@ export const adminPagesMs: Record<string, string> = {
|
||||
'user.filter.agent': 'Ejen',
|
||||
'user.filter.agent_ph': 'Semua',
|
||||
'user.col.username': 'Nama pengguna',
|
||||
'user.col.online': 'Dalam talian',
|
||||
'user.online_yes': 'Sedang dalam talian',
|
||||
'user.presence_online': 'Dalam talian',
|
||||
'user.presence_offline': 'Luar talian',
|
||||
'user.col.agent': 'Ejen',
|
||||
'user.col.invite_code': 'Kod jemputan',
|
||||
'user.col.balance': 'Tersedia / Dibekukan',
|
||||
@@ -765,11 +769,39 @@ export const adminPagesMs: Record<string, string> = {
|
||||
'content.btn.enable': 'Aktifkan',
|
||||
'content.btn.disable': 'Nyahaktif',
|
||||
'content.dialog.create': 'Kandungan awam baharu',
|
||||
'content.dialog.edit': 'Edit kandungan awam',
|
||||
'content.dialog.create_banner': 'Promosi laman utama baharu',
|
||||
'content.dialog.create_notice': 'Terbitkan notifikasi',
|
||||
'content.dialog.edit': 'Edit kandungan',
|
||||
'content.dialog.edit_banner': 'Edit promosi laman utama',
|
||||
'content.dialog.edit_notice': 'Edit notifikasi',
|
||||
'content.confirm_delete': 'Padam "{title}"?',
|
||||
'content.type.BANNER': 'Banner laman utama',
|
||||
'content.type.ANNOUNCEMENT': 'Pengumuman',
|
||||
'content.hint.announcement': 'Dipaparkan di ticker atas pemain; isi tajuk atau kandungan',
|
||||
'content.type.BANNER': 'Promosi laman utama',
|
||||
'content.type.ANNOUNCEMENT': 'Notifikasi',
|
||||
'content.type.INBOX_NOTIFY': 'Notifikasi peti mesej',
|
||||
'content.inbox_notify.inbox_enabled': 'Peti mesej pemain',
|
||||
'content.inbox_notify.inbox_enabled_hint': 'Jika dimatikan, pemain hanya dibawa ke sokongan (tiada tab peti mesej)',
|
||||
'content.inbox_notify.deposit': 'Keputusan deposit',
|
||||
'content.inbox_notify.deposit_hint': 'Hantar mesej apabila diluluskan atau ditolak',
|
||||
'content.inbox_notify.manual_title': 'Tanda "Notifikasi peti mesej" semasa mencipta:',
|
||||
'content.inbox_notify.banner_note': 'Promosi laman utama',
|
||||
'content.inbox_notify.announcement_note': 'Notifikasi / ticker',
|
||||
'content.hint.banner': 'Dipaparkan dalam karusel laman utama; ketik untuk halaman butiran. Muat naik imej muka depan dan kandungan kaya seperti pengumuman laman rasmi.',
|
||||
'content.hint.announcement': 'Dipaparkan sebagai teks bergulir di bahagian atas aplikasi pemain. Isi tajuk dan teks bergulir setiap bahasa — teks biasa sahaja.',
|
||||
'content.section.publish': 'Tetapan terbitan',
|
||||
'content.section.content': 'Kandungan notifikasi',
|
||||
'content.field.publish_kind': 'Jenis terbitan',
|
||||
'content.publish_kind.notice': 'Notifikasi penuh (halaman butiran)',
|
||||
'content.publish_kind.ticker': 'Teks ticker sahaja',
|
||||
'content.publish_kind.hint': 'Notifikasi penuh muncul dalam senarai dan butiran; ticker hanya papar satu baris bergulir.',
|
||||
'content.field.cover_image': 'Imej muka depan',
|
||||
'content.field.ticker_title_ph': 'Tajuk ticker (pilihan)',
|
||||
'content.field.ticker_body_ph': 'Teks dipaparkan dalam ticker',
|
||||
'content.field.ticker_hint': 'Ticker hanya papar teks biasa — tiada imej atau format kaya.',
|
||||
'content.editor.placeholder': 'Tulis kandungan notifikasi; boleh sisip imej dan senarai…',
|
||||
'content.editor.insert_image': 'Sisip imej',
|
||||
'content.upload.cover_size_hint': 'Lebar disyorkan 860px+. Imej muka depan dan dalam kandungan akan menyesuaikan lebar pada pemain.',
|
||||
'content.upload.pick_media_title': 'Pilih imej',
|
||||
'content.upload.no_media': 'Tiada imej dalam pustaka — muat naik dahulu',
|
||||
'content.status.DRAFT': 'Draf',
|
||||
'content.status.ACTIVE': 'Aktif',
|
||||
'content.status.INACTIVE': 'Tidak aktif',
|
||||
@@ -783,6 +815,9 @@ export const adminPagesMs: Record<string, string> = {
|
||||
'content.field.link_target': 'Sasaran pautan',
|
||||
'content.field.start_time': 'Masa mula',
|
||||
'content.field.end_time': 'Masa tamat',
|
||||
'content.field.notify_inbox': 'Notifikasi peti mesej',
|
||||
'content.field.notify_inbox_hint': 'Hantar mesej peti kepada semua pemain tentang promosi ini selepas simpan',
|
||||
'content.msg.notify_sent': 'Notifikasi dihantar kepada {count} pemain',
|
||||
'content.field.title': 'Tajuk',
|
||||
'content.field.title_ph': 'Pilihan',
|
||||
'content.field.body': 'Kandungan',
|
||||
@@ -795,8 +830,6 @@ export const adminPagesMs: Record<string, string> = {
|
||||
'content.upload.size_error': 'Imej mestilah di bawah 5 MB',
|
||||
'content.upload.remove': 'Buang imej',
|
||||
'content.upload.pick_media': 'Pilih dari pustaka',
|
||||
'content.upload.pick_media_title': 'Pilih Imej Banner',
|
||||
'content.upload.no_media': 'Tiada imej banner dalam pustaka — muat naik dahulu',
|
||||
'content.upload.url_placeholder': 'Atau tampal URL imej',
|
||||
'content.upload.recommended_size': 'Saiz disyorkan: 860 x 360 px, atau imej nisbah 43:18. Karusel pemain memaparkan imej penuh dan mengisi ruang tambahan.',
|
||||
'content.link.none': 'Tiada pautan',
|
||||
|
||||
@@ -838,15 +838,33 @@ export const adminPagesZh: Record<string, string> = {
|
||||
'content.btn.enable': '启用',
|
||||
'content.btn.disable': '停用',
|
||||
'content.dialog.create': '新建公共内容',
|
||||
'content.dialog.edit': '编辑公共内容',
|
||||
'content.dialog.create_banner': '新建首页推广',
|
||||
'content.dialog.create_notice': '发布通知公告',
|
||||
'content.dialog.edit': '编辑内容',
|
||||
'content.dialog.edit_banner': '编辑首页推广',
|
||||
'content.dialog.edit_notice': '编辑通知公告',
|
||||
'content.confirm_delete': '确定删除「{title}」?',
|
||||
'content.type.BANNER': '首页轮播',
|
||||
'content.type.ANNOUNCEMENT': '公告滚动',
|
||||
'content.hint.announcement': '显示在玩家端顶部跑马灯;标题与正文填一项即可,建议正文为主',
|
||||
'content.type.BANNER': '首页推广',
|
||||
'content.type.ANNOUNCEMENT': '通知公告',
|
||||
'content.hint.banner': '用于首页轮播展示,点击后进入通知详情页;请填写封面图与正文,像官网发布活动通知一样编辑。',
|
||||
'content.hint.announcement': '在玩家端顶部显示滚动跑马灯文字;填写各语言标题与滚动文案即可,纯文本无富文本。',
|
||||
'content.section.publish': '发布设置',
|
||||
'content.section.content': '通知内容',
|
||||
'content.field.publish_kind': '发布类型',
|
||||
'content.publish_kind.notice': '完整通知(详情页)',
|
||||
'content.publish_kind.ticker': '仅跑马灯文字',
|
||||
'content.publish_kind.hint': '完整通知会出现在公告列表与详情页;跑马灯仅显示顶部滚动一行文字。',
|
||||
'content.field.cover_image': '封面图',
|
||||
'content.field.ticker_title_ph': '跑马灯标题(选填)',
|
||||
'content.field.ticker_body_ph': '跑马灯显示的文字',
|
||||
'content.field.ticker_hint': '跑马灯只显示纯文字,不支持图片与富文本格式。',
|
||||
'content.editor.placeholder': '输入通知正文,可插入图片、列表等…',
|
||||
'content.editor.insert_image': '插入图片',
|
||||
'content.upload.cover_size_hint': '建议宽度 860px 以上;玩家端详情页会完整显示封面,正文内图片也会自适应宽度。',
|
||||
'content.status.DRAFT': '草稿',
|
||||
'content.status.ACTIVE': '已启用',
|
||||
'content.status.INACTIVE': '已停用',
|
||||
'content.col.sort': '排序',
|
||||
'content.col.sort': '排序值',
|
||||
'content.col.preview': '预览',
|
||||
'content.col.title': '标题/摘要',
|
||||
'content.col.player_visible': '玩家可见',
|
||||
@@ -857,7 +875,7 @@ export const adminPagesZh: Record<string, string> = {
|
||||
'content.field.start_time': '开始时间',
|
||||
'content.field.end_time': '结束时间',
|
||||
'content.field.title': '标题',
|
||||
'content.field.title_ph': '选填,可与正文相同',
|
||||
'content.field.title_ph': '通知标题,玩家端详情页展示',
|
||||
'content.field.body': '正文',
|
||||
'content.field.announce_text': '滚动文案',
|
||||
'content.field.image_url': '图片地址',
|
||||
@@ -868,8 +886,8 @@ export const adminPagesZh: Record<string, string> = {
|
||||
'content.upload.size_error': '图片大小不能超过 5MB',
|
||||
'content.upload.remove': '移除图片',
|
||||
'content.upload.pick_media': '从媒体库选择',
|
||||
'content.upload.pick_media_title': '选择 Banner 图片',
|
||||
'content.upload.no_media': '媒体库中暂无 Banner 图片,请先上传',
|
||||
'content.upload.pick_media_title': '选择图片',
|
||||
'content.upload.no_media': '媒体库中暂无图片,请先上传',
|
||||
'content.upload.url_placeholder': '或手动粘贴图片 URL',
|
||||
'content.upload.recommended_size': '建议尺寸:860 x 360 px,或 43:18 同比例图片;前台会完整显示并自动填充不合比例区域。',
|
||||
'content.link.none': '无跳转',
|
||||
@@ -1911,11 +1929,29 @@ export const adminPagesEn: Record<string, string> = {
|
||||
'content.btn.enable': 'Enable',
|
||||
'content.btn.disable': 'Disable',
|
||||
'content.dialog.create': 'New public content',
|
||||
'content.dialog.edit': 'Edit public content',
|
||||
'content.dialog.create_banner': 'New home promotion',
|
||||
'content.dialog.create_notice': 'Publish notification',
|
||||
'content.dialog.edit': 'Edit content',
|
||||
'content.dialog.edit_banner': 'Edit home promotion',
|
||||
'content.dialog.edit_notice': 'Edit notification',
|
||||
'content.confirm_delete': 'Delete "{title}"?',
|
||||
'content.type.BANNER': 'Home banners',
|
||||
'content.type.ANNOUNCEMENT': 'Announcements',
|
||||
'content.hint.announcement': 'Shown in the player top marquee; fill title or body (body recommended)',
|
||||
'content.type.BANNER': 'Home promotions',
|
||||
'content.type.ANNOUNCEMENT': 'Notifications',
|
||||
'content.hint.banner': 'Shown in the home carousel; tapping opens the detail page. Add a cover image and rich body like an official site announcement.',
|
||||
'content.hint.announcement': 'Shows as a scrolling marquee at the top of the player app. Enter title and marquee text per language — plain text only.',
|
||||
'content.section.publish': 'Publish settings',
|
||||
'content.section.content': 'Notification content',
|
||||
'content.field.publish_kind': 'Publish type',
|
||||
'content.publish_kind.notice': 'Full notification (detail page)',
|
||||
'content.publish_kind.ticker': 'Ticker text only',
|
||||
'content.publish_kind.hint': 'Full notifications appear in the list and detail page; ticker-only shows one scrolling line at the top.',
|
||||
'content.field.cover_image': 'Cover image',
|
||||
'content.field.ticker_title_ph': 'Ticker title (optional)',
|
||||
'content.field.ticker_body_ph': 'Text shown in the marquee',
|
||||
'content.field.ticker_hint': 'Ticker shows plain text only — no images or rich formatting.',
|
||||
'content.editor.placeholder': 'Write the notification body; you can insert images and lists…',
|
||||
'content.editor.insert_image': 'Insert image',
|
||||
'content.upload.cover_size_hint': 'Recommended width 860px+. Cover and inline images scale to fit on the player detail page.',
|
||||
'content.status.DRAFT': 'Draft',
|
||||
'content.status.ACTIVE': 'Active',
|
||||
'content.status.INACTIVE': 'Inactive',
|
||||
@@ -1930,7 +1966,7 @@ export const adminPagesEn: Record<string, string> = {
|
||||
'content.field.start_time': 'Start time',
|
||||
'content.field.end_time': 'End time',
|
||||
'content.field.title': 'Title',
|
||||
'content.field.title_ph': 'Optional; can match body',
|
||||
'content.field.title_ph': 'Title shown on the player detail page',
|
||||
'content.field.body': 'Body',
|
||||
'content.field.announce_text': 'Marquee text',
|
||||
'content.field.image_url': 'Image URL',
|
||||
@@ -1941,8 +1977,8 @@ export const adminPagesEn: Record<string, string> = {
|
||||
'content.upload.size_error': 'Image must be under 5 MB',
|
||||
'content.upload.remove': 'Remove image',
|
||||
'content.upload.pick_media': 'Pick from library',
|
||||
'content.upload.pick_media_title': 'Select Banner Image',
|
||||
'content.upload.no_media': 'No banner images in library — upload one first',
|
||||
'content.upload.pick_media_title': 'Select image',
|
||||
'content.upload.no_media': 'No images in library — upload one first',
|
||||
'content.upload.url_placeholder': 'Or paste image URL',
|
||||
'content.upload.recommended_size': 'Recommended size: 860 x 360 px, or any 43:18 image. The player carousel keeps the full image visible and fills extra space.',
|
||||
'content.link.none': 'No link',
|
||||
|
||||
@@ -8,15 +8,17 @@ const loaders: Record<AdminLocale, () => Promise<{ default: Record<string, strin
|
||||
};
|
||||
|
||||
const inflight = new Map<AdminLocale, Promise<void>>();
|
||||
const loaded = new Set<AdminLocale>();
|
||||
|
||||
/** 按语言动态加载文案包(仅当前 locale 进入主路径,其余为独立 chunk)。 */
|
||||
export async function ensureAdminLocaleLoaded(locale: AdminLocale): Promise<void> {
|
||||
if (Object.keys(adminMessages[locale]).length > 0) return;
|
||||
if (loaded.has(locale)) return;
|
||||
const pending = inflight.get(locale);
|
||||
if (pending) return pending;
|
||||
|
||||
const task = loaders[locale]().then((mod) => {
|
||||
adminMessages[locale] = mod.default;
|
||||
Object.assign(adminMessages[locale], mod.default);
|
||||
loaded.add(locale);
|
||||
});
|
||||
inflight.set(locale, task);
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,10 @@ const adminPages: Record<string, string> = {
|
||||
'user.filter.agent': 'Agent',
|
||||
'user.filter.agent_ph': 'All',
|
||||
'user.col.username': 'Username',
|
||||
'user.col.online': 'Online',
|
||||
'user.online_yes': 'Online now',
|
||||
'user.presence_online': 'Online',
|
||||
'user.presence_offline': 'Offline',
|
||||
'user.col.agent': 'Agent',
|
||||
'user.col.agent_cashback': 'Agent cashback',
|
||||
'user.col.player_cashback': 'Player cashback',
|
||||
@@ -786,15 +790,43 @@ const adminPages: Record<string, string> = {
|
||||
'msg.outright_odds_saved': 'Outright odds saved',
|
||||
'msg.load_failed': 'Load failed',
|
||||
|
||||
'content.upload.pick_media_title': 'Select image',
|
||||
'content.upload.no_media': 'No images in library — upload one first',
|
||||
'content.btn.create': 'New content',
|
||||
'content.btn.enable': 'Enable',
|
||||
'content.btn.disable': 'Disable',
|
||||
'content.dialog.create': 'New public content',
|
||||
'content.dialog.edit': 'Edit public content',
|
||||
'content.dialog.create_banner': 'New home promotion',
|
||||
'content.dialog.create_notice': 'Publish notification',
|
||||
'content.dialog.edit': 'Edit content',
|
||||
'content.dialog.edit_banner': 'Edit home promotion',
|
||||
'content.dialog.edit_notice': 'Edit notification',
|
||||
'content.confirm_delete': 'Delete "{title}"?',
|
||||
'content.type.BANNER': 'Home banners',
|
||||
'content.type.ANNOUNCEMENT': 'Announcements',
|
||||
'content.hint.announcement': 'Shown in the player top marquee; fill title or body (body recommended)',
|
||||
'content.type.BANNER': 'Home promotions',
|
||||
'content.type.ANNOUNCEMENT': 'Notifications',
|
||||
'content.type.INBOX_NOTIFY': 'Inbox notify',
|
||||
'content.inbox_notify.inbox_enabled': 'Player inbox',
|
||||
'content.inbox_notify.inbox_enabled_hint': 'When off, the player hub opens support only (no mailbox tab)',
|
||||
'content.inbox_notify.deposit': 'Deposit results',
|
||||
'content.inbox_notify.deposit_hint': 'Auto-send inbox messages on approve or reject',
|
||||
'content.inbox_notify.manual_title': 'Check "Inbox notify" when creating:',
|
||||
'content.inbox_notify.banner_note': 'Homepage promo',
|
||||
'content.inbox_notify.announcement_note': 'Announcements / ticker',
|
||||
'content.hint.banner': 'Shown in the home carousel; tapping opens the detail page. Add a cover image and rich body like an official site announcement.',
|
||||
'content.hint.announcement': 'Shows as a scrolling marquee at the top of the player app. Enter title and marquee text per language — plain text only.',
|
||||
'content.section.publish': 'Publish settings',
|
||||
'content.section.content': 'Notification content',
|
||||
'content.field.publish_kind': 'Publish type',
|
||||
'content.publish_kind.notice': 'Full notification (detail page)',
|
||||
'content.publish_kind.ticker': 'Ticker text only',
|
||||
'content.publish_kind.hint': 'Full notifications appear in the list and detail page; ticker-only shows one scrolling line at the top.',
|
||||
'content.field.cover_image': 'Cover image',
|
||||
'content.field.ticker_title_ph': 'Ticker title (optional)',
|
||||
'content.field.ticker_body_ph': 'Text shown in the marquee',
|
||||
'content.field.ticker_hint': 'Ticker shows plain text only — no images or rich formatting.',
|
||||
'content.editor.placeholder': 'Write the notification body; you can insert images and lists…',
|
||||
'content.editor.insert_image': 'Insert image',
|
||||
'content.upload.cover_size_hint': 'Recommended width 860px+. Cover and inline images scale to fit on the player detail page.',
|
||||
'content.status.DRAFT': 'Draft',
|
||||
'content.status.ACTIVE': 'Active',
|
||||
'content.status.INACTIVE': 'Inactive',
|
||||
@@ -808,8 +840,11 @@ const adminPages: Record<string, string> = {
|
||||
'content.field.link_target': 'Link target',
|
||||
'content.field.start_time': 'Start time',
|
||||
'content.field.end_time': 'End time',
|
||||
'content.field.notify_inbox': 'Inbox notification',
|
||||
'content.field.notify_inbox_hint': 'Send an inbox message to all players about this promotion after saving',
|
||||
'content.msg.notify_sent': 'Inbox notification sent to {count} player(s)',
|
||||
'content.field.title': 'Title',
|
||||
'content.field.title_ph': 'Optional; can match body',
|
||||
'content.field.title_ph': 'Title shown on the player detail page',
|
||||
'content.field.body': 'Body',
|
||||
'content.field.announce_text': 'Marquee text',
|
||||
'content.field.image_url': 'Image URL',
|
||||
@@ -820,8 +855,6 @@ const adminPages: Record<string, string> = {
|
||||
'content.upload.size_error': 'Image must be under 5 MB',
|
||||
'content.upload.remove': 'Remove image',
|
||||
'content.upload.pick_media': 'Pick from library',
|
||||
'content.upload.pick_media_title': 'Select Banner Image',
|
||||
'content.upload.no_media': 'No banner images in library — upload one first',
|
||||
'content.upload.url_placeholder': 'Or paste image URL',
|
||||
'content.upload.recommended_size': 'Recommended size: 860 x 360 px, or any 43:18 image. The player carousel keeps the full image visible and fills extra space.',
|
||||
'content.link.none': 'No link',
|
||||
|
||||
@@ -28,6 +28,10 @@ const adminPages: Record<string, string> = {
|
||||
'user.filter.agent': '所属代理',
|
||||
'user.filter.agent_ph': '全部',
|
||||
'user.col.username': '用户名',
|
||||
'user.col.online': '在线',
|
||||
'user.online_yes': '当前在线',
|
||||
'user.presence_online': '在线',
|
||||
'user.presence_offline': '离线',
|
||||
'user.col.agent': '所属代理',
|
||||
'user.col.agent_cashback': '代理返水率',
|
||||
'user.col.player_cashback': '玩家返水率',
|
||||
@@ -790,15 +794,43 @@ const adminPages: Record<string, string> = {
|
||||
'content.btn.enable': '启用',
|
||||
'content.btn.disable': '停用',
|
||||
'content.dialog.create': '新建公共内容',
|
||||
'content.dialog.edit': '编辑公共内容',
|
||||
'content.dialog.create_banner': '新建首页推广',
|
||||
'content.dialog.create_notice': '发布通知公告',
|
||||
'content.dialog.edit': '编辑内容',
|
||||
'content.dialog.edit_banner': '编辑首页推广',
|
||||
'content.dialog.edit_notice': '编辑通知公告',
|
||||
'content.confirm_delete': '确定删除「{title}」?',
|
||||
'content.type.BANNER': '首页轮播',
|
||||
'content.type.ANNOUNCEMENT': '公告滚动',
|
||||
'content.hint.announcement': '显示在玩家端顶部跑马灯;标题与正文填一项即可,建议正文为主',
|
||||
'content.type.BANNER': '首页推广',
|
||||
'content.type.ANNOUNCEMENT': '通知公告',
|
||||
'content.type.INBOX_NOTIFY': '邮箱通知',
|
||||
'content.inbox_notify.inbox_enabled': '站内邮箱',
|
||||
'content.inbox_notify.inbox_enabled_hint': '关闭后玩家端入口直达客服,不展示邮箱标签页',
|
||||
'content.inbox_notify.deposit': '充值结果',
|
||||
'content.inbox_notify.deposit_hint': '审核通过或拒绝时自动发送站内信',
|
||||
'content.inbox_notify.manual_title': '以下类型在新建时勾选「邮箱通知」',
|
||||
'content.inbox_notify.banner_note': '首页推广',
|
||||
'content.inbox_notify.announcement_note': '通知公告 / 跑马灯',
|
||||
'content.hint.banner': '用于首页轮播展示,点击后进入通知详情页;请填写封面图与正文,像官网发布活动通知一样编辑。',
|
||||
'content.hint.announcement': '在玩家端顶部显示滚动跑马灯文字;填写各语言标题与滚动文案即可,纯文本无富文本。',
|
||||
'content.section.publish': '发布设置',
|
||||
'content.section.content': '通知内容',
|
||||
'content.field.publish_kind': '发布类型',
|
||||
'content.publish_kind.notice': '完整通知(详情页)',
|
||||
'content.publish_kind.ticker': '仅跑马灯文字',
|
||||
'content.publish_kind.hint': '完整通知会出现在公告列表与详情页;跑马灯仅显示顶部滚动一行文字。',
|
||||
'content.field.cover_image': '封面图',
|
||||
'content.field.ticker_title_ph': '跑马灯标题(选填)',
|
||||
'content.field.ticker_body_ph': '跑马灯显示的文字',
|
||||
'content.field.ticker_hint': '跑马灯只显示纯文字,不支持图片与富文本格式。',
|
||||
'content.editor.placeholder': '输入通知正文,可插入图片、列表等…',
|
||||
'content.editor.insert_image': '插入图片',
|
||||
'content.upload.cover_size_hint': '建议宽度 860px 以上;玩家端详情页会完整显示封面,正文内图片也会自适应宽度。',
|
||||
'content.upload.pick_media_title': '选择图片',
|
||||
'content.upload.no_media': '媒体库中暂无图片,请先上传',
|
||||
'content.status.DRAFT': '草稿',
|
||||
'content.status.ACTIVE': '已启用',
|
||||
'content.status.INACTIVE': '已停用',
|
||||
'content.col.sort': '排序',
|
||||
'content.col.sort': '排序值',
|
||||
'content.col.preview': '预览',
|
||||
'content.col.title': '标题/摘要',
|
||||
'content.col.player_visible': '玩家可见',
|
||||
@@ -808,8 +840,11 @@ const adminPages: Record<string, string> = {
|
||||
'content.field.link_target': '链接目标',
|
||||
'content.field.start_time': '开始时间',
|
||||
'content.field.end_time': '结束时间',
|
||||
'content.field.notify_inbox': '邮箱通知',
|
||||
'content.field.notify_inbox_hint': '保存后向全部玩家发送站内信,通知查看此推广',
|
||||
'content.msg.notify_sent': '已向 {count} 位玩家发送邮箱通知',
|
||||
'content.field.title': '标题',
|
||||
'content.field.title_ph': '选填,可与正文相同',
|
||||
'content.field.title_ph': '通知标题,玩家端详情页展示',
|
||||
'content.field.body': '正文',
|
||||
'content.field.announce_text': '滚动文案',
|
||||
'content.field.image_url': '图片地址',
|
||||
@@ -820,8 +855,6 @@ const adminPages: Record<string, string> = {
|
||||
'content.upload.size_error': '图片大小不能超过 5MB',
|
||||
'content.upload.remove': '移除图片',
|
||||
'content.upload.pick_media': '从媒体库选择',
|
||||
'content.upload.pick_media_title': '选择 Banner 图片',
|
||||
'content.upload.no_media': '媒体库中暂无 Banner 图片,请先上传',
|
||||
'content.upload.url_placeholder': '或手动粘贴图片 URL',
|
||||
'content.upload.recommended_size': '建议尺寸:860 x 360 px,或 43:18 同比例图片;前台会完整显示并自动填充不合比例区域。',
|
||||
'content.link.none': '无跳转',
|
||||
|
||||
@@ -9,6 +9,7 @@ import { AdminPerm } from '../constants/permissions';
|
||||
import AdminLocaleSwitcher from '../components/AdminLocaleSwitcher.vue';
|
||||
import AdminNavIcon from '../components/AdminNavIcon.vue';
|
||||
import { resolveAdminBreadcrumb } from '../utils/admin-breadcrumb';
|
||||
import { useDepositPendingCount } from '../composables/useDepositPendingCount';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -16,11 +17,18 @@ const auth = useAuthStore();
|
||||
const { t } = useAdminLocale();
|
||||
const { allowed: smokeTestsAllowed, ensureLoaded: ensureSmokeTestsAllowed } = useSmokeTestsAllowed();
|
||||
const { hasPermission, role: adminRole } = usePermissions();
|
||||
const { pendingCount: depositPendingCount, startDepositPendingPolling, stopDepositPendingPolling } =
|
||||
useDepositPendingCount();
|
||||
|
||||
const canSeeDepositPending = computed(
|
||||
() => auth.isAdmin.value && hasPermission(AdminPerm.depositReview, AdminPerm.depositManage),
|
||||
);
|
||||
|
||||
const sidebarOpen = ref(false);
|
||||
const isMobileNav = ref(false);
|
||||
|
||||
type AdminMenuItem = {
|
||||
key: string;
|
||||
path: string;
|
||||
label: string;
|
||||
icon: string;
|
||||
@@ -34,23 +42,30 @@ function menuVisible(item: AdminMenuItem): boolean {
|
||||
const code = adminRole.value;
|
||||
if (item.path === '/smoke-tests' && smokeTestsAllowed.value === false) return false;
|
||||
if (code && code !== 'SUPER_ADMIN' && item.excludeRoles?.includes(code)) return false;
|
||||
return hasPermission(...item.permissions);
|
||||
if (!hasPermission(...item.permissions)) return false;
|
||||
|
||||
const visible = auth.user.value?.visibleMenus;
|
||||
if (visible) {
|
||||
const list = visible.split(',');
|
||||
return list.includes(item.key);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const adminMenus = computed(() => {
|
||||
const items: AdminMenuItem[] = [
|
||||
{ path: '/', label: t('nav.dashboard'), icon: 'dashboard', matchPrefix: true, permissions: [AdminPerm.reports], excludeRoles: ['SUPPORT'] },
|
||||
{ path: '/matches', label: t('nav.matches'), icon: 'matches', matchPrefix: true, permissions: [AdminPerm.matches] },
|
||||
{ path: '/users', label: t('nav.agents_players'), icon: 'users', permissions: [AdminPerm.usersView, AdminPerm.agentsView] },
|
||||
{ path: '/finance-logs', label: t('nav.finance_logs'), icon: 'finance', permissions: [AdminPerm.reports], excludeRoles: ['MATCH_ADMIN'] },
|
||||
{ path: '/deposit', label: t('nav.deposit_manage'), icon: 'deposit', matchPrefix: true, permissions: [AdminPerm.depositManage, AdminPerm.depositReview] },
|
||||
{ path: '/cashback', label: t('nav.cashback'), icon: 'cashback', permissions: [AdminPerm.cashback], excludeRoles: ['MATCH_ADMIN', 'SUPPORT'] },
|
||||
{ path: '/bets', label: t('nav.bets'), icon: 'bets', permissions: [AdminPerm.bets] },
|
||||
{ path: '/contents', label: t('nav.contents'), icon: 'contents', permissions: [AdminPerm.content] },
|
||||
{ path: '/media', label: t('nav.media'), icon: 'media', permissions: [AdminPerm.content, AdminPerm.matches] },
|
||||
{ path: '/audit', label: t('nav.audit'), icon: 'audit', permissions: [AdminPerm.audit], excludeRoles: ['MATCH_ADMIN'] },
|
||||
{ path: '/staff', label: t('nav.staff'), icon: 'users', permissions: [AdminPerm.settings] },
|
||||
{ path: '/smoke-tests', label: t('nav.smoke_tests'), icon: 'smoke-tests', permissions: [AdminPerm.settings] },
|
||||
{ key: 'dashboard', path: '/', label: t('nav.dashboard'), icon: 'dashboard', matchPrefix: true, permissions: [AdminPerm.reports], excludeRoles: ['SUPPORT'] },
|
||||
{ key: 'matches', path: '/matches', label: t('nav.matches'), icon: 'matches', matchPrefix: true, permissions: [AdminPerm.matches] },
|
||||
{ key: 'users', path: '/users', label: t('nav.agents_players'), icon: 'users', permissions: [AdminPerm.usersView, AdminPerm.agentsView] },
|
||||
{ key: 'finance-logs', path: '/finance-logs', label: t('nav.finance_logs'), icon: 'finance', permissions: [AdminPerm.reports], excludeRoles: ['MATCH_ADMIN'] },
|
||||
{ key: 'deposit', path: '/deposit', label: t('nav.deposit_manage'), icon: 'deposit', matchPrefix: true, permissions: [AdminPerm.depositManage, AdminPerm.depositReview] },
|
||||
{ key: 'cashback', path: '/cashback', label: t('nav.cashback'), icon: 'cashback', permissions: [AdminPerm.cashback], excludeRoles: ['MATCH_ADMIN', 'SUPPORT'] },
|
||||
{ key: 'bets', path: '/bets', label: t('nav.bets'), icon: 'bets', permissions: [AdminPerm.bets] },
|
||||
{ key: 'contents', path: '/contents', label: t('nav.contents'), icon: 'contents', permissions: [AdminPerm.content] },
|
||||
{ key: 'media', path: '/media', label: t('nav.media'), icon: 'media', permissions: [AdminPerm.content, AdminPerm.matches] },
|
||||
{ key: 'audit', path: '/audit', label: t('nav.audit'), icon: 'audit', permissions: [AdminPerm.audit], excludeRoles: ['MATCH_ADMIN'] },
|
||||
{ key: 'staff', path: '/staff', label: t('nav.staff'), icon: 'users', permissions: [AdminPerm.settings] },
|
||||
{ key: 'smoke-tests', path: '/smoke-tests', label: t('nav.smoke_tests'), icon: 'smoke-tests', permissions: [AdminPerm.settings] },
|
||||
];
|
||||
return items.filter(menuVisible);
|
||||
});
|
||||
@@ -149,11 +164,13 @@ onMounted(() => {
|
||||
window.addEventListener('resize', syncMobileNav);
|
||||
if (auth.isAdmin.value) {
|
||||
void ensureSmokeTestsAllowed();
|
||||
if (canSeeDepositPending.value) startDepositPendingPolling();
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', syncMobileNav);
|
||||
stopDepositPendingPolling();
|
||||
});
|
||||
|
||||
watch(() => route.path, () => {
|
||||
@@ -177,6 +194,7 @@ watch(() => route.path, () => {
|
||||
<aside class="sidebar" :class="{ open: sidebarOpen }">
|
||||
<div class="brand">
|
||||
<img src="/logo.png" alt="TheBet365" class="brand-logo" />
|
||||
<span class="brand-title">{{ isAdminPortal ? t('portal.admin') : t('portal.agent') }}</span>
|
||||
</div>
|
||||
|
||||
<nav class="nav">
|
||||
@@ -197,7 +215,16 @@ watch(() => route.path, () => {
|
||||
@click="onNavClick"
|
||||
>
|
||||
<AdminNavIcon :name="m.icon" />
|
||||
<span class="nav-label">{{ m.label }}</span>
|
||||
<span class="nav-label">
|
||||
{{ m.label }}
|
||||
<span
|
||||
v-if="'path' in m && m.path === '/deposit' && depositPendingCount > 0"
|
||||
class="nav-pending-badge"
|
||||
:title="t('deposit.pending_badge', { n: depositPendingCount })"
|
||||
>
|
||||
{{ depositPendingCount > 99 ? '99+' : depositPendingCount }}
|
||||
</span>
|
||||
</span>
|
||||
</RouterLink>
|
||||
</nav>
|
||||
|
||||
@@ -245,7 +272,6 @@ watch(() => route.path, () => {
|
||||
</div>
|
||||
</div>
|
||||
<AdminLocaleSwitcher />
|
||||
<div class="portal-tag">{{ isAdminPortal ? t('portal.admin') : t('portal.agent') }}</div>
|
||||
<button class="btn-logout" @click="logout">{{ t('logout') }}</button>
|
||||
</div>
|
||||
</header>
|
||||
@@ -285,17 +311,26 @@ watch(() => route.path, () => {
|
||||
border-bottom: 1px solid #1a1a1a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
flex-shrink: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.brand-logo {
|
||||
max-width: 118px;
|
||||
max-height: 34px;
|
||||
max-width: 52px;
|
||||
max-height: 32px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.brand-title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
color: #f0f0f0;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.nav {
|
||||
@@ -324,8 +359,26 @@ watch(() => route.path, () => {
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
.nav-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
line-height: 1.25;
|
||||
flex: 1;
|
||||
}
|
||||
.nav-pending-badge {
|
||||
flex-shrink: 0;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 9px;
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 0 2px rgba(245, 108, 108, 0.25);
|
||||
}
|
||||
.nav-item:hover {
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
@@ -584,14 +637,23 @@ watch(() => route.path, () => {
|
||||
.brand {
|
||||
height: 64px;
|
||||
min-height: 64px;
|
||||
padding: 0 16px;
|
||||
padding: 0 12px;
|
||||
border-bottom: 1px solid var(--border-soft);
|
||||
justify-content: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
max-width: 132px;
|
||||
max-height: 38px;
|
||||
max-width: 56px;
|
||||
max-height: 34px;
|
||||
}
|
||||
|
||||
.brand-title {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
color: #2a2824;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.nav {
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface StaffUser {
|
||||
maxAgentLevel?: number | null;
|
||||
canManageSubAgents?: boolean;
|
||||
inviteCode?: string | null;
|
||||
visibleMenus?: string | null;
|
||||
}
|
||||
|
||||
const TOKEN_KEY = 'manage_token';
|
||||
@@ -98,6 +99,7 @@ export function reconcileStaffSessionFromToken(): boolean {
|
||||
role: claims.role ?? user.value?.role,
|
||||
permissions: user.value?.permissions,
|
||||
inviteCode: user.value?.inviteCode,
|
||||
visibleMenus: user.value?.visibleMenus,
|
||||
};
|
||||
user.value = next;
|
||||
localStorage.setItem(USER_KEY, JSON.stringify(next));
|
||||
|
||||
12
apps/admin/src/utils/html.ts
Normal file
12
apps/admin/src/utils/html.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/** 去除 HTML 标签,用于列表摘要与跑马灯纯文本 */
|
||||
export function stripHtml(html: string): string {
|
||||
if (!html) return '';
|
||||
if (!/[<>]/.test(html)) return html.trim();
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return (doc.body.textContent ?? '').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
/** 判断富文本是否实质为空 */
|
||||
export function isHtmlEmpty(html: string): boolean {
|
||||
return !stripHtml(html);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ interface CreditTxRow {
|
||||
const items = ref<CreditTxRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSize = ref(10);
|
||||
const keyword = ref('');
|
||||
const agentId = ref('');
|
||||
const transactionType = ref('');
|
||||
|
||||
@@ -77,6 +77,7 @@ import { formatRatePercent, percentToDecimalRate, decimalRateToPercent } from '.
|
||||
import InviteCodePanel from '../components/InviteCodePanel.vue';
|
||||
import InviteManageDialog from '../components/InviteManageDialog.vue';
|
||||
import AdminTableWrap from '../components/AdminTableWrap.vue';
|
||||
import AdminPlayerStatusCell from '../components/AdminPlayerStatusCell.vue';
|
||||
import AdminAgentRowActions from '../components/AdminAgentRowActions.vue';
|
||||
import AdminPlayerRowActions from '../components/AdminPlayerRowActions.vue';
|
||||
import AdminDetailGrid from '../components/AdminDetailGrid.vue';
|
||||
@@ -94,7 +95,7 @@ const inviteDialogOpen = ref(false);
|
||||
const tier1Agents = ref<AgentRow[]>([]);
|
||||
const tier1Total = ref(0);
|
||||
const tier1Page = ref(1);
|
||||
const tier1PageSize = ref(20);
|
||||
const tier1PageSize = ref(10);
|
||||
const tier1Keyword = ref('');
|
||||
const tier1FilterStatus = ref('');
|
||||
|
||||
@@ -117,7 +118,7 @@ function ensureSubAgentState(level: number): SubAgentLevelState {
|
||||
agents: [],
|
||||
total: 0,
|
||||
page: 1,
|
||||
pageSize: 20,
|
||||
pageSize: 10,
|
||||
keyword: '',
|
||||
filterStatus: '',
|
||||
};
|
||||
@@ -166,7 +167,7 @@ const activeViewTab = ref('players');
|
||||
const allPlayers = ref<PlayerRow[]>([]);
|
||||
const playerTotal = ref(0);
|
||||
const playerPage = ref(1);
|
||||
const playerPageSize = ref(20);
|
||||
const playerPageSize = ref(10);
|
||||
const playerKeyword = ref('');
|
||||
const playerFilterStatus = ref('');
|
||||
const playerFilterAgent = ref('');
|
||||
@@ -1557,11 +1558,11 @@ function creditTypeLabel(type: string) {
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column prop="id" label="ID" width="72" />
|
||||
<el-table-column type="index" :index="(i: number) => (playerPage - 1) * playerPageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="120" />
|
||||
<el-table-column :label="t('common.status')" width="88">
|
||||
<el-table-column :label="t('common.status')" min-width="128">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">{{ statusLabel(row.status) }}</el-tag>
|
||||
<AdminPlayerStatusCell :status="row.status" :is-online="row.isOnline" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.agent')" min-width="200">
|
||||
@@ -1671,19 +1672,19 @@ function creditTypeLabel(type: string) {
|
||||
</div>
|
||||
<el-table :data="getPlayers(row.userId)" stripe class="inner-table">
|
||||
<template #empty><AdminTableEmpty /></template>
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column type="index" :label="t('common.seq')" width="55" align="center" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="100" />
|
||||
<el-table-column :label="t('common.status')" min-width="120">
|
||||
<template #default="{ row: player }">
|
||||
<AdminPlayerStatusCell :status="player.status" :is-online="player.isOnline" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.invite_code')" min-width="96" show-overflow-tooltip>
|
||||
<template #default="{ row: player }">
|
||||
<code v-if="player.inviteCode" class="invite-code-cell">{{ player.inviteCode }}</code>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('common.status')" width="80">
|
||||
<template #default="{ row: player }">
|
||||
<el-tag :type="statusTagType(player.status)" size="small">{{ statusLabel(player.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.balance')" min-width="120" align="right">
|
||||
<template #default="{ row: player }">
|
||||
<el-tooltip :content="`${formatAmountFull(player.availableBalance)} / ${formatAmountFull(player.frozenBalance)}`" placement="top">
|
||||
@@ -1717,8 +1718,7 @@ function creditTypeLabel(type: string) {
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="userId" label="ID" min-width="64" />
|
||||
<el-table-column type="index" :index="(i: number) => (tier1Page - 1) * tier1PageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column :label="t('common.status')" min-width="72">
|
||||
<template #default="{ row }">
|
||||
@@ -1837,19 +1837,19 @@ function creditTypeLabel(type: string) {
|
||||
</div>
|
||||
<el-table :data="getPlayers(row.userId)" stripe class="inner-table">
|
||||
<template #empty><AdminTableEmpty /></template>
|
||||
<el-table-column prop="id" label="ID" width="60" />
|
||||
<el-table-column type="index" :label="t('common.seq')" width="55" align="center" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="100" />
|
||||
<el-table-column :label="t('common.status')" min-width="120">
|
||||
<template #default="{ row: player }">
|
||||
<AdminPlayerStatusCell :status="player.status" :is-online="player.isOnline" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.invite_code')" min-width="96" show-overflow-tooltip>
|
||||
<template #default="{ row: player }">
|
||||
<code v-if="player.inviteCode" class="invite-code-cell">{{ player.inviteCode }}</code>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('common.status')" width="80">
|
||||
<template #default="{ row: player }">
|
||||
<el-tag :type="statusTagType(player.status)" size="small">{{ statusLabel(player.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.balance')" min-width="120" align="right">
|
||||
<template #default="{ row: player }">
|
||||
<span class="amount-compact">{{ formatAmount(player.availableBalance) }} / {{ formatAmount(player.frozenBalance) }}</span>
|
||||
@@ -1875,7 +1875,7 @@ function creditTypeLabel(type: string) {
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="userId" label="ID" min-width="64" />
|
||||
<el-table-column type="index" :index="(i: number) => (ensureSubAgentState(agentLevel).page - 1) * ensureSubAgentState(agentLevel).pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column :label="t('agent.col.parent_chain')" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ parentChainLabel(row) }}</template>
|
||||
|
||||
@@ -174,6 +174,7 @@ async function openDetail(row: BetListRow) {
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="id" :label="t('bet.col.serial')" width="64" align="center" />
|
||||
<el-table-column prop="betNo" :label="t('bet.col.bet_no')" min-width="200" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
|
||||
@@ -453,6 +453,7 @@ onMounted(loadHistory);
|
||||
<template #empty>
|
||||
<AdminTableEmpty :text="t('cashback.history_empty')" />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (historyPage - 1) * historyPageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="batchNo" :label="t('cashback.batch_no')" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="t('cashback.col.period')" min-width="190">
|
||||
<template #default="{ row }">{{ formatPeriodRange(row) }}</template>
|
||||
|
||||
@@ -7,6 +7,9 @@ import { usePermissions } from '../composables/usePermissions';
|
||||
import { AdminPerm } from '../constants/permissions';
|
||||
import api from '../api';
|
||||
import AdminTableEmpty from '../components/AdminTableEmpty.vue';
|
||||
import ContentImageField from '../components/ContentImageField.vue';
|
||||
import ContentRichEditor from '../components/ContentRichEditor.vue';
|
||||
import { stripHtml } from '../utils/html';
|
||||
import {
|
||||
normalizeStartTimeForApi,
|
||||
normalizeStartTimeForPicker,
|
||||
@@ -16,91 +19,8 @@ const { t, localeTag } = useAdminLocale();
|
||||
const { hasPermission } = usePermissions();
|
||||
const canManageContent = computed(() => hasPermission(AdminPerm.content));
|
||||
|
||||
/* ── Image upload helpers ── */
|
||||
const IMAGE_ACCEPT = 'image/png,image/jpeg,image/webp,image/gif,image/svg+xml';
|
||||
const MAX_UPLOAD_SIZE = 5 * 1024 * 1024;
|
||||
|
||||
interface MediaFile {
|
||||
id: string;
|
||||
filename: string;
|
||||
category: string;
|
||||
mimeType: string;
|
||||
size: number;
|
||||
url: string;
|
||||
inUse: boolean;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
/** Per-locale uploading state */
|
||||
const uploadingLocale = ref<string | null>(null);
|
||||
|
||||
/** Media picker state */
|
||||
const mediaPickerVisible = ref(false);
|
||||
const mediaPickerLocale = ref('');
|
||||
const mediaFiles = ref<MediaFile[]>([]);
|
||||
const mediaLoading = ref(false);
|
||||
|
||||
async function uploadBannerImage(locale: string, file: File) {
|
||||
if (file.size > MAX_UPLOAD_SIZE) {
|
||||
ElMessage.error(t('content.upload.size_error'));
|
||||
return;
|
||||
}
|
||||
uploadingLocale.value = locale;
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
const { data } = await api.post('/admin/uploads?category=banners', fd, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
const url = data.data?.url as string;
|
||||
if (url) {
|
||||
const tr = form.value.translations.find((item) => item.locale === locale);
|
||||
if (tr) tr.imageUrl = url;
|
||||
ElMessage.success(t('content.upload.success'));
|
||||
}
|
||||
} catch (err: any) {
|
||||
const msg = err?.response?.data?.message || t('content.upload.failed');
|
||||
ElMessage.error(String(msg));
|
||||
} finally {
|
||||
uploadingLocale.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function onBannerFileChange(e: Event, locale: string) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
if (input.files?.[0]) {
|
||||
void uploadBannerImage(locale, input.files[0]);
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function removeBannerImage(locale: string) {
|
||||
const tr = form.value.translations.find((item) => item.locale === locale);
|
||||
if (tr) tr.imageUrl = '';
|
||||
}
|
||||
|
||||
async function openMediaPicker(locale: string) {
|
||||
mediaPickerLocale.value = locale;
|
||||
mediaPickerVisible.value = true;
|
||||
mediaLoading.value = true;
|
||||
try {
|
||||
const res = await api.get('/admin/files', { params: { category: 'banners', pageSize: 200 } });
|
||||
mediaFiles.value = res.data.data.items ?? [];
|
||||
} catch {
|
||||
mediaFiles.value = [];
|
||||
} finally {
|
||||
mediaLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function pickMediaFile(file: MediaFile) {
|
||||
const tr = form.value.translations.find((item) => item.locale === mediaPickerLocale.value);
|
||||
if (tr) tr.imageUrl = file.url;
|
||||
mediaPickerVisible.value = false;
|
||||
}
|
||||
|
||||
type StoredContentType = 'BANNER' | 'NOTICE' | 'TICKER';
|
||||
type AdminTab = 'BANNER' | 'ANNOUNCEMENT';
|
||||
type AdminTab = 'BANNER' | 'ANNOUNCEMENT' | 'INBOX_NOTIFY';
|
||||
type ContentStatus = 'DRAFT' | 'ACTIVE' | 'INACTIVE';
|
||||
|
||||
interface TranslationForm {
|
||||
@@ -126,7 +46,7 @@ interface ContentItem {
|
||||
translations: TranslationForm[];
|
||||
}
|
||||
|
||||
const ADMIN_TABS: AdminTab[] = ['BANNER', 'ANNOUNCEMENT'];
|
||||
const ADMIN_TABS: AdminTab[] = ['BANNER', 'ANNOUNCEMENT', 'INBOX_NOTIFY'];
|
||||
const LOCALES = ['zh-CN', 'en-US', 'ms-MY'] as const;
|
||||
|
||||
const activeType = ref<AdminTab>('BANNER');
|
||||
@@ -142,9 +62,24 @@ const selectedRows = ref<ContentItem[]>([]);
|
||||
|
||||
const hasSelection = computed(() => selectedRows.value.length > 0);
|
||||
|
||||
const dialogVisible = ref(false);
|
||||
const bannerDialogVisible = ref(false);
|
||||
const announcementDialogVisible = ref(false);
|
||||
const bannerEditorRef = ref<InstanceType<typeof ContentRichEditor> | null>(null);
|
||||
const editingId = ref<string | null>(null);
|
||||
const editingContentType = ref<StoredContentType>('NOTICE');
|
||||
const editingContentType = ref<StoredContentType>('TICKER');
|
||||
const activeLocale = ref<string>('zh-CN');
|
||||
const notifyInbox = ref(false);
|
||||
|
||||
interface InboxNotifySettings {
|
||||
inboxEnabled: boolean;
|
||||
deposit: boolean;
|
||||
}
|
||||
|
||||
const inboxNotifySettings = ref<InboxNotifySettings>({
|
||||
inboxEnabled: true,
|
||||
deposit: true,
|
||||
});
|
||||
const inboxNotifySaving = ref(false);
|
||||
|
||||
const form = ref({
|
||||
sortOrder: 0,
|
||||
@@ -200,12 +135,63 @@ function formatTime(v: string | null) {
|
||||
});
|
||||
}
|
||||
|
||||
const isBanner = computed(() => activeType.value === 'BANNER');
|
||||
const isAnnouncement = computed(() => activeType.value === 'ANNOUNCEMENT');
|
||||
const dialogTitle = computed(() =>
|
||||
editingId.value ? t('content.dialog.edit') : t('content.dialog.create'),
|
||||
function previewText(row: ContentItem) {
|
||||
const raw = row.previewTitle || row.translations.find((tr) => tr.body)?.body || '';
|
||||
return stripHtml(raw) || '—';
|
||||
}
|
||||
|
||||
const isBannerTab = computed(() => activeType.value === 'BANNER');
|
||||
const isInboxNotifyTab = computed(() => activeType.value === 'INBOX_NOTIFY');
|
||||
|
||||
const activeTranslation = computed(
|
||||
() =>
|
||||
form.value.translations.find((tr) => tr.locale === activeLocale.value) ??
|
||||
form.value.translations[0],
|
||||
);
|
||||
|
||||
const bannerDialogTitle = computed(() =>
|
||||
editingId.value ? t('content.dialog.edit_banner') : t('content.dialog.create_banner'),
|
||||
);
|
||||
|
||||
const announcementDialogTitle = computed(() =>
|
||||
editingId.value ? t('content.dialog.edit_notice') : t('content.dialog.create_notice'),
|
||||
);
|
||||
|
||||
async function loadInboxNotifySettings() {
|
||||
try {
|
||||
const { data } = await api.get('/admin/contents/inbox-notify-settings');
|
||||
inboxNotifySettings.value = {
|
||||
inboxEnabled: data.data?.inboxEnabled !== false,
|
||||
deposit: Boolean(data.data?.deposit),
|
||||
};
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string } } };
|
||||
ElMessage.error(err.response?.data?.error ?? t('msg.load_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
async function saveInboxNotifySettings() {
|
||||
if (!canManageContent.value) return;
|
||||
inboxNotifySaving.value = true;
|
||||
try {
|
||||
const { data } = await api.put('/admin/contents/inbox-notify-settings', {
|
||||
inboxEnabled: inboxNotifySettings.value.inboxEnabled,
|
||||
deposit: inboxNotifySettings.value.deposit,
|
||||
});
|
||||
inboxNotifySettings.value = {
|
||||
inboxEnabled: data.data?.inboxEnabled !== false,
|
||||
deposit: Boolean(data.data?.deposit),
|
||||
};
|
||||
ElMessage.success(t('msg.saved'));
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string } } };
|
||||
ElMessage.error(err.response?.data?.error ?? t('msg.save_failed'));
|
||||
await loadInboxNotifySettings();
|
||||
} finally {
|
||||
inboxNotifySaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -244,6 +230,10 @@ watch([activeType, filterStatus], () => {
|
||||
page.value = 1;
|
||||
selectedRows.value = [];
|
||||
tableRef.value?.clearSelection();
|
||||
if (activeType.value === 'INBOX_NOTIFY') {
|
||||
void loadInboxNotifySettings();
|
||||
return;
|
||||
}
|
||||
void load();
|
||||
});
|
||||
|
||||
@@ -311,6 +301,8 @@ function batchDelete() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
activeLocale.value = 'zh-CN';
|
||||
notifyInbox.value = false;
|
||||
form.value = {
|
||||
sortOrder: 0,
|
||||
status: 'DRAFT',
|
||||
@@ -322,15 +314,7 @@ function resetForm() {
|
||||
};
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editingId.value = null;
|
||||
resetForm();
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
function openEdit(row: ContentItem) {
|
||||
editingId.value = row.id;
|
||||
editingContentType.value = row.contentType;
|
||||
function loadRowIntoForm(row: ContentItem, plainBody = false) {
|
||||
const byLocale = new Map(row.translations.map((tr) => [tr.locale, tr]));
|
||||
form.value = {
|
||||
sortOrder: row.sortOrder,
|
||||
@@ -341,33 +325,57 @@ function openEdit(row: ContentItem) {
|
||||
endTime: normalizeStartTimeForPicker(row.endTime ?? undefined),
|
||||
translations: LOCALES.map((locale) => {
|
||||
const tr = byLocale.get(locale);
|
||||
const rawBody = tr?.body ?? '';
|
||||
return {
|
||||
locale,
|
||||
title: tr?.title ?? '',
|
||||
body: tr?.body ?? '',
|
||||
body: plainBody ? stripHtml(rawBody) : rawBody,
|
||||
imageUrl: tr?.imageUrl ?? '',
|
||||
};
|
||||
}),
|
||||
};
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
|
||||
function buildPayload() {
|
||||
const contentType: StoredContentType = editingId.value
|
||||
? editingContentType.value
|
||||
: isBanner.value
|
||||
? 'BANNER'
|
||||
: 'NOTICE';
|
||||
function openCreate() {
|
||||
editingId.value = null;
|
||||
resetForm();
|
||||
if (isBannerTab.value) {
|
||||
editingContentType.value = 'BANNER';
|
||||
bannerDialogVisible.value = true;
|
||||
} else {
|
||||
editingContentType.value = 'TICKER';
|
||||
announcementDialogVisible.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function openEdit(row: ContentItem) {
|
||||
editingId.value = row.id;
|
||||
editingContentType.value = row.contentType;
|
||||
activeLocale.value = 'zh-CN';
|
||||
if (row.contentType === 'BANNER') {
|
||||
loadRowIntoForm(row, false);
|
||||
bannerDialogVisible.value = true;
|
||||
} else {
|
||||
loadRowIntoForm(row, true);
|
||||
announcementDialogVisible.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function buildScheduleFields() {
|
||||
return {
|
||||
contentType,
|
||||
sortOrder: form.value.sortOrder,
|
||||
status: form.value.status,
|
||||
linkType: isBanner.value && form.value.linkType ? form.value.linkType : null,
|
||||
linkTarget:
|
||||
isBanner.value && form.value.linkType ? form.value.linkTarget.trim() : null,
|
||||
startTime: form.value.startTime ? normalizeStartTimeForApi(form.value.startTime) : null,
|
||||
endTime: form.value.endTime ? normalizeStartTimeForApi(form.value.endTime) : null,
|
||||
};
|
||||
}
|
||||
|
||||
function buildBannerPayload() {
|
||||
const payload = {
|
||||
contentType: 'BANNER' as const,
|
||||
...buildScheduleFields(),
|
||||
linkType: form.value.linkType ? form.value.linkType : null,
|
||||
linkTarget: form.value.linkType ? form.value.linkTarget.trim() : null,
|
||||
translations: form.value.translations.map((tr) => ({
|
||||
locale: tr.locale,
|
||||
title: tr.title.trim() || undefined,
|
||||
@@ -375,25 +383,94 @@ function buildPayload() {
|
||||
imageUrl: tr.imageUrl.trim() || undefined,
|
||||
})),
|
||||
};
|
||||
if (!editingId.value) {
|
||||
return { ...payload, notifyInbox: notifyInbox.value };
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
if (uploadingLocale.value) {
|
||||
ElMessage.warning(t('content.upload.uploading'));
|
||||
return;
|
||||
function buildAnnouncementPayload() {
|
||||
const contentType: StoredContentType = editingId.value ? editingContentType.value : 'TICKER';
|
||||
const payload = {
|
||||
contentType,
|
||||
...buildScheduleFields(),
|
||||
linkType: null,
|
||||
linkTarget: null,
|
||||
translations: form.value.translations.map((tr) => ({
|
||||
locale: tr.locale,
|
||||
title: tr.title.trim() || undefined,
|
||||
body: tr.body.trim() || undefined,
|
||||
})),
|
||||
};
|
||||
if (!editingId.value) {
|
||||
return { ...payload, notifyInbox: notifyInbox.value };
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
async function submitBannerForm() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = buildPayload();
|
||||
const editor = bannerEditorRef.value;
|
||||
if (editor) {
|
||||
activeTranslation.value.body = editor.getHtml();
|
||||
for (const tr of form.value.translations) {
|
||||
tr.body = await editor.uploadPendingImages(tr.body);
|
||||
}
|
||||
}
|
||||
|
||||
const payload = buildBannerPayload();
|
||||
const isCreate = !editingId.value;
|
||||
if (editingId.value) {
|
||||
const { contentType: _type, ...updateBody } = payload;
|
||||
const { contentType: _type, notifyInbox: _notify, ...updateBody } = payload as ReturnType<typeof buildBannerPayload> & { notifyInbox?: boolean };
|
||||
await api.put(`/admin/contents/${editingId.value}`, updateBody);
|
||||
ElMessage.success(t('msg.saved'));
|
||||
} else {
|
||||
await api.post('/admin/contents', payload);
|
||||
const { data } = await api.post('/admin/contents', payload);
|
||||
const notifiedCount = Number(data.data?.notifiedCount ?? 0);
|
||||
if (notifyInbox.value && notifiedCount > 0) {
|
||||
ElMessage.success(t('content.msg.notify_sent', { count: notifiedCount }));
|
||||
} else {
|
||||
ElMessage.success(t('msg.saved'));
|
||||
}
|
||||
}
|
||||
ElMessage.success(t('msg.saved'));
|
||||
dialogVisible.value = false;
|
||||
bannerDialogVisible.value = false;
|
||||
if (isCreate) page.value = 1;
|
||||
await load();
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string; message?: string | string[] } } };
|
||||
const msg = err.response?.data?.error
|
||||
?? (Array.isArray(err.response?.data?.message)
|
||||
? err.response?.data?.message.join(', ')
|
||||
: err.response?.data?.message)
|
||||
?? (e instanceof Error ? e.message : t('msg.save_failed'));
|
||||
ElMessage.error(String(msg));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submitAnnouncementForm() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = buildAnnouncementPayload();
|
||||
const isCreate = !editingId.value;
|
||||
if (editingId.value) {
|
||||
const { contentType: _type, notifyInbox: _notify, ...updateBody } = payload as ReturnType<
|
||||
typeof buildAnnouncementPayload
|
||||
> & { notifyInbox?: boolean };
|
||||
await api.put(`/admin/contents/${editingId.value}`, updateBody);
|
||||
ElMessage.success(t('msg.saved'));
|
||||
} else {
|
||||
const { data } = await api.post('/admin/contents', payload);
|
||||
const notifiedCount = Number(data.data?.notifiedCount ?? 0);
|
||||
if (notifyInbox.value && notifiedCount > 0) {
|
||||
ElMessage.success(t('content.msg.notify_sent', { count: notifiedCount }));
|
||||
} else {
|
||||
ElMessage.success(t('msg.saved'));
|
||||
}
|
||||
}
|
||||
announcementDialogVisible.value = false;
|
||||
if (isCreate) page.value = 1;
|
||||
await load();
|
||||
} catch (e: unknown) {
|
||||
@@ -426,7 +503,7 @@ async function setStatus(row: ContentItem, status: ContentStatus) {
|
||||
async function removeItem(row: ContentItem) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('content.confirm_delete', { title: row.previewTitle || row.id }),
|
||||
t('content.confirm_delete', { title: previewText(row) }),
|
||||
{ type: 'warning' },
|
||||
);
|
||||
} catch {
|
||||
@@ -459,8 +536,42 @@ void load();
|
||||
:name="tp"
|
||||
/>
|
||||
</el-tabs>
|
||||
<p v-if="isAnnouncement" class="type-hint">{{ t('content.hint.announcement') }}</p>
|
||||
<el-form inline class="filter-row">
|
||||
|
||||
<template v-if="isInboxNotifyTab">
|
||||
<div class="inbox-notify-panel">
|
||||
<div class="inbox-notify-row">
|
||||
<div class="inbox-notify-row-text">
|
||||
<span class="inbox-notify-label">{{ t('content.inbox_notify.inbox_enabled') }}</span>
|
||||
<span class="inbox-notify-hint">{{ t('content.inbox_notify.inbox_enabled_hint') }}</span>
|
||||
</div>
|
||||
<el-switch
|
||||
v-model="inboxNotifySettings.inboxEnabled"
|
||||
:disabled="!canManageContent || inboxNotifySaving"
|
||||
@change="saveInboxNotifySettings"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-show="inboxNotifySettings.inboxEnabled" class="inbox-notify-row">
|
||||
<div class="inbox-notify-row-text">
|
||||
<span class="inbox-notify-label">{{ t('content.inbox_notify.deposit') }}</span>
|
||||
<span class="inbox-notify-hint">{{ t('content.inbox_notify.deposit_hint') }}</span>
|
||||
</div>
|
||||
<el-switch
|
||||
v-model="inboxNotifySettings.deposit"
|
||||
:disabled="!canManageContent || inboxNotifySaving"
|
||||
@change="saveInboxNotifySettings"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p v-show="inboxNotifySettings.inboxEnabled" class="inbox-notify-notes-title">{{ t('content.inbox_notify.manual_title') }}</p>
|
||||
<ul v-show="inboxNotifySettings.inboxEnabled" class="inbox-notify-notes">
|
||||
<li>{{ t('content.inbox_notify.banner_note') }}</li>
|
||||
<li>{{ t('content.inbox_notify.announcement_note') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form v-else inline class="filter-row">
|
||||
<el-form-item :label="t('common.status')">
|
||||
<el-select v-model="filterStatus" clearable style="width: 140px">
|
||||
<el-option :label="t('common.all')" value="" />
|
||||
@@ -478,38 +589,24 @@ void load();
|
||||
{{ t('content.btn.create') }}
|
||||
</el-button>
|
||||
<template v-if="canManageContent">
|
||||
<span v-if="hasSelection" class="batch-hint">
|
||||
{{ t('content.batch.selected', { n: selectedRows.length }) }}
|
||||
</span>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="!hasSelection || saving"
|
||||
@click="batchEnable"
|
||||
>
|
||||
{{ t('content.batch.enable') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="!hasSelection || saving"
|
||||
@click="batchDisable"
|
||||
>
|
||||
{{ t('content.batch.disable') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
size="small"
|
||||
:disabled="!hasSelection || saving"
|
||||
@click="batchDelete"
|
||||
>
|
||||
{{ t('content.batch.delete') }}
|
||||
</el-button>
|
||||
<span v-if="hasSelection" class="batch-hint">
|
||||
{{ t('content.batch.selected', { n: selectedRows.length }) }}
|
||||
</span>
|
||||
<el-button size="small" :disabled="!hasSelection || saving" @click="batchEnable">
|
||||
{{ t('content.batch.enable') }}
|
||||
</el-button>
|
||||
<el-button size="small" :disabled="!hasSelection || saving" @click="batchDisable">
|
||||
{{ t('content.batch.disable') }}
|
||||
</el-button>
|
||||
<el-button type="danger" plain size="small" :disabled="!hasSelection || saving" @click="batchDelete">
|
||||
{{ t('content.batch.delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-loading="loading" class="data-card" shadow="never">
|
||||
<el-card v-if="!isInboxNotifyTab" v-loading="loading" class="data-card" shadow="never">
|
||||
<div class="table-wrap">
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
@@ -523,21 +620,17 @@ void load();
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="selection" width="44" :selectable="() => !saving" />
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="sortOrder" :label="t('content.col.sort')" width="64" align="center" />
|
||||
<el-table-column v-if="isBanner" :label="t('content.col.preview')" width="88" align="center">
|
||||
<el-table-column :label="t('content.col.preview')" width="88" align="center">
|
||||
<template #default="{ row }">
|
||||
<img
|
||||
v-if="row.previewImageUrl"
|
||||
:src="row.previewImageUrl"
|
||||
alt=""
|
||||
class="thumb"
|
||||
/>
|
||||
<img v-if="row.previewImageUrl" :src="row.previewImageUrl" alt="" class="thumb" />
|
||||
<span v-else class="thumb-empty">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('content.col.title')" min-width="160">
|
||||
<el-table-column :label="t('content.col.title')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="preview-title">{{ row.previewTitle || '—' }}</span>
|
||||
<span class="preview-title">{{ previewText(row) }}</span>
|
||||
<p v-if="!row.playerVisible && row.playerHiddenReason" class="hidden-tip">
|
||||
{{ hiddenTip(row.playerHiddenReason) }}
|
||||
</p>
|
||||
@@ -564,7 +657,7 @@ void load();
|
||||
<span class="schedule-line">{{ formatTime(row.endTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isBanner" :label="t('content.col.link')" min-width="120">
|
||||
<el-table-column :label="t('content.col.link')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<template v-if="row.linkType">
|
||||
{{ row.linkType }} · {{ row.linkTarget || '—' }}
|
||||
@@ -586,13 +679,7 @@ void load();
|
||||
>
|
||||
{{ t('content.btn.enable') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
link
|
||||
type="warning"
|
||||
:disabled="saving"
|
||||
@click="setStatus(row, 'INACTIVE')"
|
||||
>
|
||||
<el-button v-else link type="warning" :disabled="saving" @click="setStatus(row, 'INACTIVE')">
|
||||
{{ t('content.btn.disable') }}
|
||||
</el-button>
|
||||
<el-button link type="danger" :disabled="saving" @click="removeItem(row)">
|
||||
@@ -616,134 +703,261 @@ void load();
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="640px" destroy-on-close>
|
||||
<el-form label-width="96px" size="small">
|
||||
<el-form-item :label="t('content.col.sort')">
|
||||
<el-input-number v-model="form.sortOrder" :min="0" :step="1" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('common.status')">
|
||||
<el-select v-model="form.status" style="width: 160px">
|
||||
<el-option
|
||||
v-for="st in ['DRAFT', 'ACTIVE', 'INACTIVE']"
|
||||
:key="st"
|
||||
:label="statusLabel(st)"
|
||||
:value="st"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template v-if="isBanner">
|
||||
<el-form-item :label="t('content.field.link_type')">
|
||||
<el-select v-model="form.linkType" clearable style="width: 160px">
|
||||
<el-option :label="t('content.link.none')" value="" />
|
||||
<el-option label="ROUTE" value="ROUTE" />
|
||||
<el-option label="URL" value="URL" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.linkType" :label="t('content.field.link_target')">
|
||||
<el-input
|
||||
v-model="form.linkTarget"
|
||||
:placeholder="form.linkType === 'ROUTE' ? '/football' : 'https://'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<el-form-item :label="t('content.field.start_time')">
|
||||
<el-date-picker
|
||||
v-model="form.startTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('content.field.end_time')">
|
||||
<el-date-picker
|
||||
v-model="form.endTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-dialog
|
||||
v-model="bannerDialogVisible"
|
||||
:title="bannerDialogTitle"
|
||||
width="1000px"
|
||||
class="content-publish-dialog"
|
||||
destroy-on-close
|
||||
>
|
||||
<el-form label-width="84px" size="small" class="publish-form">
|
||||
<div class="publish-layout">
|
||||
<aside class="publish-meta">
|
||||
<section class="publish-section publish-section--compact">
|
||||
<div class="publish-section-head">{{ t('content.section.publish') }}</div>
|
||||
|
||||
<div v-for="tr in form.translations" :key="tr.locale" class="locale-block">
|
||||
<div class="locale-head">{{ localeLabel(tr.locale) }}</div>
|
||||
<el-form-item :label="t('content.field.title')">
|
||||
<el-input v-model="tr.title" :placeholder="t('content.field.title_ph')" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="isBanner"
|
||||
:label="t('content.field.image_url')"
|
||||
:required="form.status === 'ACTIVE'"
|
||||
>
|
||||
<div class="banner-upload-field">
|
||||
<p class="banner-size-hint">{{ t('content.upload.recommended_size') }}</p>
|
||||
<!-- Image preview -->
|
||||
<div v-if="tr.imageUrl" class="banner-preview">
|
||||
<img :src="tr.imageUrl" alt="" class="banner-preview-img" />
|
||||
<button type="button" class="banner-preview-remove" :title="t('content.upload.remove')" @click="removeBannerImage(tr.locale)">×</button>
|
||||
</div>
|
||||
<!-- Upload actions -->
|
||||
<div class="banner-upload-actions">
|
||||
<label
|
||||
class="banner-upload-btn"
|
||||
:class="{ 'is-uploading': uploadingLocale === tr.locale }"
|
||||
<el-row :gutter="8" class="publish-grid">
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="t('common.status')" label-position="top" class="publish-field">
|
||||
<el-select v-model="form.status" style="width: 100%">
|
||||
<el-option
|
||||
v-for="st in ['DRAFT', 'ACTIVE', 'INACTIVE']"
|
||||
:key="st"
|
||||
:label="statusLabel(st)"
|
||||
:value="st"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="t('content.col.sort')" label-position="top" class="publish-field">
|
||||
<el-input-number
|
||||
v-model="form.sortOrder"
|
||||
:min="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-row :gutter="8" class="publish-grid">
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="t('content.field.start_time')" label-position="top" class="publish-field">
|
||||
<el-date-picker
|
||||
v-model="form.startTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="t('content.field.end_time')" label-position="top" class="publish-field">
|
||||
<el-date-picker
|
||||
v-model="form.endTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item :label="t('content.field.link_type')" label-position="top" class="publish-field">
|
||||
<el-select v-model="form.linkType" clearable style="width: 100%">
|
||||
<el-option :label="t('content.link.none')" value="" />
|
||||
<el-option label="ROUTE" value="ROUTE" />
|
||||
<el-option label="URL" value="URL" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="form.linkType"
|
||||
:label="t('content.field.link_target')"
|
||||
label-position="top"
|
||||
class="publish-field"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.linkTarget"
|
||||
:placeholder="form.linkType === 'ROUTE' ? '/bet' : 'https://'"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="!editingId" label-position="top" class="publish-field notify-inbox-field">
|
||||
<template #label>{{ t('content.field.notify_inbox') }}</template>
|
||||
<div class="notify-inbox-block">
|
||||
<el-switch v-model="notifyInbox" :disabled="form.status !== 'ACTIVE'" />
|
||||
<p class="notify-inbox-hint">{{ t('content.field.notify_inbox_hint') }}</p>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</section>
|
||||
|
||||
<section class="publish-section publish-meta-fields">
|
||||
<h3 class="section-title">{{ t('content.section.content') }}</h3>
|
||||
<el-tabs v-model="activeLocale" class="locale-tabs">
|
||||
<el-tab-pane
|
||||
v-for="tr in form.translations"
|
||||
:key="tr.locale"
|
||||
:label="localeLabel(tr.locale)"
|
||||
:name="tr.locale"
|
||||
>
|
||||
<input
|
||||
type="file"
|
||||
:accept="IMAGE_ACCEPT"
|
||||
style="display: none"
|
||||
:disabled="uploadingLocale === tr.locale"
|
||||
@change="onBannerFileChange($event, tr.locale)"
|
||||
/>
|
||||
{{ uploadingLocale === tr.locale ? t('content.upload.uploading') : t('content.upload.upload_btn') }}
|
||||
</label>
|
||||
<button type="button" class="banner-pick-btn" @click="openMediaPicker(tr.locale)">
|
||||
{{ t('content.upload.pick_media') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- Manual URL fallback -->
|
||||
<el-input
|
||||
v-model="tr.imageUrl"
|
||||
:placeholder="t('content.upload.url_placeholder')"
|
||||
size="small"
|
||||
class="banner-url-input"
|
||||
/>
|
||||
<el-form-item
|
||||
:label="t('content.field.title')"
|
||||
:required="form.status === 'ACTIVE'"
|
||||
>
|
||||
<el-input v-model="tr.title" :placeholder="t('content.field.title_ph')" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
:label="t('content.field.cover_image')"
|
||||
:required="form.status === 'ACTIVE'"
|
||||
>
|
||||
<ContentImageField
|
||||
v-model="tr.imageUrl"
|
||||
category="banners"
|
||||
size-hint-key="content.upload.recommended_size"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div class="publish-body">
|
||||
<div class="publish-body-head">
|
||||
<span class="publish-body-label">
|
||||
{{ t('content.field.body') }}
|
||||
<span v-if="form.status === 'ACTIVE'" class="required-mark">*</span>
|
||||
</span>
|
||||
<span class="locale-badge">{{ localeLabel(activeLocale) }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="isAnnouncement ? t('content.field.announce_text') : t('content.field.body')"
|
||||
:required="isAnnouncement && form.status === 'ACTIVE'"
|
||||
>
|
||||
<el-input v-model="tr.body" type="textarea" :rows="isAnnouncement ? 2 : 3" />
|
||||
</el-form-item>
|
||||
|
||||
<ContentRichEditor
|
||||
ref="bannerEditorRef"
|
||||
v-model="activeTranslation.body"
|
||||
fill
|
||||
upload-category="banners"
|
||||
:placeholder="t('content.editor.placeholder')"
|
||||
class="publish-rich-editor"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="saving" :disabled="!!uploadingLocale" @click="submitForm">
|
||||
<el-button @click="bannerDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitBannerForm">
|
||||
{{ t('common.save') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- Media picker dialog -->
|
||||
<el-dialog v-model="mediaPickerVisible" :title="t('content.upload.pick_media_title')" width="680px" destroy-on-close append-to-body>
|
||||
<div v-if="mediaLoading" class="media-picker-loading">{{ t('common.loading') }}</div>
|
||||
<div v-else-if="mediaFiles.length === 0" class="media-picker-empty">{{ t('content.upload.no_media') }}</div>
|
||||
<div v-else class="media-picker-grid">
|
||||
<div
|
||||
v-for="file in mediaFiles"
|
||||
:key="file.id"
|
||||
class="media-picker-card"
|
||||
@click="pickMediaFile(file)"
|
||||
>
|
||||
<div class="media-picker-thumb">
|
||||
<img v-if="file.mimeType !== 'image/svg+xml'" :src="file.url" :alt="file.filename" loading="lazy" />
|
||||
<div v-else class="media-picker-svg">SVG</div>
|
||||
</div>
|
||||
<div class="media-picker-name" :title="file.filename">{{ file.filename }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog
|
||||
v-model="announcementDialogVisible"
|
||||
:title="announcementDialogTitle"
|
||||
width="640px"
|
||||
class="announcement-dialog"
|
||||
destroy-on-close
|
||||
>
|
||||
<p class="announcement-hint">{{ t('content.hint.announcement') }}</p>
|
||||
<el-form label-width="96px" size="small" class="announcement-form">
|
||||
<section class="announcement-publish">
|
||||
<div class="publish-section-head">{{ t('content.section.publish') }}</div>
|
||||
<el-row :gutter="8" class="announcement-publish-row">
|
||||
<el-col :xs="12" :sm="6">
|
||||
<el-form-item :label="t('common.status')" label-position="top" class="publish-field">
|
||||
<el-select v-model="form.status" style="width: 100%">
|
||||
<el-option
|
||||
v-for="st in ['DRAFT', 'ACTIVE', 'INACTIVE']"
|
||||
:key="st"
|
||||
:label="statusLabel(st)"
|
||||
:value="st"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="6">
|
||||
<el-form-item :label="t('content.col.sort')" label-position="top" class="publish-field">
|
||||
<el-input-number
|
||||
v-model="form.sortOrder"
|
||||
:min="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="6">
|
||||
<el-form-item :label="t('content.field.start_time')" label-position="top" class="publish-field">
|
||||
<el-date-picker
|
||||
v-model="form.startTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="6">
|
||||
<el-form-item :label="t('content.field.end_time')" label-position="top" class="publish-field">
|
||||
<el-date-picker
|
||||
v-model="form.endTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-form-item v-if="!editingId" label-position="top" class="publish-field notify-inbox-field">
|
||||
<template #label>{{ t('content.field.notify_inbox') }}</template>
|
||||
<div class="notify-inbox-block">
|
||||
<el-switch v-model="notifyInbox" :disabled="form.status !== 'ACTIVE'" />
|
||||
<p class="notify-inbox-hint">{{ t('content.field.notify_inbox_hint') }}</p>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</section>
|
||||
|
||||
<section class="announcement-content">
|
||||
<h3 class="section-title">{{ t('content.section.content') }}</h3>
|
||||
<el-tabs v-model="activeLocale" class="locale-tabs">
|
||||
<el-tab-pane
|
||||
v-for="tr in form.translations"
|
||||
:key="tr.locale"
|
||||
:label="localeLabel(tr.locale)"
|
||||
:name="tr.locale"
|
||||
>
|
||||
<el-form-item :label="t('content.field.title')">
|
||||
<el-input v-model="tr.title" :placeholder="t('content.field.ticker_title_ph')" />
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('content.field.announce_text')"
|
||||
:required="form.status === 'ACTIVE'"
|
||||
>
|
||||
<el-input
|
||||
v-model="tr.body"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('content.field.ticker_body_ph')"
|
||||
/>
|
||||
<p class="field-hint compact-hint">{{ t('content.field.ticker_hint') }}</p>
|
||||
</el-form-item>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</section>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="announcementDialogVisible = false">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitAnnouncementForm">
|
||||
{{ t('common.save') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -753,11 +967,27 @@ void load();
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.type-hint {
|
||||
margin: 0 0 8px;
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
.field-hint,
|
||||
.batch-hint,
|
||||
.schedule-line,
|
||||
.schedule-sep,
|
||||
.thumb-empty {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
margin: 4px 0 0;
|
||||
font-size: 11px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.field-hint.inline-hint,
|
||||
.field-hint.compact-hint {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.field-hint.inline-hint {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.filter-row {
|
||||
@@ -766,7 +996,6 @@ void load();
|
||||
|
||||
.batch-hint {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
margin: 0 4px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -776,313 +1005,257 @@ void load();
|
||||
height: 32px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
background: #222;
|
||||
}
|
||||
|
||||
.thumb-empty {
|
||||
color: #555;
|
||||
font-size: 12px;
|
||||
background: #f4f0e8;
|
||||
}
|
||||
|
||||
.preview-title {
|
||||
font-size: 13px;
|
||||
color: #ccc;
|
||||
color: var(--text);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hidden-tip {
|
||||
margin: 4px 0 0;
|
||||
font-size: 11px;
|
||||
color: #c9a227;
|
||||
color: var(--warning-text);
|
||||
}
|
||||
|
||||
.schedule-line {
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.schedule-sep {
|
||||
margin: 0 4px;
|
||||
color: #555;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.locale-block {
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #252525;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
.content-publish-dialog :deep(.el-dialog__body) {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.locale-head {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #888;
|
||||
margin-bottom: 8px;
|
||||
.content-publish-dialog :deep(.el-dialog__footer) {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
/* ── Banner image upload widget ── */
|
||||
.banner-upload-field {
|
||||
.publish-layout {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: stretch;
|
||||
min-height: 480px;
|
||||
}
|
||||
|
||||
.publish-meta {
|
||||
flex: 0 0 380px;
|
||||
max-width: 400px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.banner-size-hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: #777;
|
||||
.publish-meta-fields {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.banner-preview {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 320px;
|
||||
aspect-ratio: 43 / 18;
|
||||
.publish-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 480px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #252525;
|
||||
background: #111;
|
||||
}
|
||||
|
||||
.banner-preview-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.banner-preview-remove {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 4px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
color: #fff;
|
||||
border: 1px solid #333;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.banner-preview-remove:hover {
|
||||
background: rgba(224, 85, 85, 0.85);
|
||||
}
|
||||
|
||||
.banner-upload-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.banner-upload-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 6px 14px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: 1px solid rgba(212, 175, 55, 0.5);
|
||||
background: rgba(212, 175, 55, 0.1);
|
||||
color: var(--gold-text);
|
||||
font-weight: 600;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.banner-upload-btn:hover {
|
||||
background: rgba(212, 175, 55, 0.2);
|
||||
}
|
||||
|
||||
.banner-upload-btn.is-uploading {
|
||||
opacity: 0.6;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.banner-pick-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 6px 14px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: 1px solid #2a2a2a;
|
||||
background: transparent;
|
||||
color: #888;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.banner-pick-btn:hover {
|
||||
border-color: #444;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.banner-url-input {
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.banner-url-input :deep(.el-input__wrapper) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ── Media picker ── */
|
||||
.media-picker-loading,
|
||||
.media-picker-empty {
|
||||
text-align: center;
|
||||
padding: 40px 0;
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.media-picker-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
|
||||
gap: 12px;
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.media-picker-card {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid #1e1e1e;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.media-picker-card:hover {
|
||||
border-color: rgba(212, 175, 55, 0.5);
|
||||
box-shadow: 0 2px 12px rgba(212, 175, 55, 0.15);
|
||||
}
|
||||
|
||||
.media-picker-thumb {
|
||||
height: 80px;
|
||||
background: #111;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.media-picker-thumb img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.media-picker-svg {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: #666;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.media-picker-name {
|
||||
padding: 6px 8px;
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.contents-page {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.type-hint,
|
||||
.batch-hint,
|
||||
.banner-size-hint,
|
||||
.schedule-line,
|
||||
.schedule-sep,
|
||||
.media-picker-loading,
|
||||
.media-picker-empty,
|
||||
.media-picker-name,
|
||||
.thumb-empty,
|
||||
.locale-head {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.preview-title {
|
||||
color: var(--text);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hidden-tip {
|
||||
color: var(--warning-text);
|
||||
}
|
||||
|
||||
.thumb,
|
||||
.banner-preview,
|
||||
.media-picker-thumb {
|
||||
background: #f4f0e8;
|
||||
}
|
||||
|
||||
.banner-preview,
|
||||
.locale-block {
|
||||
border-color: var(--border);
|
||||
background: #fbfaf7;
|
||||
}
|
||||
|
||||
.banner-preview-remove {
|
||||
border-color: rgba(255, 255, 255, 0.36);
|
||||
background: rgba(31, 35, 32, 0.78);
|
||||
.publish-body-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.banner-preview-remove:hover {
|
||||
background: rgba(159, 47, 45, 0.92);
|
||||
}
|
||||
|
||||
.banner-upload-btn,
|
||||
.banner-pick-btn {
|
||||
border-radius: 7px;
|
||||
.publish-body-label {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.banner-upload-btn {
|
||||
border-color: var(--primary);
|
||||
background: var(--primary);
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.banner-upload-btn:hover {
|
||||
background: var(--primary-light);
|
||||
}
|
||||
|
||||
.banner-pick-btn {
|
||||
border-color: var(--border);
|
||||
background: #ffffff;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.banner-pick-btn:hover {
|
||||
border-color: #d5cfc3;
|
||||
background: var(--accent-hover);
|
||||
color: var(--text);
|
||||
.required-mark {
|
||||
color: var(--el-color-danger);
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.media-picker-card {
|
||||
border-color: var(--border);
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.media-picker-card:hover {
|
||||
border-color: #d5cfc3;
|
||||
box-shadow: 0 8px 22px rgba(56, 49, 37, 0.08);
|
||||
}
|
||||
|
||||
.media-picker-svg {
|
||||
.locale-badge {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.publish-rich-editor {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.publish-form :deep(.el-form-item) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.publish-form :deep(.el-form-item__label) {
|
||||
padding-right: 8px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.publish-section {
|
||||
margin-bottom: 10px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: #fbfaf7;
|
||||
}
|
||||
|
||||
.publish-section--compact {
|
||||
padding: 10px 12px 8px;
|
||||
}
|
||||
|
||||
.publish-section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0 0 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.publish-section-head {
|
||||
margin: 0 0 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.publish-section--compact :deep(.publish-field.el-form-item) {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.publish-section--compact :deep(.publish-field.el-form-item:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.publish-section--compact :deep(.publish-field .el-form-item__label) {
|
||||
padding: 0 0 4px;
|
||||
line-height: 1.35;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.publish-section--compact :deep(.publish-field .el-form-item__content) {
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.publish-grid {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.publish-grid :deep(.publish-field.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.notify-inbox-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.notify-inbox-hint {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-muted);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.notify-inbox-field {
|
||||
margin-top: 4px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px dashed var(--border);
|
||||
}
|
||||
|
||||
.publish-grid--secondary {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.announcement-dialog :deep(.el-dialog__body) {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.announcement-hint {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.announcement-publish {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: #fbfaf7;
|
||||
}
|
||||
|
||||
.announcement-content {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: #fbfaf7;
|
||||
}
|
||||
|
||||
.announcement-form :deep(.el-form-item) {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.announcement-publish-row {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.publish-layout {
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.publish-meta {
|
||||
flex: none;
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.publish-body {
|
||||
min-height: 420px;
|
||||
}
|
||||
}
|
||||
|
||||
.locale-tabs :deep(.el-tabs__header) {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.locale-tabs :deep(.el-tabs__content) {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
@@ -1091,10 +1264,56 @@ void load();
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.banner-preview,
|
||||
.banner-url-input {
|
||||
max-width: 100%;
|
||||
}
|
||||
.inbox-notify-panel {
|
||||
padding: 4px 0 12px;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.inbox-notify-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.inbox-notify-row-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.inbox-notify-label {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.inbox-notify-hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.inbox-notify-notes-title {
|
||||
margin: 14px 0 6px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.inbox-notify-notes {
|
||||
margin: 0 0 16px;
|
||||
padding-left: 18px;
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.inbox-notify-notes li {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { resolveApiError } from '../i18n/form-validation';
|
||||
import api from '../api';
|
||||
import AdminTableEmpty from '../components/AdminTableEmpty.vue';
|
||||
import { formatAmount } from '../utils/format-amount';
|
||||
import { refreshDepositPendingCount } from '../composables/useDepositPendingCount';
|
||||
|
||||
const { t } = useAdminLocale();
|
||||
|
||||
@@ -45,7 +46,7 @@ interface DepositAuditLogRow {
|
||||
const items = ref<DepositOrderRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSize = ref(10);
|
||||
const loading = ref(false);
|
||||
|
||||
// Filters
|
||||
@@ -85,6 +86,7 @@ async function fetchList() {
|
||||
const result = data.data ?? { items: [], total: 0 };
|
||||
items.value = result.items ?? [];
|
||||
total.value = result.total ?? 0;
|
||||
void refreshDepositPendingCount();
|
||||
} catch { /* */ } finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -238,6 +240,10 @@ function statusLabel(s: string) {
|
||||
return '● ' + t('deposit.status_pending');
|
||||
}
|
||||
|
||||
function refreshList() {
|
||||
void fetchList();
|
||||
}
|
||||
|
||||
function prevPage() { if (page.value > 1) { page.value--; fetchList(); } }
|
||||
function nextPage() { if (page.value * pageSize.value < total.value) { page.value++; fetchList(); } }
|
||||
|
||||
@@ -268,6 +274,9 @@ onMounted(fetchList);
|
||||
@keydown.enter="page = 1; fetchList()"
|
||||
/>
|
||||
<button class="btn-search" @click="page = 1; fetchList()">{{ t('common.search') }}</button>
|
||||
<button class="btn-refresh" type="button" :disabled="loading" @click="refreshList">
|
||||
{{ t('common.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<AdminTableEmpty v-if="!loading && !items.length" />
|
||||
@@ -275,6 +284,7 @@ onMounted(fetchList);
|
||||
<table v-if="items.length" class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60px; text-align: center;">{{ t('common.seq') }}</th>
|
||||
<th>{{ t('deposit.order_no') }}</th>
|
||||
<th>{{ t('deposit.player') }}</th>
|
||||
<th>{{ t('common.type') }}</th>
|
||||
@@ -289,7 +299,8 @@ onMounted(fetchList);
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in items" :key="row.id">
|
||||
<tr v-for="(row, idx) in items" :key="row.id">
|
||||
<td style="text-align: center;">{{ (page - 1) * pageSize + idx + 1 }}</td>
|
||||
<td class="mono">{{ row.orderNo }}</td>
|
||||
<td>{{ row.playerUsername || row.playerId }}</td>
|
||||
<td><span :class="['badge', row.methodType === 'BANK' ? 'badge-blue' : 'badge-green']">{{ row.methodType }}</span></td>
|
||||
@@ -445,6 +456,24 @@ onMounted(fetchList);
|
||||
.filters select, .filters input { padding: 6px 10px; border-radius: 4px; border: 1px solid #444; background: #1e1e1e; color: #eee; font-size: 13px; }
|
||||
.filters input { min-width: 160px; }
|
||||
.btn-search { background: #409eff; color: #fff; border: none; border-radius: 4px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 13px; }
|
||||
.btn-refresh {
|
||||
background: #fff;
|
||||
color: #606266;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
padding: 6px 14px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
.btn-refresh:hover:not(:disabled) {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
.btn-refresh:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.data-table th, .data-table td { padding: 10px 6px; border-bottom: 1px solid #333; text-align: left; }
|
||||
.data-table th { font-weight: 700; color: #aaa; font-size: 11px; text-transform: uppercase; }
|
||||
|
||||
@@ -47,12 +47,12 @@ interface TransferTxRow {
|
||||
const creditItems = ref<CreditTxRow[]>([]);
|
||||
const creditTotal = ref(0);
|
||||
const creditPage = ref(1);
|
||||
const creditPageSize = ref(20);
|
||||
const creditPageSize = ref(10);
|
||||
|
||||
const transferItems = ref<TransferTxRow[]>([]);
|
||||
const transferTotal = ref(0);
|
||||
const transferPage = ref(1);
|
||||
const transferPageSize = ref(20);
|
||||
const transferPageSize = ref(10);
|
||||
|
||||
const keyword = ref('');
|
||||
const agentId = ref('');
|
||||
@@ -320,6 +320,7 @@ watch(
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (creditPage - 1) * creditPageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column :label="t('audit.col.time')" min-width="158">
|
||||
<template #default="{ row }">{{ formatTime(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
@@ -390,6 +391,7 @@ watch(
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (transferPage - 1) * transferPageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column :label="t('audit.col.time')" min-width="158">
|
||||
<template #default="{ row }">{{ formatTime(row.createdAt) }}</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -442,7 +442,7 @@ function onLeagueArchived() {
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="72" />
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column :label="t('match.col.league')" width="148" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<div class="league-cell">
|
||||
|
||||
@@ -194,7 +194,7 @@ function isLeagueExpanded(id: string) {
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="72" />
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column :label="t('match.col.league')" width="148" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<div class="league-cell">
|
||||
|
||||
@@ -196,6 +196,7 @@ onMounted(fetchList);
|
||||
<table v-if="filteredItems.length" class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: center; width: 60px;">{{ t('common.seq') }}</th>
|
||||
<th>{{ t('common.type') }}</th>
|
||||
<th>{{ t('deposit.display_name') }}</th>
|
||||
<th>{{ t('deposit.details') }}</th>
|
||||
@@ -205,7 +206,8 @@ onMounted(fetchList);
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in filteredItems" :key="row.id">
|
||||
<tr v-for="(row, index) in filteredItems" :key="row.id">
|
||||
<td style="text-align: center;">{{ index + 1 }}</td>
|
||||
<td><span :class="['badge', row.methodType === 'BANK' ? 'badge-blue' : 'badge-green']">{{ row.methodType }}</span></td>
|
||||
<td>{{ row.displayName || '-' }}</td>
|
||||
<td class="details-cell">
|
||||
|
||||
@@ -851,6 +851,7 @@ onMounted(() => {
|
||||
</span>
|
||||
</div>
|
||||
<el-table :data="previewItemsPage.items" size="small" stripe class="preview-items-table">
|
||||
<el-table-column type="index" :index="(i: number) => (previewItemsPage.page - 1) * previewItemsPage.pageSize + i + 1" :label="t('common.seq')" width="55" align="center" />
|
||||
<el-table-column :label="t('bet.col.bet_no')" prop="betNo" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="t('common.type')" width="68">
|
||||
<template #default="{ row }">{{ betTypeLabel(row.betType) }}</template>
|
||||
@@ -935,6 +936,7 @@ onMounted(() => {
|
||||
stripe
|
||||
class="stats-table"
|
||||
>
|
||||
<el-table-column type="index" :index="(i: number) => ((stats?.bets.page ?? 1) - 1) * (stats?.bets.pageSize ?? 10) + i + 1" :label="t('common.seq')" width="55" align="center" />
|
||||
<el-table-column prop="betNo" :label="t('bet.col.bet_no')" width="140" />
|
||||
<el-table-column prop="username" :label="t('bet.col.player')" width="96" />
|
||||
<el-table-column :label="t('common.type')" width="72">
|
||||
|
||||
@@ -247,6 +247,7 @@ onMounted(async () => {
|
||||
<span v-else class="case-details-empty">{{ t('smoke.no_steps') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" :label="t('common.seq')" width="55" align="center" />
|
||||
<el-table-column prop="id" :label="t('smoke.col.id')" width="88" />
|
||||
<el-table-column :label="t('smoke.col.suite')" width="120">
|
||||
<template #default="{ row }">{{ suiteName(row.suite) }}</template>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import api from '../api';
|
||||
import { useAdminLocale } from '../composables/useAdminLocale';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import AdminTableEmpty from '../components/AdminTableEmpty.vue';
|
||||
import AdminTableWrap from '../components/AdminTableWrap.vue';
|
||||
|
||||
@@ -14,6 +15,7 @@ interface StaffRow {
|
||||
roleName: string | null;
|
||||
lastLoginAt: string | null;
|
||||
createdAt: string;
|
||||
visibleMenus: string | null;
|
||||
}
|
||||
|
||||
interface RoleOption {
|
||||
@@ -23,22 +25,46 @@ interface RoleOption {
|
||||
}
|
||||
|
||||
const { t, localeTag } = useAdminLocale();
|
||||
const authStore = useAuthStore();
|
||||
const currentUserId = computed(() => authStore.user.value?.id);
|
||||
|
||||
const loading = ref(false);
|
||||
const rows = ref<StaffRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSize = ref(10);
|
||||
const keyword = ref('');
|
||||
const roles = ref<RoleOption[]>([]);
|
||||
|
||||
const menuOptions = [
|
||||
{ key: 'dashboard', label: 'nav.dashboard' },
|
||||
{ key: 'matches', label: 'nav.matches' },
|
||||
{ key: 'users', label: 'nav.agents_players' },
|
||||
{ key: 'finance-logs', label: 'nav.finance_logs' },
|
||||
{ key: 'deposit', label: 'nav.deposit_manage' },
|
||||
{ key: 'cashback', label: 'nav.cashback' },
|
||||
{ key: 'bets', label: 'nav.bets' },
|
||||
{ key: 'contents', label: 'nav.contents' },
|
||||
{ key: 'media', label: 'nav.media' },
|
||||
{ key: 'audit', label: 'nav.audit' },
|
||||
{ key: 'staff', label: 'nav.staff' },
|
||||
{ key: 'smoke-tests', label: 'nav.smoke_tests' },
|
||||
];
|
||||
|
||||
const ROLE_DEFAULT_MENUS: Record<string, string[]> = {
|
||||
SUPER_ADMIN: ['dashboard', 'matches', 'users', 'finance-logs', 'deposit', 'cashback', 'bets', 'contents', 'media', 'audit', 'staff', 'smoke-tests'],
|
||||
MATCH_ADMIN: ['matches', 'bets', 'contents', 'media'],
|
||||
FINANCE_ADMIN: ['dashboard', 'users', 'finance-logs', 'deposit', 'cashback', 'bets'],
|
||||
SUPPORT: ['users', 'bets', 'contents', 'media'],
|
||||
};
|
||||
|
||||
const createVisible = ref(false);
|
||||
const createLoading = ref(false);
|
||||
const createForm = ref({ username: '', password: '', confirmPassword: '', roleCode: 'MATCH_ADMIN' });
|
||||
const createForm = ref({ username: '', password: '', confirmPassword: '', roleCode: 'MATCH_ADMIN', checkedMenus: [] as string[] });
|
||||
|
||||
const editVisible = ref(false);
|
||||
const editLoading = ref(false);
|
||||
const editForm = ref({ id: '', username: '', status: 'ACTIVE', roleCode: 'MATCH_ADMIN', password: '' });
|
||||
const editForm = ref({ id: '', username: '', status: 'ACTIVE', roleCode: 'MATCH_ADMIN', password: '', checkedMenus: [] as string[] });
|
||||
|
||||
const roleLabel = computed(() => {
|
||||
const map: Record<string, string> = {
|
||||
@@ -80,8 +106,18 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
function onCreateRoleChange(newRole: string) {
|
||||
createForm.value.checkedMenus = [...(ROLE_DEFAULT_MENUS[newRole] || [])];
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
createForm.value = { username: '', password: '', confirmPassword: '', roleCode: 'MATCH_ADMIN' };
|
||||
createForm.value = {
|
||||
username: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
roleCode: 'MATCH_ADMIN',
|
||||
checkedMenus: [...ROLE_DEFAULT_MENUS['MATCH_ADMIN']],
|
||||
};
|
||||
createVisible.value = true;
|
||||
}
|
||||
|
||||
@@ -105,6 +141,7 @@ async function submitCreate() {
|
||||
username: f.username.trim(),
|
||||
password: f.password,
|
||||
roleCode: f.roleCode,
|
||||
visibleMenus: f.checkedMenus.join(','),
|
||||
});
|
||||
ElMessage.success(t('msg.saved'));
|
||||
createVisible.value = false;
|
||||
@@ -117,6 +154,10 @@ async function submitCreate() {
|
||||
}
|
||||
}
|
||||
|
||||
function onEditRoleChange(newRole: string) {
|
||||
editForm.value.checkedMenus = [...(ROLE_DEFAULT_MENUS[newRole] || [])];
|
||||
}
|
||||
|
||||
function openEdit(row: StaffRow) {
|
||||
editForm.value = {
|
||||
id: row.id,
|
||||
@@ -124,6 +165,9 @@ function openEdit(row: StaffRow) {
|
||||
status: row.status,
|
||||
roleCode: row.role ?? 'MATCH_ADMIN',
|
||||
password: '',
|
||||
checkedMenus: row.visibleMenus
|
||||
? row.visibleMenus.split(',').filter(Boolean)
|
||||
: [...(ROLE_DEFAULT_MENUS[row.role ?? 'MATCH_ADMIN'] || [])],
|
||||
};
|
||||
editVisible.value = true;
|
||||
}
|
||||
@@ -139,6 +183,7 @@ async function submitEdit() {
|
||||
const payload: Record<string, string> = {
|
||||
status: f.status,
|
||||
roleCode: f.roleCode,
|
||||
visibleMenus: f.checkedMenus.join(','),
|
||||
};
|
||||
if (f.password.trim()) payload.password = f.password.trim();
|
||||
const { data } = await api.patch(`/admin/staff/${f.id}`, payload);
|
||||
@@ -157,6 +202,49 @@ async function submitEdit() {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleFreeze(row: StaffRow, targetStatus: string) {
|
||||
const actionText = targetStatus === 'SUSPENDED' ? t('common.freeze') : t('common.unfreeze');
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要${actionText}管理员「${row.username}」吗?`,
|
||||
t('msg.freeze_confirm_title', { action: actionText }),
|
||||
{ type: 'warning' },
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api.patch(`/admin/staff/${row.id}`, { status: targetStatus });
|
||||
ElMessage.success(t('msg.saved'));
|
||||
await load();
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string } } };
|
||||
ElMessage.error(err.response?.data?.error ?? t('msg.save_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteStaff(row: StaffRow) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确定要删除管理员「${row.username}」吗?此操作无法撤销。`,
|
||||
t('common.delete'),
|
||||
{ type: 'warning' },
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api.delete(`/admin/staff/${row.id}`);
|
||||
ElMessage.success(t('msg.saved'));
|
||||
await load();
|
||||
} catch (e: unknown) {
|
||||
const err = e as { response?: { data?: { error?: string } } };
|
||||
ElMessage.error(err.response?.data?.error ?? t('msg.save_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadRoles();
|
||||
await load();
|
||||
@@ -191,19 +279,61 @@ onMounted(async () => {
|
||||
<template #empty>
|
||||
<AdminTableEmpty />
|
||||
</template>
|
||||
<el-table-column type="index" :index="(i: number) => (page - 1) * pageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column prop="username" :label="t('login.username')" min-width="120" />
|
||||
<el-table-column :label="t('staff.col.role')" min-width="140">
|
||||
<template #default="{ row }">{{ roleLabel(row.role) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('common.status')" width="100">
|
||||
<template #default="{ row }">{{ row.status }}</template>
|
||||
<el-table-column :label="t('common.status')" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="row.status === 'ACTIVE' ? 'success' : row.status === 'SUSPENDED' ? 'warning' : 'danger'"
|
||||
effect="dark"
|
||||
>
|
||||
{{ t(`user.status.${row.status}`) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('staff.col.last_login')" min-width="160">
|
||||
<template #default="{ row }">{{ formatTime(row.lastLoginAt) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('common.actions')" width="100" align="center">
|
||||
<el-table-column :label="t('common.actions')" width="220" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" size="small" @click="openEdit(row)">{{ t('common.edit') }}</el-button>
|
||||
<el-button link type="primary" size="small" @click="openEdit(row)">
|
||||
{{ t('common.edit') }}
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-if="row.status === 'ACTIVE'"
|
||||
link
|
||||
type="warning"
|
||||
size="small"
|
||||
:disabled="row.id === currentUserId"
|
||||
@click="toggleFreeze(row, 'SUSPENDED')"
|
||||
>
|
||||
{{ t('common.freeze') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
link
|
||||
type="success"
|
||||
size="small"
|
||||
:disabled="row.id === currentUserId"
|
||||
@click="toggleFreeze(row, 'ACTIVE')"
|
||||
>
|
||||
{{ t('common.unfreeze') }}
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
size="small"
|
||||
:disabled="row.id === currentUserId"
|
||||
@click="deleteStaff(row)"
|
||||
>
|
||||
{{ t('common.delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -229,7 +359,7 @@ onMounted(async () => {
|
||||
<el-input v-model="createForm.username" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('staff.col.role')" required>
|
||||
<el-select v-model="createForm.roleCode" style="width: 100%">
|
||||
<el-select v-model="createForm.roleCode" style="width: 100%" @change="onCreateRoleChange">
|
||||
<el-option
|
||||
v-for="r in roles.filter((x) => x.code !== 'SUPER_ADMIN')"
|
||||
:key="r.code"
|
||||
@@ -238,6 +368,19 @@ onMounted(async () => {
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('staff.field.visible_menus')">
|
||||
<el-checkbox-group v-model="createForm.checkedMenus">
|
||||
<div class="menu-grid">
|
||||
<el-checkbox
|
||||
v-for="item in menuOptions"
|
||||
:key="item.key"
|
||||
:label="item.key"
|
||||
>
|
||||
{{ t(item.label) }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('login.password')" required>
|
||||
<el-input v-model="createForm.password" type="password" autocomplete="new-password" />
|
||||
</el-form-item>
|
||||
@@ -257,7 +400,7 @@ onMounted(async () => {
|
||||
<el-input :model-value="editForm.username" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('staff.col.role')">
|
||||
<el-select v-model="editForm.roleCode" style="width: 100%" :disabled="editForm.roleCode === 'SUPER_ADMIN'">
|
||||
<el-select v-model="editForm.roleCode" style="width: 100%" :disabled="editForm.roleCode === 'SUPER_ADMIN'" @change="onEditRoleChange">
|
||||
<el-option
|
||||
v-for="r in roles"
|
||||
:key="r.code"
|
||||
@@ -266,11 +409,24 @@ onMounted(async () => {
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('staff.field.visible_menus')">
|
||||
<el-checkbox-group v-model="editForm.checkedMenus">
|
||||
<div class="menu-grid">
|
||||
<el-checkbox
|
||||
v-for="item in menuOptions"
|
||||
:key="item.key"
|
||||
:label="item.key"
|
||||
>
|
||||
{{ t(item.label) }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('common.status')">
|
||||
<el-select v-model="editForm.status" style="width: 100%">
|
||||
<el-option label="ACTIVE" value="ACTIVE" />
|
||||
<el-option label="SUSPENDED" value="SUSPENDED" />
|
||||
<el-option label="DISABLED" value="DISABLED" />
|
||||
<el-option :label="t('user.status.ACTIVE')" value="ACTIVE" />
|
||||
<el-option :label="t('user.status.SUSPENDED')" value="SUSPENDED" />
|
||||
<el-option :label="t('user.status.DISABLED')" value="DISABLED" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('user.field.reset_password')">
|
||||
@@ -291,4 +447,10 @@ onMounted(async () => {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.menu-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 4px 12px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
shouldCompactAmount as shouldCompact,
|
||||
} from '../utils/format-amount';
|
||||
import AdminTableEmpty from '../components/AdminTableEmpty.vue';
|
||||
import AdminPlayerStatusCell from '../components/AdminPlayerStatusCell.vue';
|
||||
import AdminDetailGrid from '../components/AdminDetailGrid.vue';
|
||||
import AdminDetailItem from '../components/AdminDetailItem.vue';
|
||||
import WalletTransferContext from '../components/WalletTransferContext.vue';
|
||||
@@ -511,11 +512,9 @@ function statusLabel(s: string) {
|
||||
</template>
|
||||
<el-table-column prop="id" label="ID" width="72" />
|
||||
<el-table-column prop="username" :label="t('user.col.username')" min-width="120" />
|
||||
<el-table-column :label="t('common.status')" width="88">
|
||||
<el-table-column :label="t('common.status')" min-width="128">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="statusTagType(row.status)" size="small">
|
||||
{{ statusLabel(row.status) }}
|
||||
</el-tag>
|
||||
<AdminPlayerStatusCell :status="row.status" :is-online="row.isOnline" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('user.col.agent')" min-width="120">
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface AdminDashboard {
|
||||
playersActive: number;
|
||||
playersSuspended: number;
|
||||
playersDirect: number;
|
||||
playersOnlineNow: number;
|
||||
agentsTotal: number;
|
||||
agentsActive: number;
|
||||
};
|
||||
|
||||
@@ -30,6 +30,11 @@ const kpiPlayer = computed(() => {
|
||||
value: `${fmtCount(s.value.users.playersTotal)} / ${fmtCount(s.value.users.agentsTotal)}`,
|
||||
sub: t('dash.kpi_new_players', { n: fmtCount(s.value.today.newPlayers) }),
|
||||
},
|
||||
{
|
||||
label: t('dash.players_online'),
|
||||
value: fmtCount(s.value.users.playersOnlineNow ?? 0),
|
||||
sub: t('dash.players_online_hint'),
|
||||
},
|
||||
{
|
||||
label: t('dash.kpi_agents_active'),
|
||||
value: fmtCount(s.value.users.agentsActive),
|
||||
@@ -55,6 +60,7 @@ const userDistributionOption = computed(() => {
|
||||
const userSegs = u
|
||||
? [
|
||||
{ label: t('dash.user_active'), value: u.playersActive, color: '#346538' },
|
||||
{ label: t('dash.user_online'), value: u.playersOnlineNow ?? 0, color: '#2d8a4e' },
|
||||
{ label: t('dash.user_suspended'), value: u.playersSuspended, color: '#9f2f2d' },
|
||||
{ label: t('dash.user_direct'), value: u.playersDirect, color: '#1f6c9f' },
|
||||
{ label: t('dash.user_agents'), value: u.agentsTotal, color: '#956400' },
|
||||
|
||||
@@ -30,7 +30,7 @@ const archiveTitle = ref('');
|
||||
const matches = ref<unknown[]>([]);
|
||||
const loading = ref(false);
|
||||
const matchPage = ref(1);
|
||||
const matchPageSize = ref(20);
|
||||
const matchPageSize = ref(10);
|
||||
const matchTotal = ref(0);
|
||||
let loadTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
@@ -334,7 +334,7 @@ defineExpose({ reload: load });
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="matches" stripe row-key="id" class="nested-match-table">
|
||||
<el-table-column prop="id" label="ID" width="64" />
|
||||
<el-table-column type="index" :index="(i: number) => (matchPage - 1) * matchPageSize + i + 1" :label="t('common.seq')" width="70" align="center" />
|
||||
<el-table-column :label="t('match.col.matchup')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="matchup-link">{{ matchTitle(row) }}</span>
|
||||
|
||||
@@ -72,6 +72,7 @@ export interface PlayerRow {
|
||||
availableBalance: string;
|
||||
frozenBalance: string;
|
||||
lastLoginAt: string | null;
|
||||
isOnline?: boolean;
|
||||
betCount: number;
|
||||
totalStake: string;
|
||||
totalReturn: string;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "visible_menus" VARCHAR(1000);
|
||||
@@ -0,0 +1,22 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "player_messages" (
|
||||
"id" BIGSERIAL NOT NULL,
|
||||
"user_id" BIGINT NOT NULL,
|
||||
"type" VARCHAR(32) NOT NULL,
|
||||
"title" VARCHAR(256) NOT NULL,
|
||||
"body" TEXT NOT NULL,
|
||||
"payload" JSONB,
|
||||
"read_at" TIMESTAMP(3),
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "player_messages_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "player_messages_user_id_created_at_idx" ON "player_messages"("user_id", "created_at" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "player_messages_user_id_read_at_idx" ON "player_messages"("user_id", "read_at");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "player_messages" ADD CONSTRAINT "player_messages_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -23,6 +23,7 @@ model User {
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
visibleMenus String? @map("visible_menus") @db.VarChar(1000)
|
||||
|
||||
auth UserAuth?
|
||||
wallet Wallet?
|
||||
@@ -31,6 +32,7 @@ model User {
|
||||
bets Bet[]
|
||||
preferences UserPreference?
|
||||
depositOrders DepositOrder[] @relation("PlayerDepositOrders")
|
||||
playerMessages PlayerMessage[]
|
||||
|
||||
parent User? @relation("UserHierarchy", fields: [parentId], references: [id])
|
||||
children User[] @relation("UserHierarchy")
|
||||
@@ -813,6 +815,23 @@ model DepositOrderAuditLog {
|
||||
@@map("deposit_order_audit_logs")
|
||||
}
|
||||
|
||||
model PlayerMessage {
|
||||
id BigInt @id @default(autoincrement())
|
||||
userId BigInt @map("user_id")
|
||||
type String @db.VarChar(32)
|
||||
title String @db.VarChar(256)
|
||||
body String @db.Text
|
||||
payload Json?
|
||||
readAt DateTime? @map("read_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId, createdAt(sort: Desc)])
|
||||
@@index([userId, readAt])
|
||||
@@map("player_messages")
|
||||
}
|
||||
|
||||
// ============ System Config & Audit ============
|
||||
|
||||
model SystemConfig {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { PrismaService } from '../../shared/prisma/prisma.service';
|
||||
import { PresenceService } from '../../domains/presence/presence.service';
|
||||
import { Decimal } from '@prisma/client/runtime/library';
|
||||
|
||||
function dec(v: Decimal | null | undefined) {
|
||||
@@ -12,7 +13,10 @@ function sub(a: Decimal | null | undefined, b: Decimal | null | undefined) {
|
||||
|
||||
@Injectable()
|
||||
export class AdminDashboardService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
private presence: PresenceService,
|
||||
) {}
|
||||
|
||||
async getOverview() {
|
||||
const today = new Date();
|
||||
@@ -60,6 +64,7 @@ export class AdminDashboardService {
|
||||
walletAgg,
|
||||
recentBets,
|
||||
recentPlayers,
|
||||
playersOnlineNow,
|
||||
] = await Promise.all([
|
||||
this.prisma.bet.aggregate({
|
||||
where: { placedAt: { gte: today } },
|
||||
@@ -125,6 +130,7 @@ export class AdminDashboardService {
|
||||
parent: { select: { username: true } },
|
||||
},
|
||||
}),
|
||||
this.presence.getOnlineCount(),
|
||||
]);
|
||||
|
||||
const matchByStatus: Record<string, number> = {};
|
||||
@@ -164,6 +170,7 @@ export class AdminDashboardService {
|
||||
playersActive: playerActive,
|
||||
playersSuspended: playerSuspended,
|
||||
playersDirect: playerDirect,
|
||||
playersOnlineNow,
|
||||
agentsTotal: agentProfiles._count._all,
|
||||
agentsActive,
|
||||
},
|
||||
|
||||
@@ -50,6 +50,8 @@ import { P } from './admin-permissions';
|
||||
import { DatabaseResetService } from '../../infrastructure/database/database-reset.service';
|
||||
import { SmokeTestService } from '../../domains/operations/smoke-tests/smoke-test.service';
|
||||
import { DepositService } from '../../domains/deposit/deposit.service';
|
||||
import { PlayerMessagesService } from '../../domains/player-messages/player-messages.service';
|
||||
import { PresenceService } from '../../domains/presence/presence.service';
|
||||
import {
|
||||
IsString,
|
||||
IsNumber,
|
||||
@@ -272,6 +274,10 @@ class CreateStaffDto {
|
||||
|
||||
@IsString()
|
||||
roleCode!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
visibleMenus?: string;
|
||||
}
|
||||
|
||||
class UpdateStaffDto {
|
||||
@@ -287,6 +293,10 @@ class UpdateStaffDto {
|
||||
@IsString()
|
||||
@MinLength(8)
|
||||
password?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
visibleMenus?: string;
|
||||
}
|
||||
|
||||
class ResetPlayerPasswordDto {
|
||||
@@ -1046,6 +1056,10 @@ class CreateContentDto {
|
||||
@IsString()
|
||||
endTime?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
notifyInbox?: boolean;
|
||||
|
||||
@IsArray()
|
||||
translations!: ContentTranslationDto[];
|
||||
}
|
||||
@@ -1085,6 +1099,16 @@ class ContentStatusDto {
|
||||
status!: string;
|
||||
}
|
||||
|
||||
class InboxNotifySettingsDto {
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
inboxEnabled?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
deposit?: boolean;
|
||||
}
|
||||
|
||||
class CashbackPreviewDto {
|
||||
@IsString()
|
||||
periodStart!: string;
|
||||
@@ -1209,9 +1233,18 @@ export class AdminController {
|
||||
private databaseReset: DatabaseResetService,
|
||||
private smokeTests: SmokeTestService,
|
||||
private depositService: DepositService,
|
||||
private playerMessages: PlayerMessagesService,
|
||||
private staff: AdminStaffService,
|
||||
private presence: PresenceService,
|
||||
) {}
|
||||
|
||||
@Get('presence/online-count')
|
||||
@RequirePermissions(P.usersView)
|
||||
async getOnlinePlayerCount() {
|
||||
const count = await this.presence.getOnlineCount();
|
||||
return jsonResponse({ count, asOf: new Date().toISOString() });
|
||||
}
|
||||
|
||||
@Get('dashboard')
|
||||
@RequirePermissions(P.reports)
|
||||
async getDashboard() {
|
||||
@@ -1500,6 +1533,23 @@ export class AdminController {
|
||||
return jsonResponse(updated);
|
||||
}
|
||||
|
||||
@Delete('staff/:id')
|
||||
@RequirePermissions(P.settings)
|
||||
async deleteStaff(
|
||||
@CurrentUser('id') operatorId: bigint,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
await this.staff.deleteStaff(BigInt(id), operatorId);
|
||||
await this.audit.log({
|
||||
operatorId,
|
||||
operatorType: 'ADMIN',
|
||||
action: 'DELETE_STAFF',
|
||||
module: 'STAFF',
|
||||
targetId: id,
|
||||
});
|
||||
return jsonResponse({ deleted: true });
|
||||
}
|
||||
|
||||
@Delete('users/:id')
|
||||
@RequirePermissions(P.usersCreate)
|
||||
async deletePlayer(
|
||||
@@ -3104,6 +3154,20 @@ export class AdminController {
|
||||
return urls;
|
||||
}
|
||||
|
||||
@Get('contents/inbox-notify-settings')
|
||||
@RequirePermissions(P.content, P.reports)
|
||||
async getInboxNotifySettings() {
|
||||
const settings = await this.systemConfig.getInboxNotifySettings();
|
||||
return jsonResponse(settings);
|
||||
}
|
||||
|
||||
@Put('contents/inbox-notify-settings')
|
||||
@RequirePermissions(P.content)
|
||||
async updateInboxNotifySettings(@Body() dto: InboxNotifySettingsDto) {
|
||||
const settings = await this.systemConfig.updateInboxNotifySettings(dto);
|
||||
return jsonResponse(settings);
|
||||
}
|
||||
|
||||
@Get('contents')
|
||||
@RequirePermissions(P.content, P.reports)
|
||||
async listContents(
|
||||
@@ -3128,8 +3192,34 @@ export class AdminController {
|
||||
@Post('contents')
|
||||
@RequirePermissions(P.content)
|
||||
async createContent(@Body() dto: CreateContentDto) {
|
||||
const item = await this.content.create(dto);
|
||||
return jsonResponse(item);
|
||||
const { notifyInbox, ...createDto } = dto;
|
||||
const item = await this.content.create(createDto);
|
||||
let notifiedCount: number | undefined;
|
||||
if (notifyInbox && (createDto.status ?? 'DRAFT') === 'ACTIVE') {
|
||||
const inboxEnabled = await this.systemConfig.getInboxFeatureEnabled();
|
||||
if (inboxEnabled) {
|
||||
const translations = createDto.translations.map((tr) => ({
|
||||
locale: tr.locale,
|
||||
title: tr.title,
|
||||
body: tr.body,
|
||||
}));
|
||||
if (createDto.contentType === 'BANNER') {
|
||||
notifiedCount = await this.playerMessages.broadcastBannerPromotion({
|
||||
contentId: BigInt(item.id),
|
||||
translations,
|
||||
});
|
||||
} else if (
|
||||
createDto.contentType === 'NOTICE' ||
|
||||
createDto.contentType === 'TICKER'
|
||||
) {
|
||||
notifiedCount = await this.playerMessages.broadcastAnnouncementPromotion({
|
||||
contentId: BigInt(item.id),
|
||||
translations,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsonResponse({ ...item, notifiedCount });
|
||||
}
|
||||
|
||||
@Put('contents/:id')
|
||||
@@ -3349,6 +3439,13 @@ export class AdminController {
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Get('deposit-orders/pending-count')
|
||||
@RequirePermissions(P.depositReview)
|
||||
async depositPendingCount() {
|
||||
const count = await this.depositService.countPendingDepositOrders();
|
||||
return jsonResponse({ count });
|
||||
}
|
||||
|
||||
@Get('deposit-orders/:id/audit-logs')
|
||||
@RequirePermissions(P.depositReview)
|
||||
async depositOrderAuditLogs(@Param('id') id: string) {
|
||||
|
||||
@@ -15,6 +15,8 @@ import { BetsModule } from '../../domains/betting/bets.module';
|
||||
import { DatabaseModule } from '../../infrastructure/database/database.module';
|
||||
import { SmokeTestModule } from '../../domains/operations/smoke-tests/smoke-test.module';
|
||||
import { DepositModule } from '../../domains/deposit/deposit.module';
|
||||
import { PlayerMessagesModule } from '../../domains/player-messages/player-messages.module';
|
||||
import { PresenceModule } from '../../domains/presence/presence.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -31,6 +33,8 @@ import { DepositModule } from '../../domains/deposit/deposit.module';
|
||||
DatabaseModule,
|
||||
SmokeTestModule,
|
||||
DepositModule,
|
||||
PlayerMessagesModule,
|
||||
PresenceModule,
|
||||
],
|
||||
controllers: [AdminController],
|
||||
providers: [AdminDashboardService, PermissionsGuard],
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Get,
|
||||
Post,
|
||||
Patch,
|
||||
Delete,
|
||||
Body,
|
||||
Param,
|
||||
Query,
|
||||
@@ -30,6 +31,8 @@ import { BetsService } from '../../domains/betting/bets.service';
|
||||
import { ContentService } from '../../domains/operations/content/content.service';
|
||||
import { CashbackService } from '../../domains/operations/cashback/cashback.service';
|
||||
import { DepositService } from '../../domains/deposit/deposit.service';
|
||||
import { PlayerMessagesService } from '../../domains/player-messages/player-messages.service';
|
||||
import { PresenceService } from '../../domains/presence/presence.service';
|
||||
import { isInLocalTodayMatchWindow } from '@thebet365/shared';
|
||||
import { IsString, IsNumber, IsArray, ValidateNested, Min, IsOptional } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
@@ -120,8 +123,16 @@ export class PlayerController {
|
||||
private cashback: CashbackService,
|
||||
private systemConfig: SystemConfigService,
|
||||
private deposit: DepositService,
|
||||
private playerMessages: PlayerMessagesService,
|
||||
private presence: PresenceService,
|
||||
) {}
|
||||
|
||||
@Post('presence/ping')
|
||||
async presencePing(@CurrentUser('id') userId: bigint) {
|
||||
await this.presence.touch(userId);
|
||||
return jsonResponse({ ok: true });
|
||||
}
|
||||
|
||||
private async formatPlayerProfile(user: NonNullable<Awaited<ReturnType<UsersService['findById']>>>) {
|
||||
const accountSettings = await this.systemConfig.getPlayerAccountSettings();
|
||||
const prefs = user.preferences;
|
||||
@@ -175,10 +186,12 @@ export class PlayerController {
|
||||
@Headers('x-time-zone') headerTimeZone?: string,
|
||||
) {
|
||||
const locale = userLocale || headerLocale || 'zh-CN';
|
||||
const [banners, announcements, allMatches] = await Promise.all([
|
||||
const [banners, announcements, allMatches, upcomingMatches, inboxEnabled] = await Promise.all([
|
||||
this.content.listActive('BANNER', locale),
|
||||
this.content.listActiveAnnouncements(locale),
|
||||
this.matches.listPublished(locale, undefined, { includeMarkets: false }),
|
||||
this.matches.listUpcomingPublished(locale),
|
||||
this.systemConfig.getInboxFeatureEnabled(),
|
||||
]);
|
||||
const timeZone = safeTimeZone(headerTimeZone);
|
||||
const now = new Date();
|
||||
@@ -198,6 +211,8 @@ export class PlayerController {
|
||||
notices: announcements,
|
||||
hotMatches,
|
||||
todayMatches,
|
||||
upcomingMatches,
|
||||
inboxEnabled,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -245,6 +260,20 @@ export class PlayerController {
|
||||
return jsonResponse(match);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('selections/odds')
|
||||
async selectionOdds(@Query('ids') ids?: string) {
|
||||
if (!ids?.trim()) throw appBadRequest('SELECTION_NOT_FOUND');
|
||||
const parsed = ids
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
.map((s) => BigInt(s));
|
||||
if (!parsed.length || parsed.length > 20) throw appBadRequest('PARLAY_LEG_COUNT_INVALID');
|
||||
const items = await this.matches.getSelectionsOdds(parsed);
|
||||
return jsonResponse({ items });
|
||||
}
|
||||
|
||||
@Post('bets/single')
|
||||
async singleBet(@CurrentUser('id') userId: bigint, @CurrentUser('parentId') parentId: bigint, @Body() dto: SingleBetDto) {
|
||||
const bet = await this.bets.placeSingleBet(
|
||||
@@ -449,4 +478,56 @@ export class PlayerController {
|
||||
createdAt: order!.createdAt,
|
||||
});
|
||||
}
|
||||
|
||||
// ============ Messages / Inbox ============
|
||||
|
||||
@Get('messages')
|
||||
async listMessages(
|
||||
@CurrentUser('id') userId: bigint,
|
||||
@Query('page') page?: string,
|
||||
@Query('pageSize') pageSize?: string,
|
||||
) {
|
||||
const result = await this.playerMessages.listForPlayer(
|
||||
userId,
|
||||
page ? parseInt(page, 10) : 1,
|
||||
pageSize ? parseInt(pageSize, 10) : 20,
|
||||
);
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Get('messages/unread-count')
|
||||
async messageUnreadCount(@CurrentUser('id') userId: bigint) {
|
||||
const result = await this.playerMessages.getUnreadCount(userId);
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Get('messages/:id')
|
||||
async messageDetail(@CurrentUser('id') userId: bigint, @Param('id') id: string) {
|
||||
const message = await this.playerMessages.getForPlayer(userId, BigInt(id));
|
||||
return jsonResponse(message);
|
||||
}
|
||||
|
||||
@Patch('messages/read-all')
|
||||
async markAllMessagesRead(@CurrentUser('id') userId: bigint) {
|
||||
const result = await this.playerMessages.markAllRead(userId);
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Patch('messages/:id/read')
|
||||
async markMessageRead(@CurrentUser('id') userId: bigint, @Param('id') id: string) {
|
||||
const message = await this.playerMessages.markRead(userId, BigInt(id));
|
||||
return jsonResponse(message);
|
||||
}
|
||||
|
||||
@Delete('messages')
|
||||
async deleteAllMessages(@CurrentUser('id') userId: bigint) {
|
||||
const result = await this.playerMessages.deleteAllForPlayer(userId);
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Delete('messages/:id')
|
||||
async deleteMessage(@CurrentUser('id') userId: bigint, @Param('id') id: string) {
|
||||
const result = await this.playerMessages.deleteForPlayer(userId, BigInt(id));
|
||||
return jsonResponse(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ import { BetsModule } from '../../domains/betting/bets.module';
|
||||
import { ContentModule } from '../../domains/operations/content/content.module';
|
||||
import { CashbackModule } from '../../domains/operations/cashback/cashback.module';
|
||||
import { DepositModule } from '../../domains/deposit/deposit.module';
|
||||
import { PlayerMessagesModule } from '../../domains/player-messages/player-messages.module';
|
||||
import { PresenceModule } from '../../domains/presence/presence.module';
|
||||
|
||||
@Module({
|
||||
imports: [UsersModule, WalletModule, MatchesModule, BetsModule, ContentModule, CashbackModule, DepositModule],
|
||||
imports: [UsersModule, WalletModule, MatchesModule, BetsModule, ContentModule, CashbackModule, DepositModule, PlayerMessagesModule, PresenceModule],
|
||||
controllers: [PlayerController],
|
||||
})
|
||||
export class PlayerModule {}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
jest.mock('@thebet365/shared', () => ({
|
||||
isPreMatchKickoff: jest.fn(() => true),
|
||||
PARLAY_MARKET_TYPES: [],
|
||||
resolveTranslationFallback: jest.fn(
|
||||
(translations: Map<string, string>, locale: string) =>
|
||||
translations.get(locale) ?? translations.get('zh-CN') ?? translations.get('en-US') ?? null,
|
||||
),
|
||||
resolveTranslationFallback: jest.fn((translations: Map<string, string> | Record<string, string>, locale: string) => {
|
||||
const get = (key: string) =>
|
||||
translations instanceof Map ? translations.get(key) : translations[key];
|
||||
return get(locale) ?? get('zh-CN') ?? get('en-US') ?? null;
|
||||
}),
|
||||
}));
|
||||
|
||||
import { MatchesService } from './matches.service';
|
||||
@@ -18,6 +19,7 @@ describe('MatchesService publish/unpublish', () => {
|
||||
match: { findFirst: jest.Mock; update: jest.Mock };
|
||||
entityTranslation: { findFirst: jest.Mock; upsert: jest.Mock };
|
||||
settlementBatch: { deleteMany: jest.Mock };
|
||||
marketSelection: { findMany: jest.Mock };
|
||||
};
|
||||
let outright: { syncWithLeaguePublished: jest.Mock };
|
||||
let matchBetStats: { betStatsForMatches: jest.Mock };
|
||||
@@ -36,6 +38,7 @@ describe('MatchesService publish/unpublish', () => {
|
||||
},
|
||||
entityTranslation: { findFirst: jest.fn().mockResolvedValue(null), upsert: jest.fn().mockResolvedValue({}) },
|
||||
settlementBatch: { deleteMany: jest.fn().mockResolvedValue({ count: 0 }) },
|
||||
marketSelection: { findMany: jest.fn().mockResolvedValue([]) },
|
||||
};
|
||||
outright = { syncWithLeaguePublished: jest.fn().mockResolvedValue(undefined) };
|
||||
matchBetStats = { betStatsForMatches: jest.fn().mockResolvedValue(new Map()) };
|
||||
@@ -124,3 +127,177 @@ describe('MatchesService publish/unpublish', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('MatchesService getSelectionsOdds', () => {
|
||||
const selectionId = BigInt(100);
|
||||
const matchId = BigInt(10);
|
||||
|
||||
let prisma: { marketSelection: { findMany: jest.Mock } };
|
||||
let service: MatchesService;
|
||||
|
||||
beforeEach(() => {
|
||||
prisma = {
|
||||
marketSelection: { findMany: jest.fn() },
|
||||
};
|
||||
service = new MatchesService(
|
||||
prisma as never,
|
||||
{ syncWithLeaguePublished: jest.fn() } as never,
|
||||
{ betStatsForMatches: jest.fn() } as never,
|
||||
);
|
||||
});
|
||||
|
||||
it('returns odds snapshot for requested selections', async () => {
|
||||
prisma.marketSelection.findMany.mockResolvedValue([
|
||||
{
|
||||
id: selectionId,
|
||||
odds: { toString: () => '1.95' },
|
||||
oddsVersion: BigInt(3),
|
||||
status: 'OPEN',
|
||||
market: {
|
||||
status: 'OPEN',
|
||||
showOnPlayer: true,
|
||||
match: { id: matchId, status: 'PUBLISHED' },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const result = await service.getSelectionsOdds([selectionId]);
|
||||
|
||||
expect(prisma.marketSelection.findMany).toHaveBeenCalledWith({
|
||||
where: { id: { in: [selectionId] } },
|
||||
include: { market: { include: { match: true } } },
|
||||
});
|
||||
expect(result).toEqual([
|
||||
{
|
||||
id: '100',
|
||||
odds: '1.95',
|
||||
oddsVersion: '3',
|
||||
status: 'OPEN',
|
||||
marketStatus: 'OPEN',
|
||||
marketShowOnPlayer: true,
|
||||
matchStatus: 'PUBLISHED',
|
||||
matchId: '10',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns empty array when ids not found', async () => {
|
||||
prisma.marketSelection.findMany.mockResolvedValue([]);
|
||||
const result = await service.getSelectionsOdds([BigInt(999)]);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns empty array for empty id list', async () => {
|
||||
prisma.marketSelection.findMany.mockResolvedValue([]);
|
||||
const result = await service.getSelectionsOdds([]);
|
||||
expect(prisma.marketSelection.findMany).toHaveBeenCalledWith({
|
||||
where: { id: { in: [] } },
|
||||
include: { market: { include: { match: true } } },
|
||||
});
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('MatchesService listUpcomingPublished', () => {
|
||||
const leagueId = BigInt(1);
|
||||
const homeTeamId = BigInt(2);
|
||||
const awayTeamId = BigInt(3);
|
||||
const matchId = BigInt(10);
|
||||
|
||||
let prisma: {
|
||||
match: { findMany: jest.Mock };
|
||||
entityTranslation: { findMany: jest.Mock };
|
||||
};
|
||||
let service: MatchesService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
jest.setSystemTime(new Date('2026-06-17T12:00:00.000Z'));
|
||||
|
||||
prisma = {
|
||||
match: { findMany: jest.fn() },
|
||||
entityTranslation: {
|
||||
findMany: jest.fn().mockResolvedValue([{ locale: 'zh-CN', fieldName: 'name', value: '测试' }]),
|
||||
},
|
||||
};
|
||||
service = new MatchesService(
|
||||
prisma as never,
|
||||
{ syncWithLeaguePublished: jest.fn() } as never,
|
||||
{ betStatsForMatches: jest.fn().mockResolvedValue(new Map()) } as never,
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('queries published matches within the next 3 days sorted by startTime', async () => {
|
||||
const now = new Date('2026-06-17T12:00:00.000Z');
|
||||
const end = new Date(now);
|
||||
end.setDate(end.getDate() + 3);
|
||||
|
||||
prisma.match.findMany.mockResolvedValue([
|
||||
{
|
||||
id: matchId,
|
||||
leagueId,
|
||||
homeTeamId,
|
||||
awayTeamId,
|
||||
startTime: new Date('2026-06-18T15:00:00.000Z'),
|
||||
status: 'PUBLISHED',
|
||||
isHot: false,
|
||||
displayOrder: 0,
|
||||
matchName: null,
|
||||
stage: null,
|
||||
groupName: null,
|
||||
league: { logoUrl: null },
|
||||
homeTeam: { code: 'HME', logoUrl: null },
|
||||
awayTeam: { code: 'AWY', logoUrl: null },
|
||||
score: null,
|
||||
markets: [],
|
||||
},
|
||||
]);
|
||||
|
||||
const result = await service.listUpcomingPublished('zh-CN');
|
||||
|
||||
expect(prisma.match.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({
|
||||
status: { in: ['PUBLISHED', 'CLOSED', 'PENDING_SETTLEMENT'] },
|
||||
isOutright: false,
|
||||
sportType: 'FOOTBALL',
|
||||
deletedAt: null,
|
||||
startTime: { gte: now, lte: end },
|
||||
}),
|
||||
orderBy: [{ startTime: 'asc' }, { displayOrder: 'asc' }],
|
||||
take: 50,
|
||||
}),
|
||||
);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
id: '10',
|
||||
startTime: '2026-06-18T15:00:00.000Z',
|
||||
isHot: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('respects custom limit and days options', async () => {
|
||||
prisma.match.findMany.mockResolvedValue([]);
|
||||
|
||||
await service.listUpcomingPublished('en-US', { limit: 20, days: 5 });
|
||||
|
||||
const now = new Date('2026-06-17T12:00:00.000Z');
|
||||
const end = new Date(now);
|
||||
end.setDate(end.getDate() + 5);
|
||||
|
||||
expect(prisma.match.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: expect.objectContaining({
|
||||
startTime: { gte: now, lte: end },
|
||||
}),
|
||||
take: 20,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1461,6 +1461,42 @@ export class MatchesService {
|
||||
);
|
||||
}
|
||||
|
||||
/** 未来 N 天内开赛的已发布赛事(按开赛时间升序,不限 isHot) */
|
||||
async listUpcomingPublished(
|
||||
locale = 'en-US',
|
||||
options?: { limit?: number; days?: number },
|
||||
) {
|
||||
const limit = options?.limit ?? 50;
|
||||
const days = options?.days ?? 3;
|
||||
const now = new Date();
|
||||
const end = new Date(now);
|
||||
end.setDate(end.getDate() + days);
|
||||
|
||||
const matches = await this.prisma.match.findMany({
|
||||
where: {
|
||||
status: { in: ['PUBLISHED', 'CLOSED', 'PENDING_SETTLEMENT'] },
|
||||
isOutright: false,
|
||||
sportType: 'FOOTBALL',
|
||||
deletedAt: null,
|
||||
startTime: { gte: now, lte: end },
|
||||
league: { isActive: true, deletedAt: null },
|
||||
},
|
||||
include: {
|
||||
league: true,
|
||||
homeTeam: true,
|
||||
awayTeam: true,
|
||||
score: true,
|
||||
markets: this.playerMarketStatusInclude,
|
||||
},
|
||||
orderBy: [{ startTime: 'asc' }, { displayOrder: 'asc' }],
|
||||
take: limit,
|
||||
});
|
||||
|
||||
return Promise.all(
|
||||
matches.map((m) => this.enrichMatch(m, locale, { omitMarkets: true })),
|
||||
);
|
||||
}
|
||||
|
||||
async getMatchDetail(matchId: bigint, locale = 'en-US') {
|
||||
const match = await this.prisma.match.findFirst({
|
||||
where: {
|
||||
@@ -1483,6 +1519,24 @@ export class MatchesService {
|
||||
return this.enrichMatch(match, locale);
|
||||
}
|
||||
|
||||
async getSelectionsOdds(ids: bigint[]) {
|
||||
const selections = await this.prisma.marketSelection.findMany({
|
||||
where: { id: { in: ids } },
|
||||
include: { market: { include: { match: true } } },
|
||||
});
|
||||
|
||||
return selections.map((sel) => ({
|
||||
id: sel.id.toString(),
|
||||
odds: sel.odds.toString(),
|
||||
oddsVersion: sel.oddsVersion.toString(),
|
||||
status: sel.status,
|
||||
marketStatus: sel.market.status,
|
||||
marketShowOnPlayer: sel.market.showOnPlayer,
|
||||
matchStatus: sel.market.match.status,
|
||||
matchId: sel.market.match.id.toString(),
|
||||
}));
|
||||
}
|
||||
|
||||
async listOutrights(locale = 'en-US') {
|
||||
try {
|
||||
await syncWc2026OutrightMarket(this.prisma, { forceCanonical: false });
|
||||
|
||||
@@ -2,9 +2,11 @@ import { Module } from '@nestjs/common';
|
||||
import { DepositService } from './deposit.service';
|
||||
import { WalletModule } from '../ledger/wallet.module';
|
||||
import { AgentsModule } from '../agent/agents.module';
|
||||
import { PlayerMessagesModule } from '../player-messages/player-messages.module';
|
||||
import { SystemConfigModule } from '../../shared/config/system-config.module';
|
||||
|
||||
@Module({
|
||||
imports: [WalletModule, AgentsModule],
|
||||
imports: [WalletModule, AgentsModule, PlayerMessagesModule, SystemConfigModule],
|
||||
providers: [DepositService],
|
||||
exports: [DepositService],
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('DepositService', () => {
|
||||
},
|
||||
user: {
|
||||
findFirst: jest.fn(),
|
||||
findUnique: jest.fn(),
|
||||
},
|
||||
agentProfile: {
|
||||
findUnique: jest.fn(),
|
||||
@@ -38,12 +39,28 @@ describe('DepositService', () => {
|
||||
const credit = {
|
||||
recalculateUsedCredit: jest.fn(),
|
||||
};
|
||||
const playerMessages = {
|
||||
createDepositApprovedMessage: jest.fn(),
|
||||
createDepositRejectedMessage: jest.fn(),
|
||||
};
|
||||
const systemConfig = {
|
||||
getInboxNotifySettings: jest.fn().mockResolvedValue({
|
||||
inboxEnabled: true,
|
||||
deposit: true,
|
||||
}),
|
||||
};
|
||||
|
||||
let service: DepositService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
service = new DepositService(prisma as never, funds as never, credit as never);
|
||||
service = new DepositService(
|
||||
prisma as never,
|
||||
funds as never,
|
||||
credit as never,
|
||||
playerMessages as never,
|
||||
systemConfig as never,
|
||||
);
|
||||
tx.$queryRaw.mockResolvedValue([{ id: 1n }]);
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
@@ -57,8 +74,11 @@ describe('DepositService', () => {
|
||||
});
|
||||
tx.bet.findMany.mockResolvedValue([]);
|
||||
tx.user.findFirst.mockResolvedValue(null);
|
||||
tx.user.findUnique.mockResolvedValue({ locale: 'en-US' });
|
||||
tx.agentProfile.findUnique.mockResolvedValue(null);
|
||||
credit.recalculateUsedCredit.mockResolvedValue(undefined);
|
||||
playerMessages.createDepositApprovedMessage.mockResolvedValue({});
|
||||
playerMessages.createDepositRejectedMessage.mockResolvedValue({});
|
||||
});
|
||||
|
||||
it('posts approved deposits as player wallet transactions and refreshes parent credit', async () => {
|
||||
@@ -131,7 +151,7 @@ describe('DepositService', () => {
|
||||
});
|
||||
|
||||
it('uses approval cycle key when revoking a funded deposit for re-review', async () => {
|
||||
const reviewedAt = new Date('2026-06-15T14:08:48.000Z');
|
||||
const reviewedAt = new Date();
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
|
||||
@@ -7,6 +7,8 @@ import { FundsPostingService } from '../ledger/funds-posting.service';
|
||||
import { AgentCreditService } from '../agent/agent-credit.service';
|
||||
import { appBadRequest } from '../../shared/common/app-error';
|
||||
import { deleteUploadFileByUrl } from '../../shared/uploads/delete-upload-file';
|
||||
import { PlayerMessagesService } from '../player-messages/player-messages.service';
|
||||
import { SystemConfigService } from '../../shared/config/system-config.service';
|
||||
|
||||
function generateOrderNo(): string {
|
||||
const ts = Date.now().toString(36).toUpperCase();
|
||||
@@ -49,6 +51,8 @@ export class DepositService {
|
||||
private prisma: PrismaService,
|
||||
private funds: FundsPostingService,
|
||||
private credit: AgentCreditService,
|
||||
private playerMessages: PlayerMessagesService,
|
||||
private systemConfig: SystemConfigService,
|
||||
) {}
|
||||
|
||||
// ============ Payment Methods (Admin CRUD) ============
|
||||
@@ -254,6 +258,14 @@ export class DepositService {
|
||||
|
||||
// ============ Deposit Orders ============
|
||||
|
||||
private async getPlayerLocale(playerId: bigint, tx: Prisma.TransactionClient | PrismaService = this.prisma) {
|
||||
const user = await tx.user.findUnique({
|
||||
where: { id: playerId },
|
||||
select: { locale: true },
|
||||
});
|
||||
return user?.locale ?? 'en-US';
|
||||
}
|
||||
|
||||
private async recordDepositAudit(
|
||||
client: AuditLogWriter,
|
||||
data: {
|
||||
@@ -670,6 +682,10 @@ export class DepositService {
|
||||
};
|
||||
}
|
||||
|
||||
async countPendingDepositOrders(): Promise<number> {
|
||||
return this.prisma.depositOrder.count({ where: { status: 'PENDING' } });
|
||||
}
|
||||
|
||||
async approveDepositOrder(
|
||||
orderId: bigint,
|
||||
operatorId: bigint,
|
||||
@@ -722,6 +738,22 @@ export class DepositService {
|
||||
await this.credit.recalculateUsedCredit(parentAgentId, tx);
|
||||
}
|
||||
|
||||
const playerLocale = await this.getPlayerLocale(order.playerId, tx);
|
||||
const inboxNotify = await this.systemConfig.getInboxNotifySettings();
|
||||
if (inboxNotify.inboxEnabled && inboxNotify.deposit) {
|
||||
await this.playerMessages.createDepositApprovedMessage(
|
||||
order.playerId,
|
||||
{
|
||||
depositOrderId: orderId,
|
||||
orderNo: order.orderNo,
|
||||
amount: order.amount.toString(),
|
||||
approvedAmount: creditAmount.toString(),
|
||||
locale: playerLocale,
|
||||
},
|
||||
tx,
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
});
|
||||
}
|
||||
@@ -753,6 +785,18 @@ export class DepositService {
|
||||
remark: reason,
|
||||
});
|
||||
|
||||
const playerLocale = await this.getPlayerLocale(order.playerId);
|
||||
const inboxNotify = await this.systemConfig.getInboxNotifySettings();
|
||||
if (inboxNotify.inboxEnabled && inboxNotify.deposit) {
|
||||
await this.playerMessages.createDepositRejectedMessage(order.playerId, {
|
||||
depositOrderId: orderId,
|
||||
orderNo: order.orderNo,
|
||||
amount: order.amount.toString(),
|
||||
rejectReason: reason,
|
||||
locale: playerLocale,
|
||||
});
|
||||
}
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
|
||||
@@ -61,11 +61,12 @@ export class AdminStaffService {
|
||||
roleName: u.adminRole?.role?.name ?? null,
|
||||
lastLoginAt: u.auth?.lastLoginAt ?? null,
|
||||
createdAt: u.createdAt,
|
||||
visibleMenus: u.visibleMenus,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
async createStaff(data: { username: string; password: string; roleCode: string }) {
|
||||
async createStaff(data: { username: string; password: string; roleCode: string; visibleMenus?: string }) {
|
||||
const username = data.username.trim();
|
||||
if (!username) throw appBadRequest('USERNAME_REQUIRED');
|
||||
if (data.password.length < 8) throw appBadRequest('PASSWORD_MIN_LENGTH');
|
||||
@@ -86,6 +87,7 @@ export class AdminStaffService {
|
||||
userType: 'ADMIN',
|
||||
auth: { create: { passwordHash: hash } },
|
||||
adminRole: { create: { roleId: role.id } },
|
||||
visibleMenus: data.visibleMenus,
|
||||
},
|
||||
include: {
|
||||
adminRole: { include: { role: { select: { code: true, name: true } } } },
|
||||
@@ -99,12 +101,13 @@ export class AdminStaffService {
|
||||
status: user.status,
|
||||
role: user.adminRole?.role?.code ?? null,
|
||||
roleName: user.adminRole?.role?.name ?? null,
|
||||
visibleMenus: user.visibleMenus,
|
||||
};
|
||||
}
|
||||
|
||||
async updateStaff(
|
||||
staffId: bigint,
|
||||
data: { status?: string; roleCode?: string; password?: string },
|
||||
data: { status?: string; roleCode?: string; password?: string; visibleMenus?: string },
|
||||
) {
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: { id: staffId, userType: 'ADMIN', deletedAt: null },
|
||||
@@ -140,6 +143,13 @@ export class AdminStaffService {
|
||||
}
|
||||
}
|
||||
|
||||
if (data.visibleMenus !== undefined) {
|
||||
await this.prisma.user.update({
|
||||
where: { id: staffId },
|
||||
data: { visibleMenus: data.visibleMenus },
|
||||
});
|
||||
}
|
||||
|
||||
let plainPassword: string | undefined;
|
||||
if (data.password !== undefined) {
|
||||
if (data.password.length < 8) throw appBadRequest('PASSWORD_MIN_LENGTH');
|
||||
@@ -163,10 +173,40 @@ export class AdminStaffService {
|
||||
status: refreshed!.status,
|
||||
role: refreshed!.adminRole?.role?.code ?? null,
|
||||
roleName: refreshed!.adminRole?.role?.name ?? null,
|
||||
visibleMenus: refreshed!.visibleMenus,
|
||||
...(plainPassword ? { password: plainPassword } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
async deleteStaff(staffId: bigint, operatorId?: bigint) {
|
||||
if (operatorId && staffId === operatorId) {
|
||||
throw appBadRequest('CANNOT_DELETE_SELF');
|
||||
}
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: { id: staffId, userType: 'ADMIN', deletedAt: null },
|
||||
include: { adminRole: { include: { role: true } } },
|
||||
});
|
||||
if (!user) throw appNotFound('STAFF_NOT_FOUND');
|
||||
|
||||
if (user.adminRole?.role?.code === 'SUPER_ADMIN') {
|
||||
const superAdminCount = await this.prisma.user.count({
|
||||
where: {
|
||||
userType: 'ADMIN',
|
||||
deletedAt: null,
|
||||
adminRole: { role: { code: 'SUPER_ADMIN' } },
|
||||
},
|
||||
});
|
||||
if (superAdminCount <= 1) {
|
||||
throw appBadRequest('CANNOT_DELETE_LAST_SUPER_ADMIN');
|
||||
}
|
||||
}
|
||||
|
||||
return this.prisma.user.update({
|
||||
where: { id: staffId },
|
||||
data: { deletedAt: new Date(), status: 'DISABLED' },
|
||||
});
|
||||
}
|
||||
|
||||
async resetPlayerPassword(playerId: bigint, password?: string) {
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: { id: playerId, userType: 'PLAYER', deletedAt: null },
|
||||
|
||||
@@ -10,6 +10,8 @@ import { JwtAuthGuard } from './guards';
|
||||
import { jsonResponse } from '../../shared/common/filters';
|
||||
import { getClientIp } from '../../shared/common/client-ip.util';
|
||||
|
||||
import { PrismaService } from '../../shared/prisma/prisma.service';
|
||||
|
||||
@ApiTags('Auth')
|
||||
@Controller()
|
||||
export class AuthController {
|
||||
@@ -17,6 +19,7 @@ export class AuthController {
|
||||
private auth: AuthService,
|
||||
private invites: InvitesService,
|
||||
private systemConfig: SystemConfigService,
|
||||
private prisma: PrismaService,
|
||||
) {}
|
||||
|
||||
@Public()
|
||||
@@ -189,6 +192,15 @@ export class AuthController {
|
||||
inviteCode = (await this.auth.getInviteInfo(userId)).inviteCode;
|
||||
}
|
||||
|
||||
let visibleMenus: string | null = null;
|
||||
if (userType === 'ADMIN') {
|
||||
const userDb = await this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { visibleMenus: true },
|
||||
});
|
||||
visibleMenus = userDb?.visibleMenus ?? null;
|
||||
}
|
||||
|
||||
return jsonResponse({
|
||||
id: userId.toString(),
|
||||
username,
|
||||
@@ -200,6 +212,7 @@ export class AuthController {
|
||||
maxAgentLevel,
|
||||
canManageSubAgents,
|
||||
inviteCode,
|
||||
visibleMenus,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ export class AuthService {
|
||||
locale: user.locale,
|
||||
role: user.adminRole?.role?.code,
|
||||
agentLevel: user.userType === 'AGENT' ? user.agentLevel : null,
|
||||
visibleMenus: user.visibleMenus,
|
||||
...(adminPermissions ? { permissions: adminPermissions } : {}),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,9 +3,10 @@ import { UsersService } from './users.service';
|
||||
import { AdminStaffService } from './admin-staff.service';
|
||||
import { AgentsModule } from '../agent/agents.module';
|
||||
import { CashbackModule } from '../operations/cashback/cashback.module';
|
||||
import { PresenceModule } from '../presence/presence.module';
|
||||
|
||||
@Module({
|
||||
imports: [AgentsModule, CashbackModule],
|
||||
imports: [AgentsModule, CashbackModule, PresenceModule],
|
||||
providers: [UsersService, AdminStaffService],
|
||||
exports: [UsersService, AdminStaffService],
|
||||
})
|
||||
|
||||
@@ -5,6 +5,7 @@ import { PrismaService } from '../../shared/prisma/prisma.service';
|
||||
import { SystemConfigService } from '../../shared/config/system-config.service';
|
||||
import { AgentsService } from '../agent/agents.service';
|
||||
import { CashbackService } from '../operations/cashback/cashback.service';
|
||||
import { PresenceService } from '../presence/presence.service';
|
||||
import { appBadRequest, appForbidden, appNotFound } from '../../shared/common/app-error';
|
||||
import { Decimal } from '@prisma/client/runtime/library';
|
||||
|
||||
@@ -22,6 +23,7 @@ export class UsersService {
|
||||
private agents: AgentsService,
|
||||
private systemConfig: SystemConfigService,
|
||||
private cashback: CashbackService,
|
||||
private presence: PresenceService,
|
||||
) {}
|
||||
|
||||
private buildAffiliationAgents(
|
||||
@@ -297,14 +299,19 @@ export class UsersService {
|
||||
|
||||
const betMap = await this.loadBetStatsMap(rows.map((r) => r.id));
|
||||
const affiliationMap = await this.buildAffiliationChainMap(rows.map((r) => r.parentId));
|
||||
const onlineSet = await this.presence.filterOnlineIds(rows.map((r) => r.id));
|
||||
return {
|
||||
items: rows.map((u) =>
|
||||
this.formatPlayerRow(
|
||||
items: rows.map((u) => {
|
||||
const row = this.formatPlayerRow(
|
||||
u,
|
||||
betMap.get(u.id.toString()),
|
||||
u.parentId ? affiliationMap.get(u.parentId.toString()) : undefined,
|
||||
),
|
||||
),
|
||||
);
|
||||
return {
|
||||
...row,
|
||||
isOnline: onlineSet.has(row.id),
|
||||
};
|
||||
}),
|
||||
total,
|
||||
page,
|
||||
pageSize,
|
||||
|
||||
@@ -222,6 +222,9 @@ export class ContentService {
|
||||
id: item.id.toString(),
|
||||
contentType: item.contentType,
|
||||
sortOrder: item.sortOrder,
|
||||
createdAt: item.createdAt.toISOString(),
|
||||
linkType: item.linkType,
|
||||
linkTarget: item.linkTarget,
|
||||
translation: tr,
|
||||
};
|
||||
});
|
||||
@@ -252,6 +255,7 @@ export class ContentService {
|
||||
id: item.id.toString(),
|
||||
contentType: item.contentType,
|
||||
sortOrder: item.sortOrder,
|
||||
createdAt: item.createdAt.toISOString(),
|
||||
linkType: item.linkType,
|
||||
linkTarget: item.linkTarget,
|
||||
translation: t,
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PlayerMessagesService } from './player-messages.service';
|
||||
|
||||
@Module({
|
||||
providers: [PlayerMessagesService],
|
||||
exports: [PlayerMessagesService],
|
||||
})
|
||||
export class PlayerMessagesModule {}
|
||||
@@ -0,0 +1,165 @@
|
||||
import { PlayerMessagesService } from './player-messages.service';
|
||||
|
||||
describe('PlayerMessagesService', () => {
|
||||
const prisma = {
|
||||
playerMessage: {
|
||||
create: jest.fn(),
|
||||
findMany: jest.fn(),
|
||||
count: jest.fn(),
|
||||
findFirst: jest.fn(),
|
||||
update: jest.fn(),
|
||||
updateMany: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
deleteMany: jest.fn(),
|
||||
createMany: jest.fn(),
|
||||
},
|
||||
user: {
|
||||
findUnique: jest.fn(),
|
||||
findMany: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
let service: PlayerMessagesService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
service = new PlayerMessagesService(prisma as never);
|
||||
});
|
||||
|
||||
it('creates localized deposit approved messages', async () => {
|
||||
prisma.playerMessage.create.mockResolvedValue({
|
||||
id: 1n,
|
||||
type: 'DEPOSIT_APPROVED',
|
||||
title: '充值已到账',
|
||||
body: 'body',
|
||||
payload: { orderNo: 'DEP-1' },
|
||||
readAt: null,
|
||||
createdAt: new Date('2026-06-17T10:00:00.000Z'),
|
||||
});
|
||||
|
||||
const result = await service.createDepositApprovedMessage(7n, {
|
||||
depositOrderId: 10n,
|
||||
orderNo: 'DEP-1',
|
||||
amount: '100',
|
||||
approvedAmount: '100',
|
||||
locale: 'zh-CN',
|
||||
});
|
||||
|
||||
expect(prisma.playerMessage.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
userId: 7n,
|
||||
type: 'DEPOSIT_APPROVED',
|
||||
title: '充值已到账',
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(result.type).toBe('DEPOSIT_APPROVED');
|
||||
expect(result.isRead).toBe(false);
|
||||
});
|
||||
|
||||
it('returns paginated inbox with unread count', async () => {
|
||||
prisma.playerMessage.findMany.mockResolvedValue([
|
||||
{
|
||||
id: 2n,
|
||||
type: 'DEPOSIT_REJECTED',
|
||||
title: 'Deposit rejected',
|
||||
body: 'Rejected',
|
||||
payload: null,
|
||||
readAt: null,
|
||||
createdAt: new Date('2026-06-17T11:00:00.000Z'),
|
||||
},
|
||||
]);
|
||||
prisma.playerMessage.count.mockResolvedValueOnce(1).mockResolvedValueOnce(1);
|
||||
|
||||
const result = await service.listForPlayer(7n, 1, 20);
|
||||
|
||||
expect(result.items).toHaveLength(1);
|
||||
expect(result.unreadCount).toBe(1);
|
||||
expect(result.total).toBe(1);
|
||||
});
|
||||
|
||||
it('deletes a single message for the player', async () => {
|
||||
prisma.playerMessage.findFirst.mockResolvedValue({
|
||||
id: 3n,
|
||||
type: 'DEPOSIT_APPROVED',
|
||||
title: 'Deposit approved',
|
||||
body: 'body',
|
||||
payload: null,
|
||||
readAt: null,
|
||||
createdAt: new Date('2026-06-17T12:00:00.000Z'),
|
||||
});
|
||||
prisma.playerMessage.delete.mockResolvedValue({ id: 3n });
|
||||
|
||||
const result = await service.deleteForPlayer(7n, 3n);
|
||||
|
||||
expect(prisma.playerMessage.delete).toHaveBeenCalledWith({ where: { id: 3n } });
|
||||
expect(result).toEqual({ deleted: true, wasUnread: true });
|
||||
});
|
||||
|
||||
it('deletes all messages for the player', async () => {
|
||||
prisma.playerMessage.deleteMany.mockResolvedValue({ count: 4 });
|
||||
|
||||
const result = await service.deleteAllForPlayer(7n);
|
||||
|
||||
expect(prisma.playerMessage.deleteMany).toHaveBeenCalledWith({ where: { userId: 7n } });
|
||||
expect(result).toEqual({ deleted: 4 });
|
||||
});
|
||||
|
||||
it('broadcasts banner promotion inbox messages to active players', async () => {
|
||||
prisma.user.findMany.mockResolvedValue([
|
||||
{ id: 10n, locale: 'zh-CN', preferences: { locale: 'zh-CN' } },
|
||||
{ id: 11n, locale: 'en-US', preferences: null },
|
||||
]);
|
||||
prisma.playerMessage.createMany.mockResolvedValue({ count: 2 });
|
||||
|
||||
const count = await service.broadcastBannerPromotion({
|
||||
contentId: 99n,
|
||||
translations: [
|
||||
{ locale: 'zh-CN', title: '夏季活动', body: '<p>限时优惠</p>' },
|
||||
{ locale: 'en-US', title: 'Summer promo', body: '' },
|
||||
],
|
||||
});
|
||||
|
||||
expect(count).toBe(2);
|
||||
expect(prisma.playerMessage.createMany).toHaveBeenCalledWith({
|
||||
data: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
userId: 10n,
|
||||
type: 'BANNER_PROMO',
|
||||
title: '夏季活动',
|
||||
body: '限时优惠',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
userId: 11n,
|
||||
type: 'BANNER_PROMO',
|
||||
title: 'Summer promo',
|
||||
}),
|
||||
]),
|
||||
});
|
||||
});
|
||||
|
||||
it('broadcasts announcement promotion inbox messages to active players', async () => {
|
||||
prisma.user.findMany.mockResolvedValue([
|
||||
{ id: 10n, locale: 'zh-CN', preferences: { locale: 'zh-CN' } },
|
||||
]);
|
||||
prisma.playerMessage.createMany.mockResolvedValue({ count: 1 });
|
||||
|
||||
const count = await service.broadcastAnnouncementPromotion({
|
||||
contentId: 100n,
|
||||
translations: [{ locale: 'zh-CN', title: '维护通知', body: '系统维护中' }],
|
||||
});
|
||||
|
||||
expect(count).toBe(1);
|
||||
expect(prisma.playerMessage.createMany).toHaveBeenCalledWith({
|
||||
data: [
|
||||
expect.objectContaining({
|
||||
userId: 10n,
|
||||
type: 'ANNOUNCEMENT_PROMO',
|
||||
title: '维护通知',
|
||||
body: '系统维护中',
|
||||
}),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
437
apps/api/src/domains/player-messages/player-messages.service.ts
Normal file
437
apps/api/src/domains/player-messages/player-messages.service.ts
Normal file
@@ -0,0 +1,437 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../../shared/prisma/prisma.service';
|
||||
import { appNotFound } from '../../shared/common/app-error';
|
||||
|
||||
export type PlayerMessageType =
|
||||
| 'DEPOSIT_APPROVED'
|
||||
| 'DEPOSIT_REJECTED'
|
||||
| 'BANNER_PROMO'
|
||||
| 'ANNOUNCEMENT_PROMO';
|
||||
|
||||
export type DepositMessagePayload = {
|
||||
depositOrderId: string;
|
||||
orderNo: string;
|
||||
amount: string;
|
||||
approvedAmount?: string | null;
|
||||
rejectReason?: string | null;
|
||||
};
|
||||
|
||||
export type BannerPromoPayload = {
|
||||
contentId: string;
|
||||
};
|
||||
|
||||
type ContentTranslationLike = {
|
||||
locale: string;
|
||||
title?: string | null;
|
||||
body?: string | null;
|
||||
};
|
||||
|
||||
const SUPPORTED_LOCALES = ['zh-CN', 'en-US', 'ms-MY'] as const;
|
||||
|
||||
const BANNER_PROMO_DEFAULT_TITLE: Record<string, string> = {
|
||||
'zh-CN': '新推广活动',
|
||||
'en-US': 'New promotion',
|
||||
'ms-MY': 'Promosi baharu',
|
||||
};
|
||||
|
||||
const ANNOUNCEMENT_PROMO_DEFAULT_TITLE: Record<string, string> = {
|
||||
'zh-CN': '新公告',
|
||||
'en-US': 'New announcement',
|
||||
'ms-MY': 'Pengumuman baharu',
|
||||
};
|
||||
|
||||
type MessageTemplate = {
|
||||
title: string;
|
||||
body: (payload: DepositMessagePayload) => string;
|
||||
};
|
||||
|
||||
const MESSAGE_TEMPLATES: Record<
|
||||
Exclude<PlayerMessageType, 'BANNER_PROMO' | 'ANNOUNCEMENT_PROMO'>,
|
||||
Record<string, MessageTemplate>
|
||||
> = {
|
||||
DEPOSIT_APPROVED: {
|
||||
'zh-CN': {
|
||||
title: '充值已到账',
|
||||
body: (p) =>
|
||||
`您的充值订单 ${p.orderNo} 已审核通过,申请金额 ${p.amount},到账金额 ${p.approvedAmount ?? p.amount}。`,
|
||||
},
|
||||
'en-US': {
|
||||
title: 'Deposit approved',
|
||||
body: (p) =>
|
||||
`Your deposit order ${p.orderNo} has been approved. Requested ${p.amount}, credited ${p.approvedAmount ?? p.amount}.`,
|
||||
},
|
||||
'ms-MY': {
|
||||
title: 'Deposit diluluskan',
|
||||
body: (p) =>
|
||||
`Pesanan deposit ${p.orderNo} telah diluluskan. Diminta ${p.amount}, dikreditkan ${p.approvedAmount ?? p.amount}.`,
|
||||
},
|
||||
},
|
||||
DEPOSIT_REJECTED: {
|
||||
'zh-CN': {
|
||||
title: '充值未通过',
|
||||
body: (p) => {
|
||||
const reason = p.rejectReason?.trim();
|
||||
return reason
|
||||
? `您的充值订单 ${p.orderNo}(${p.amount})未通过审核。原因:${reason}`
|
||||
: `您的充值订单 ${p.orderNo}(${p.amount})未通过审核。`;
|
||||
},
|
||||
},
|
||||
'en-US': {
|
||||
title: 'Deposit rejected',
|
||||
body: (p) => {
|
||||
const reason = p.rejectReason?.trim();
|
||||
return reason
|
||||
? `Your deposit order ${p.orderNo} (${p.amount}) was rejected. Reason: ${reason}`
|
||||
: `Your deposit order ${p.orderNo} (${p.amount}) was rejected.`;
|
||||
},
|
||||
},
|
||||
'ms-MY': {
|
||||
title: 'Deposit ditolak',
|
||||
body: (p) => {
|
||||
const reason = p.rejectReason?.trim();
|
||||
return reason
|
||||
? `Pesanan deposit ${p.orderNo} (${p.amount}) ditolak. Sebab: ${reason}`
|
||||
: `Pesanan deposit ${p.orderNo} (${p.amount}) ditolak.`;
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
function resolveLocale(locale?: string | null): string {
|
||||
const value = locale?.trim();
|
||||
if (value && SUPPORTED_LOCALES.includes(value as (typeof SUPPORTED_LOCALES)[number])) {
|
||||
return value;
|
||||
}
|
||||
return 'en-US';
|
||||
}
|
||||
|
||||
function pickContentTranslation<T extends { locale: string }>(
|
||||
translations: T[],
|
||||
locale: string,
|
||||
): T | undefined {
|
||||
const chain = [locale, 'en-US', 'zh-CN', 'ms-MY'];
|
||||
for (const loc of chain) {
|
||||
const hit = translations.find((tr) => tr.locale === loc);
|
||||
if (hit) return hit;
|
||||
}
|
||||
return translations[0];
|
||||
}
|
||||
|
||||
function stripHtml(value: string): string {
|
||||
return value.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
function buildBannerPromoFallbackBody(locale: string, title: string): string {
|
||||
if (locale === 'zh-CN') return `「${title}」已上线,请到首页查看详情。`;
|
||||
if (locale === 'ms-MY') return `"${title}" kini tersedia. Lihat butiran di halaman utama.`;
|
||||
return `"${title}" is now live. View details on the home page.`;
|
||||
}
|
||||
|
||||
function buildAnnouncementPromoFallbackBody(locale: string, title: string): string {
|
||||
if (locale === 'zh-CN') return `公告「${title}」已发布,请及时查看。`;
|
||||
if (locale === 'ms-MY') return `Pengumuman "${title}" telah diterbitkan. Sila semak.`;
|
||||
return `Announcement "${title}" is published. Please check it out.`;
|
||||
}
|
||||
|
||||
function buildBannerPromoMessage(
|
||||
locale: string | null | undefined,
|
||||
contentId: bigint,
|
||||
translations: ContentTranslationLike[],
|
||||
) {
|
||||
const resolvedLocale = resolveLocale(locale);
|
||||
const tr = pickContentTranslation(translations, resolvedLocale);
|
||||
const title =
|
||||
tr?.title?.trim() ||
|
||||
BANNER_PROMO_DEFAULT_TITLE[resolvedLocale] ||
|
||||
BANNER_PROMO_DEFAULT_TITLE['en-US'];
|
||||
const rawBody = tr?.body?.trim() ? stripHtml(tr.body) : '';
|
||||
const body = rawBody || buildBannerPromoFallbackBody(resolvedLocale, title);
|
||||
const payload: BannerPromoPayload = { contentId: contentId.toString() };
|
||||
return {
|
||||
type: 'BANNER_PROMO' as const,
|
||||
title,
|
||||
body,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
function buildAnnouncementPromoMessage(
|
||||
locale: string | null | undefined,
|
||||
contentId: bigint,
|
||||
translations: ContentTranslationLike[],
|
||||
) {
|
||||
const resolvedLocale = resolveLocale(locale);
|
||||
const tr = pickContentTranslation(translations, resolvedLocale);
|
||||
const title =
|
||||
tr?.title?.trim() ||
|
||||
(tr?.body?.trim() ? tr.body.trim().slice(0, 40) : '') ||
|
||||
ANNOUNCEMENT_PROMO_DEFAULT_TITLE[resolvedLocale] ||
|
||||
ANNOUNCEMENT_PROMO_DEFAULT_TITLE['en-US'];
|
||||
const rawBody = tr?.body?.trim() ?? '';
|
||||
const body = rawBody || buildAnnouncementPromoFallbackBody(resolvedLocale, title);
|
||||
const payload: BannerPromoPayload = { contentId: contentId.toString() };
|
||||
return {
|
||||
type: 'ANNOUNCEMENT_PROMO' as const,
|
||||
title,
|
||||
body,
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
function mapMessageRow(row: {
|
||||
id: bigint;
|
||||
type: string;
|
||||
title: string;
|
||||
body: string;
|
||||
payload: Prisma.JsonValue;
|
||||
readAt: Date | null;
|
||||
createdAt: Date;
|
||||
}) {
|
||||
return {
|
||||
id: row.id.toString(),
|
||||
type: row.type,
|
||||
title: row.title,
|
||||
body: row.body,
|
||||
payload: row.payload ?? null,
|
||||
readAt: row.readAt?.toISOString() ?? null,
|
||||
createdAt: row.createdAt.toISOString(),
|
||||
isRead: row.readAt != null,
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class PlayerMessagesService {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
private buildDepositMessage(
|
||||
type: Exclude<PlayerMessageType, 'BANNER_PROMO' | 'ANNOUNCEMENT_PROMO'>,
|
||||
locale: string | null | undefined,
|
||||
payload: DepositMessagePayload,
|
||||
) {
|
||||
const resolvedLocale = resolveLocale(locale);
|
||||
const templates = MESSAGE_TEMPLATES[type];
|
||||
const template = templates[resolvedLocale] ?? templates['en-US'];
|
||||
return {
|
||||
type,
|
||||
title: template.title,
|
||||
body: template.body(payload),
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
async createDepositApprovedMessage(
|
||||
userId: bigint,
|
||||
data: {
|
||||
depositOrderId: bigint;
|
||||
orderNo: string;
|
||||
amount: string;
|
||||
approvedAmount: string;
|
||||
locale?: string | null;
|
||||
},
|
||||
client: Prisma.TransactionClient | PrismaService = this.prisma,
|
||||
) {
|
||||
const payload: DepositMessagePayload = {
|
||||
depositOrderId: data.depositOrderId.toString(),
|
||||
orderNo: data.orderNo,
|
||||
amount: data.amount,
|
||||
approvedAmount: data.approvedAmount,
|
||||
};
|
||||
const content = this.buildDepositMessage('DEPOSIT_APPROVED', data.locale, payload);
|
||||
const row = await client.playerMessage.create({
|
||||
data: {
|
||||
userId,
|
||||
type: content.type,
|
||||
title: content.title,
|
||||
body: content.body,
|
||||
payload: content.payload as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
return mapMessageRow(row);
|
||||
}
|
||||
|
||||
async createDepositRejectedMessage(
|
||||
userId: bigint,
|
||||
data: {
|
||||
depositOrderId: bigint;
|
||||
orderNo: string;
|
||||
amount: string;
|
||||
rejectReason?: string | null;
|
||||
locale?: string | null;
|
||||
},
|
||||
client: Prisma.TransactionClient | PrismaService = this.prisma,
|
||||
) {
|
||||
const payload: DepositMessagePayload = {
|
||||
depositOrderId: data.depositOrderId.toString(),
|
||||
orderNo: data.orderNo,
|
||||
amount: data.amount,
|
||||
rejectReason: data.rejectReason ?? null,
|
||||
};
|
||||
const content = this.buildDepositMessage('DEPOSIT_REJECTED', data.locale, payload);
|
||||
const row = await client.playerMessage.create({
|
||||
data: {
|
||||
userId,
|
||||
type: content.type,
|
||||
title: content.title,
|
||||
body: content.body,
|
||||
payload: content.payload as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
return mapMessageRow(row);
|
||||
}
|
||||
|
||||
async broadcastBannerPromotion(data: {
|
||||
contentId: bigint;
|
||||
translations: ContentTranslationLike[];
|
||||
}) {
|
||||
const players = await this.prisma.user.findMany({
|
||||
where: { userType: 'PLAYER', deletedAt: null, status: 'ACTIVE' },
|
||||
select: {
|
||||
id: true,
|
||||
locale: true,
|
||||
preferences: { select: { locale: true } },
|
||||
},
|
||||
});
|
||||
|
||||
if (!players.length) return 0;
|
||||
|
||||
const rows = players.map((player) => {
|
||||
const playerLocale = player.preferences?.locale ?? player.locale;
|
||||
const content = buildBannerPromoMessage(
|
||||
playerLocale,
|
||||
data.contentId,
|
||||
data.translations,
|
||||
);
|
||||
return {
|
||||
userId: player.id,
|
||||
type: content.type,
|
||||
title: content.title,
|
||||
body: content.body,
|
||||
payload: content.payload as Prisma.InputJsonValue,
|
||||
};
|
||||
});
|
||||
|
||||
const batchSize = 200;
|
||||
for (let i = 0; i < rows.length; i += batchSize) {
|
||||
await this.prisma.playerMessage.createMany({ data: rows.slice(i, i + batchSize) });
|
||||
}
|
||||
|
||||
return rows.length;
|
||||
}
|
||||
|
||||
async broadcastAnnouncementPromotion(data: {
|
||||
contentId: bigint;
|
||||
translations: ContentTranslationLike[];
|
||||
}) {
|
||||
const players = await this.prisma.user.findMany({
|
||||
where: { userType: 'PLAYER', deletedAt: null, status: 'ACTIVE' },
|
||||
select: {
|
||||
id: true,
|
||||
locale: true,
|
||||
preferences: { select: { locale: true } },
|
||||
},
|
||||
});
|
||||
|
||||
if (!players.length) return 0;
|
||||
|
||||
const rows = players.map((player) => {
|
||||
const playerLocale = player.preferences?.locale ?? player.locale;
|
||||
const content = buildAnnouncementPromoMessage(
|
||||
playerLocale,
|
||||
data.contentId,
|
||||
data.translations,
|
||||
);
|
||||
return {
|
||||
userId: player.id,
|
||||
type: content.type,
|
||||
title: content.title,
|
||||
body: content.body,
|
||||
payload: content.payload as Prisma.InputJsonValue,
|
||||
};
|
||||
});
|
||||
|
||||
const batchSize = 200;
|
||||
for (let i = 0; i < rows.length; i += batchSize) {
|
||||
await this.prisma.playerMessage.createMany({ data: rows.slice(i, i + batchSize) });
|
||||
}
|
||||
|
||||
return rows.length;
|
||||
}
|
||||
|
||||
async listForPlayer(userId: bigint, page = 1, pageSize = 20) {
|
||||
const safePage = Math.max(1, page);
|
||||
const safePageSize = Math.min(50, Math.max(1, pageSize));
|
||||
const skip = (safePage - 1) * safePageSize;
|
||||
const where = { userId };
|
||||
|
||||
const [rows, total, unreadCount] = await Promise.all([
|
||||
this.prisma.playerMessage.findMany({
|
||||
where,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
skip,
|
||||
take: safePageSize,
|
||||
}),
|
||||
this.prisma.playerMessage.count({ where }),
|
||||
this.prisma.playerMessage.count({ where: { ...where, readAt: null } }),
|
||||
]);
|
||||
|
||||
return {
|
||||
items: rows.map(mapMessageRow),
|
||||
total,
|
||||
unreadCount,
|
||||
page: safePage,
|
||||
pageSize: safePageSize,
|
||||
};
|
||||
}
|
||||
|
||||
async getForPlayer(userId: bigint, messageId: bigint) {
|
||||
const row = await this.prisma.playerMessage.findFirst({
|
||||
where: { id: messageId, userId },
|
||||
});
|
||||
if (!row) throw appNotFound('MESSAGE_NOT_FOUND');
|
||||
return mapMessageRow(row);
|
||||
}
|
||||
|
||||
async markRead(userId: bigint, messageId: bigint) {
|
||||
const row = await this.prisma.playerMessage.findFirst({
|
||||
where: { id: messageId, userId },
|
||||
});
|
||||
if (!row) throw appNotFound('MESSAGE_NOT_FOUND');
|
||||
if (row.readAt) return mapMessageRow(row);
|
||||
|
||||
const updated = await this.prisma.playerMessage.update({
|
||||
where: { id: messageId },
|
||||
data: { readAt: new Date() },
|
||||
});
|
||||
return mapMessageRow(updated);
|
||||
}
|
||||
|
||||
async markAllRead(userId: bigint) {
|
||||
const result = await this.prisma.playerMessage.updateMany({
|
||||
where: { userId, readAt: null },
|
||||
data: { readAt: new Date() },
|
||||
});
|
||||
return { updated: result.count };
|
||||
}
|
||||
|
||||
async getUnreadCount(userId: bigint) {
|
||||
const unreadCount = await this.prisma.playerMessage.count({
|
||||
where: { userId, readAt: null },
|
||||
});
|
||||
return { unreadCount };
|
||||
}
|
||||
|
||||
async deleteForPlayer(userId: bigint, messageId: bigint) {
|
||||
const row = await this.prisma.playerMessage.findFirst({
|
||||
where: { id: messageId, userId },
|
||||
});
|
||||
if (!row) throw appNotFound('MESSAGE_NOT_FOUND');
|
||||
await this.prisma.playerMessage.delete({ where: { id: messageId } });
|
||||
return { deleted: true, wasUnread: row.readAt == null };
|
||||
}
|
||||
|
||||
async deleteAllForPlayer(userId: bigint) {
|
||||
const result = await this.prisma.playerMessage.deleteMany({ where: { userId } });
|
||||
return { deleted: result.count };
|
||||
}
|
||||
}
|
||||
10
apps/api/src/domains/presence/presence.module.ts
Normal file
10
apps/api/src/domains/presence/presence.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { RedisModule } from '../../shared/redis/redis.module';
|
||||
import { PresenceService } from './presence.service';
|
||||
|
||||
@Module({
|
||||
imports: [RedisModule],
|
||||
providers: [PresenceService],
|
||||
exports: [PresenceService],
|
||||
})
|
||||
export class PresenceModule {}
|
||||
70
apps/api/src/domains/presence/presence.service.spec.ts
Normal file
70
apps/api/src/domains/presence/presence.service.spec.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { PresenceService } from './presence.service';
|
||||
|
||||
describe('PresenceService', () => {
|
||||
const pipeline = {
|
||||
exists: jest.fn().mockReturnThis(),
|
||||
exec: jest.fn(),
|
||||
};
|
||||
|
||||
const redis = {
|
||||
set: jest.fn(),
|
||||
exists: jest.fn(),
|
||||
raw: {
|
||||
scan: jest.fn(),
|
||||
pipeline: jest.fn(() => pipeline),
|
||||
},
|
||||
};
|
||||
|
||||
let service: PresenceService;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
service = new PresenceService(redis as never);
|
||||
});
|
||||
|
||||
it('touches player key with 120s TTL', async () => {
|
||||
await service.touch(42n);
|
||||
expect(redis.set).toHaveBeenCalledWith('presence:player:42', '1', 120);
|
||||
});
|
||||
|
||||
it('checks single player online status', async () => {
|
||||
redis.exists.mockResolvedValue(true);
|
||||
await expect(service.isOnline(7n)).resolves.toBe(true);
|
||||
expect(redis.exists).toHaveBeenCalledWith('presence:player:7');
|
||||
});
|
||||
|
||||
it('counts online keys via SCAN', async () => {
|
||||
redis.raw.scan
|
||||
.mockResolvedValueOnce(['1', ['presence:player:1', 'presence:player:2']])
|
||||
.mockResolvedValueOnce(['0', ['presence:player:3']]);
|
||||
|
||||
await expect(service.getOnlineCount()).resolves.toBe(3);
|
||||
expect(redis.raw.scan).toHaveBeenCalledWith(
|
||||
'0',
|
||||
'MATCH',
|
||||
'presence:player:*',
|
||||
'COUNT',
|
||||
200,
|
||||
);
|
||||
});
|
||||
|
||||
it('filters online ids with pipeline exists', async () => {
|
||||
pipeline.exec.mockResolvedValue([
|
||||
[null, 1],
|
||||
[null, 0],
|
||||
[null, 1],
|
||||
]);
|
||||
|
||||
const result = await service.filterOnlineIds([10n, 20n, 30n]);
|
||||
expect(result).toEqual(new Set(['10', '30']));
|
||||
expect(pipeline.exists).toHaveBeenCalledTimes(3);
|
||||
expect(pipeline.exists).toHaveBeenNthCalledWith(1, 'presence:player:10');
|
||||
expect(pipeline.exists).toHaveBeenNthCalledWith(2, 'presence:player:20');
|
||||
expect(pipeline.exists).toHaveBeenNthCalledWith(3, 'presence:player:30');
|
||||
});
|
||||
|
||||
it('returns empty set when no ids provided', async () => {
|
||||
await expect(service.filterOnlineIds([])).resolves.toEqual(new Set());
|
||||
expect(redis.raw.pipeline).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
57
apps/api/src/domains/presence/presence.service.ts
Normal file
57
apps/api/src/domains/presence/presence.service.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { RedisService } from '../../shared/redis/redis.service';
|
||||
|
||||
const TTL_SECONDS = 120;
|
||||
const KEY_PREFIX = 'presence:player:';
|
||||
|
||||
function keyFor(userId: bigint): string {
|
||||
return `${KEY_PREFIX}${userId.toString()}`;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class PresenceService {
|
||||
constructor(private readonly redis: RedisService) {}
|
||||
|
||||
async touch(userId: bigint): Promise<void> {
|
||||
await this.redis.set(keyFor(userId), '1', TTL_SECONDS);
|
||||
}
|
||||
|
||||
async isOnline(userId: bigint): Promise<boolean> {
|
||||
return this.redis.exists(keyFor(userId));
|
||||
}
|
||||
|
||||
async getOnlineCount(): Promise<number> {
|
||||
let cursor = '0';
|
||||
let count = 0;
|
||||
do {
|
||||
const [next, keys] = await this.redis.raw.scan(
|
||||
cursor,
|
||||
'MATCH',
|
||||
`${KEY_PREFIX}*`,
|
||||
'COUNT',
|
||||
200,
|
||||
);
|
||||
cursor = next;
|
||||
count += keys.length;
|
||||
} while (cursor !== '0');
|
||||
return count;
|
||||
}
|
||||
|
||||
async filterOnlineIds(ids: bigint[]): Promise<Set<string>> {
|
||||
const online = new Set<string>();
|
||||
if (ids.length === 0) return online;
|
||||
|
||||
const pipeline = this.redis.raw.pipeline();
|
||||
for (const id of ids) {
|
||||
pipeline.exists(keyFor(id));
|
||||
}
|
||||
const results = await pipeline.exec();
|
||||
ids.forEach((id, index) => {
|
||||
const entry = results?.[index];
|
||||
if (!entry) return;
|
||||
const [err, value] = entry;
|
||||
if (!err && value === 1) online.add(id.toString());
|
||||
});
|
||||
return online;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,17 @@ export const AGENT_MAX_LEVEL = 'agent.max_level';
|
||||
export const AGENT_DEFAULT_SUB_CREDIT_RATIO = 'agent.default_sub_credit_ratio';
|
||||
export const CASHBACK_PLATFORM_DIRECT_RATE = 'cashback.platform_direct_rate';
|
||||
export const CASHBACK_ADMIN_INVITE_RATE = 'cashback.admin_invite_rate';
|
||||
export const INBOX_NOTIFY_DEPOSIT = 'inbox.notify.deposit';
|
||||
export const INBOX_FEATURE_ENABLED = 'inbox.feature_enabled';
|
||||
export const INBOX_NOTIFY_BANNER = 'inbox.notify.banner';
|
||||
export const INBOX_NOTIFY_ANNOUNCEMENT = 'inbox.notify.announcement';
|
||||
|
||||
export type InboxNotifySettings = {
|
||||
/** 玩家端是否展示站内邮箱(关闭后入口直达客服) */
|
||||
inboxEnabled: boolean;
|
||||
/** 充值审核通过/拒绝时发送站内信 */
|
||||
deposit: boolean;
|
||||
};
|
||||
|
||||
export type PlatformDirectCashbackSettings = {
|
||||
/** 平台直属玩家默认返水比例(小数,0.01 = 1%) */
|
||||
@@ -222,4 +233,34 @@ export class SystemConfigService {
|
||||
}
|
||||
return this.getPlatformDirectCashbackSettings();
|
||||
}
|
||||
|
||||
async getInboxFeatureEnabled(): Promise<boolean> {
|
||||
return this.getBoolean(INBOX_FEATURE_ENABLED, true);
|
||||
}
|
||||
|
||||
async getInboxNotifySettings(): Promise<InboxNotifySettings> {
|
||||
const [inboxEnabled, deposit] = await Promise.all([
|
||||
this.getBoolean(INBOX_FEATURE_ENABLED, true),
|
||||
this.getBoolean(INBOX_NOTIFY_DEPOSIT, true),
|
||||
]);
|
||||
return { inboxEnabled, deposit };
|
||||
}
|
||||
|
||||
async updateInboxNotifySettings(data: Partial<InboxNotifySettings>) {
|
||||
if (data.inboxEnabled !== undefined) {
|
||||
await this.setBoolean(
|
||||
INBOX_FEATURE_ENABLED,
|
||||
data.inboxEnabled,
|
||||
'玩家端是否开启站内邮箱功能',
|
||||
);
|
||||
}
|
||||
if (data.deposit !== undefined) {
|
||||
await this.setBoolean(
|
||||
INBOX_NOTIFY_DEPOSIT,
|
||||
data.deposit,
|
||||
'充值审核结果是否通过站内邮箱通知玩家',
|
||||
);
|
||||
}
|
||||
return this.getInboxNotifySettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ items: string[]; embedded?: boolean }>(),
|
||||
defineProps<{ items: string[]; targetId?: string; embedded?: boolean }>(),
|
||||
{ embedded: false },
|
||||
);
|
||||
|
||||
const detailTo = computed(() =>
|
||||
props.targetId ? `/announcements/${props.targetId}` : '/announcements',
|
||||
);
|
||||
|
||||
const text = computed(() => {
|
||||
const list = props.items.filter(Boolean);
|
||||
if (!list.length) return '';
|
||||
return list.join(' ◆ ');
|
||||
});
|
||||
|
||||
function goDetail() {
|
||||
void router.push(detailTo.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="text" class="marquee-bar" :class="{ embedded }">
|
||||
<button
|
||||
v-if="text"
|
||||
type="button"
|
||||
class="marquee-bar"
|
||||
:class="{ embedded }"
|
||||
@click="goDetail"
|
||||
>
|
||||
<span class="marquee-badge">{{ t('home.announcement_badge') }}</span>
|
||||
<div class="marquee-viewport">
|
||||
<div class="marquee-track">
|
||||
@@ -25,21 +41,26 @@ const text = computed(() => {
|
||||
<span class="marquee-text" aria-hidden="true">{{ text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.marquee-bar {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: -4px -2px 14px;
|
||||
padding: 10px 12px;
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E5E7EB;
|
||||
border-radius: 8px;
|
||||
background: #EFF6FF;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
touch-action: manipulation;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
.marquee-bar.embedded {
|
||||
@@ -47,8 +68,8 @@ const text = computed(() => {
|
||||
padding: 8px 12px;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
border-bottom: 1px solid #E5E7EB;
|
||||
background: #F5F7FA;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: #EFF6FF;
|
||||
}
|
||||
|
||||
.marquee-bar.embedded .marquee-badge {
|
||||
@@ -66,9 +87,9 @@ const text = computed(() => {
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.12em;
|
||||
color: #FFFFFF;
|
||||
background: #003D6B;
|
||||
border: 1px solid #003D6B;
|
||||
color: #fff;
|
||||
background: var(--primary);
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
@@ -83,6 +104,7 @@ const text = computed(() => {
|
||||
display: flex;
|
||||
width: max-content;
|
||||
animation: marquee-scroll 18s linear infinite;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.marquee-text {
|
||||
@@ -90,7 +112,7 @@ const text = computed(() => {
|
||||
padding-right: 80px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #003D6B;
|
||||
color: var(--primary-light);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { computed, onUnmounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { PARLAY_MIN_LEGS, PARLAY_MAX_LEGS } from '@thebet365/shared';
|
||||
import {
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { formatMoney, parseAmount } from '../utils/localeDisplay';
|
||||
import BetSuccessOverlay from './BetSuccessOverlay.vue';
|
||||
import ConfirmDialog from './ConfirmDialog.vue';
|
||||
import api from '../api';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
|
||||
@@ -37,6 +38,28 @@ const MIN_STAKE = 5;
|
||||
const MAX_STAKE_INTEGER_LENGTH = 9;
|
||||
const stakeInput = ref('');
|
||||
const keypadKeys = ['1', '2', '3', '4', '5', 'backspace', '6', '7', '8', '9', '0', '00'];
|
||||
const ODDS_POLL_MS = 5000;
|
||||
|
||||
type OddsDelta = {
|
||||
oldOdds: number;
|
||||
newOdds: number;
|
||||
newVersion: string;
|
||||
suspended: boolean;
|
||||
};
|
||||
|
||||
interface SelectionOddsRow {
|
||||
id: string;
|
||||
odds: string;
|
||||
oddsVersion: string;
|
||||
status: string;
|
||||
marketStatus: string;
|
||||
marketShowOnPlayer: boolean;
|
||||
matchStatus: string;
|
||||
}
|
||||
|
||||
const oddsDeltas = ref<Record<string, OddsDelta>>({});
|
||||
let oddsPollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
const clearConfirmVisible = ref(false);
|
||||
|
||||
const activeItems = computed<SlipItem[]>(() => {
|
||||
if (activeTab.value === 'parlay') return slip.parlayItems;
|
||||
@@ -44,20 +67,47 @@ const activeItems = computed<SlipItem[]>(() => {
|
||||
});
|
||||
|
||||
const activeCount = computed(() => activeItems.value.length);
|
||||
|
||||
function effectiveOdds(item: SlipItem) {
|
||||
return oddsDeltas.value[item.selectionId]?.newOdds ?? item.odds;
|
||||
}
|
||||
|
||||
const activeTotalOdds = computed(() =>
|
||||
activeItems.value.reduce((acc, item) => acc * item.odds, 1),
|
||||
activeItems.value.reduce((acc, item) => acc * effectiveOdds(item), 1),
|
||||
);
|
||||
const activeEstimatedReturn = computed(() => {
|
||||
if (!activeItems.value.length || !Number.isFinite(slip.stake) || slip.stake <= 0) return 0;
|
||||
if (activeTab.value === 'parlay') return slip.stake * activeTotalOdds.value;
|
||||
return slip.stake * activeItems.value[0].odds;
|
||||
return slip.stake * effectiveOdds(activeItems.value[0]);
|
||||
});
|
||||
|
||||
const hasSuspendedSelections = computed(() =>
|
||||
Object.values(oddsDeltas.value).some((delta) => delta.suspended),
|
||||
);
|
||||
|
||||
const hasPendingOddsChanges = computed(() =>
|
||||
Object.values(oddsDeltas.value).some((delta) => !delta.suspended),
|
||||
);
|
||||
|
||||
const oddsWarningText = computed(() => {
|
||||
if (hasSuspendedSelections.value) return t('bet.odds_suspended');
|
||||
if (hasPendingOddsChanges.value) return t('bet.odds_changed');
|
||||
return '';
|
||||
});
|
||||
|
||||
const submitButtonLabel = computed(() => {
|
||||
if (loading.value) return t('bet.placing');
|
||||
if (hasPendingOddsChanges.value) return t('bet.accept_changes_place');
|
||||
return t('bet.place_bet_short');
|
||||
});
|
||||
|
||||
const canSubmitWithOdds = computed(() => canSubmitActive.value && !hasSuspendedSelections.value);
|
||||
|
||||
const canSubmitActive = computed(() => {
|
||||
if (activeTab.value === 'parlay') {
|
||||
return slip.parlayItems.length >= PARLAY_MIN_LEGS && slip.parlayItems.length <= PARLAY_MAX_LEGS;
|
||||
}
|
||||
return Boolean(slip.singleItem) && slip.singleItem.allowSingle !== false;
|
||||
return Boolean(slip.singleItem) && slip.singleItem!.allowSingle !== false;
|
||||
});
|
||||
|
||||
const singleParlayOnlyHint = computed(
|
||||
@@ -222,6 +272,93 @@ function setMaxStake() {
|
||||
if (balance.value != null && balance.value > 0) setStake(balance.value, false);
|
||||
}
|
||||
|
||||
function stopOddsPolling() {
|
||||
if (oddsPollTimer) {
|
||||
clearInterval(oddsPollTimer);
|
||||
oddsPollTimer = null;
|
||||
}
|
||||
oddsDeltas.value = {};
|
||||
}
|
||||
|
||||
function acceptPendingOdds() {
|
||||
for (const [selectionId, delta] of Object.entries(oddsDeltas.value)) {
|
||||
if (!delta.suspended) {
|
||||
slip.updateSelectionOdds(selectionId, delta.newOdds, delta.newVersion);
|
||||
}
|
||||
}
|
||||
oddsDeltas.value = {};
|
||||
}
|
||||
|
||||
async function pollSelectionsOdds() {
|
||||
const items = activeItems.value;
|
||||
if (!items.length || !show.value) return;
|
||||
|
||||
try {
|
||||
const ids = items.map((item) => item.selectionId).join(',');
|
||||
const { data } = await api.get('/player/selections/odds', { params: { ids } });
|
||||
const rows: SelectionOddsRow[] = data.data?.items ?? [];
|
||||
const rowMap = new Map(rows.map((row) => [row.id, row]));
|
||||
const next: Record<string, OddsDelta> = {};
|
||||
|
||||
for (const item of items) {
|
||||
const row = rowMap.get(item.selectionId);
|
||||
if (!row) continue;
|
||||
|
||||
const suspended =
|
||||
row.status !== 'OPEN' ||
|
||||
row.marketStatus !== 'OPEN' ||
|
||||
row.marketShowOnPlayer === false ||
|
||||
row.matchStatus !== 'PUBLISHED';
|
||||
const newOdds = parseFloat(row.odds);
|
||||
const versionChanged = row.oddsVersion !== item.oddsVersion;
|
||||
const oddsChanged = Number.isFinite(newOdds) && Math.abs(newOdds - item.odds) > 0.0001;
|
||||
|
||||
if (suspended || versionChanged || oddsChanged) {
|
||||
const existing = oddsDeltas.value[item.selectionId];
|
||||
next[item.selectionId] = {
|
||||
oldOdds: existing?.oldOdds ?? item.odds,
|
||||
newOdds: Number.isFinite(newOdds) ? newOdds : item.odds,
|
||||
newVersion: row.oddsVersion,
|
||||
suspended,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
oddsDeltas.value = next;
|
||||
} catch {
|
||||
/* silent retry on next tick */
|
||||
}
|
||||
}
|
||||
|
||||
function startOddsPolling() {
|
||||
stopOddsPolling();
|
||||
void pollSelectionsOdds();
|
||||
oddsPollTimer = setInterval(() => {
|
||||
void pollSelectionsOdds();
|
||||
}, ODDS_POLL_MS);
|
||||
}
|
||||
|
||||
function oddsDeltaFor(selectionId: string) {
|
||||
return oddsDeltas.value[selectionId];
|
||||
}
|
||||
|
||||
function oddsTrendClass(delta: OddsDelta) {
|
||||
if (delta.suspended) return 'odds-suspended';
|
||||
return delta.newOdds >= delta.oldOdds ? 'odds-up' : 'odds-down';
|
||||
}
|
||||
|
||||
function onClearSlip() {
|
||||
if (!activeItems.value.length) return;
|
||||
clearConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
function confirmClearSlip() {
|
||||
if (activeTab.value === 'parlay') slip.clearParlay();
|
||||
else slip.clearSingle();
|
||||
clearConfirmVisible.value = false;
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
async function placeBet() {
|
||||
if (!activeItems.value.length) return;
|
||||
if (!auth.token) {
|
||||
@@ -242,6 +379,13 @@ async function placeBet() {
|
||||
: t('bet.parlay_need_more');
|
||||
return;
|
||||
}
|
||||
if (hasSuspendedSelections.value) {
|
||||
error.value = t('bet.odds_suspended');
|
||||
return;
|
||||
}
|
||||
if (hasPendingOddsChanges.value) {
|
||||
acceptPendingOdds();
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
@@ -287,7 +431,10 @@ async function placeBet() {
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (!open) return;
|
||||
if (!open) {
|
||||
stopOddsPolling();
|
||||
return;
|
||||
}
|
||||
activeTab.value = slip.mode;
|
||||
if (activeTab.value === 'single' && !slip.singleItem && slip.parlayItems.length) {
|
||||
activeTab.value = 'parlay';
|
||||
@@ -297,9 +444,21 @@ watch(
|
||||
success.value = '';
|
||||
syncStakeInputFromSlip();
|
||||
loadBalance();
|
||||
startOddsPolling();
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => activeItems.value.map((item) => item.selectionId).join(','),
|
||||
() => {
|
||||
if (show.value) void pollSelectionsOdds();
|
||||
},
|
||||
);
|
||||
|
||||
onUnmounted(() => {
|
||||
stopOddsPolling();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => slip.mode,
|
||||
(mode) => {
|
||||
@@ -329,6 +488,8 @@ watch(
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="oddsWarningText" class="odds-warning">{{ oddsWarningText }}</p>
|
||||
|
||||
<div class="slip-tabs">
|
||||
<button
|
||||
type="button"
|
||||
@@ -362,7 +523,19 @@ watch(
|
||||
<div v-if="slip.singleItem.marketName" class="item-market">{{ slip.singleItem.marketName }}</div>
|
||||
<div class="item-pick">{{ slip.singleItem.selectionName }}</div>
|
||||
</div>
|
||||
<div class="item-odds">{{ slip.singleItem.odds.toFixed(2) }}</div>
|
||||
<div class="item-odds">
|
||||
<template v-if="oddsDeltaFor(slip.singleItem.selectionId)">
|
||||
<span
|
||||
class="odds-change"
|
||||
:class="oddsTrendClass(oddsDeltaFor(slip.singleItem.selectionId)!)"
|
||||
>
|
||||
{{ oddsDeltaFor(slip.singleItem.selectionId)!.oldOdds.toFixed(2) }}
|
||||
→
|
||||
{{ oddsDeltaFor(slip.singleItem.selectionId)!.newOdds.toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>{{ slip.singleItem.odds.toFixed(2) }}</template>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="singleParlayOnlyHint" class="warning">{{ t('bet.slip_parlay_only_hint') }}</p>
|
||||
|
||||
@@ -379,7 +552,19 @@ watch(
|
||||
<div class="item-pick">{{ item.selectionName }}</div>
|
||||
</div>
|
||||
<div class="item-side">
|
||||
<strong>{{ item.odds.toFixed(2) }}</strong>
|
||||
<strong>
|
||||
<template v-if="oddsDeltaFor(item.selectionId)">
|
||||
<span
|
||||
class="odds-change"
|
||||
:class="oddsTrendClass(oddsDeltaFor(item.selectionId)!)"
|
||||
>
|
||||
{{ oddsDeltaFor(item.selectionId)!.oldOdds.toFixed(2) }}
|
||||
→
|
||||
{{ oddsDeltaFor(item.selectionId)!.newOdds.toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>{{ item.odds.toFixed(2) }}</template>
|
||||
</strong>
|
||||
<button type="button" class="remove" @click="removeItem(item.selectionId)">
|
||||
{{ t('bet.slip_remove') }}
|
||||
</button>
|
||||
@@ -450,16 +635,25 @@ watch(
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="loading || !canSubmitActive"
|
||||
:disabled="loading || !canSubmitWithOdds"
|
||||
@click="placeBet"
|
||||
>
|
||||
{{ loading ? t('bet.placing') : t('bet.place_bet_short') }}
|
||||
{{ submitButtonLabel }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BetSuccessOverlay :show="showSuccess" @done="onSuccessDone" />
|
||||
|
||||
<ConfirmDialog
|
||||
v-model:visible="clearConfirmVisible"
|
||||
:title="t('bet.slip_clear_title', '清空投注单')"
|
||||
:message="t('bet.slip_clear_confirm', '确认清空投注单?')"
|
||||
:confirm-text="t('bet.slip_clear_confirm_btn', '清空')"
|
||||
danger
|
||||
@confirm="confirmClearSlip"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -871,4 +1065,34 @@ watch(
|
||||
.btn-primary:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.odds-warning {
|
||||
margin: 0;
|
||||
padding: 8px 14px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
background: rgba(234, 179, 8, 0.08);
|
||||
color: #92400e;
|
||||
border-bottom: 1px solid rgba(234, 179, 8, 0.2);
|
||||
}
|
||||
|
||||
.odds-change {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.odds-up {
|
||||
color: #16a34a;
|
||||
}
|
||||
|
||||
.odds-down {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.odds-suspended {
|
||||
color: #6b7280;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
</style>
|
||||
|
||||
186
apps/player/src/components/ConfirmDialog.vue
Normal file
186
apps/player/src/components/ConfirmDialog.vue
Normal file
@@ -0,0 +1,186 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
title?: string;
|
||||
message: string;
|
||||
confirmText?: string;
|
||||
cancelText?: string;
|
||||
danger?: boolean;
|
||||
loading?: boolean;
|
||||
}>(),
|
||||
{
|
||||
danger: false,
|
||||
loading: false,
|
||||
},
|
||||
);
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean];
|
||||
confirm: [];
|
||||
cancel: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const resolvedTitle = computed(() => props.title ?? t('common.confirm'));
|
||||
const resolvedConfirmText = computed(() => props.confirmText ?? t('common.confirm'));
|
||||
const resolvedCancelText = computed(() => props.cancelText ?? t('common.cancel'));
|
||||
|
||||
function close() {
|
||||
if (props.loading) return;
|
||||
emit('update:visible', false);
|
||||
emit('cancel');
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
if (props.loading) return;
|
||||
emit('confirm');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="confirm-fade">
|
||||
<div
|
||||
v-if="visible"
|
||||
class="confirm-overlay"
|
||||
@click.self="close"
|
||||
>
|
||||
<div
|
||||
class="confirm-modal"
|
||||
role="alertdialog"
|
||||
aria-modal="true"
|
||||
:aria-labelledby="title ? 'confirm-dialog-title' : undefined"
|
||||
:aria-describedby="'confirm-dialog-message'"
|
||||
>
|
||||
<h2 v-if="title" id="confirm-dialog-title" class="confirm-title">{{ resolvedTitle }}</h2>
|
||||
<p id="confirm-dialog-message" class="confirm-message">{{ message }}</p>
|
||||
|
||||
<div class="confirm-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="confirm-btn cancel"
|
||||
:disabled="loading"
|
||||
@click="close"
|
||||
>
|
||||
{{ resolvedCancelText }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="confirm-btn confirm"
|
||||
:class="{ danger }"
|
||||
:disabled="loading"
|
||||
@click="onConfirm"
|
||||
>
|
||||
{{ resolvedConfirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.confirm-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
|
||||
background: rgba(0, 0, 0, 0.48);
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.confirm-modal {
|
||||
width: 100%;
|
||||
max-width: 340px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: 22px 18px 16px;
|
||||
box-shadow: 0 8px 32px rgba(0, 61, 107, 0.12);
|
||||
}
|
||||
|
||||
.confirm-title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 17px;
|
||||
font-weight: 800;
|
||||
color: var(--primary);
|
||||
text-align: center;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.confirm-message {
|
||||
margin: 0 0 20px;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.confirm-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.confirm-btn {
|
||||
flex: 1;
|
||||
min-height: 44px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.15s;
|
||||
}
|
||||
|
||||
.confirm-btn:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.confirm-btn.cancel {
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.confirm-btn.confirm {
|
||||
border: none;
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-btn.confirm.danger {
|
||||
background: #dc2626;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.confirm-fade-enter-active,
|
||||
.confirm-fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.confirm-fade-enter-active .confirm-modal,
|
||||
.confirm-fade-leave-active .confirm-modal {
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.confirm-fade-enter-from,
|
||||
.confirm-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.confirm-fade-enter-from .confirm-modal,
|
||||
.confirm-fade-leave-to .confirm-modal {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
</style>
|
||||
@@ -1,165 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildCustomerServiceUrl } from '../config/customerService';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
|
||||
const props = defineProps<{ modelValue: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [boolean] }>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const { profileRaw, avatarUrl } = usePlayerProfile();
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v),
|
||||
});
|
||||
|
||||
const iframeSrc = computed(() => {
|
||||
const visitor = auth.user
|
||||
? {
|
||||
name:
|
||||
profileRaw.value?.username ||
|
||||
profileRaw.value?.preferences?.phone ||
|
||||
auth.user.username ||
|
||||
'',
|
||||
avatar: avatarUrl.value
|
||||
? new URL(avatarUrl.value, window.location.origin).href
|
||||
: '',
|
||||
id: String(profileRaw.value?.id ?? auth.user.id ?? ''),
|
||||
}
|
||||
: null;
|
||||
|
||||
return buildCustomerServiceUrl(t('support.connecting'), visitor);
|
||||
});
|
||||
|
||||
function close() {
|
||||
visible.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="fade">
|
||||
<div v-if="visible" class="cs-overlay" @click.self="close">
|
||||
<div class="cs-modal" role="dialog" :aria-label="t('support.title')">
|
||||
<header class="cs-header">
|
||||
<h2 class="cs-title">{{ t('support.title') }}</h2>
|
||||
<button type="button" class="close-btn" :aria-label="t('support.close')" @click="close">
|
||||
✕
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="cs-body">
|
||||
<iframe
|
||||
v-if="visible"
|
||||
:key="iframeSrc"
|
||||
class="cs-frame"
|
||||
:src="iframeSrc"
|
||||
:title="t('support.title')"
|
||||
allow="microphone; camera; clipboard-read; clipboard-write"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cs-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
background: rgba(0, 0, 0, 0.35);
|
||||
backdrop-filter: blur(4px);
|
||||
-webkit-backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.cs-modal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: min(100%, 420px);
|
||||
height: min(82vh, 680px);
|
||||
background: #FFFFFF;
|
||||
border: 1px solid #E5E7EB;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.cs-header {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
border-bottom: 1px solid #E5E7EB;
|
||||
background: #FFFFFF;
|
||||
}
|
||||
|
||||
.cs-title {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: #003D6B;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #6B7280;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
color: #1A1A2E;
|
||||
}
|
||||
|
||||
.cs-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
background: #F5F7FA;
|
||||
}
|
||||
|
||||
.cs-frame {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.cs-empty {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: #6B7280;
|
||||
}
|
||||
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.25s ease;
|
||||
}
|
||||
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
60
apps/player/src/components/CustomerServicePanel.vue
Normal file
60
apps/player/src/components/CustomerServicePanel.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildCustomerServiceUrl } from '../config/customerService';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const { profileRaw, avatarUrl } = usePlayerProfile();
|
||||
|
||||
const iframeSrc = computed(() => {
|
||||
const visitor = auth.user
|
||||
? {
|
||||
name:
|
||||
profileRaw.value?.username ||
|
||||
profileRaw.value?.preferences?.phone ||
|
||||
auth.user.username ||
|
||||
'',
|
||||
avatar: avatarUrl.value
|
||||
? new URL(avatarUrl.value, window.location.origin).href
|
||||
: '',
|
||||
id: String(profileRaw.value?.id ?? auth.user.id ?? ''),
|
||||
}
|
||||
: null;
|
||||
|
||||
return buildCustomerServiceUrl(t('support.connecting'), visitor);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cs-panel">
|
||||
<iframe
|
||||
:key="iframeSrc"
|
||||
class="cs-frame"
|
||||
:src="iframeSrc"
|
||||
:title="t('support.title')"
|
||||
allow="microphone; camera; clipboard-read; clipboard-write"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cs-panel {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 -16px;
|
||||
background: var(--bg-body);
|
||||
}
|
||||
|
||||
.cs-frame {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-height: calc(100dvh - 140px);
|
||||
border: 0;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
345
apps/player/src/components/MessageListPanel.vue
Normal file
345
apps/player/src/components/MessageListPanel.vue
Normal file
@@ -0,0 +1,345 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatLocalMatchDateTime } from '@thebet365/shared';
|
||||
import GoldSpinner from './GoldSpinner.vue';
|
||||
import ConfirmDialog from './ConfirmDialog.vue';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { usePlayerMessages, type DepositMessagePayload, type PlayerMessage } from '../composables/usePlayerMessages';
|
||||
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const {
|
||||
messages,
|
||||
loading,
|
||||
listLoaded,
|
||||
loadMessages,
|
||||
refreshUnreadCount,
|
||||
deleteMessage,
|
||||
} = usePlayerMessages();
|
||||
|
||||
const page = ref(1);
|
||||
const total = ref(0);
|
||||
const deletingId = ref<string | null>(null);
|
||||
const deleteConfirmVisible = ref(false);
|
||||
const pendingDeleteId = ref<string | null>(null);
|
||||
|
||||
const hasMore = computed(() => messages.value.length < total.value);
|
||||
|
||||
function formatDate(createdAt?: string) {
|
||||
if (!createdAt) return '';
|
||||
return formatLocalMatchDateTime(createdAt, locale.value, { variant: 'full' });
|
||||
}
|
||||
|
||||
function messageTitle(item: PlayerMessage) {
|
||||
if (item.type === 'DEPOSIT_APPROVED') return t('messages.deposit_approved_title');
|
||||
if (item.type === 'DEPOSIT_REJECTED') return t('messages.deposit_rejected_title');
|
||||
return item.title;
|
||||
}
|
||||
|
||||
function messagePreview(item: PlayerMessage) {
|
||||
if (item.type === 'DEPOSIT_APPROVED' || item.type === 'DEPOSIT_REJECTED') {
|
||||
const deposit = item.payload as DepositMessagePayload | null;
|
||||
if (deposit?.orderNo) return deposit.orderNo;
|
||||
}
|
||||
return item.body.length > 80 ? `${item.body.slice(0, 80)}…` : item.body;
|
||||
}
|
||||
|
||||
function openDetail(id: string) {
|
||||
router.push(`/messages/${id}`);
|
||||
}
|
||||
|
||||
async function fetchPage(nextPage: number, append = false) {
|
||||
const result = await loadMessages(nextPage, append);
|
||||
if (result) {
|
||||
page.value = result.page;
|
||||
total.value = result.total;
|
||||
}
|
||||
}
|
||||
|
||||
function tryLoad() {
|
||||
if (!auth.token) return;
|
||||
void fetchPage(1);
|
||||
void refreshUnreadCount();
|
||||
}
|
||||
|
||||
function goLogin() {
|
||||
auth.showLoginPrompt('/messages');
|
||||
}
|
||||
|
||||
function onDelete(id: string, event: Event) {
|
||||
event.stopPropagation();
|
||||
if (deletingId.value) return;
|
||||
pendingDeleteId.value = id;
|
||||
deleteConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
function onDeleteCancel() {
|
||||
pendingDeleteId.value = null;
|
||||
}
|
||||
|
||||
async function confirmDelete() {
|
||||
const id = pendingDeleteId.value;
|
||||
if (!id || deletingId.value) return;
|
||||
deletingId.value = id;
|
||||
try {
|
||||
await deleteMessage(id);
|
||||
total.value = Math.max(0, total.value - 1);
|
||||
deleteConfirmVisible.value = false;
|
||||
pendingDeleteId.value = null;
|
||||
} finally {
|
||||
deletingId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(tryLoad);
|
||||
onActivated(tryLoad);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="message-list-panel">
|
||||
<div v-if="!auth.token" class="guest-hint">
|
||||
<p>{{ t('auth.login_required') }}</p>
|
||||
<button type="button" class="login-link" @click="goLogin">{{ t('auth.go_login') }}</button>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="loading && !listLoaded" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!messages.length" class="empty">
|
||||
<p>{{ t('messages.empty') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="list">
|
||||
<div
|
||||
v-for="item in messages"
|
||||
:key="item.id"
|
||||
class="list-row"
|
||||
:class="{ unread: !item.isRead }"
|
||||
>
|
||||
<button type="button" class="row-body" @click="openDetail(item.id)">
|
||||
<span class="row-dot" aria-hidden="true" />
|
||||
<span class="row-main">
|
||||
<span class="title-row">
|
||||
<span class="title">{{ messageTitle(item) }}</span>
|
||||
<span class="status-badge" :class="{ unread: !item.isRead }">
|
||||
{{ item.isRead ? t('messages.status_read') : t('messages.status_unread') }}
|
||||
</span>
|
||||
</span>
|
||||
<span class="preview">{{ messagePreview(item) }}</span>
|
||||
<span v-if="item.createdAt" class="date">{{ formatDate(item.createdAt) }}</span>
|
||||
</span>
|
||||
<span class="chevron" aria-hidden="true">›</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="delete-btn"
|
||||
:aria-label="t('messages.delete')"
|
||||
:disabled="deletingId === item.id"
|
||||
@click="onDelete(item.id, $event)"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path
|
||||
d="M6 7h12M9 7V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2m2 0v12a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V7h12Z"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button v-if="hasMore" type="button" class="load-more" :disabled="loading" @click="fetchPage(page + 1, true)">
|
||||
{{ loading ? t('common.loading_more') : t('messages.load_more') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ConfirmDialog
|
||||
v-model:visible="deleteConfirmVisible"
|
||||
:title="t('messages.delete')"
|
||||
:message="t('messages.delete_confirm')"
|
||||
:confirm-text="t('messages.delete')"
|
||||
danger
|
||||
:loading="!!deletingId"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="onDeleteCancel"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.message-list-panel {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.guest-hint,
|
||||
.state,
|
||||
.empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 48px 16px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.login-link {
|
||||
border: 1px solid var(--border-active);
|
||||
border-radius: 8px;
|
||||
padding: 8px 14px;
|
||||
background: rgba(0, 61, 107, 0.06);
|
||||
color: var(--primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.list-row {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.row-body {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 14px 0;
|
||||
border: none;
|
||||
background: none;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.list-row.unread .title {
|
||||
color: var(--primary-dark, #002847);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.row-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.list-row.unread .row-dot {
|
||||
background: var(--primary);
|
||||
box-shadow: 0 0 6px rgba(0, 61, 107, 0.35);
|
||||
}
|
||||
|
||||
.row-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 15px;
|
||||
color: #374151;
|
||||
line-height: 1.35;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
flex-shrink: 0;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.status-badge.unread {
|
||||
color: var(--primary);
|
||||
background: rgba(0, 61, 107, 0.08);
|
||||
}
|
||||
|
||||
.preview {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
color: var(--text-muted);
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
flex-shrink: 0;
|
||||
align-self: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
margin-left: 4px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: #9ca3af;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-btn:active:not(:disabled) {
|
||||
background: rgba(220, 38, 38, 0.08);
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.delete-btn svg {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.delete-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
margin-top: 12px;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
174
apps/player/src/composables/useDepositNotifications.ts
Normal file
174
apps/player/src/composables/useDepositNotifications.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
import api from '../api';
|
||||
import { usePlayerProfile } from './usePlayerProfile';
|
||||
import { usePlayerMessages } from './usePlayerMessages';
|
||||
|
||||
interface DepositOrderRow {
|
||||
id: string;
|
||||
orderNo: string;
|
||||
amount: string;
|
||||
status: string;
|
||||
rejectReason?: string | null;
|
||||
}
|
||||
|
||||
const POLL_FAST_MS = 8_000;
|
||||
const POLL_SLOW_MS = 30_000;
|
||||
const TRACKED_STORAGE_KEY = 'player_deposit_tracked_pending';
|
||||
|
||||
const lastStatus = new Map<string, string>();
|
||||
const trackedPending = new Set<string>();
|
||||
const notifiedKeys = new Set<string>();
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let pollingActive = false;
|
||||
|
||||
function notifyKey(orderId: string, type: 'approved' | 'rejected') {
|
||||
return `${orderId}:${type}`;
|
||||
}
|
||||
|
||||
function loadTrackedFromStorage() {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(TRACKED_STORAGE_KEY);
|
||||
if (!raw) return;
|
||||
const ids: string[] = JSON.parse(raw);
|
||||
for (const id of ids) {
|
||||
if (id) trackedPending.add(String(id));
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
function persistTrackedToStorage() {
|
||||
try {
|
||||
sessionStorage.setItem(TRACKED_STORAGE_KEY, JSON.stringify([...trackedPending]));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
function addTracked(orderId: string) {
|
||||
trackedPending.add(orderId);
|
||||
persistTrackedToStorage();
|
||||
}
|
||||
|
||||
function removeTracked(orderId: string) {
|
||||
if (!trackedPending.delete(orderId)) return;
|
||||
persistTrackedToStorage();
|
||||
}
|
||||
|
||||
function hasPendingInterest() {
|
||||
return trackedPending.size > 0;
|
||||
}
|
||||
|
||||
function schedulePoll(intervalMs: number) {
|
||||
if (pollTimer) clearInterval(pollTimer);
|
||||
pollTimer = setInterval(() => {
|
||||
void pollOnce();
|
||||
}, intervalMs);
|
||||
}
|
||||
|
||||
function adjustPollInterval() {
|
||||
if (!pollingActive) return;
|
||||
schedulePoll(hasPendingInterest() ? POLL_FAST_MS : POLL_SLOW_MS);
|
||||
}
|
||||
|
||||
function trackPendingOrder(orderId: string) {
|
||||
const id = String(orderId);
|
||||
if (!id) return;
|
||||
addTracked(id);
|
||||
lastStatus.set(id, 'PENDING');
|
||||
adjustPollInterval();
|
||||
void pollOnce();
|
||||
}
|
||||
|
||||
function shouldNotify(orderId: string, prev: string | undefined, next: string) {
|
||||
if (next !== 'APPROVED' && next !== 'REJECTED') return false;
|
||||
if (prev === 'PENDING') return true;
|
||||
if (trackedPending.has(orderId)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleStatusChange(order: DepositOrderRow): boolean {
|
||||
const prev = lastStatus.get(order.id);
|
||||
const next = order.status;
|
||||
lastStatus.set(order.id, next);
|
||||
|
||||
if (next === 'PENDING') {
|
||||
addTracked(order.id);
|
||||
return false;
|
||||
}
|
||||
|
||||
removeTracked(order.id);
|
||||
|
||||
if (!shouldNotify(order.id, prev, next)) return false;
|
||||
|
||||
const type = next === 'APPROVED' ? 'approved' : 'rejected';
|
||||
const key = notifyKey(order.id, type);
|
||||
if (notifiedKeys.has(key)) return false;
|
||||
notifiedKeys.add(key);
|
||||
|
||||
void usePlayerMessages().refreshUnreadCount();
|
||||
return next === 'APPROVED';
|
||||
}
|
||||
|
||||
async function pollOnce() {
|
||||
try {
|
||||
const { data } = await api.get('/player/deposit-orders', { params: { page: 1 } });
|
||||
const items: DepositOrderRow[] = data.data?.items ?? [];
|
||||
const { refreshProfile } = usePlayerProfile();
|
||||
|
||||
let needsProfileRefresh = false;
|
||||
for (const order of items) {
|
||||
if (handleStatusChange(order)) needsProfileRefresh = true;
|
||||
}
|
||||
|
||||
if (needsProfileRefresh) await refreshProfile();
|
||||
adjustPollInterval();
|
||||
} catch {
|
||||
/* silent retry on next tick */
|
||||
}
|
||||
}
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (!document.hidden && pollingActive) void pollOnce();
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
if (pollingActive) {
|
||||
void pollOnce();
|
||||
return;
|
||||
}
|
||||
pollingActive = true;
|
||||
loadTrackedFromStorage();
|
||||
for (const id of trackedPending) {
|
||||
if (!lastStatus.has(id)) lastStatus.set(id, 'PENDING');
|
||||
}
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
void pollOnce();
|
||||
schedulePoll(hasPendingInterest() ? POLL_FAST_MS : POLL_SLOW_MS);
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
pollingActive = false;
|
||||
trackedPending.clear();
|
||||
lastStatus.clear();
|
||||
notifiedKeys.clear();
|
||||
try {
|
||||
sessionStorage.removeItem(TRACKED_STORAGE_KEY);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
if (pollTimer) {
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = null;
|
||||
}
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
}
|
||||
|
||||
export function useDepositNotifications() {
|
||||
return {
|
||||
trackPendingOrder,
|
||||
startPolling,
|
||||
stopPolling,
|
||||
pollOnce,
|
||||
};
|
||||
}
|
||||
23
apps/player/src/composables/useInboxFeature.ts
Normal file
23
apps/player/src/composables/useInboxFeature.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { computed } from 'vue';
|
||||
import { usePlayerHome } from './usePlayerHome';
|
||||
|
||||
/** 玩家端站内邮箱功能开关(来自 /player/home) */
|
||||
export function useInboxFeature() {
|
||||
const { homeRaw } = usePlayerHome();
|
||||
|
||||
const inboxEnabled = computed(() => homeRaw.value?.inboxEnabled !== false);
|
||||
|
||||
const hubRoute = computed(() =>
|
||||
inboxEnabled.value ? '/messages' : '/messages?tab=support',
|
||||
);
|
||||
|
||||
const hubOpenLabelKey = computed(() =>
|
||||
inboxEnabled.value ? 'inbox_hub.open' : 'inbox_hub.open_support',
|
||||
);
|
||||
|
||||
const hubTitleKey = computed(() =>
|
||||
inboxEnabled.value ? 'inbox_hub.title' : 'inbox_hub.tab_support',
|
||||
);
|
||||
|
||||
return { inboxEnabled, hubRoute, hubOpenLabelKey, hubTitleKey };
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import api from '../api';
|
||||
import type { BannerItem } from '../components/BannerCarousel.vue';
|
||||
import { resolveBanners } from '../constants/defaultBanner';
|
||||
import { resolveAnnouncements } from '../constants/defaultAnnouncement';
|
||||
import { stripHtml } from '../utils/html';
|
||||
|
||||
export interface PlayerHomeMatch {
|
||||
id: string;
|
||||
@@ -20,12 +21,52 @@ export interface PlayerHomeMatch {
|
||||
displayOrder?: number;
|
||||
}
|
||||
|
||||
export interface PlayerContentItem {
|
||||
id: string;
|
||||
contentType?: string;
|
||||
sortOrder?: number;
|
||||
createdAt?: string;
|
||||
linkType?: string | null;
|
||||
linkTarget?: string | null;
|
||||
translation?: {
|
||||
title?: string | null;
|
||||
body?: string | null;
|
||||
imageUrl?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export type PlayerAnnouncementItem = PlayerContentItem;
|
||||
|
||||
interface HomePayload {
|
||||
banners?: BannerItem[];
|
||||
announcements?: Array<{ translation?: { title?: string; body?: string } }>;
|
||||
ticker?: Array<{ translation?: { title?: string; body?: string } }>;
|
||||
notices?: Array<{ translation?: { title?: string; body?: string } }>;
|
||||
banners?: PlayerContentItem[];
|
||||
announcements?: PlayerAnnouncementItem[];
|
||||
ticker?: PlayerAnnouncementItem[];
|
||||
notices?: PlayerAnnouncementItem[];
|
||||
hotMatches?: PlayerHomeMatch[];
|
||||
upcomingMatches?: PlayerHomeMatch[];
|
||||
inboxEnabled?: boolean;
|
||||
}
|
||||
|
||||
function mergeMatchList(
|
||||
existing: PlayerHomeMatch[] | undefined,
|
||||
fresh: PlayerHomeMatch[] | undefined,
|
||||
): PlayerHomeMatch[] | undefined {
|
||||
if (!fresh) return existing;
|
||||
if (!existing) return fresh;
|
||||
|
||||
const freshMap = new Map(fresh.map((m) => [m.id, m]));
|
||||
for (const m of existing) {
|
||||
const f = freshMap.get(m.id);
|
||||
if (f) Object.assign(m, f);
|
||||
}
|
||||
const existingIds = new Set(existing.map((m) => m.id));
|
||||
for (const fm of fresh) {
|
||||
if (!existingIds.has(fm.id)) existing.push(fm);
|
||||
}
|
||||
for (let i = existing.length - 1; i >= 0; i--) {
|
||||
if (!freshMap.has(existing[i].id)) existing.splice(i, 1);
|
||||
}
|
||||
return existing;
|
||||
}
|
||||
|
||||
const homeRaw = ref<HomePayload | null>(null);
|
||||
@@ -40,12 +81,22 @@ function collectAnnouncementLines(data: HomePayload | null): string[] {
|
||||
|
||||
const lines: string[] = [];
|
||||
for (const item of source) {
|
||||
const text = item.translation?.title || item.translation?.body;
|
||||
const title = item.translation?.title?.trim();
|
||||
const text = title || stripHtml(item.translation?.body ?? '');
|
||||
if (text) lines.push(text);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
function collectAnnouncementItems(data: HomePayload | null): PlayerAnnouncementItem[] {
|
||||
if (!data) return [];
|
||||
const source =
|
||||
data.announcements && data.announcements.length > 0
|
||||
? data.announcements
|
||||
: [...(data.ticker ?? []), ...(data.notices ?? [])];
|
||||
return source.filter((item) => item.translation?.title || item.translation?.body);
|
||||
}
|
||||
|
||||
/** 管理端公共内容 → 玩家端首页/跑马灯(单例,避免重复请求) */
|
||||
export function usePlayerHome() {
|
||||
const { t } = useI18n();
|
||||
@@ -64,26 +115,10 @@ export function usePlayerHome() {
|
||||
existing.announcements = fresh.announcements;
|
||||
existing.ticker = fresh.ticker;
|
||||
existing.notices = fresh.notices;
|
||||
existing.inboxEnabled = fresh.inboxEnabled;
|
||||
|
||||
if (fresh.hotMatches && existing.hotMatches) {
|
||||
const freshMap = new Map(fresh.hotMatches.map((m) => [m.id, m]));
|
||||
for (const m of existing.hotMatches) {
|
||||
const f = freshMap.get(m.id);
|
||||
if (f) Object.assign(m, f);
|
||||
}
|
||||
// 处理新增或删除的比赛
|
||||
const existingIds = new Set(existing.hotMatches.map((m) => m.id));
|
||||
for (const fm of fresh.hotMatches) {
|
||||
if (!existingIds.has(fm.id)) existing.hotMatches.push(fm);
|
||||
}
|
||||
for (let i = existing.hotMatches.length - 1; i >= 0; i--) {
|
||||
if (!freshMap.has(existing.hotMatches[i].id)) {
|
||||
existing.hotMatches.splice(i, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
existing.hotMatches = fresh.hotMatches;
|
||||
}
|
||||
existing.hotMatches = mergeMatchList(existing.hotMatches, fresh.hotMatches);
|
||||
existing.upcomingMatches = mergeMatchList(existing.upcomingMatches, fresh.upcomingMatches);
|
||||
} else {
|
||||
homeRaw.value = fresh;
|
||||
}
|
||||
@@ -94,18 +129,24 @@ export function usePlayerHome() {
|
||||
}
|
||||
}
|
||||
|
||||
const banners = computed(() => resolveBanners(homeRaw.value?.banners));
|
||||
const banners = computed(() => resolveBanners(homeRaw.value?.banners as BannerItem[] | undefined));
|
||||
const bannerItems = computed(() => homeRaw.value?.banners ?? []);
|
||||
const announcements = computed(() =>
|
||||
resolveAnnouncements(collectAnnouncementLines(homeRaw.value), t('home.announcement_default')),
|
||||
);
|
||||
const announcementItems = computed(() => collectAnnouncementItems(homeRaw.value));
|
||||
const hotMatches = computed(() => homeRaw.value?.hotMatches ?? []);
|
||||
const upcomingMatches = computed(() => homeRaw.value?.upcomingMatches ?? []);
|
||||
|
||||
return {
|
||||
homeRaw,
|
||||
loading,
|
||||
load,
|
||||
banners,
|
||||
bannerItems,
|
||||
announcements,
|
||||
announcementItems,
|
||||
hotMatches,
|
||||
upcomingMatches,
|
||||
};
|
||||
}
|
||||
|
||||
130
apps/player/src/composables/usePlayerMessages.ts
Normal file
130
apps/player/src/composables/usePlayerMessages.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { ref } from 'vue';
|
||||
import api from '../api';
|
||||
|
||||
export type PlayerMessageType =
|
||||
| 'DEPOSIT_APPROVED'
|
||||
| 'DEPOSIT_REJECTED'
|
||||
| 'BANNER_PROMO'
|
||||
| 'ANNOUNCEMENT_PROMO';
|
||||
|
||||
export type DepositMessagePayload = {
|
||||
depositOrderId?: string;
|
||||
orderNo?: string;
|
||||
amount?: string;
|
||||
approvedAmount?: string | null;
|
||||
rejectReason?: string | null;
|
||||
};
|
||||
|
||||
export type BannerPromoPayload = {
|
||||
contentId?: string;
|
||||
};
|
||||
|
||||
export interface PlayerMessage {
|
||||
id: string;
|
||||
type: PlayerMessageType | string;
|
||||
title: string;
|
||||
body: string;
|
||||
payload: DepositMessagePayload | BannerPromoPayload | null;
|
||||
readAt: string | null;
|
||||
createdAt: string;
|
||||
isRead: boolean;
|
||||
}
|
||||
|
||||
interface MessageListResponse {
|
||||
items: PlayerMessage[];
|
||||
total: number;
|
||||
unreadCount: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
const unreadCount = ref(0);
|
||||
const messages = ref<PlayerMessage[]>([]);
|
||||
const loading = ref(false);
|
||||
const listLoaded = ref(false);
|
||||
|
||||
async function refreshUnreadCount() {
|
||||
try {
|
||||
const { data } = await api.get('/player/messages/unread-count');
|
||||
unreadCount.value = Number(data.data?.unreadCount ?? 0);
|
||||
} catch {
|
||||
/* silent */
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMessages(page = 1, append = false) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await api.get('/player/messages', { params: { page, pageSize: 20 } });
|
||||
const payload = data.data as MessageListResponse;
|
||||
const items = payload?.items ?? [];
|
||||
messages.value = append ? [...messages.value, ...items] : items;
|
||||
unreadCount.value = Number(payload?.unreadCount ?? unreadCount.value);
|
||||
listLoaded.value = true;
|
||||
return payload;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMessageDetail(id: string) {
|
||||
const { data } = await api.get(`/player/messages/${id}`);
|
||||
return data.data as PlayerMessage;
|
||||
}
|
||||
|
||||
async function markMessageRead(id: string) {
|
||||
const { data } = await api.patch(`/player/messages/${id}/read`);
|
||||
const updated = data.data as PlayerMessage;
|
||||
messages.value = messages.value.map((item) =>
|
||||
item.id === id ? { ...item, ...updated, isRead: true } : item,
|
||||
);
|
||||
if (unreadCount.value > 0) unreadCount.value -= 1;
|
||||
return updated;
|
||||
}
|
||||
|
||||
async function markAllRead() {
|
||||
await api.patch('/player/messages/read-all');
|
||||
messages.value = messages.value.map((item) => ({
|
||||
...item,
|
||||
isRead: true,
|
||||
readAt: item.readAt ?? new Date().toISOString(),
|
||||
}));
|
||||
unreadCount.value = 0;
|
||||
}
|
||||
|
||||
async function deleteMessage(id: string) {
|
||||
const { data } = await api.delete(`/player/messages/${id}`);
|
||||
const wasUnread = Boolean(data.data?.wasUnread);
|
||||
messages.value = messages.value.filter((item) => item.id !== id);
|
||||
if (wasUnread && unreadCount.value > 0) unreadCount.value -= 1;
|
||||
}
|
||||
|
||||
async function deleteAllMessages() {
|
||||
await api.delete('/player/messages');
|
||||
messages.value = [];
|
||||
unreadCount.value = 0;
|
||||
listLoaded.value = true;
|
||||
}
|
||||
|
||||
function resetMessagesState() {
|
||||
unreadCount.value = 0;
|
||||
messages.value = [];
|
||||
listLoaded.value = false;
|
||||
}
|
||||
|
||||
export function usePlayerMessages() {
|
||||
return {
|
||||
unreadCount,
|
||||
messages,
|
||||
loading,
|
||||
listLoaded,
|
||||
refreshUnreadCount,
|
||||
loadMessages,
|
||||
loadMessageDetail,
|
||||
markMessageRead,
|
||||
markAllRead,
|
||||
deleteMessage,
|
||||
deleteAllMessages,
|
||||
resetMessagesState,
|
||||
};
|
||||
}
|
||||
37
apps/player/src/composables/usePresencePing.ts
Normal file
37
apps/player/src/composables/usePresencePing.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import api from '../api';
|
||||
|
||||
const PING_INTERVAL_MS = 60_000;
|
||||
|
||||
let pingTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let active = false;
|
||||
|
||||
async function sendPing() {
|
||||
if (document.visibilityState !== 'visible') return;
|
||||
try {
|
||||
await api.post('/player/presence/ping');
|
||||
} catch {
|
||||
/* ignore transient network errors */
|
||||
}
|
||||
}
|
||||
|
||||
function onVisibilityChange() {
|
||||
if (!active) return;
|
||||
if (document.visibilityState === 'visible') void sendPing();
|
||||
}
|
||||
|
||||
export function startPresencePing() {
|
||||
if (active) return;
|
||||
active = true;
|
||||
void sendPing();
|
||||
pingTimer = setInterval(() => void sendPing(), PING_INTERVAL_MS);
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
}
|
||||
|
||||
export function stopPresencePing() {
|
||||
active = false;
|
||||
if (pingTimer) {
|
||||
clearInterval(pingTimer);
|
||||
pingTimer = null;
|
||||
}
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
}
|
||||
@@ -8,11 +8,16 @@ export default {
|
||||
load_failed: 'Failed to load',
|
||||
retry: 'Retry',
|
||||
back_to_top: 'Back to top',
|
||||
cancel: 'Cancel',
|
||||
confirm: 'Confirm',
|
||||
},
|
||||
nav: { home: 'Home', bet: 'Bet', bet_history: 'History', wallet: 'Wallet', profile: 'Profile' },
|
||||
home: {
|
||||
hot_matches: 'Hot matches',
|
||||
hot_tab: 'Hot',
|
||||
upcoming_tab: 'Upcoming',
|
||||
no_matches: 'No matches',
|
||||
upcoming_empty: 'No matches kicking off in the next 3 days',
|
||||
announcement_badge: 'Notice',
|
||||
announcement_default:
|
||||
'Welcome to TheBet365 · Football events are live · Bet responsibly',
|
||||
@@ -21,6 +26,67 @@ export default {
|
||||
banner_slide: 'Slide {n}',
|
||||
banner_fallback: 'Banner',
|
||||
},
|
||||
announcements: {
|
||||
title: 'Announcements',
|
||||
detail_title: 'Announcement',
|
||||
empty: 'No announcements yet',
|
||||
not_found: 'This announcement is unavailable',
|
||||
view_all: 'View all announcements',
|
||||
type_notice: 'Notice',
|
||||
type_ticker: 'Ticker',
|
||||
type_banner: 'Banner',
|
||||
related_link: 'Related link',
|
||||
go_link: 'Go to page',
|
||||
open_link: 'Open link',
|
||||
back: 'Back',
|
||||
},
|
||||
search: {
|
||||
placeholder: 'Search teams or leagues',
|
||||
no_results: 'No matches found',
|
||||
results_count: '{count} matches found',
|
||||
hint: 'Enter a team or league to filter on the Bet page',
|
||||
},
|
||||
deposit_notify: {
|
||||
approved_title: 'Deposit approved',
|
||||
rejected_title: 'Deposit rejected',
|
||||
view_history: 'View deposit history',
|
||||
view_messages: 'Open inbox',
|
||||
dismiss: 'Dismiss',
|
||||
},
|
||||
messages: {
|
||||
title: 'Inbox',
|
||||
detail_title: 'Message',
|
||||
empty: 'No messages yet',
|
||||
not_found: 'Message not found',
|
||||
view_all: 'Back to inbox',
|
||||
back: 'Back',
|
||||
mark_all_read: 'Mark all read',
|
||||
load_more: 'Load more',
|
||||
delete: 'Delete',
|
||||
delete_all: 'Delete all',
|
||||
delete_confirm: 'Delete this message?',
|
||||
delete_all_confirm: 'Delete all messages? This cannot be undone.',
|
||||
banner_promo_view: 'View promotion',
|
||||
content_promo_view: 'View details',
|
||||
status_unread: 'Unread',
|
||||
status_read: 'Read',
|
||||
deposit_approved_title: 'Deposit approved',
|
||||
deposit_rejected_title: 'Deposit rejected',
|
||||
deposit_approved_body: 'Order {orderNo} approved. Requested {amount}, credited {approvedAmount}.',
|
||||
deposit_rejected_body: 'Order {orderNo} ({amount}) was rejected. {reason}',
|
||||
reject_reason: 'Rejection reason',
|
||||
no_reason: 'No reason provided',
|
||||
view_recharge_history: 'View recharge history',
|
||||
unread_badge: '{count} unread',
|
||||
open_inbox: 'Open inbox',
|
||||
},
|
||||
inbox_hub: {
|
||||
title: 'Messages & Support',
|
||||
tab_messages: 'Inbox',
|
||||
tab_support: 'Support',
|
||||
open: 'Open messages and support',
|
||||
open_support: 'Open support',
|
||||
},
|
||||
history: {
|
||||
league_default: 'Football',
|
||||
stake: 'Stake',
|
||||
@@ -396,6 +462,11 @@ export default {
|
||||
slip_currency: 'Amount',
|
||||
slip_min: 'Min',
|
||||
slip_min_error: 'Minimum stake is {amount}',
|
||||
odds_changed: 'Odds have changed on some selections. Accept to continue.',
|
||||
odds_suspended: 'Some selections are suspended or closed. Remove them to continue.',
|
||||
accept_changes_place: 'Accept changes & place bet',
|
||||
odds_was: 'Was',
|
||||
odds_now: 'Now',
|
||||
place_success: 'Bet placed',
|
||||
place_failed: 'Bet failed',
|
||||
},
|
||||
|
||||
@@ -8,6 +8,8 @@ export default {
|
||||
load_failed: 'Gagal dimuat',
|
||||
retry: 'Cuba lagi',
|
||||
back_to_top: 'Kembali ke atas',
|
||||
cancel: 'Batal',
|
||||
confirm: 'Sahkan',
|
||||
},
|
||||
nav: {
|
||||
home: 'Laman Utama',
|
||||
@@ -18,7 +20,10 @@ export default {
|
||||
},
|
||||
home: {
|
||||
hot_matches: 'Perlawanan popular',
|
||||
hot_tab: 'Popular',
|
||||
upcoming_tab: 'Terdekat',
|
||||
no_matches: 'Tiada perlawanan',
|
||||
upcoming_empty: 'Tiada perlawanan dalam 3 hari akan datang',
|
||||
announcement_badge: 'Notis',
|
||||
announcement_default:
|
||||
'Selamat datang ke TheBet365 · Perlawanan bola sepak sedang berlangsung · Bertaruh secara bertanggungjawab',
|
||||
@@ -27,6 +32,67 @@ export default {
|
||||
banner_slide: 'Slaid {n}',
|
||||
banner_fallback: 'Banner',
|
||||
},
|
||||
announcements: {
|
||||
title: 'Pusat Pengumuman',
|
||||
detail_title: 'Butiran Pengumuman',
|
||||
empty: 'Tiada pengumuman',
|
||||
not_found: 'Pengumuman tidak tersedia',
|
||||
view_all: 'Lihat semua pengumuman',
|
||||
type_notice: 'Notis',
|
||||
type_ticker: 'Ticker',
|
||||
type_banner: 'Banner',
|
||||
related_link: 'Pautan berkaitan',
|
||||
go_link: 'Pergi ke halaman',
|
||||
open_link: 'Buka pautan',
|
||||
back: 'Kembali',
|
||||
},
|
||||
search: {
|
||||
placeholder: 'Cari pasukan atau liga',
|
||||
no_results: 'Tiada perlawanan dijumpai',
|
||||
results_count: '{count} perlawanan dijumpai',
|
||||
hint: 'Masukkan pasukan atau liga untuk tapis di halaman Pertaruhan',
|
||||
},
|
||||
deposit_notify: {
|
||||
approved_title: 'Deposit diluluskan',
|
||||
rejected_title: 'Deposit ditolak',
|
||||
view_history: 'Lihat sejarah deposit',
|
||||
view_messages: 'Buka peti mesej',
|
||||
dismiss: 'Tutup',
|
||||
},
|
||||
messages: {
|
||||
title: 'Peti Mesej',
|
||||
detail_title: 'Butiran Mesej',
|
||||
empty: 'Tiada mesej',
|
||||
not_found: 'Mesej tidak dijumpai',
|
||||
view_all: 'Kembali ke peti mesej',
|
||||
back: 'Kembali',
|
||||
mark_all_read: 'Tanda semua dibaca',
|
||||
load_more: 'Muat lagi',
|
||||
delete: 'Padam',
|
||||
delete_all: 'Padam semua',
|
||||
delete_confirm: 'Padam mesej ini?',
|
||||
delete_all_confirm: 'Padam semua mesej? Tindakan ini tidak boleh dibatalkan.',
|
||||
banner_promo_view: 'Lihat promosi',
|
||||
content_promo_view: 'Lihat butiran',
|
||||
status_unread: 'Belum dibaca',
|
||||
status_read: 'Dibaca',
|
||||
deposit_approved_title: 'Deposit diluluskan',
|
||||
deposit_rejected_title: 'Deposit ditolak',
|
||||
deposit_approved_body: 'Pesanan {orderNo} diluluskan. Diminta {amount}, dikreditkan {approvedAmount}.',
|
||||
deposit_rejected_body: 'Pesanan {orderNo} ({amount}) ditolak. {reason}',
|
||||
reject_reason: 'Sebab penolakan',
|
||||
no_reason: 'Tiada sebab diberikan',
|
||||
view_recharge_history: 'Lihat sejarah deposit',
|
||||
unread_badge: '{count} belum dibaca',
|
||||
open_inbox: 'Buka peti mesej',
|
||||
},
|
||||
inbox_hub: {
|
||||
title: 'Mesej & Sokongan',
|
||||
tab_messages: 'Peti Mesej',
|
||||
tab_support: 'Sokongan',
|
||||
open: 'Buka mesej dan sokongan',
|
||||
open_support: 'Buka sokongan',
|
||||
},
|
||||
history: {
|
||||
league_default: 'Bola Sepak',
|
||||
stake: 'Jumlah',
|
||||
@@ -402,6 +468,11 @@ export default {
|
||||
slip_currency: 'Amaun',
|
||||
slip_min: 'Min',
|
||||
slip_min_error: 'Jumlah minimum ialah {amount}',
|
||||
odds_changed: 'Odds beberapa pilihan telah berubah. Terima untuk teruskan.',
|
||||
odds_suspended: 'Beberapa pilihan digantung atau ditutup. Buang untuk teruskan.',
|
||||
accept_changes_place: 'Terima perubahan & pertaruh',
|
||||
odds_was: 'Asal',
|
||||
odds_now: 'Baharu',
|
||||
place_success: 'Pertaruhan berjaya',
|
||||
place_failed: 'Pertaruhan gagal',
|
||||
},
|
||||
|
||||
@@ -8,11 +8,16 @@ export default {
|
||||
load_failed: '加载失败',
|
||||
retry: '重试',
|
||||
back_to_top: '回到顶部',
|
||||
cancel: '取消',
|
||||
confirm: '确定',
|
||||
},
|
||||
nav: { home: '主页', bet: '投注', bet_history: '历史投注', wallet: '账单', profile: '我的' },
|
||||
home: {
|
||||
hot_matches: '热门赛事',
|
||||
hot_tab: '热门',
|
||||
upcoming_tab: '近期',
|
||||
no_matches: '暂无赛事',
|
||||
upcoming_empty: '未来 3 天内暂无赛事',
|
||||
announcement_badge: '公告',
|
||||
announcement_default:
|
||||
'欢迎光临 TheBet365 · 足球赛事火热进行中 · 理性投注,量力而行',
|
||||
@@ -21,6 +26,67 @@ export default {
|
||||
banner_slide: '第 {n} 张',
|
||||
banner_fallback: 'Banner',
|
||||
},
|
||||
announcements: {
|
||||
title: '公告中心',
|
||||
detail_title: '公告详情',
|
||||
empty: '暂无公告',
|
||||
not_found: '公告不存在或已下线',
|
||||
view_all: '查看全部公告',
|
||||
type_notice: '公告',
|
||||
type_ticker: '跑马灯',
|
||||
type_banner: 'Banner',
|
||||
related_link: '相关链接',
|
||||
go_link: '前往页面',
|
||||
open_link: '打开链接',
|
||||
back: '返回',
|
||||
},
|
||||
search: {
|
||||
placeholder: '搜索球队或联赛',
|
||||
no_results: '未找到相关赛事',
|
||||
results_count: '找到 {count} 场赛事',
|
||||
hint: '输入球队或联赛名称,跳转至投注页筛选',
|
||||
},
|
||||
deposit_notify: {
|
||||
approved_title: '充值已到账',
|
||||
rejected_title: '充值未通过',
|
||||
view_history: '查看充值记录',
|
||||
view_messages: '查看消息中心',
|
||||
dismiss: '关闭',
|
||||
},
|
||||
messages: {
|
||||
title: '消息中心',
|
||||
detail_title: '消息详情',
|
||||
empty: '暂无消息',
|
||||
not_found: '消息不存在',
|
||||
view_all: '返回消息列表',
|
||||
back: '返回',
|
||||
mark_all_read: '全部已读',
|
||||
load_more: '加载更多',
|
||||
delete: '删除',
|
||||
delete_all: '全部删除',
|
||||
delete_confirm: '确定删除这条消息吗?',
|
||||
delete_all_confirm: '确定删除全部消息吗?此操作不可恢复。',
|
||||
banner_promo_view: '查看推广',
|
||||
content_promo_view: '查看详情',
|
||||
status_unread: '未读',
|
||||
status_read: '已读',
|
||||
deposit_approved_title: '充值已到账',
|
||||
deposit_rejected_title: '充值未通过',
|
||||
deposit_approved_body: '订单 {orderNo} 已审核通过,申请 {amount},到账 {approvedAmount}。',
|
||||
deposit_rejected_body: '订单 {orderNo}({amount})未通过审核。{reason}',
|
||||
reject_reason: '拒绝原因',
|
||||
no_reason: '未提供原因',
|
||||
view_recharge_history: '查看充值记录',
|
||||
unread_badge: '{count} 条未读',
|
||||
open_inbox: '打开消息中心',
|
||||
},
|
||||
inbox_hub: {
|
||||
title: '消息与客服',
|
||||
tab_messages: '邮箱',
|
||||
tab_support: '客服',
|
||||
open: '打开消息与客服',
|
||||
open_support: '打开客服',
|
||||
},
|
||||
history: {
|
||||
league_default: '足球',
|
||||
stake: '投注',
|
||||
@@ -235,7 +301,7 @@ export default {
|
||||
audit_amount: '金额',
|
||||
audit_credited: '入账金额',
|
||||
audit_remark_label: '备注',
|
||||
audit_summary: '审核记录 · {count} 步',
|
||||
audit_summary: '审核记录 · {count} 条',
|
||||
audit_toggle_show: '查看审核记录',
|
||||
audit_toggle_hide: '收起审核记录',
|
||||
view_detail: '查看详情',
|
||||
@@ -396,6 +462,11 @@ export default {
|
||||
slip_currency: '金额',
|
||||
slip_min: '最低',
|
||||
slip_min_error: '最低投注金额为 {amount}',
|
||||
odds_changed: '部分选项赔率已变更,请确认后下注',
|
||||
odds_suspended: '部分选项已暂停或关闭,请移除后重试',
|
||||
accept_changes_place: '接受变更并下注',
|
||||
odds_was: '原赔率',
|
||||
odds_now: '新赔率',
|
||||
place_success: '下注成功',
|
||||
place_failed: '下注失败',
|
||||
},
|
||||
|
||||
@@ -13,17 +13,19 @@ import BackToTopButton from '../components/BackToTopButton.vue';
|
||||
import { computed, defineAsyncComponent, onMounted, ref, watch } from 'vue';
|
||||
|
||||
const BetSlipDrawer = defineAsyncComponent(() => import('../components/BetSlipDrawer.vue'));
|
||||
const CustomerServiceModal = defineAsyncComponent(
|
||||
() => import('../components/CustomerServiceModal.vue'),
|
||||
);
|
||||
import { usePlayerHome } from '../composables/usePlayerHome';
|
||||
import { useInboxFeature } from '../composables/useInboxFeature';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
import { useDepositNotifications } from '../composables/useDepositNotifications';
|
||||
import { usePlayerMessages } from '../composables/usePlayerMessages';
|
||||
import { startPresencePing, stopPresencePing } from '../composables/usePresencePing';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const { initFromUser } = useAppLocale();
|
||||
const route = useRoute();
|
||||
const slip = useBetSlipStore();
|
||||
const { inboxEnabled, hubRoute, hubOpenLabelKey } = useInboxFeature();
|
||||
|
||||
const isDetailPage = computed(() => {
|
||||
const p = route.path;
|
||||
@@ -32,31 +34,40 @@ const isDetailPage = computed(() => {
|
||||
p.startsWith('/bet/') ||
|
||||
p.startsWith('/bets/') ||
|
||||
p.startsWith('/wallet/') ||
|
||||
p.startsWith('/messages') ||
|
||||
p === '/profile/edit' ||
|
||||
p === '/profile/cashbacks'
|
||||
);
|
||||
});
|
||||
|
||||
const showHeader = computed(() => !isDetailPage.value);
|
||||
const showAnnouncement = computed(() => !isDetailPage.value && !route.path.startsWith('/profile'));
|
||||
const showAnnouncement = computed(
|
||||
() => !isDetailPage.value && !route.path.startsWith('/profile') && !route.path.startsWith('/announcements'),
|
||||
);
|
||||
|
||||
const showBottomNav = computed(() => {
|
||||
const p = route.path;
|
||||
if (
|
||||
p === '/' ||
|
||||
p === '/bet' ||
|
||||
p === '/announcements' ||
|
||||
p.startsWith('/announcements/') ||
|
||||
p.startsWith('/match/') ||
|
||||
p === '/bets' ||
|
||||
p === '/wallet' ||
|
||||
p === '/profile'
|
||||
) return true;
|
||||
// 邮箱关闭时客服页保留底部导航,避免用户无法离开
|
||||
if (!inboxEnabled.value && p === '/messages') return true;
|
||||
return false;
|
||||
});
|
||||
const { announcements, load: loadPlayerHome } = usePlayerHome();
|
||||
const { announcements, announcementItems, load: loadPlayerHome } = usePlayerHome();
|
||||
const { loadProfile, refreshProfile, bindProfileVisibilityRefresh } = usePlayerProfile();
|
||||
const { startPolling, stopPolling } = useDepositNotifications();
|
||||
const { unreadCount, refreshUnreadCount, resetMessagesState } = usePlayerMessages();
|
||||
const mainRef = ref<HTMLElement | null>(null);
|
||||
const tabScrollTops = new Map<string, number>();
|
||||
const customerServiceOpen = ref(false);
|
||||
const primaryAnnouncementId = computed(() => announcementItems.value[0]?.id ?? '');
|
||||
|
||||
watch(locale, (next, prev) => {
|
||||
if (prev && next !== prev) void loadPlayerHome(true);
|
||||
@@ -87,6 +98,13 @@ watch(
|
||||
// 个人资料仅登录用户需要
|
||||
if (token) {
|
||||
void loadProfile(true);
|
||||
startPolling();
|
||||
startPresencePing();
|
||||
if (inboxEnabled.value) void refreshUnreadCount();
|
||||
} else {
|
||||
stopPolling();
|
||||
stopPresencePing();
|
||||
resetMessagesState();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
@@ -96,6 +114,9 @@ watch(
|
||||
() => route.path,
|
||||
(path) => {
|
||||
if (!auth.token) return;
|
||||
if (inboxEnabled.value && path.startsWith('/messages')) {
|
||||
void refreshUnreadCount();
|
||||
}
|
||||
if (balanceRefreshPaths.some((p) => path === p || path.startsWith(`${p}/`))) {
|
||||
void refreshProfile();
|
||||
}
|
||||
@@ -112,11 +133,10 @@ watch(
|
||||
<text x="74" y="18" font-family="'Inter','SF Pro Display',system-ui,sans-serif" font-size="18" font-weight="900" fill="#F8971F" letter-spacing="0.01em">365</text>
|
||||
</svg>
|
||||
<div class="header-actions">
|
||||
<button
|
||||
type="button"
|
||||
<RouterLink
|
||||
:to="hubRoute"
|
||||
class="support-btn"
|
||||
:aria-label="t('support.open')"
|
||||
@click="customerServiceOpen = true"
|
||||
:aria-label="inboxEnabled && unreadCount ? t('messages.unread_badge', { count: unreadCount }) : t(hubOpenLabelKey)"
|
||||
>
|
||||
<svg class="support-icon" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path
|
||||
@@ -130,7 +150,8 @@ watch(
|
||||
<circle cx="12" cy="11" r="1" fill="currentColor" />
|
||||
<circle cx="15" cy="11" r="1" fill="currentColor" />
|
||||
</svg>
|
||||
</button>
|
||||
<span v-if="auth.user && inboxEnabled && unreadCount > 0" class="hub-badge">{{ unreadCount > 99 ? '99+' : unreadCount }}</span>
|
||||
</RouterLink>
|
||||
<div class="header-divider" />
|
||||
<LocaleSwitcher />
|
||||
<template v-if="auth.user">
|
||||
@@ -144,7 +165,11 @@ watch(
|
||||
</header>
|
||||
|
||||
<div v-if="showAnnouncement" class="announce-strip">
|
||||
<AnnouncementMarquee :items="announcements" embedded />
|
||||
<AnnouncementMarquee
|
||||
:items="announcements"
|
||||
:target-id="primaryAnnouncementId"
|
||||
embedded
|
||||
/>
|
||||
</div>
|
||||
|
||||
<main ref="mainRef" :class="['main', { 'has-nav': showBottomNav }]">
|
||||
@@ -186,7 +211,6 @@ watch(
|
||||
<BackToTopButton :scroll-el="mainRef" :above-nav="showBottomNav" />
|
||||
|
||||
<BetSlipDrawer v-model="slip.drawerOpen" />
|
||||
<CustomerServiceModal v-model="customerServiceOpen" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -258,6 +282,8 @@ watch(
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
text-decoration: none;
|
||||
}
|
||||
.support-btn:active {
|
||||
background: var(--bg-hover);
|
||||
@@ -270,6 +296,22 @@ watch(
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.hub-badge {
|
||||
position: absolute;
|
||||
top: -4px;
|
||||
right: -4px;
|
||||
min-width: 16px;
|
||||
padding: 0 4px;
|
||||
border-radius: 8px;
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.support-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ const router = createRouter({
|
||||
{ path: '', component: () => import('../views/HomeView.vue'), meta: { keepAlive: true } },
|
||||
{ path: 'bet', component: () => import('../views/FootballView.vue'), meta: { keepAlive: true } },
|
||||
{ path: 'football', redirect: '/bet' },
|
||||
{ path: 'announcements', component: () => import('../views/AnnouncementListView.vue') },
|
||||
{ path: 'announcements/:id', component: () => import('../views/AnnouncementDetailView.vue') },
|
||||
{ path: 'messages', component: () => import('../views/InboxHubView.vue'), meta: { keepAlive: true, requiresAuth: false } },
|
||||
{ path: 'messages/:id', component: () => import('../views/MessageDetailView.vue'), meta: { requiresAuth: true } },
|
||||
{ path: 'match/:id', component: () => import('../views/MatchDetailView.vue') },
|
||||
// 需要登录的页面
|
||||
{ path: 'bets', component: () => import('../views/MyBetsView.vue'), meta: { keepAlive: true, requiresAuth: true } },
|
||||
|
||||
@@ -179,6 +179,16 @@ export const useBetSlipStore = defineStore('betSlip', () => {
|
||||
drawerOpen.value = false;
|
||||
}
|
||||
|
||||
function updateSelectionOdds(selectionId: string, odds: number, oddsVersion: string) {
|
||||
if (singleItem.value?.selectionId === selectionId) {
|
||||
singleItem.value = { ...singleItem.value, odds, oddsVersion };
|
||||
}
|
||||
const idx = parlayItems.value.findIndex((i) => i.selectionId === selectionId);
|
||||
if (idx >= 0) {
|
||||
parlayItems.value[idx] = { ...parlayItems.value[idx], odds, oddsVersion };
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
singleItem,
|
||||
parlayItems,
|
||||
@@ -209,5 +219,6 @@ export const useBetSlipStore = defineStore('betSlip', () => {
|
||||
clearAll,
|
||||
openDrawer,
|
||||
closeDrawer,
|
||||
updateSelectionOdds,
|
||||
};
|
||||
});
|
||||
|
||||
65
apps/player/src/utils/html.ts
Normal file
65
apps/player/src/utils/html.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
const ALLOWED_TAGS = new Set([
|
||||
'p', 'br', 'strong', 'b', 'em', 'i', 'u', 'ul', 'ol', 'li',
|
||||
'img', 'a', 'h2', 'h3', 'blockquote', 'div', 'span',
|
||||
]);
|
||||
|
||||
function sanitizeNode(node: Node): Node | null {
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
return node.cloneNode(false);
|
||||
}
|
||||
if (node.nodeType !== Node.ELEMENT_NODE) return null;
|
||||
|
||||
const el = node as HTMLElement;
|
||||
const tag = el.tagName.toLowerCase();
|
||||
if (!ALLOWED_TAGS.has(tag)) {
|
||||
const frag = document.createDocumentFragment();
|
||||
for (const child of Array.from(el.childNodes)) {
|
||||
const safe = sanitizeNode(child);
|
||||
if (safe) frag.appendChild(safe);
|
||||
}
|
||||
return frag;
|
||||
}
|
||||
|
||||
const out = document.createElement(tag);
|
||||
if (tag === 'img') {
|
||||
const src = el.getAttribute('src')?.trim();
|
||||
if (!src || /^javascript:/i.test(src)) return null;
|
||||
out.setAttribute('src', src);
|
||||
const alt = el.getAttribute('alt');
|
||||
if (alt) out.setAttribute('alt', alt);
|
||||
return out;
|
||||
}
|
||||
if (tag === 'a') {
|
||||
const href = el.getAttribute('href')?.trim();
|
||||
if (!href || /^javascript:/i.test(href)) return null;
|
||||
out.setAttribute('href', href);
|
||||
out.setAttribute('target', '_blank');
|
||||
out.setAttribute('rel', 'noopener noreferrer');
|
||||
}
|
||||
for (const child of Array.from(el.childNodes)) {
|
||||
const safe = sanitizeNode(child);
|
||||
if (safe) out.appendChild(safe);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** 玩家端公告正文 HTML 白名单净化 */
|
||||
export function sanitizeAnnouncementHtml(html: string): string {
|
||||
if (!html?.trim()) return '';
|
||||
if (!/[<>]/.test(html)) return html;
|
||||
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
const container = document.createElement('div');
|
||||
for (const child of Array.from(doc.body.childNodes)) {
|
||||
const safe = sanitizeNode(child);
|
||||
if (safe) container.appendChild(safe);
|
||||
}
|
||||
return container.innerHTML;
|
||||
}
|
||||
|
||||
export function stripHtml(html: string): string {
|
||||
if (!html) return '';
|
||||
if (!/[<>]/.test(html)) return html.trim();
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
return (doc.body.textContent ?? '').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
323
apps/player/src/views/AnnouncementDetailView.vue
Normal file
323
apps/player/src/views/AnnouncementDetailView.vue
Normal file
@@ -0,0 +1,323 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatLocalMatchDateTime } from '@thebet365/shared';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import defaultBannerImg from '../assets/images/banner.webp';
|
||||
import { usePlayerHome, type PlayerContentItem } from '../composables/usePlayerHome';
|
||||
import { sanitizeAnnouncementHtml, stripHtml } from '../utils/html';
|
||||
|
||||
const FALLBACK_IMG = '/uploads/banners/welcome.svg';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const { announcementItems, bannerItems, loading, load } = usePlayerHome();
|
||||
|
||||
const announcementId = computed(() => String(route.params.id ?? ''));
|
||||
|
||||
const item = computed<PlayerContentItem | null>(() => {
|
||||
const id = announcementId.value;
|
||||
return (
|
||||
bannerItems.value.find((entry) => entry.id === id) ??
|
||||
announcementItems.value.find((entry) => entry.id === id) ??
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
const isBanner = computed(() => item.value?.contentType === 'BANNER');
|
||||
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
|
||||
function goList() {
|
||||
router.push('/announcements');
|
||||
}
|
||||
|
||||
function formatDate(createdAt?: string) {
|
||||
if (!createdAt) return '';
|
||||
return formatLocalMatchDateTime(createdAt, locale.value, { variant: 'full' });
|
||||
}
|
||||
|
||||
function itemTitle(entry: PlayerContentItem) {
|
||||
const title = entry.translation?.title?.trim();
|
||||
if (title) return title;
|
||||
const bodyText = stripHtml(entry.translation?.body ?? '');
|
||||
return bodyText || t('home.announcement_badge');
|
||||
}
|
||||
|
||||
function itemBodyHtml(entry: PlayerContentItem) {
|
||||
const title = entry.translation?.title?.trim();
|
||||
const body = entry.translation?.body?.trim();
|
||||
if (!body) return '';
|
||||
if (title && stripHtml(body) === title) return '';
|
||||
return sanitizeAnnouncementHtml(body);
|
||||
}
|
||||
|
||||
const heroImageUrl = computed(() => {
|
||||
const url = item.value?.translation?.imageUrl?.trim();
|
||||
if (url) return url;
|
||||
if (isBanner.value) return defaultBannerImg || FALLBACK_IMG;
|
||||
return '';
|
||||
});
|
||||
|
||||
const linkTarget = computed(() => item.value?.linkTarget?.trim() ?? '');
|
||||
|
||||
const externalLinkUrl = computed(() => {
|
||||
if (item.value?.linkType !== 'URL' || !linkTarget.value) return '';
|
||||
return /^https?:\/\//i.test(linkTarget.value)
|
||||
? linkTarget.value
|
||||
: `https://${linkTarget.value}`;
|
||||
});
|
||||
|
||||
function onHeroError(e: Event) {
|
||||
const img = e.target as HTMLImageElement;
|
||||
if (img.dataset.fallbackApplied) return;
|
||||
img.dataset.fallbackApplied = '1';
|
||||
img.src = defaultBannerImg || FALLBACK_IMG;
|
||||
}
|
||||
|
||||
function followRouteLink() {
|
||||
if (item.value?.linkType === 'ROUTE' && linkTarget.value) {
|
||||
void router.push(linkTarget.value);
|
||||
}
|
||||
}
|
||||
|
||||
function openExternalLink() {
|
||||
if (externalLinkUrl.value) {
|
||||
window.open(externalLinkUrl.value, '_blank', 'noopener');
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
await load(true);
|
||||
}
|
||||
|
||||
onActivated(() => {
|
||||
void refresh();
|
||||
});
|
||||
|
||||
watch(announcementId, () => {
|
||||
if (!item.value && !loading.value) void refresh();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="announce-detail">
|
||||
<header class="page-header">
|
||||
<button type="button" class="back-btn" :aria-label="t('announcements.back')" @click="goBack">‹</button>
|
||||
<h1>{{ t('announcements.detail_title') }}</h1>
|
||||
</header>
|
||||
|
||||
<div v-if="loading && !item" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!item" class="empty">
|
||||
<p>{{ t('announcements.not_found') }}</p>
|
||||
<button type="button" class="link-btn" @click="goList">{{ t('announcements.view_all') }}</button>
|
||||
</div>
|
||||
|
||||
<article v-else class="detail-article">
|
||||
<figure v-if="heroImageUrl" class="detail-hero">
|
||||
<img :src="heroImageUrl" :alt="itemTitle(item)" loading="lazy" @error="onHeroError" />
|
||||
</figure>
|
||||
|
||||
<div class="detail-body-wrap">
|
||||
<p v-if="item.createdAt" class="detail-date">{{ formatDate(item.createdAt) }}</p>
|
||||
<h2 class="detail-title">{{ itemTitle(item) }}</h2>
|
||||
<div v-if="itemBodyHtml(item)" class="detail-body" v-html="itemBodyHtml(item)" />
|
||||
|
||||
<div v-if="item.linkType && linkTarget" class="detail-link">
|
||||
<p class="link-label">{{ t('announcements.related_link') }}</p>
|
||||
<p class="link-address">{{ linkTarget }}</p>
|
||||
<button
|
||||
v-if="item.linkType === 'ROUTE'"
|
||||
type="button"
|
||||
class="link-action"
|
||||
@click="followRouteLink"
|
||||
>
|
||||
{{ t('announcements.go_link') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="item.linkType === 'URL'"
|
||||
type="button"
|
||||
class="link-action link-action--outline"
|
||||
@click="openExternalLink"
|
||||
>
|
||||
{{ t('announcements.open_link') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announce-detail {
|
||||
min-height: 100%;
|
||||
padding: 0 0 24px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 0 14px;
|
||||
margin-bottom: 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.state,
|
||||
.empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 48px 16px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.link-btn {
|
||||
border: 1px solid var(--border-active);
|
||||
border-radius: 8px;
|
||||
padding: 8px 14px;
|
||||
background: rgba(0, 61, 107, 0.06);
|
||||
color: var(--primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.detail-article {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.detail-hero {
|
||||
margin: 16px -16px 0;
|
||||
padding: 0;
|
||||
background: var(--bg-body);
|
||||
line-height: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.detail-hero img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
object-fit: contain;
|
||||
object-position: center;
|
||||
}
|
||||
|
||||
.detail-body-wrap {
|
||||
padding: 18px 0 0;
|
||||
}
|
||||
|
||||
.detail-date {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1.45;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.detail-body {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
line-height: 1.75;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.detail-body :deep(p) {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
.detail-body :deep(p:last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.detail-body :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
margin: 14px 0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.detail-body :deep(ul),
|
||||
.detail-body :deep(ol) {
|
||||
margin: 0 0 12px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.detail-body :deep(a) {
|
||||
color: var(--primary-light);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.detail-link {
|
||||
margin-top: 24px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.link-label {
|
||||
margin: 0 0 8px;
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.link-address {
|
||||
margin: 0 0 14px;
|
||||
font-size: 14px;
|
||||
line-height: 1.55;
|
||||
color: var(--primary-light);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.link-action {
|
||||
width: 100%;
|
||||
padding: 11px 14px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.link-action--outline {
|
||||
background: transparent;
|
||||
border: 1px solid var(--border-active);
|
||||
color: var(--primary);
|
||||
}
|
||||
</style>
|
||||
179
apps/player/src/views/AnnouncementListView.vue
Normal file
179
apps/player/src/views/AnnouncementListView.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatLocalMatchDateTime } from '@thebet365/shared';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePlayerHome } from '../composables/usePlayerHome';
|
||||
import { stripHtml } from '../utils/html';
|
||||
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const { announcementItems, loading, load } = usePlayerHome();
|
||||
|
||||
const items = computed(() => announcementItems.value);
|
||||
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
|
||||
function openDetail(id: string) {
|
||||
router.push(`/announcements/${id}`);
|
||||
}
|
||||
|
||||
function formatDate(createdAt?: string) {
|
||||
if (!createdAt) return '';
|
||||
return formatLocalMatchDateTime(createdAt, locale.value, { variant: 'full' });
|
||||
}
|
||||
|
||||
function itemTitle(item: (typeof items.value)[number]) {
|
||||
const title = item.translation?.title?.trim();
|
||||
if (title) return title;
|
||||
return stripHtml(item.translation?.body ?? '') || t('home.announcement_badge');
|
||||
}
|
||||
|
||||
function itemPreview(item: (typeof items.value)[number]) {
|
||||
const title = item.translation?.title?.trim();
|
||||
const bodyText = stripHtml(item.translation?.body ?? '');
|
||||
if (bodyText && bodyText !== title) return bodyText;
|
||||
return '';
|
||||
}
|
||||
|
||||
onActivated(() => {
|
||||
void load(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="announce-page">
|
||||
<header class="page-header">
|
||||
<button type="button" class="back-btn" :aria-label="t('announcements.back')" @click="goBack">‹</button>
|
||||
<h1>{{ t('announcements.title') }}</h1>
|
||||
</header>
|
||||
|
||||
<div v-if="loading && !items.length" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="!items.length" class="empty">
|
||||
<p>{{ t('announcements.empty') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="list">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="list-row"
|
||||
@click="openDetail(item.id)"
|
||||
>
|
||||
<span class="row-main">
|
||||
<span class="title">{{ itemTitle(item) }}</span>
|
||||
<span v-if="itemPreview(item)" class="preview">{{ itemPreview(item) }}</span>
|
||||
<span v-if="item.createdAt" class="date">{{ formatDate(item.createdAt) }}</span>
|
||||
</span>
|
||||
<span class="chevron" aria-hidden="true">›</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announce-page {
|
||||
min-height: 100%;
|
||||
padding: 0 0 24px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 0 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.state,
|
||||
.empty {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 48px 16px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.list-row {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 0;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.row-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--primary-dark, #002847);
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.preview {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
color: var(--text-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.date {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
flex-shrink: 0;
|
||||
font-size: 20px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onActivated } from 'vue';
|
||||
import { onActivated, computed, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import emptyMatchesImg from '../assets/images/empty-matches.svg';
|
||||
@@ -11,11 +11,28 @@ import TeamEmblem from '../components/TeamEmblem.vue';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
import { formatLocalMatchDateTime } from '@thebet365/shared';
|
||||
import type { PlayerHomeMatch } from '../composables/usePlayerHome';
|
||||
|
||||
type HotTab = 'hot' | 'upcoming';
|
||||
|
||||
const matchCardBg = `url(${cardBg})`;
|
||||
const { t, locale } = useI18n();
|
||||
const router = useRouter();
|
||||
const { banners, hotMatches, loading, load } = usePlayerHome();
|
||||
const { banners, hotMatches, upcomingMatches, loading, load, announcementItems } = usePlayerHome();
|
||||
const activeTab = ref<HotTab>('hot');
|
||||
|
||||
const bannerFallbackTo = computed(() => {
|
||||
const id = announcementItems.value[0]?.id;
|
||||
return id ? `/announcements/${id}` : '/announcements';
|
||||
});
|
||||
|
||||
const displayedMatches = computed<PlayerHomeMatch[]>(() =>
|
||||
activeTab.value === 'hot' ? hotMatches.value : upcomingMatches.value,
|
||||
);
|
||||
|
||||
const emptyMessage = computed(() =>
|
||||
activeTab.value === 'hot' ? t('home.no_matches') : t('home.upcoming_empty'),
|
||||
);
|
||||
|
||||
const { pullDistance, refreshing, spinning, progress } = usePullToRefresh({
|
||||
onRefresh: async () => { await load(true); },
|
||||
@@ -47,7 +64,7 @@ function formatKickoff(startTime: string) {
|
||||
<GoldSpinner v-if="spinning" :size="28" :progress="progress" :active="spinning" />
|
||||
</div>
|
||||
|
||||
<BannerCarousel :banners="banners" />
|
||||
<BannerCarousel :banners="banners" :fallback-to="bannerFallbackTo" />
|
||||
|
||||
<div class="quick-entries">
|
||||
<button type="button" class="qe-item" @click="router.push('/bet')">
|
||||
@@ -70,9 +87,31 @@ function formatKickoff(startTime: string) {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h2 class="section-title">{{ t('home.hot_matches') }}</h2>
|
||||
<div class="hot-tabs" role="tablist" :aria-label="t('home.hot_matches')">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="hot-tab"
|
||||
:class="{ active: activeTab === 'hot' }"
|
||||
:aria-selected="activeTab === 'hot'"
|
||||
@click="activeTab = 'hot'"
|
||||
>
|
||||
{{ t('home.hot_tab') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="hot-tab"
|
||||
:class="{ active: activeTab === 'upcoming' }"
|
||||
:aria-selected="activeTab === 'upcoming'"
|
||||
@click="activeTab = 'upcoming'"
|
||||
>
|
||||
{{ t('home.upcoming_tab') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="(match, index) in hotMatches"
|
||||
v-for="(match, index) in displayedMatches"
|
||||
:key="match.id"
|
||||
class="match-card"
|
||||
:class="{ 'match-card--live-anim': index < 3 }"
|
||||
@@ -123,9 +162,9 @@ function formatKickoff(startTime: string) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!loading && !hotMatches.length" class="empty">
|
||||
<div v-if="!loading && !displayedMatches.length" class="empty">
|
||||
<img :src="emptyMatchesImg" alt="" class="empty-icon" />
|
||||
<p>{{ t('home.no_matches') }}</p>
|
||||
<p>{{ emptyMessage }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -139,6 +178,31 @@ function formatKickoff(startTime: string) {
|
||||
transition: height 0.15s ease;
|
||||
}
|
||||
|
||||
.hot-tabs {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.hot-tab {
|
||||
flex: 1;
|
||||
padding: 8px 4px;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.hot-tab.active {
|
||||
color: var(--primary);
|
||||
border-bottom-color: var(--primary);
|
||||
}
|
||||
|
||||
.quick-entries {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
||||
315
apps/player/src/views/InboxHubView.vue
Normal file
315
apps/player/src/views/InboxHubView.vue
Normal file
@@ -0,0 +1,315 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import MessageListPanel from '../components/MessageListPanel.vue';
|
||||
import CustomerServicePanel from '../components/CustomerServicePanel.vue';
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { usePlayerMessages } from '../composables/usePlayerMessages';
|
||||
import { useInboxFeature } from '../composables/useInboxFeature';
|
||||
|
||||
type HubTab = 'messages' | 'support';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
const { inboxEnabled, hubTitleKey } = useInboxFeature();
|
||||
const {
|
||||
unreadCount,
|
||||
messages,
|
||||
listLoaded,
|
||||
refreshUnreadCount,
|
||||
markAllRead,
|
||||
deleteAllMessages,
|
||||
} = usePlayerMessages();
|
||||
|
||||
const markingAll = ref(false);
|
||||
const deletingAll = ref(false);
|
||||
const deleteAllConfirmVisible = ref(false);
|
||||
|
||||
const activeTab = computed<HubTab>(() => {
|
||||
if (!inboxEnabled.value) return 'support';
|
||||
return route.query.tab === 'support' ? 'support' : 'messages';
|
||||
});
|
||||
|
||||
const unreadInList = computed(() => messages.value.filter((item) => !item.isRead).length);
|
||||
const hasMessages = computed(() => listLoaded.value && messages.value.length > 0);
|
||||
const showMessageActions = computed(
|
||||
() => inboxEnabled.value && activeTab.value === 'messages' && auth.token && hasMessages.value,
|
||||
);
|
||||
|
||||
function switchTab(tab: HubTab) {
|
||||
if (!inboxEnabled.value || tab === activeTab.value) return;
|
||||
router.replace({ path: '/messages', query: tab === 'support' ? { tab: 'support' } : {} });
|
||||
}
|
||||
|
||||
async function onMarkAllRead() {
|
||||
if (!unreadInList.value || markingAll.value) return;
|
||||
markingAll.value = true;
|
||||
try {
|
||||
await markAllRead();
|
||||
await refreshUnreadCount();
|
||||
} finally {
|
||||
markingAll.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDeleteAll() {
|
||||
if (deletingAll.value || !messages.value.length) return;
|
||||
deleteAllConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
async function confirmDeleteAll() {
|
||||
if (deletingAll.value || !messages.value.length) return;
|
||||
deletingAll.value = true;
|
||||
try {
|
||||
await deleteAllMessages();
|
||||
await refreshUnreadCount();
|
||||
deleteAllConfirmVisible.value = false;
|
||||
} finally {
|
||||
deletingAll.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function ensureSupportTabWhenDisabled() {
|
||||
if (inboxEnabled.value || route.path !== '/messages') return;
|
||||
if (route.query.tab === 'support') return;
|
||||
void router.replace({ path: '/messages', query: { tab: 'support' } });
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
|
||||
watch(inboxEnabled, (enabled, prev) => {
|
||||
if (prev && !enabled) ensureSupportTabWhenDisabled();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.query.tab,
|
||||
() => {
|
||||
if (inboxEnabled.value && activeTab.value === 'messages') void refreshUnreadCount();
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(ensureSupportTabWhenDisabled);
|
||||
|
||||
onActivated(() => {
|
||||
if (inboxEnabled.value) {
|
||||
void refreshUnreadCount();
|
||||
return;
|
||||
}
|
||||
ensureSupportTabWhenDisabled();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="inbox-hub" :class="{ 'inbox-hub--tabs': inboxEnabled }">
|
||||
<header v-if="!inboxEnabled" class="page-header">
|
||||
<button type="button" class="back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
||||
<h1>{{ t(hubTitleKey) }}</h1>
|
||||
</header>
|
||||
|
||||
<div v-if="inboxEnabled" class="hub-top-bar">
|
||||
<button type="button" class="hub-back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
||||
<nav class="hub-tabs" role="tablist">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="hub-tab"
|
||||
:class="{ active: activeTab === 'messages' }"
|
||||
:aria-selected="activeTab === 'messages'"
|
||||
@click="switchTab('messages')"
|
||||
>
|
||||
<span class="hub-tab-label">{{ t('inbox_hub.tab_messages') }}</span>
|
||||
<span v-if="auth.token && unreadCount > 0" class="hub-tab-badge">
|
||||
{{ unreadCount > 99 ? '99+' : unreadCount }}
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
class="hub-tab"
|
||||
:class="{ active: activeTab === 'support' }"
|
||||
:aria-selected="activeTab === 'support'"
|
||||
@click="switchTab('support')"
|
||||
>
|
||||
{{ t('inbox_hub.tab_support') }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div v-if="showMessageActions" class="message-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn"
|
||||
:disabled="!unreadInList || markingAll"
|
||||
@click="onMarkAllRead"
|
||||
>
|
||||
{{ t('messages.mark_all_read') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn danger"
|
||||
:disabled="deletingAll"
|
||||
@click="onDeleteAll"
|
||||
>
|
||||
{{ t('messages.delete_all') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<MessageListPanel v-if="inboxEnabled" v-show="activeTab === 'messages'" />
|
||||
<CustomerServicePanel v-if="activeTab === 'support'" />
|
||||
|
||||
<ConfirmDialog
|
||||
v-model:visible="deleteAllConfirmVisible"
|
||||
:title="t('messages.delete_all')"
|
||||
:message="t('messages.delete_all_confirm')"
|
||||
:confirm-text="t('messages.delete_all')"
|
||||
danger
|
||||
:loading="deletingAll"
|
||||
@confirm="confirmDeleteAll"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.inbox-hub {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
padding: 0 0 24px;
|
||||
}
|
||||
|
||||
.inbox-hub--tabs {
|
||||
margin: -12px -16px 0;
|
||||
padding: max(12px, env(safe-area-inset-top, 0px)) 16px 0;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 0 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.hub-top-bar {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.hub-back-btn {
|
||||
flex-shrink: 0;
|
||||
align-self: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.hub-tabs {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
gap: 0;
|
||||
margin: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.hub-tab {
|
||||
flex: 1;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 10px 8px;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: color 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.hub-tab.active {
|
||||
color: var(--primary);
|
||||
border-bottom-color: var(--primary);
|
||||
}
|
||||
|
||||
.hub-tab-label {
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.hub-tab-badge {
|
||||
min-width: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 9px;
|
||||
background: var(--primary);
|
||||
color: #fff;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
line-height: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.message-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 10px 0 4px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
flex: 1;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--border-active);
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 61, 107, 0.06);
|
||||
color: var(--primary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.action-btn:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.action-btn.danger {
|
||||
border-color: rgba(220, 38, 38, 0.35);
|
||||
background: rgba(220, 38, 38, 0.06);
|
||||
color: #dc2626;
|
||||
}
|
||||
</style>
|
||||
364
apps/player/src/views/MessageDetailView.vue
Normal file
364
apps/player/src/views/MessageDetailView.vue
Normal file
@@ -0,0 +1,364 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatLocalMatchDateTime } from '@thebet365/shared';
|
||||
import { formatMoney } from '../utils/localeDisplay';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import ConfirmDialog from '../components/ConfirmDialog.vue';
|
||||
import {
|
||||
usePlayerMessages,
|
||||
type DepositMessagePayload,
|
||||
type BannerPromoPayload,
|
||||
type PlayerMessage,
|
||||
} from '../composables/usePlayerMessages';
|
||||
import { useInboxFeature } from '../composables/useInboxFeature';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
const { loadMessageDetail, markMessageRead, deleteMessage } = usePlayerMessages();
|
||||
const { hubRoute } = useInboxFeature();
|
||||
|
||||
const messageId = computed(() => String(route.params.id ?? ''));
|
||||
const message = ref<PlayerMessage | null>(null);
|
||||
const loading = ref(false);
|
||||
const error = ref(false);
|
||||
const deleting = ref(false);
|
||||
const deleteConfirmVisible = ref(false);
|
||||
|
||||
const depositPayload = computed(() => {
|
||||
if (
|
||||
!message.value ||
|
||||
message.value.type === 'BANNER_PROMO' ||
|
||||
message.value.type === 'ANNOUNCEMENT_PROMO'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return (message.value.payload ?? null) as DepositMessagePayload | null;
|
||||
});
|
||||
const contentPromoId = computed(() => {
|
||||
if (
|
||||
message.value?.type !== 'BANNER_PROMO' &&
|
||||
message.value?.type !== 'ANNOUNCEMENT_PROMO'
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return (message.value.payload as BannerPromoPayload | null)?.contentId;
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
router.back();
|
||||
}
|
||||
|
||||
function goList() {
|
||||
router.push(hubRoute.value);
|
||||
}
|
||||
|
||||
function viewContentPromo() {
|
||||
if (!contentPromoId.value) return;
|
||||
router.push(`/announcements/${contentPromoId.value}`);
|
||||
}
|
||||
|
||||
function formatDate(createdAt?: string) {
|
||||
if (!createdAt) return '';
|
||||
return formatLocalMatchDateTime(createdAt, locale.value, { variant: 'full' });
|
||||
}
|
||||
|
||||
function messageTitle(item: PlayerMessage) {
|
||||
if (item.type === 'DEPOSIT_APPROVED') return t('messages.deposit_approved_title');
|
||||
if (item.type === 'DEPOSIT_REJECTED') return t('messages.deposit_rejected_title');
|
||||
if (item.type === 'BANNER_PROMO' || item.type === 'ANNOUNCEMENT_PROMO') return item.title;
|
||||
return item.title;
|
||||
}
|
||||
|
||||
function messageBody(item: PlayerMessage) {
|
||||
const deposit = depositPayload.value;
|
||||
if (item.type === 'DEPOSIT_APPROVED' && deposit?.orderNo) {
|
||||
return t('messages.deposit_approved_body', {
|
||||
orderNo: deposit.orderNo,
|
||||
amount: formatMoney(deposit.amount ?? '0', locale.value),
|
||||
approvedAmount: formatMoney(
|
||||
deposit.approvedAmount ?? deposit.amount ?? '0',
|
||||
locale.value,
|
||||
),
|
||||
});
|
||||
}
|
||||
if (item.type === 'DEPOSIT_REJECTED' && deposit?.orderNo) {
|
||||
return t('messages.deposit_rejected_body', {
|
||||
orderNo: deposit.orderNo,
|
||||
amount: formatMoney(deposit.amount ?? '0', locale.value),
|
||||
reason: deposit.rejectReason?.trim() || t('messages.no_reason'),
|
||||
});
|
||||
}
|
||||
return item.body;
|
||||
}
|
||||
|
||||
async function fetchDetail() {
|
||||
if (!messageId.value) return;
|
||||
loading.value = true;
|
||||
error.value = false;
|
||||
try {
|
||||
message.value = await loadMessageDetail(messageId.value);
|
||||
if (message.value && !message.value.isRead) {
|
||||
await markMessageRead(messageId.value);
|
||||
message.value = { ...message.value, isRead: true };
|
||||
}
|
||||
} catch {
|
||||
error.value = true;
|
||||
message.value = null;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDelete() {
|
||||
if (!messageId.value || deleting.value) return;
|
||||
deleteConfirmVisible.value = true;
|
||||
}
|
||||
|
||||
async function confirmDelete() {
|
||||
if (!messageId.value || deleting.value) return;
|
||||
deleting.value = true;
|
||||
try {
|
||||
await deleteMessage(messageId.value);
|
||||
deleteConfirmVisible.value = false;
|
||||
router.replace(hubRoute.value);
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void fetchDetail();
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
void fetchDetail();
|
||||
});
|
||||
|
||||
watch(messageId, () => {
|
||||
void fetchDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="message-detail">
|
||||
<header class="page-header">
|
||||
<button type="button" class="back-btn" :aria-label="t('messages.back')" @click="goBack">‹</button>
|
||||
<h1>{{ t('messages.detail_title') }}</h1>
|
||||
<button
|
||||
v-if="message"
|
||||
type="button"
|
||||
class="delete-header-btn"
|
||||
:aria-label="t('messages.delete')"
|
||||
:disabled="deleting"
|
||||
@click="onDelete"
|
||||
>
|
||||
{{ t('messages.delete') }}
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div v-if="loading && !message" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="error || !message" class="empty">
|
||||
<p>{{ t('messages.not_found') }}</p>
|
||||
<button type="button" class="link-btn" @click="goList">{{ t('messages.view_all') }}</button>
|
||||
</div>
|
||||
|
||||
<article v-else class="detail-article">
|
||||
<span class="status-badge" :class="{ unread: !message.isRead }">
|
||||
{{ message.isRead ? t('messages.status_read') : t('messages.status_unread') }}
|
||||
</span>
|
||||
<p v-if="message.createdAt" class="detail-date">{{ formatDate(message.createdAt) }}</p>
|
||||
<h2 class="detail-title">{{ messageTitle(message) }}</h2>
|
||||
<p class="detail-body">{{ messageBody(message) }}</p>
|
||||
|
||||
<div
|
||||
v-if="message.type === 'DEPOSIT_REJECTED' && depositPayload?.rejectReason?.trim()"
|
||||
class="reason-box"
|
||||
>
|
||||
<p class="reason-label">{{ t('messages.reject_reason') }}</p>
|
||||
<p class="reason-text">{{ depositPayload.rejectReason }}</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="contentPromoId"
|
||||
type="button"
|
||||
class="action-btn"
|
||||
@click="viewContentPromo"
|
||||
>
|
||||
{{ t('messages.content_promo_view') }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="depositPayload?.depositOrderId"
|
||||
type="button"
|
||||
class="action-btn"
|
||||
@click="router.push('/wallet/recharge/history')"
|
||||
>
|
||||
{{ t('messages.view_recharge_history') }}
|
||||
</button>
|
||||
</article>
|
||||
|
||||
<ConfirmDialog
|
||||
v-model:visible="deleteConfirmVisible"
|
||||
:title="t('messages.delete')"
|
||||
:message="t('messages.delete_confirm')"
|
||||
:confirm-text="t('messages.delete')"
|
||||
danger
|
||||
:loading="deleting"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.message-detail {
|
||||
min-height: 100%;
|
||||
padding: 0 0 24px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 0 0 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--bg-card);
|
||||
color: var(--primary);
|
||||
font-size: 22px;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.delete-header-btn {
|
||||
border: 1px solid rgba(220, 38, 38, 0.35);
|
||||
border-radius: 8px;
|
||||
padding: 6px 10px;
|
||||
background: rgba(220, 38, 38, 0.06);
|
||||
color: #dc2626;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.delete-header-btn:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
margin-bottom: 8px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.status-badge.unread {
|
||||
color: var(--primary);
|
||||
background: rgba(0, 61, 107, 0.08);
|
||||
}
|
||||
|
||||
.state,
|
||||
.empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 48px 16px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.link-btn {
|
||||
border: 1px solid var(--border-active);
|
||||
border-radius: 8px;
|
||||
padding: 8px 14px;
|
||||
background: rgba(0, 61, 107, 0.06);
|
||||
color: var(--primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.detail-article {
|
||||
padding: 18px 0 0;
|
||||
}
|
||||
|
||||
.detail-date {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
margin: 0 0 12px;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
line-height: 1.45;
|
||||
color: var(--primary-dark, #002847);
|
||||
}
|
||||
|
||||
.detail-body {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
line-height: 1.75;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.reason-box {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(220, 38, 38, 0.2);
|
||||
background: rgba(220, 38, 38, 0.05);
|
||||
}
|
||||
|
||||
.reason-label {
|
||||
margin: 0 0 8px;
|
||||
font-size: 12px;
|
||||
color: #dc2626;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.reason-text {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.55;
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
margin-top: 24px;
|
||||
width: 100%;
|
||||
padding: 11px 14px;
|
||||
border: 1px solid var(--border-active);
|
||||
border-radius: 8px;
|
||||
background: rgba(0, 61, 107, 0.06);
|
||||
color: var(--primary);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -11,6 +11,7 @@ import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
import { parseCashbackApiData, sumCashbackAmount } from '../utils/cashback';
|
||||
import { useInboxFeature } from '../composables/useInboxFeature';
|
||||
import walletBg from '../assets/images/wallet-bg.webp';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
@@ -18,6 +19,7 @@ const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const { locales, setLocale, initFromUser } = useAppLocale();
|
||||
const { profileRaw, refreshProfile } = usePlayerProfile();
|
||||
const { hubRoute } = useInboxFeature();
|
||||
|
||||
const loading = ref(true);
|
||||
const error = ref(false);
|
||||
@@ -188,6 +190,12 @@ const balanceAmountClass = computed(() => {
|
||||
</span>
|
||||
<span class="qa-label">{{ t('recharge.history_title') }}</span>
|
||||
</RouterLink>
|
||||
<RouterLink :to="hubRoute" class="qa-item">
|
||||
<span class="qa-icon qa-icon--inbox">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" width="24" height="24"><path d="M4 6.5A2.5 2.5 0 0 1 6.5 4h11A2.5 2.5 0 0 1 20 6.5v11A2.5 2.5 0 0 1 17.5 20H6.5A2.5 2.5 0 0 1 4 17.5v-11Z"/><path d="m4 7 8 5.5L20 7"/></svg>
|
||||
</span>
|
||||
<span class="qa-label">{{ t('messages.title') }}</span>
|
||||
</RouterLink>
|
||||
</div>
|
||||
|
||||
<section class="settings-group">
|
||||
@@ -577,6 +585,11 @@ const balanceAmountClass = computed(() => {
|
||||
color: #6366F1;
|
||||
}
|
||||
|
||||
.qa-icon--inbox {
|
||||
background: rgba(14, 165, 233, 0.1);
|
||||
color: #0EA5E9;
|
||||
}
|
||||
|
||||
.qa-label {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
|
||||
156
docs/玩家端缺失功能分析.md
Normal file
156
docs/玩家端缺失功能分析.md
Normal file
@@ -0,0 +1,156 @@
|
||||
## 玩家端缺失功能分析
|
||||
|
||||
> 基于 PRD v1.2 要求 + 行业通用标准,对比当前代码实际实现情况
|
||||
> 分析日期:2026-06-17
|
||||
|
||||
---
|
||||
|
||||
### 一、PRD 明确要求但尚未完整实现的功能
|
||||
|
||||
#### 1. 首页「今日赛事」板块
|
||||
|
||||
PRD 4.4 节明确要求首页同时展示「热门赛事」和「今日赛事」两个板块。当前 HomeView.vue 只渲染了 `hotMatches`,缺少按当天开赛时间筛选的「今日赛事」列表。后端 `/player/home` 接口实际已返回 `todayMatches` 数据,前端未消费。
|
||||
|
||||
#### 2. 公告详情页
|
||||
|
||||
PRD 17.2 节将公告定义为"可点击查看详情的完整内容",与走马灯(短文案滚动)是两种不同的内容形态。当前只有 AnnouncementMarquee 走马灯组件,点击后没有跳转到公告详情页查看完整正文。
|
||||
|
||||
#### 3. 投注规则独立页面
|
||||
|
||||
PRD 3.3 节要求"投注规则说明必须三语,减少争议"。当前规则内容硬编码在 ProfileView.vue 的 5 段 i18n 翻译文本中(rules_p1 ~ rules_p5),不可由后台动态维护,也没有独立的规则页面。建议做成后台可编辑、前台可独立访问的规则中心页面。
|
||||
|
||||
---
|
||||
|
||||
### 二、业务闭环缺失的关键功能
|
||||
|
||||
#### 4. 提款 / 出金
|
||||
|
||||
当前已实现充值(Recharge)全流程——银行转账、USDT、截图上传、审核、入账。但完全没有提款/出金功能。玩家赢了钱却无法主动申请提款,这在业务闭环上是最大的缺口。至少需要:提款申请页面、提款方式选择、金额输入、提款记录与状态追踪。
|
||||
|
||||
#### 5. 注单结算/派彩通知
|
||||
|
||||
玩家下注后,赛事结算完成时没有任何主动通知机制。玩家只能反复刷"我的投注"才知道结果。需要:注单结算后推送通知(站内消息或 WebSocket 实时推送),至少在下注成功页和注单列表中有明确的"等待开奖"与"已开奖"状态区分。
|
||||
|
||||
#### 6. 充值/提款状态通知
|
||||
|
||||
充值订单审核通过或被拒绝后,玩家没有收到即时通知。目前只能在充值历史页面手动查看状态变化。
|
||||
|
||||
---
|
||||
|
||||
### 三、体验层面的缺失功能
|
||||
|
||||
#### 7. 赛事 / 球队搜索
|
||||
|
||||
当前赛事浏览路径只有:联赛筛选 → 时间筛选 → 列表滚动。当赛事数量多时,玩家无法通过关键词搜索球队名或联赛名快速定位比赛。需要在赛事列表页或首页增加搜索框。
|
||||
|
||||
#### 8. 投注单清空确认
|
||||
|
||||
BetSlipDrawer 中清空投注单没有二次确认弹窗,容易误操作导致已选择的投注项丢失。
|
||||
|
||||
#### 9. 投注单赔率实时更新提示
|
||||
|
||||
PRD 7.3 节要求"赔率已变化,拒绝下注,提示重新确认"。当前提交时校验赔率版本会报错,但在投注单停留期间没有实时检测赔率变化并主动标记(如高亮变化项、显示新旧赔率对比),玩家只有在点提交时才知道赔率变了。
|
||||
|
||||
#### 10. 盘口封盘倒计时
|
||||
|
||||
赛事列表和详情页没有显示距离封盘的倒计时。玩家不知道赛事何时关闭投注,影响下注决策。
|
||||
|
||||
#### 11. 快捷金额按钮自定义
|
||||
|
||||
PRD 4.3 节桌面端布局提到"快捷投注金额"。当前 BetSlipDrawer 中有固定的快捷金额按钮(Min/5、+50、+100、Max),但不能由后台配置或让玩家自定义。
|
||||
|
||||
#### 12. 我的投注 - 按赛事/时间筛选
|
||||
|
||||
MyBetsView 目前支持按状态筛选(全部/赢/输/待结算/走水),缺少按赛事、按时间范围筛选的能力,注单多了之后查找困难。
|
||||
|
||||
#### 13. 注单详情页 - 缺少分享/截图功能
|
||||
|
||||
玩家无法分享或保存注单截图。在社交平台传播场景中,注单截图是常见的拉新素材。
|
||||
|
||||
---
|
||||
|
||||
### 四、安全与合规相关缺失
|
||||
|
||||
#### 14. 负责任博彩 / 自我限额
|
||||
|
||||
PRD 18.1 节提到玩家每日投注上限和派彩上限由后台配置,但前台没有向玩家展示当前限额使用情况(如"今日已投注 X / 上限 Y"),也没有自我设置存款限额、投注限额、冷静期等负责任博彩工具。对于面向合法市场的平台,这通常是合规要求。
|
||||
|
||||
#### 15. 登录安全 - 缺少二次验证
|
||||
|
||||
玩家端登录只有密码 + 人机验证(RobotVerify),没有可选的短信验证码二次验证或 TOTP,安全性偏弱。
|
||||
|
||||
#### 16. 会话管理
|
||||
|
||||
玩家无法查看当前活跃会话(哪些设备在登录),也无法远程踢出其他设备的会话。
|
||||
|
||||
---
|
||||
|
||||
### 五、运营与增长相关缺失
|
||||
|
||||
#### 17. 邀请好友入口
|
||||
|
||||
后端已有完整的邀请码系统(生成邀请码、设置返水比例、邀请列表、撤销),但玩家前台没有"邀请好友"入口页面,无法查看自己的邀请码、邀请链接、邀请记录和奖励。
|
||||
|
||||
#### 18. 活动 / 优惠专区
|
||||
|
||||
没有活动页面或优惠专区。运营无法通过前台展示限时活动、新人奖励、充值优惠等信息。目前只能依赖 Banner 和公告,缺乏独立的活动落地页。
|
||||
|
||||
#### 19. VIP / 等级体系
|
||||
|
||||
没有玩家等级体系。成熟平台通常根据投注量、充值额等划分 VIP 等级,不同等级享受不同返水比例、专属客服、提款加速等权益。
|
||||
|
||||
---
|
||||
|
||||
### 六、数据辅助功能缺失
|
||||
|
||||
#### 20. 赛事数据 / 历史战绩
|
||||
|
||||
赛事详情页只展示盘口和赔率,没有历史交锋记录、球队近期战绩、联赛积分榜等辅助数据。这些数据可以帮助玩家做投注决策,也是提升用户粘性的手段。
|
||||
|
||||
#### 21. 投注统计 / 个人报表
|
||||
|
||||
虽然有 BetStatsPanel 显示注单数/赢/输/待结算的基础统计,但缺少更丰富的个人投注报表:按时间段统计、按玩法统计、盈亏趋势图、返水收入统计等。
|
||||
|
||||
---
|
||||
|
||||
### 七、其他体验优化建议
|
||||
|
||||
| 编号 | 功能 | 说明 |
|
||||
|---|---|---|
|
||||
| 22 | 赛事收藏 / 关注 | 玩家可以收藏感兴趣的赛事,快速筛选查看 |
|
||||
| 23 | 多赔率格式切换 | PRD 二期提到支持 Decimal/Malay/HK/Indo/American 格式,当前只有十进制 |
|
||||
| 24 | PWA / 添加到主屏幕 | 移动端 H5 支持 PWA 安装提示,提升留存 |
|
||||
| 25 | 网络状态提示 | 弱网或断网时显示明确提示,避免下注失败无感知 |
|
||||
| 26 | 暗色/亮色主题切换 | 当前只有深色主题,没有亮色模式 |
|
||||
| 27 | 系统公告弹窗 | 维护、重大赛事等场景的全屏弹窗通知,目前只有走马灯 |
|
||||
| 28 | 盘口排序偏好 | 允许玩家调整盘口分组默认排序(如把让球放在独赢前面) |
|
||||
|
||||
---
|
||||
|
||||
### 优先级建议
|
||||
|
||||
**P0 - 必须补齐(影响业务闭环):**
|
||||
- 提款功能(#4)
|
||||
- 邀请好友入口(#17)— 后端已就绪,只差前端页面
|
||||
- 注单结算通知(#5)
|
||||
|
||||
**P1 - 高优先级(影响核心体验):**
|
||||
- 今日赛事板块(#1)— 后端数据已有,前端未消费
|
||||
- 赛事搜索(#7)
|
||||
- 投注规则独立页面(#3)
|
||||
- 公告详情页(#2)
|
||||
- 负责任博彩 / 限额展示(#14)
|
||||
|
||||
**P2 - 中优先级(体验优化):**
|
||||
- 盘口封盘倒计时(#10)
|
||||
- 赔率变化实时标记(#9)
|
||||
- 注单筛选增强(#12)
|
||||
- 投注单清空确认(#8)
|
||||
- 充值/提款状态通知(#6)
|
||||
|
||||
**P3 - 低优先级(长期迭代):**
|
||||
- VIP 等级体系(#19)
|
||||
- 活动专区(#18)
|
||||
- 赛事数据/历史战绩(#20)
|
||||
- 多赔率格式(#23)
|
||||
- PWA(#24)
|
||||
@@ -42,6 +42,21 @@ export const API_ERROR_MESSAGES = {
|
||||
'en-US': 'User not found',
|
||||
'ms-MY': 'Pengguna tidak dijumpai',
|
||||
},
|
||||
CANNOT_DELETE_SELF: {
|
||||
'zh-CN': '不能删除自己',
|
||||
'en-US': 'Cannot delete yourself',
|
||||
'ms-MY': 'Tidak boleh memadam diri sendiri',
|
||||
},
|
||||
STAFF_NOT_FOUND: {
|
||||
'zh-CN': '管理员不存在',
|
||||
'en-US': 'Staff member not found',
|
||||
'ms-MY': 'Ahli kakitangan tidak dijumpai',
|
||||
},
|
||||
CANNOT_DELETE_LAST_SUPER_ADMIN: {
|
||||
'zh-CN': '不能删除唯一的超级管理员',
|
||||
'en-US': 'Cannot delete the last super admin',
|
||||
'ms-MY': 'Tidak boleh memadam pentadbir super terakhir',
|
||||
},
|
||||
PASSWORD_CHANGE_DISABLED: {
|
||||
'zh-CN': '当前平台未开放玩家自行修改密码',
|
||||
'en-US': 'Password change is disabled for players',
|
||||
@@ -842,6 +857,11 @@ export const API_ERROR_MESSAGES = {
|
||||
'en-US': 'Content not found',
|
||||
'ms-MY': 'Kandungan tidak dijumpai',
|
||||
},
|
||||
MESSAGE_NOT_FOUND: {
|
||||
'zh-CN': '消息不存在',
|
||||
'en-US': 'Message not found',
|
||||
'ms-MY': 'Mesej tidak dijumpai',
|
||||
},
|
||||
CONTENT_ACTIVE_BANNER_INCOMPLETE: {
|
||||
'zh-CN': '启用 Banner 须至少一种语言配置图片地址',
|
||||
'en-US': 'ACTIVE banner requires imageUrl in at least one locale',
|
||||
|
||||
@@ -44,6 +44,21 @@ export const API_ERROR_MESSAGES = {
|
||||
'en-US': 'User not found',
|
||||
'ms-MY': 'Pengguna tidak dijumpai',
|
||||
},
|
||||
CANNOT_DELETE_SELF: {
|
||||
'zh-CN': '不能删除自己',
|
||||
'en-US': 'Cannot delete yourself',
|
||||
'ms-MY': 'Tidak boleh memadam diri sendiri',
|
||||
},
|
||||
STAFF_NOT_FOUND: {
|
||||
'zh-CN': '管理员不存在',
|
||||
'en-US': 'Staff member not found',
|
||||
'ms-MY': 'Ahli kakitangan tidak dijumpai',
|
||||
},
|
||||
CANNOT_DELETE_LAST_SUPER_ADMIN: {
|
||||
'zh-CN': '不能删除唯一的超级管理员',
|
||||
'en-US': 'Cannot delete the last super admin',
|
||||
'ms-MY': 'Tidak boleh memadam pentadbir super terakhir',
|
||||
},
|
||||
PASSWORD_CHANGE_DISABLED: {
|
||||
'zh-CN': '当前平台未开放玩家自行修改密码',
|
||||
'en-US': 'Password change is disabled for players',
|
||||
@@ -844,6 +859,11 @@ export const API_ERROR_MESSAGES = {
|
||||
'en-US': 'Content not found',
|
||||
'ms-MY': 'Kandungan tidak dijumpai',
|
||||
},
|
||||
MESSAGE_NOT_FOUND: {
|
||||
'zh-CN': '消息不存在',
|
||||
'en-US': 'Message not found',
|
||||
'ms-MY': 'Mesej tidak dijumpai',
|
||||
},
|
||||
CONTENT_ACTIVE_BANNER_INCOMPLETE: {
|
||||
'zh-CN': '启用 Banner 须至少一种语言配置图片地址',
|
||||
'en-US': 'ACTIVE banner requires imageUrl in at least one locale',
|
||||
|
||||
Reference in New Issue
Block a user