1.菜单规则权限管理

2.备份数据库
This commit is contained in:
2026-04-29 11:52:02 +08:00
parent f136e1c1ca
commit e8c2b9d345
8 changed files with 1352 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@@ -42,7 +42,8 @@ class Auth
return [];
}
return $this->getChildren($this->children[0]);
$menus = $this->getChildren($this->children[0]);
return $this->filterVisibleMenus($menus, $uid);
}
private function getChildren(array $rules): array
@@ -55,6 +56,55 @@ class Auth
return $rules;
}
private function filterVisibleMenus(array $menus, int $uid): array
{
$ruleList = $this->getRuleList($uid);
if (in_array('*', $ruleList, true)) {
return $menus;
}
$allowedRuleMap = [];
foreach ($ruleList as $ruleName) {
if (is_string($ruleName) && $ruleName !== '') {
$allowedRuleMap[strtolower($ruleName)] = true;
}
}
return $this->doFilterVisibleMenus($menus, $allowedRuleMap);
}
private function doFilterVisibleMenus(array $menus, array $allowedRuleMap): array
{
$visibleMenus = [];
foreach ($menus as $menu) {
if (!is_array($menu)) {
continue;
}
$children = $menu['children'] ?? [];
if (is_array($children) && $children) {
$menu['children'] = $this->doFilterVisibleMenus($children, $allowedRuleMap);
}
$name = strtolower(strval($menu['name'] ?? ''));
$type = strval($menu['type'] ?? '');
$isAllowed = $name !== '' && isset($allowedRuleMap[$name]);
if ($type === 'button') {
if ($isAllowed) {
$visibleMenus[] = $menu;
}
continue;
}
if ($isAllowed || !empty($menu['children'])) {
$visibleMenus[] = $menu;
}
}
return $visibleMenus;
}
public function check(string $name, int $uid, string $relation = 'or', string $mode = 'url'): bool
{
$ruleList = $this->getRuleList($uid);

View File

@@ -5,7 +5,7 @@
</el-alert>
<div class="toolbar">
<el-button type="primary" :loading="saving" :disabled="loading" @click="onSave">
<el-button v-if="canSave" type="primary" :loading="saving" :disabled="loading" @click="onSave">
{{ t('config.financeCashierConfig.btn_save') }}
</el-button>
</div>
@@ -25,7 +25,7 @@
<el-card shadow="never" class="section-card">
<template #header>
<span>{{ t('config.financeCashierConfig.sec_currencies') }}</span>
<el-button type="primary" link class="ml-2" @click="addCurrency">{{ t('config.financeCashierConfig.btn_add_row') }}</el-button>
<el-button v-if="canSave" type="primary" link class="ml-2" @click="addCurrency">{{ t('config.financeCashierConfig.btn_add_row') }}</el-button>
</template>
<p class="hint">{{ t('config.financeCashierConfig.currency_rates_hint') }}</p>
<el-table :data="form.currencies" border stripe size="small">
@@ -66,7 +66,7 @@
</el-table-column>
<el-table-column :label="t('Operate')" width="90" align="center">
<template #default="{ $index }">
<el-button type="danger" link @click="removeRow(form.currencies, $index)">{{ t('Delete') }}</el-button>
<el-button v-if="canSave" type="danger" link @click="removeRow(form.currencies, $index)">{{ t('Delete') }}</el-button>
</template>
</el-table-column>
</el-table>
@@ -109,7 +109,7 @@
<el-card shadow="never" class="section-card">
<template #header>
<span>{{ t('config.financeCashierConfig.sec_banks') }}</span>
<el-button type="primary" link class="ml-2" @click="addBank">{{ t('config.financeCashierConfig.btn_add_row') }}</el-button>
<el-button v-if="canSave" type="primary" link class="ml-2" @click="addBank">{{ t('config.financeCashierConfig.btn_add_row') }}</el-button>
</template>
<el-table :data="form.withdraw_banks" border stripe size="small">
<el-table-column :label="t('config.financeCashierConfig.col_bank_code')" width="140">
@@ -134,7 +134,7 @@
</el-table-column>
<el-table-column :label="t('Operate')" width="90" align="center">
<template #default="{ $index }">
<el-button type="danger" link @click="removeRow(form.withdraw_banks, $index)">{{ t('Delete') }}</el-button>
<el-button v-if="canSave" type="danger" link @click="removeRow(form.withdraw_banks, $index)">{{ t('Delete') }}</el-button>
</template>
</el-table-column>
</el-table>
@@ -210,6 +210,7 @@ defineOptions({
})
const { t, locale } = useI18n()
const canSave = auth('save')
type CurrencyRow = {
code: string

View File

@@ -24,7 +24,7 @@
<div class="config-form-item-name">{{ item.config_key }}</div>
</div>
<el-button @click="onReset">{{ t('Reset') }}</el-button>
<el-button type="primary" :loading="state.submitLoading" @click="onSubmit()">{{ t('Save') }}</el-button>
<el-button v-if="canSave" type="primary" :loading="state.submitLoading" @click="onSubmit()">{{ t('Save') }}</el-button>
</el-tab-pane>
</el-tabs>
</el-form>
@@ -39,6 +39,7 @@ import { useI18n } from 'vue-i18n'
import { baTableApi } from '/@/api/common'
import FormItem from '/@/components/formItem/index.vue'
import createAxios from '/@/utils/axios'
import { auth } from '/@/utils/common'
defineOptions({
name: 'config/gameConfig',
@@ -56,6 +57,7 @@ const { t, te } = useI18n()
const formRef = useTemplateRef('formRef')
const api = new baTableApi('/admin/config.GameConfig/')
const excludedConfigKeys = new Set(['period_auto_create_enabled', 'period_manual_create_enabled'])
const canSave = auth('save')
const state: {
loading: boolean

View File

@@ -5,7 +5,7 @@
</el-alert>
<div class="toolbar">
<el-button type="success" :loading="saving" :disabled="loading" @click="onSave">
<el-button v-if="canSave" type="success" :loading="saving" :disabled="loading" @click="onSave">
{{ t('config.streakWinReward.btn_save') }}
</el-button>
</div>
@@ -50,6 +50,7 @@ defineOptions({
})
const { t } = useI18n()
const canSave = auth('save')
type Row = {
streak: number

View File

@@ -5,7 +5,7 @@
</el-alert>
<div class="toolbar">
<el-button type="primary" :loading="saving" :disabled="loading" @click="onSave">
<el-button v-if="canSave" type="primary" :loading="saving" :disabled="loading" @click="onSave">
{{ t('config.ziHuaDictionary.btn_save') }}
</el-button>
</div>
@@ -39,6 +39,7 @@ defineOptions({
})
const { t } = useI18n()
const canSave = auth('save')
type Item = { no: number; name: string; category: string }

View File

@@ -39,8 +39,8 @@
</div>
<template #footer>
<el-button @click="closeReviewDialog">{{ t('Cancel') }}</el-button>
<el-button type="danger" :loading="reviewDialog.loading" @click="submitReject">{{ t('game.playRecord.review_reject') }}</el-button>
<el-button type="primary" :loading="reviewDialog.loading" @click="submitApprove">{{ t('game.playRecord.review_approve') }}</el-button>
<el-button v-if="canRejectJackpot" type="danger" :loading="reviewDialog.loading" @click="submitReject">{{ t('game.playRecord.review_reject') }}</el-button>
<el-button v-if="canApproveJackpot" type="primary" :loading="reviewDialog.loading" @click="submitApprove">{{ t('game.playRecord.review_approve') }}</el-button>
</template>
</el-dialog>
</div>
@@ -56,12 +56,15 @@ import TableHeader from '/@/components/table/header/index.vue'
import Table from '/@/components/table/index.vue'
import baTableClass from '/@/utils/baTable'
import createAxios from '/@/utils/axios'
import { auth } from '/@/utils/common'
defineOptions({
name: 'game/playRecord',
})
const { t } = useI18n()
const canApproveJackpot = auth('approveJackpot')
const canRejectJackpot = auth('rejectJackpot')
const tableRef = useTemplateRef('tableRef')
const optButtons: OptButton[] = defaultOptButtons([])
const reviewDialog = reactive({
@@ -321,6 +324,9 @@ optButtons.unshift({
icon: 'fa fa-check',
disabledTip: true,
display: (row: any) => {
if (!canApproveJackpot && !canRejectJackpot) {
return false
}
const v = row?.can_jackpot_approve
return String(v ?? '') === '1'
},

View File

@@ -5,7 +5,7 @@
</el-alert>
<div class="toolbar">
<el-button type="primary" :loading="saving" :disabled="loading" @click="onSave">
<el-button v-if="canSave" type="primary" :loading="saving" :disabled="loading" @click="onSave">
{{ t('game.ziHuaDictionary.btn_save') }}
</el-button>
</div>
@@ -39,6 +39,7 @@ defineOptions({
})
const { t } = useI18n()
const canSave = auth('save')
type Item = { no: number; name: string; category: string }