[fix]修复参数格式问题
This commit is contained in:
@@ -69,8 +69,8 @@ export interface SaveGameRtpPayload {
|
|||||||
auto_game_rtp: 0 | 1
|
auto_game_rtp: 0 | 1
|
||||||
auto_rtp_amount: Record<string, string | number>
|
auto_rtp_amount: Record<string, string | number>
|
||||||
auto_frequency: number
|
auto_frequency: number
|
||||||
provider_display: string
|
provider_display: Record<string, unknown> | unknown[]
|
||||||
custom_config: string
|
custom_config: Record<string, unknown>
|
||||||
header_image_url: string
|
header_image_url: string
|
||||||
text_color: string
|
text_color: string
|
||||||
button_text_color: string
|
button_text_color: string
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ export default {
|
|||||||
urlRequired: 'Please enter the game image URL',
|
urlRequired: 'Please enter the game image URL',
|
||||||
saved: 'Settings saved',
|
saved: 'Settings saved',
|
||||||
invalidAutoAmount: 'Auto RTP Amount must be a valid JSON object',
|
invalidAutoAmount: 'Auto RTP Amount must be a valid JSON object',
|
||||||
|
invalidProviderDisplay: 'Provider Display must be a valid JSON array or object',
|
||||||
|
invalidCustomConfig: 'Custom Config must be a valid JSON object',
|
||||||
copied: 'Embed code copied',
|
copied: 'Embed code copied',
|
||||||
copyFailed: 'Unable to copy the embed code',
|
copyFailed: 'Unable to copy the embed code',
|
||||||
operationSuccess: 'Operation completed',
|
operationSuccess: 'Operation completed',
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ export default {
|
|||||||
urlRequired: '请输入游戏图片 URL',
|
urlRequired: '请输入游戏图片 URL',
|
||||||
saved: '设置已保存',
|
saved: '设置已保存',
|
||||||
invalidAutoAmount: '自动 RTP 范围必须是有效的 JSON 对象',
|
invalidAutoAmount: '自动 RTP 范围必须是有效的 JSON 对象',
|
||||||
|
invalidProviderDisplay: '显示供应商必须是有效的 JSON 数组或对象',
|
||||||
|
invalidCustomConfig: '自定义配置必须是有效的 JSON 对象',
|
||||||
copied: '嵌入代码已复制',
|
copied: '嵌入代码已复制',
|
||||||
copyFailed: '无法复制嵌入代码',
|
copyFailed: '无法复制嵌入代码',
|
||||||
operationSuccess: '操作成功',
|
operationSuccess: '操作成功',
|
||||||
|
|||||||
@@ -207,8 +207,8 @@ interface GameRtpSetting {
|
|||||||
auto_game_rtp?: number | string
|
auto_game_rtp?: number | string
|
||||||
auto_rtp_amount?: string | Record<string, string | number> | null
|
auto_rtp_amount?: string | Record<string, string | number> | null
|
||||||
auto_frequency?: number | string
|
auto_frequency?: number | string
|
||||||
provider_display?: string | null
|
provider_display?: string | Record<string, unknown> | unknown[] | null
|
||||||
custom_config?: string | null
|
custom_config?: string | Record<string, unknown> | null
|
||||||
header_image_url?: string | null
|
header_image_url?: string | null
|
||||||
text_color?: string | null
|
text_color?: string | null
|
||||||
button_text_color?: string | null
|
button_text_color?: string | null
|
||||||
@@ -335,7 +335,7 @@ const formatUpdateTime = (value: unknown) => {
|
|||||||
return new Date(timestamp * (timestamp < 1e12 ? 1000 : 1)).toLocaleString()
|
return new Date(timestamp * (timestamp < 1e12 ? 1000 : 1)).toLocaleString()
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatJsonSetting = (value: string | Record<string, unknown> | null | undefined) => {
|
const formatJsonSetting = (value: string | Record<string, unknown> | unknown[] | null | undefined) => {
|
||||||
if (!value) return ''
|
if (!value) return ''
|
||||||
return typeof value === 'string' ? value : JSON.stringify(value)
|
return typeof value === 'string' ? value : JSON.stringify(value)
|
||||||
}
|
}
|
||||||
@@ -345,8 +345,8 @@ const applyRtpSetting = (setting?: GameRtpSetting) => {
|
|||||||
settings.autoRtp = toNumber(setting.auto_game_rtp) === 1 ? 1 : 0
|
settings.autoRtp = toNumber(setting.auto_game_rtp) === 1 ? 1 : 0
|
||||||
settings.autoAmount = formatJsonSetting(setting.auto_rtp_amount)
|
settings.autoAmount = formatJsonSetting(setting.auto_rtp_amount)
|
||||||
settings.frequency = String(setting.auto_frequency ?? '')
|
settings.frequency = String(setting.auto_frequency ?? '')
|
||||||
settings.providerDisplay = setting.provider_display ?? ''
|
settings.providerDisplay = formatJsonSetting(setting.provider_display)
|
||||||
settings.customConfig = setting.custom_config ?? ''
|
settings.customConfig = formatJsonSetting(setting.custom_config)
|
||||||
settings.headerImage = setting.header_image_url ?? ''
|
settings.headerImage = setting.header_image_url ?? ''
|
||||||
settings.textColor = setting.text_color ?? ''
|
settings.textColor = setting.text_color ?? ''
|
||||||
settings.buttonTextColor = setting.button_text_color ?? ''
|
settings.buttonTextColor = setting.button_text_color ?? ''
|
||||||
@@ -420,6 +420,8 @@ const savingSettings = ref(false)
|
|||||||
|
|
||||||
const saveSettings = async () => {
|
const saveSettings = async () => {
|
||||||
let autoRtpAmount: Record<string, string | number>
|
let autoRtpAmount: Record<string, string | number>
|
||||||
|
let providerDisplay: Record<string, unknown> | unknown[] = []
|
||||||
|
let customConfig: Record<string, unknown> = {}
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(settings.autoAmount)
|
const parsed = JSON.parse(settings.autoAmount)
|
||||||
if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') throw new Error()
|
if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') throw new Error()
|
||||||
@@ -429,14 +431,36 @@ const saveSettings = async () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (settings.providerDisplay.trim()) {
|
||||||
|
const parsed = JSON.parse(settings.providerDisplay)
|
||||||
|
if (!parsed || typeof parsed !== 'object') throw new Error()
|
||||||
|
providerDisplay = parsed
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
ElMessage.error(t('embed.gameRtp.invalidProviderDisplay'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (settings.customConfig.trim()) {
|
||||||
|
const parsed = JSON.parse(settings.customConfig)
|
||||||
|
if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') throw new Error()
|
||||||
|
customConfig = parsed
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
ElMessage.error(t('embed.gameRtp.invalidCustomConfig'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
savingSettings.value = true
|
savingSettings.value = true
|
||||||
try {
|
try {
|
||||||
await saveGameRtp({
|
await saveGameRtp({
|
||||||
auto_game_rtp: settings.autoRtp as 0 | 1,
|
auto_game_rtp: settings.autoRtp as 0 | 1,
|
||||||
auto_rtp_amount: autoRtpAmount,
|
auto_rtp_amount: autoRtpAmount,
|
||||||
auto_frequency: toNumber(settings.frequency),
|
auto_frequency: toNumber(settings.frequency),
|
||||||
provider_display: settings.providerDisplay,
|
provider_display: providerDisplay,
|
||||||
custom_config: settings.customConfig,
|
custom_config: customConfig,
|
||||||
header_image_url: settings.headerImage,
|
header_image_url: settings.headerImage,
|
||||||
text_color: settings.textColor,
|
text_color: settings.textColor,
|
||||||
button_text_color: settings.buttonTextColor,
|
button_text_color: settings.buttonTextColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user