|
|
|
|
@@ -207,8 +207,8 @@ interface GameRtpSetting {
|
|
|
|
|
auto_game_rtp?: number | string
|
|
|
|
|
auto_rtp_amount?: string | Record<string, string | number> | null
|
|
|
|
|
auto_frequency?: number | string
|
|
|
|
|
provider_display?: string | null
|
|
|
|
|
custom_config?: string | null
|
|
|
|
|
provider_display?: string | Record<string, unknown> | unknown[] | null
|
|
|
|
|
custom_config?: string | Record<string, unknown> | null
|
|
|
|
|
header_image_url?: string | null
|
|
|
|
|
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()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatJsonSetting = (value: string | Record<string, unknown> | null | undefined) => {
|
|
|
|
|
const formatJsonSetting = (value: string | Record<string, unknown> | unknown[] | null | undefined) => {
|
|
|
|
|
if (!value) return ''
|
|
|
|
|
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.autoAmount = formatJsonSetting(setting.auto_rtp_amount)
|
|
|
|
|
settings.frequency = String(setting.auto_frequency ?? '')
|
|
|
|
|
settings.providerDisplay = setting.provider_display ?? ''
|
|
|
|
|
settings.customConfig = setting.custom_config ?? ''
|
|
|
|
|
settings.providerDisplay = formatJsonSetting(setting.provider_display)
|
|
|
|
|
settings.customConfig = formatJsonSetting(setting.custom_config)
|
|
|
|
|
settings.headerImage = setting.header_image_url ?? ''
|
|
|
|
|
settings.textColor = setting.text_color ?? ''
|
|
|
|
|
settings.buttonTextColor = setting.button_text_color ?? ''
|
|
|
|
|
@@ -420,6 +420,8 @@ const savingSettings = ref(false)
|
|
|
|
|
|
|
|
|
|
const saveSettings = async () => {
|
|
|
|
|
let autoRtpAmount: Record<string, string | number>
|
|
|
|
|
let providerDisplay: Record<string, unknown> | unknown[] = []
|
|
|
|
|
let customConfig: Record<string, unknown> = {}
|
|
|
|
|
try {
|
|
|
|
|
const parsed = JSON.parse(settings.autoAmount)
|
|
|
|
|
if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') throw new Error()
|
|
|
|
|
@@ -429,14 +431,36 @@ const saveSettings = async () => {
|
|
|
|
|
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
|
|
|
|
|
try {
|
|
|
|
|
await saveGameRtp({
|
|
|
|
|
auto_game_rtp: settings.autoRtp as 0 | 1,
|
|
|
|
|
auto_rtp_amount: autoRtpAmount,
|
|
|
|
|
auto_frequency: toNumber(settings.frequency),
|
|
|
|
|
provider_display: settings.providerDisplay,
|
|
|
|
|
custom_config: settings.customConfig,
|
|
|
|
|
provider_display: providerDisplay,
|
|
|
|
|
custom_config: customConfig,
|
|
|
|
|
header_image_url: settings.headerImage,
|
|
|
|
|
text_color: settings.textColor,
|
|
|
|
|
button_text_color: settings.buttonTextColor,
|
|
|
|
|
|