后台新增获取游戏连接按钮
This commit is contained in:
@@ -76,6 +76,9 @@
|
|||||||
"paidDrawCount": "Paid Draw Count",
|
"paidDrawCount": "Paid Draw Count",
|
||||||
"freeDrawCount": "Free Draw Count",
|
"freeDrawCount": "Free Draw Count",
|
||||||
"createTime": "Create Time",
|
"createTime": "Create Time",
|
||||||
"updateTime": "Update Time"
|
"updateTime": "Update Time",
|
||||||
|
"getGameLink": "Get Game Link",
|
||||||
|
"getGameLinkSuccess": "Game link copied",
|
||||||
|
"getGameLinkFail": "Failed to get game link"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,9 @@
|
|||||||
"paidDrawCount": "购买抽奖次数",
|
"paidDrawCount": "购买抽奖次数",
|
||||||
"freeDrawCount": "赠送抽奖次数",
|
"freeDrawCount": "赠送抽奖次数",
|
||||||
"createTime": "创建时间",
|
"createTime": "创建时间",
|
||||||
"updateTime": "更新时间"
|
"updateTime": "更新时间",
|
||||||
|
"getGameLink": "获取游戏链接",
|
||||||
|
"getGameLinkSuccess": "游戏链接已复制",
|
||||||
|
"getGameLinkFail": "获取游戏链接失败"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,16 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取玩家游戏链接
|
||||||
|
*/
|
||||||
|
getGameUrl(params: { id: number | string; lang?: 'zh' | 'en' }) {
|
||||||
|
return request.get<Api.Common.ApiData>({
|
||||||
|
url: '/core/dice/player/DicePlayer/getGameUrl',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取彩金池配置选项(DiceLotteryPoolConfig.id、name),供 lottery_config_id 下拉使用
|
* 获取彩金池配置选项(DiceLotteryPoolConfig.id、name),供 lottery_config_id 下拉使用
|
||||||
* @returns [ { id, name } ]
|
* @returns [ { id, name } ]
|
||||||
|
|||||||
@@ -64,7 +64,14 @@
|
|||||||
</template>
|
</template>
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<template #operation="{ row }">
|
<template #operation="{ row }">
|
||||||
<div class="flex gap-2">
|
<div class="flex items-center justify-center gap-1">
|
||||||
|
<SaButton
|
||||||
|
v-permission="'dice:player:index:getGameUrl'"
|
||||||
|
type="success"
|
||||||
|
icon="ri:links-line"
|
||||||
|
:tool-tip="$t('page.table.getGameLink')"
|
||||||
|
@click="handleGetGameUrl(row)"
|
||||||
|
/>
|
||||||
<SaButton
|
<SaButton
|
||||||
v-permission="'dice:player:index:update'"
|
v-permission="'dice:player:index:update'"
|
||||||
type="secondary"
|
type="secondary"
|
||||||
@@ -98,6 +105,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { useClipboard } from '@vueuse/core'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useTable } from '@/hooks/core/useTable'
|
import { useTable } from '@/hooks/core/useTable'
|
||||||
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
import { useSaiAdmin } from '@/composables/useSaiAdmin'
|
||||||
@@ -107,6 +116,7 @@
|
|||||||
import WalletOperateDialog from './modules/WalletOperateDialog.vue'
|
import WalletOperateDialog from './modules/WalletOperateDialog.vue'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
const { copy } = useClipboard()
|
||||||
|
|
||||||
// 搜索表单
|
// 搜索表单
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
@@ -221,7 +231,7 @@
|
|||||||
{
|
{
|
||||||
prop: 'operation',
|
prop: 'operation',
|
||||||
label: 'table.actions.operation',
|
label: 'table.actions.operation',
|
||||||
width: 100,
|
width: 132,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
useSlot: true
|
useSlot: true
|
||||||
@@ -268,4 +278,21 @@
|
|||||||
}
|
}
|
||||||
walletDialogVisible.value = true
|
walletDialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleGetGameUrl(row: Record<string, any>) {
|
||||||
|
try {
|
||||||
|
const res = await api.getGameUrl({ id: row.id })
|
||||||
|
const url =
|
||||||
|
typeof res?.url === 'string' ? res.url : typeof res?.data?.url === 'string' ? res.data.url : ''
|
||||||
|
if (!url) {
|
||||||
|
ElMessage.warning(t('page.table.getGameLinkFail'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await copy(url)
|
||||||
|
ElMessage.success(t('page.table.getGameLinkSuccess'))
|
||||||
|
} catch (e: any) {
|
||||||
|
const msg = typeof e?.message === 'string' && e.message !== '' ? e.message : t('page.table.getGameLinkFail')
|
||||||
|
ElMessage.warning(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use plugin\saiadmin\service\Permission;
|
|||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
use app\api\cache\UserCache;
|
use app\api\cache\UserCache;
|
||||||
|
use Tinywan\Jwt\JwtToken;
|
||||||
use app\dice\model\player\DicePlayer;
|
use app\dice\model\player\DicePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,6 +211,63 @@ class DicePlayerController extends BaseController
|
|||||||
return $this->success('update success');
|
return $this->success('update success');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取游戏链接
|
||||||
|
* @param Request $request
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
#[Permission('获取游戏链接', 'dice:player:index:getGameUrl')]
|
||||||
|
public function getGameUrl(Request $request): Response
|
||||||
|
{
|
||||||
|
$id = $request->input('id');
|
||||||
|
if ($id === null || $id === '') {
|
||||||
|
return $this->fail('missing parameter id');
|
||||||
|
}
|
||||||
|
$player = $this->logic->read($id);
|
||||||
|
if (!$player) {
|
||||||
|
return $this->fail('not found');
|
||||||
|
}
|
||||||
|
$allowedIds = AdminScopeHelper::getAllowedAdminIds($this->adminInfo ?? null);
|
||||||
|
if ($allowedIds !== null && !in_array((int) ($player->admin_id ?? 0), $allowedIds, true)) {
|
||||||
|
return $this->fail('no permission to view this record');
|
||||||
|
}
|
||||||
|
if ((int) ($player->status ?? 1) === 0) {
|
||||||
|
return $this->fail('account is disabled');
|
||||||
|
}
|
||||||
|
$username = trim((string) ($player->username ?? ''));
|
||||||
|
if ($username === '') {
|
||||||
|
return $this->fail('username is empty');
|
||||||
|
}
|
||||||
|
$lang = trim((string) $request->input('lang', 'zh'));
|
||||||
|
if (!in_array($lang, ['zh', 'en'], true)) {
|
||||||
|
$lang = 'zh';
|
||||||
|
}
|
||||||
|
|
||||||
|
$exp = (int) config('api.session_expire', 604800);
|
||||||
|
$tokenResult = JwtToken::generateToken([
|
||||||
|
'id' => (int) $player->id,
|
||||||
|
'username' => $username,
|
||||||
|
'plat' => 'api_login',
|
||||||
|
'access_exp' => $exp,
|
||||||
|
]);
|
||||||
|
$token = (string) ($tokenResult['access_token'] ?? '');
|
||||||
|
if ($token === '') {
|
||||||
|
return $this->fail('generate token failed');
|
||||||
|
}
|
||||||
|
UserCache::setSessionByUsername($username, $token);
|
||||||
|
$userArr = $player->hidden(['password', 'lottery_config_id', 't1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'])->toArray();
|
||||||
|
UserCache::setUser((int) $player->id, $userArr);
|
||||||
|
UserCache::setPlayerByUsername($username, $userArr);
|
||||||
|
|
||||||
|
$gameUrlBase = rtrim((string) env('GAME_URL', (string) config('api.game_url', '')), '/');
|
||||||
|
if ($gameUrlBase === '') {
|
||||||
|
return $this->fail('GAME_URL is not configured');
|
||||||
|
}
|
||||||
|
$tokenInUrl = str_replace('%3D', '=', urlencode($token));
|
||||||
|
$url = $gameUrlBase . '/?token=' . $tokenInUrl . '&lang=' . $lang;
|
||||||
|
return $this->success(['url' => $url]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除数据
|
* 删除数据
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
|||||||
28
server/db/dice_player_add_get_game_link_permission.sql
Normal file
28
server/db/dice_player_add_get_game_link_permission.sql
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
-- 玩家管理:新增“获取游戏链接”按钮权限
|
||||||
|
|
||||||
|
SET @now = NOW();
|
||||||
|
|
||||||
|
-- 优先使用已有“数据列表”按钮找到玩家菜单 ID
|
||||||
|
SET @player_menu_id = (
|
||||||
|
SELECT `parent_id` FROM `sa_system_menu`
|
||||||
|
WHERE `slug` = 'dice:player:index:index' AND `type` = 3
|
||||||
|
ORDER BY `id` ASC LIMIT 1
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 兜底:按玩家菜单路径查找
|
||||||
|
SET @player_menu_id = IFNULL(
|
||||||
|
@player_menu_id,
|
||||||
|
(
|
||||||
|
SELECT `id` FROM `sa_system_menu`
|
||||||
|
WHERE `path` = 'player' AND `type` = 2
|
||||||
|
ORDER BY `id` ASC LIMIT 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO `sa_system_menu`
|
||||||
|
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
|
||||||
|
SELECT @player_menu_id, '获取游戏链接', '', 'dice:player:index:getGameUrl', 3, '', '', '', 100, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
|
||||||
|
WHERE @player_menu_id IS NOT NULL
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:player:index:getGameUrl' AND `type` = 3
|
||||||
|
);
|
||||||
@@ -94,6 +94,7 @@ Route::group('/core', function () {
|
|||||||
Route::put('/dice/player/DicePlayer/updateStatus', [\app\dice\controller\player\DicePlayerController::class, 'updateStatus']);
|
Route::put('/dice/player/DicePlayer/updateStatus', [\app\dice\controller\player\DicePlayerController::class, 'updateStatus']);
|
||||||
Route::get('/dice/player/DicePlayer/getLotteryConfigOptions', [\app\dice\controller\player\DicePlayerController::class, 'getLotteryConfigOptions']);
|
Route::get('/dice/player/DicePlayer/getLotteryConfigOptions', [\app\dice\controller\player\DicePlayerController::class, 'getLotteryConfigOptions']);
|
||||||
Route::get('/dice/player/DicePlayer/getSystemUserOptions', [\app\dice\controller\player\DicePlayerController::class, 'getSystemUserOptions']);
|
Route::get('/dice/player/DicePlayer/getSystemUserOptions', [\app\dice\controller\player\DicePlayerController::class, 'getSystemUserOptions']);
|
||||||
|
Route::get('/dice/player/DicePlayer/getGameUrl', [\app\dice\controller\player\DicePlayerController::class, 'getGameUrl']);
|
||||||
fastRoute('dice/play_record/DicePlayRecord', \app\dice\controller\play_record\DicePlayRecordController::class);
|
fastRoute('dice/play_record/DicePlayRecord', \app\dice\controller\play_record\DicePlayRecordController::class);
|
||||||
Route::get('/dice/play_record/DicePlayRecord/getPlayerOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getPlayerOptions']);
|
Route::get('/dice/play_record/DicePlayRecord/getPlayerOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getPlayerOptions']);
|
||||||
Route::get('/dice/play_record/DicePlayRecord/getLotteryConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getLotteryConfigOptions']);
|
Route::get('/dice/play_record/DicePlayRecord/getLotteryConfigOptions', [\app\dice\controller\play_record\DicePlayRecordController::class, 'getLotteryConfigOptions']);
|
||||||
|
|||||||
Reference in New Issue
Block a user