fix(admin): 生产环境隐藏并禁用自动化测试

侧栏与路由按服务端 NODE_ENV 控制;可通过 ALLOW_SMOKE_TESTS=true 临时开启。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 17:52:07 +08:00
parent e469611138
commit 283252c841
7 changed files with 94 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { RouterView, RouterLink, useRoute, useRouter } from 'vue-router';
import { useAuthStore } from '../stores/auth';
import { useAdminLocale } from '../composables/useAdminLocale';
import { useSmokeTestsAllowed } from '../composables/useSmokeTestsAllowed';
import AdminLocaleSwitcher from '../components/AdminLocaleSwitcher.vue';
import AdminNavIcon from '../components/AdminNavIcon.vue';
import { resolveAdminBreadcrumb } from '../utils/admin-breadcrumb';
@@ -11,23 +12,30 @@ const route = useRoute();
const router = useRouter();
const auth = useAuthStore();
const { t } = useAdminLocale();
const { allowed: smokeTestsAllowed, ensureLoaded: ensureSmokeTestsAllowed } = useSmokeTestsAllowed();
const sidebarOpen = ref(false);
const isMobileNav = ref(false);
const adminMenus = computed(() => [
{ path: '/', label: t('nav.dashboard'), icon: 'dashboard', matchPrefix: true },
{ path: '/matches', label: t('nav.matches'), icon: 'matches', matchPrefix: true },
{ path: '/users', label: t('nav.agents_players'), icon: 'users' },
{ path: '/finance-logs', label: t('nav.finance_logs'), icon: 'finance' },
{ path: '/deposit', label: t('nav.deposit_manage'), icon: 'deposit', matchPrefix: true },
{ path: '/cashback', label: t('nav.cashback'), icon: 'cashback' },
{ path: '/bets', label: t('nav.bets'), icon: 'bets' },
{ path: '/contents', label: t('nav.contents'), icon: 'contents' },
{ path: '/media', label: t('nav.media'), icon: 'media' },
{ path: '/audit', label: t('nav.audit'), icon: 'audit' },
{ path: '/smoke-tests', label: t('nav.smoke_tests'), icon: 'smoke-tests' },
]);
const adminMenus = computed(() => {
const items = [
{ path: '/', label: t('nav.dashboard'), icon: 'dashboard', matchPrefix: true },
{ path: '/matches', label: t('nav.matches'), icon: 'matches', matchPrefix: true },
{ path: '/users', label: t('nav.agents_players'), icon: 'users' },
{ path: '/finance-logs', label: t('nav.finance_logs'), icon: 'finance' },
{ path: '/deposit', label: t('nav.deposit_manage'), icon: 'deposit', matchPrefix: true },
{ path: '/cashback', label: t('nav.cashback'), icon: 'cashback' },
{ path: '/bets', label: t('nav.bets'), icon: 'bets' },
{ path: '/contents', label: t('nav.contents'), icon: 'contents' },
{ path: '/media', label: t('nav.media'), icon: 'media' },
{ path: '/audit', label: t('nav.audit'), icon: 'audit' },
{ path: '/smoke-tests', label: t('nav.smoke_tests'), icon: 'smoke-tests' },
];
if (smokeTestsAllowed.value === false) {
return items.filter((item) => item.path !== '/smoke-tests');
}
return items;
});
const agentMenus = computed(() => [
{ path: '/', label: t('nav.dashboard'), icon: 'dashboard' },
@@ -114,6 +122,9 @@ function logout() {
onMounted(() => {
syncMobileNav();
window.addEventListener('resize', syncMobileNav);
if (auth.isAdmin.value) {
void ensureSmokeTestsAllowed();
}
});
onUnmounted(() => {