refactor: 移除旧版数据库配置的简易模式实现
移除与 PR #66 冲突的旧版简易模式实现(commit 7d4b7de)。 新版简易模式通过 run_mode 配置文件/环境变量控制,无需数据库设置。 后端变更: - 移除 SettingKeySimpleMode 常量 - 移除 SystemSettings/PublicSettings 中的 SimpleMode 字段 - 移除 setting_handler 中的简易模式切换逻辑 - 移除 userService 依赖(不再需要自动设置管理员并发数) 前端变更: - 移除 appStore.simpleMode 状态 - 移除设置页面的"使用模式"设置区块 - 移除 GroupsView 中的简易模式相关逻辑 - 移除相关国际化文案
This commit is contained in:
@@ -99,7 +99,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
|
|||||||
geminiOAuthHandler := admin.NewGeminiOAuthHandler(geminiOAuthService)
|
geminiOAuthHandler := admin.NewGeminiOAuthHandler(geminiOAuthService)
|
||||||
proxyHandler := admin.NewProxyHandler(adminService)
|
proxyHandler := admin.NewProxyHandler(adminService)
|
||||||
adminRedeemHandler := admin.NewRedeemHandler(adminService)
|
adminRedeemHandler := admin.NewRedeemHandler(adminService)
|
||||||
settingHandler := admin.NewSettingHandler(settingService, emailService, userService)
|
settingHandler := admin.NewSettingHandler(settingService, emailService)
|
||||||
updateCache := repository.NewUpdateCache(client)
|
updateCache := repository.NewUpdateCache(client)
|
||||||
gitHubReleaseClient := repository.NewGitHubReleaseClient()
|
gitHubReleaseClient := repository.NewGitHubReleaseClient()
|
||||||
serviceBuildInfo := provideServiceBuildInfo(buildInfo)
|
serviceBuildInfo := provideServiceBuildInfo(buildInfo)
|
||||||
|
|||||||
@@ -12,15 +12,13 @@ import (
|
|||||||
type SettingHandler struct {
|
type SettingHandler struct {
|
||||||
settingService *service.SettingService
|
settingService *service.SettingService
|
||||||
emailService *service.EmailService
|
emailService *service.EmailService
|
||||||
userService *service.UserService
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSettingHandler 创建系统设置处理器
|
// NewSettingHandler 创建系统设置处理器
|
||||||
func NewSettingHandler(settingService *service.SettingService, emailService *service.EmailService, userService *service.UserService) *SettingHandler {
|
func NewSettingHandler(settingService *service.SettingService, emailService *service.EmailService) *SettingHandler {
|
||||||
return &SettingHandler{
|
return &SettingHandler{
|
||||||
settingService: settingService,
|
settingService: settingService,
|
||||||
emailService: emailService,
|
emailService: emailService,
|
||||||
userService: userService,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ func (h *SettingHandler) GetSettings(c *gin.Context) {
|
|||||||
DocUrl: settings.DocUrl,
|
DocUrl: settings.DocUrl,
|
||||||
DefaultConcurrency: settings.DefaultConcurrency,
|
DefaultConcurrency: settings.DefaultConcurrency,
|
||||||
DefaultBalance: settings.DefaultBalance,
|
DefaultBalance: settings.DefaultBalance,
|
||||||
SimpleMode: settings.SimpleMode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,9 +86,6 @@ type UpdateSettingsRequest struct {
|
|||||||
// 默认配置
|
// 默认配置
|
||||||
DefaultConcurrency int `json:"default_concurrency"`
|
DefaultConcurrency int `json:"default_concurrency"`
|
||||||
DefaultBalance float64 `json:"default_balance"`
|
DefaultBalance float64 `json:"default_balance"`
|
||||||
|
|
||||||
// 使用模式
|
|
||||||
SimpleMode bool `json:"simple_mode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSettings 更新系统设置
|
// UpdateSettings 更新系统设置
|
||||||
@@ -114,14 +108,8 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
|
|||||||
req.SmtpPort = 587
|
req.SmtpPort = 587
|
||||||
}
|
}
|
||||||
|
|
||||||
// 简单模式下自动关闭开放注册
|
|
||||||
registrationEnabled := req.RegistrationEnabled
|
|
||||||
if req.SimpleMode {
|
|
||||||
registrationEnabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
settings := &service.SystemSettings{
|
settings := &service.SystemSettings{
|
||||||
RegistrationEnabled: registrationEnabled,
|
RegistrationEnabled: req.RegistrationEnabled,
|
||||||
EmailVerifyEnabled: req.EmailVerifyEnabled,
|
EmailVerifyEnabled: req.EmailVerifyEnabled,
|
||||||
SmtpHost: req.SmtpHost,
|
SmtpHost: req.SmtpHost,
|
||||||
SmtpPort: req.SmtpPort,
|
SmtpPort: req.SmtpPort,
|
||||||
@@ -141,7 +129,6 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
|
|||||||
DocUrl: req.DocUrl,
|
DocUrl: req.DocUrl,
|
||||||
DefaultConcurrency: req.DefaultConcurrency,
|
DefaultConcurrency: req.DefaultConcurrency,
|
||||||
DefaultBalance: req.DefaultBalance,
|
DefaultBalance: req.DefaultBalance,
|
||||||
SimpleMode: req.SimpleMode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.settingService.UpdateSettings(c.Request.Context(), settings); err != nil {
|
if err := h.settingService.UpdateSettings(c.Request.Context(), settings); err != nil {
|
||||||
@@ -149,14 +136,6 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果切换到简单模式,自动将管理员并发数设为 99999
|
|
||||||
if req.SimpleMode && h.userService != nil {
|
|
||||||
admin, err := h.userService.GetFirstAdmin(c.Request.Context())
|
|
||||||
if err == nil && admin != nil {
|
|
||||||
_ = h.userService.UpdateConcurrency(c.Request.Context(), admin.ID, 99999)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重新获取设置返回
|
// 重新获取设置返回
|
||||||
updatedSettings, err := h.settingService.GetAllSettings(c.Request.Context())
|
updatedSettings, err := h.settingService.GetAllSettings(c.Request.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -185,7 +164,6 @@ func (h *SettingHandler) UpdateSettings(c *gin.Context) {
|
|||||||
DocUrl: updatedSettings.DocUrl,
|
DocUrl: updatedSettings.DocUrl,
|
||||||
DefaultConcurrency: updatedSettings.DefaultConcurrency,
|
DefaultConcurrency: updatedSettings.DefaultConcurrency,
|
||||||
DefaultBalance: updatedSettings.DefaultBalance,
|
DefaultBalance: updatedSettings.DefaultBalance,
|
||||||
SimpleMode: updatedSettings.SimpleMode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ type SystemSettings struct {
|
|||||||
|
|
||||||
DefaultConcurrency int `json:"default_concurrency"`
|
DefaultConcurrency int `json:"default_concurrency"`
|
||||||
DefaultBalance float64 `json:"default_balance"`
|
DefaultBalance float64 `json:"default_balance"`
|
||||||
|
|
||||||
SimpleMode bool `json:"simple_mode"` // 简单模式
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PublicSettings struct {
|
type PublicSettings struct {
|
||||||
@@ -42,5 +40,4 @@ type PublicSettings struct {
|
|||||||
ContactInfo string `json:"contact_info"`
|
ContactInfo string `json:"contact_info"`
|
||||||
DocUrl string `json:"doc_url"`
|
DocUrl string `json:"doc_url"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
SimpleMode bool `json:"simple_mode"` // 简单模式
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,5 @@ func (h *SettingHandler) GetPublicSettings(c *gin.Context) {
|
|||||||
ContactInfo: settings.ContactInfo,
|
ContactInfo: settings.ContactInfo,
|
||||||
DocUrl: settings.DocUrl,
|
DocUrl: settings.DocUrl,
|
||||||
Version: h.version,
|
Version: h.version,
|
||||||
SimpleMode: settings.SimpleMode,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,9 +90,6 @@ const (
|
|||||||
|
|
||||||
// 管理员 API Key
|
// 管理员 API Key
|
||||||
SettingKeyAdminApiKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成)
|
SettingKeyAdminApiKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成)
|
||||||
|
|
||||||
// 使用模式
|
|
||||||
SettingKeySimpleMode = "simple_mode" // 简单模式(隐藏多用户管理功能)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Admin API Key prefix (distinct from user "sk-" keys)
|
// Admin API Key prefix (distinct from user "sk-" keys)
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ func (s *SettingService) GetPublicSettings(ctx context.Context) (*PublicSettings
|
|||||||
SettingKeyApiBaseUrl,
|
SettingKeyApiBaseUrl,
|
||||||
SettingKeyContactInfo,
|
SettingKeyContactInfo,
|
||||||
SettingKeyDocUrl,
|
SettingKeyDocUrl,
|
||||||
SettingKeySimpleMode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings, err := s.settingRepo.GetMultiple(ctx, keys)
|
settings, err := s.settingRepo.GetMultiple(ctx, keys)
|
||||||
@@ -83,7 +82,6 @@ func (s *SettingService) GetPublicSettings(ctx context.Context) (*PublicSettings
|
|||||||
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
||||||
ContactInfo: settings[SettingKeyContactInfo],
|
ContactInfo: settings[SettingKeyContactInfo],
|
||||||
DocUrl: settings[SettingKeyDocUrl],
|
DocUrl: settings[SettingKeyDocUrl],
|
||||||
SimpleMode: settings[SettingKeySimpleMode] == "true",
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,9 +123,6 @@ func (s *SettingService) UpdateSettings(ctx context.Context, settings *SystemSet
|
|||||||
updates[SettingKeyDefaultConcurrency] = strconv.Itoa(settings.DefaultConcurrency)
|
updates[SettingKeyDefaultConcurrency] = strconv.Itoa(settings.DefaultConcurrency)
|
||||||
updates[SettingKeyDefaultBalance] = strconv.FormatFloat(settings.DefaultBalance, 'f', 8, 64)
|
updates[SettingKeyDefaultBalance] = strconv.FormatFloat(settings.DefaultBalance, 'f', 8, 64)
|
||||||
|
|
||||||
// 使用模式
|
|
||||||
updates[SettingKeySimpleMode] = strconv.FormatBool(settings.SimpleMode)
|
|
||||||
|
|
||||||
return s.settingRepo.SetMultiple(ctx, updates)
|
return s.settingRepo.SetMultiple(ctx, updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +223,6 @@ func (s *SettingService) parseSettings(settings map[string]string) *SystemSettin
|
|||||||
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
||||||
ContactInfo: settings[SettingKeyContactInfo],
|
ContactInfo: settings[SettingKeyContactInfo],
|
||||||
DocUrl: settings[SettingKeyDocUrl],
|
DocUrl: settings[SettingKeyDocUrl],
|
||||||
SimpleMode: settings[SettingKeySimpleMode] == "true",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析整数类型
|
// 解析整数类型
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ type SystemSettings struct {
|
|||||||
|
|
||||||
DefaultConcurrency int
|
DefaultConcurrency int
|
||||||
DefaultBalance float64
|
DefaultBalance float64
|
||||||
|
|
||||||
SimpleMode bool // 简单模式
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PublicSettings struct {
|
type PublicSettings struct {
|
||||||
@@ -41,5 +39,4 @@ type PublicSettings struct {
|
|||||||
ContactInfo string
|
ContactInfo string
|
||||||
DocUrl string
|
DocUrl string
|
||||||
Version string
|
Version string
|
||||||
SimpleMode bool // 简单模式
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ export interface SystemSettings {
|
|||||||
turnstile_enabled: boolean
|
turnstile_enabled: boolean
|
||||||
turnstile_site_key: string
|
turnstile_site_key: string
|
||||||
turnstile_secret_key: string
|
turnstile_secret_key: string
|
||||||
// Usage mode
|
|
||||||
simple_mode: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1413,16 +1413,6 @@ export default {
|
|||||||
securityWarning: 'Warning: This key provides full admin access. Keep it secure.',
|
securityWarning: 'Warning: This key provides full admin access. Keep it secure.',
|
||||||
usage: 'Usage: Add to request header - x-api-key: <your-admin-api-key>'
|
usage: 'Usage: Add to request header - x-api-key: <your-admin-api-key>'
|
||||||
},
|
},
|
||||||
usageMode: {
|
|
||||||
title: 'Usage Mode',
|
|
||||||
description: 'Toggle simple mode for a simplified interface',
|
|
||||||
simpleMode: 'Simple Mode',
|
|
||||||
simpleModeHint: 'Hide multi-user management features, suitable for personal use',
|
|
||||||
simpleModeWarning: 'When enabled, user management and redeem code menus will be hidden, registration will be disabled, and admin concurrency will be set to unlimited',
|
|
||||||
confirmTitle: 'Confirm Mode Change',
|
|
||||||
confirmEnableMessage: 'Are you sure you want to enable Simple Mode? This will hide multi-user management menus, disable registration, and set admin concurrency to 99999 (unlimited).',
|
|
||||||
confirmDisableMessage: 'Are you sure you want to disable Simple Mode? This will restore all management menus.'
|
|
||||||
},
|
|
||||||
saveSettings: 'Save Settings',
|
saveSettings: 'Save Settings',
|
||||||
saving: 'Saving...',
|
saving: 'Saving...',
|
||||||
settingsSaved: 'Settings saved successfully',
|
settingsSaved: 'Settings saved successfully',
|
||||||
|
|||||||
@@ -1610,16 +1610,6 @@ export default {
|
|||||||
securityWarning: '警告:此密钥拥有完整的管理员权限,请妥善保管。',
|
securityWarning: '警告:此密钥拥有完整的管理员权限,请妥善保管。',
|
||||||
usage: '使用方法:在请求头中添加 x-api-key: <your-admin-api-key>'
|
usage: '使用方法:在请求头中添加 x-api-key: <your-admin-api-key>'
|
||||||
},
|
},
|
||||||
usageMode: {
|
|
||||||
title: '使用模式',
|
|
||||||
description: '切换简单模式以简化界面',
|
|
||||||
simpleMode: '简单模式',
|
|
||||||
simpleModeHint: '隐藏多用户管理功能,适合个人使用',
|
|
||||||
simpleModeWarning: '启用后将隐藏用户管理、兑换码管理等菜单,关闭用户注册功能,并将管理员并发数设为无限制',
|
|
||||||
confirmTitle: '确认切换使用模式',
|
|
||||||
confirmEnableMessage: '确定要启用简单模式吗?启用后将隐藏多用户管理相关菜单、关闭用户注册功能,并将管理员并发数设为 99999(无限制)。',
|
|
||||||
confirmDisableMessage: '确定要关闭简单模式吗?关闭后将恢复显示所有管理菜单。'
|
|
||||||
},
|
|
||||||
saveSettings: '保存设置',
|
saveSettings: '保存设置',
|
||||||
saving: '保存中...',
|
saving: '保存中...',
|
||||||
settingsSaved: '设置保存成功',
|
settingsSaved: '设置保存成功',
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export const useAppStore = defineStore('app', () => {
|
|||||||
const contactInfo = ref<string>('')
|
const contactInfo = ref<string>('')
|
||||||
const apiBaseUrl = ref<string>('')
|
const apiBaseUrl = ref<string>('')
|
||||||
const docUrl = ref<string>('')
|
const docUrl = ref<string>('')
|
||||||
const simpleMode = ref<boolean>(false)
|
|
||||||
|
|
||||||
// Version cache state
|
// Version cache state
|
||||||
const versionLoaded = ref<boolean>(false)
|
const versionLoaded = ref<boolean>(false)
|
||||||
@@ -297,8 +296,7 @@ export const useAppStore = defineStore('app', () => {
|
|||||||
api_base_url: apiBaseUrl.value,
|
api_base_url: apiBaseUrl.value,
|
||||||
contact_info: contactInfo.value,
|
contact_info: contactInfo.value,
|
||||||
doc_url: docUrl.value,
|
doc_url: docUrl.value,
|
||||||
version: siteVersion.value,
|
version: siteVersion.value
|
||||||
simple_mode: simpleMode.value
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +314,6 @@ export const useAppStore = defineStore('app', () => {
|
|||||||
contactInfo.value = data.contact_info || ''
|
contactInfo.value = data.contact_info || ''
|
||||||
apiBaseUrl.value = data.api_base_url || ''
|
apiBaseUrl.value = data.api_base_url || ''
|
||||||
docUrl.value = data.doc_url || ''
|
docUrl.value = data.doc_url || ''
|
||||||
simpleMode.value = data.simple_mode || false
|
|
||||||
publicSettingsLoaded.value = true
|
publicSettingsLoaded.value = true
|
||||||
return data
|
return data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -351,7 +348,6 @@ export const useAppStore = defineStore('app', () => {
|
|||||||
contactInfo,
|
contactInfo,
|
||||||
apiBaseUrl,
|
apiBaseUrl,
|
||||||
docUrl,
|
docUrl,
|
||||||
simpleMode,
|
|
||||||
|
|
||||||
// Version state
|
// Version state
|
||||||
versionLoaded,
|
versionLoaded,
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ export interface PublicSettings {
|
|||||||
contact_info: string
|
contact_info: string
|
||||||
doc_url: string
|
doc_url: string
|
||||||
version: string
|
version: string
|
||||||
simple_mode: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthResponse {
|
export interface AuthResponse {
|
||||||
|
|||||||
@@ -683,18 +683,10 @@ const editStatusOptions = computed(() => [
|
|||||||
{ value: 'inactive', label: t('common.inactive') }
|
{ value: 'inactive', label: t('common.inactive') }
|
||||||
])
|
])
|
||||||
|
|
||||||
const subscriptionTypeOptions = computed(() => {
|
const subscriptionTypeOptions = computed(() => [
|
||||||
// 简单模式下只显示订阅模式(配额模式)
|
{ value: 'standard', label: t('admin.groups.subscription.standard') },
|
||||||
if (appStore.simpleMode) {
|
{ value: 'subscription', label: t('admin.groups.subscription.subscription') }
|
||||||
return [
|
])
|
||||||
{ value: 'subscription', label: t('admin.groups.subscription.subscription') }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
return [
|
|
||||||
{ value: 'standard', label: t('admin.groups.subscription.standard') },
|
|
||||||
{ value: 'subscription', label: t('admin.groups.subscription.subscription') }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
const groups = ref<Group[]>([])
|
const groups = ref<Group[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -804,7 +796,7 @@ const closeCreateModal = () => {
|
|||||||
createForm.platform = 'anthropic'
|
createForm.platform = 'anthropic'
|
||||||
createForm.rate_multiplier = 1.0
|
createForm.rate_multiplier = 1.0
|
||||||
createForm.is_exclusive = false
|
createForm.is_exclusive = false
|
||||||
createForm.subscription_type = appStore.simpleMode ? 'subscription' : 'standard'
|
createForm.subscription_type = 'standard'
|
||||||
createForm.daily_limit_usd = null
|
createForm.daily_limit_usd = null
|
||||||
createForm.weekly_limit_usd = null
|
createForm.weekly_limit_usd = null
|
||||||
createForm.monthly_limit_usd = null
|
createForm.monthly_limit_usd = null
|
||||||
@@ -895,9 +887,5 @@ watch(
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadGroups()
|
loadGroups()
|
||||||
// 简单模式下默认使用订阅模式
|
|
||||||
if (appStore.simpleMode) {
|
|
||||||
createForm.subscription_type = 'subscription'
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -153,58 +153,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Usage Mode Settings -->
|
|
||||||
<div class="card">
|
|
||||||
<div class="border-b border-gray-100 px-6 py-4 dark:border-dark-700">
|
|
||||||
<h2 class="text-lg font-semibold text-gray-900 dark:text-white">
|
|
||||||
{{ t('admin.settings.usageMode.title') }}
|
|
||||||
</h2>
|
|
||||||
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">
|
|
||||||
{{ t('admin.settings.usageMode.description') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="space-y-5 p-6">
|
|
||||||
<!-- Simple Mode Toggle -->
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<div>
|
|
||||||
<label class="font-medium text-gray-900 dark:text-white">
|
|
||||||
{{ t('admin.settings.usageMode.simpleMode') }}
|
|
||||||
</label>
|
|
||||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
||||||
{{ t('admin.settings.usageMode.simpleModeHint') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<Toggle
|
|
||||||
:model-value="form.simple_mode"
|
|
||||||
@update:model-value="onSimpleModeToggle"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Warning when simple mode is enabled -->
|
|
||||||
<div
|
|
||||||
v-if="form.simple_mode"
|
|
||||||
class="rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20"
|
|
||||||
>
|
|
||||||
<div class="flex items-start">
|
|
||||||
<svg
|
|
||||||
class="mt-0.5 h-5 w-5 flex-shrink-0 text-amber-500"
|
|
||||||
fill="currentColor"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fill-rule="evenodd"
|
|
||||||
d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
|
|
||||||
clip-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
<p class="ml-3 text-sm text-amber-700 dark:text-amber-300">
|
|
||||||
{{ t('admin.settings.usageMode.simpleModeWarning') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Registration Settings -->
|
<!-- Registration Settings -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="border-b border-gray-100 px-6 py-4 dark:border-dark-700">
|
<div class="border-b border-gray-100 px-6 py-4 dark:border-dark-700">
|
||||||
@@ -758,19 +706,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Simple Mode Confirmation Dialog -->
|
|
||||||
<ConfirmDialog
|
|
||||||
:show="showSimpleModeConfirm"
|
|
||||||
:title="t('admin.settings.usageMode.confirmTitle')"
|
|
||||||
:message="pendingSimpleModeValue
|
|
||||||
? t('admin.settings.usageMode.confirmEnableMessage')
|
|
||||||
: t('admin.settings.usageMode.confirmDisableMessage')"
|
|
||||||
:confirm-text="t('common.confirm')"
|
|
||||||
:cancel-text="t('common.cancel')"
|
|
||||||
@confirm="confirmSimpleModeChange"
|
|
||||||
@cancel="cancelSimpleModeChange"
|
|
||||||
/>
|
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -781,7 +716,6 @@ import { adminAPI } from '@/api'
|
|||||||
import type { SystemSettings } from '@/api/admin/settings'
|
import type { SystemSettings } from '@/api/admin/settings'
|
||||||
import AppLayout from '@/components/layout/AppLayout.vue'
|
import AppLayout from '@/components/layout/AppLayout.vue'
|
||||||
import Toggle from '@/components/common/Toggle.vue'
|
import Toggle from '@/components/common/Toggle.vue'
|
||||||
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
|
|
||||||
import { useAppStore } from '@/stores'
|
import { useAppStore } from '@/stores'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
@@ -794,10 +728,6 @@ const sendingTestEmail = ref(false)
|
|||||||
const testEmailAddress = ref('')
|
const testEmailAddress = ref('')
|
||||||
const logoError = ref('')
|
const logoError = ref('')
|
||||||
|
|
||||||
// Simple mode confirmation dialog
|
|
||||||
const showSimpleModeConfirm = ref(false)
|
|
||||||
const pendingSimpleModeValue = ref(false)
|
|
||||||
|
|
||||||
// Admin API Key 状态
|
// Admin API Key 状态
|
||||||
const adminApiKeyLoading = ref(true)
|
const adminApiKeyLoading = ref(true)
|
||||||
const adminApiKeyExists = ref(false)
|
const adminApiKeyExists = ref(false)
|
||||||
@@ -826,9 +756,7 @@ const form = reactive<SystemSettings>({
|
|||||||
// Cloudflare Turnstile
|
// Cloudflare Turnstile
|
||||||
turnstile_enabled: false,
|
turnstile_enabled: false,
|
||||||
turnstile_site_key: '',
|
turnstile_site_key: '',
|
||||||
turnstile_secret_key: '',
|
turnstile_secret_key: ''
|
||||||
// Usage mode
|
|
||||||
simple_mode: false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleLogoUpload(event: Event) {
|
function handleLogoUpload(event: Event) {
|
||||||
@@ -899,40 +827,6 @@ async function saveSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple mode toggle handlers
|
|
||||||
function onSimpleModeToggle(value: boolean) {
|
|
||||||
pendingSimpleModeValue.value = value
|
|
||||||
showSimpleModeConfirm.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmSimpleModeChange() {
|
|
||||||
showSimpleModeConfirm.value = false
|
|
||||||
form.simple_mode = pendingSimpleModeValue.value
|
|
||||||
|
|
||||||
saving.value = true
|
|
||||||
try {
|
|
||||||
await adminAPI.settings.updateSettings(form)
|
|
||||||
await appStore.fetchPublicSettings(true)
|
|
||||||
appStore.showSuccess(t('admin.settings.settingsSaved'))
|
|
||||||
// Reload page to apply menu changes
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.reload()
|
|
||||||
}, 500)
|
|
||||||
} catch (error: any) {
|
|
||||||
// Revert on error
|
|
||||||
form.simple_mode = !pendingSimpleModeValue.value
|
|
||||||
appStore.showError(
|
|
||||||
t('admin.settings.failedToSave') + ': ' + (error.message || t('common.unknownError'))
|
|
||||||
)
|
|
||||||
} finally {
|
|
||||||
saving.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelSimpleModeChange() {
|
|
||||||
showSimpleModeConfirm.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testSmtpConnection() {
|
async function testSmtpConnection() {
|
||||||
testingSmtp.value = true
|
testingSmtp.value = true
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user