refactor: 移除旧版数据库配置的简易模式实现

移除与 PR #66 冲突的旧版简易模式实现(commit 7d4b7de)。
新版简易模式通过 run_mode 配置文件/环境变量控制,无需数据库设置。

后端变更:
- 移除 SettingKeySimpleMode 常量
- 移除 SystemSettings/PublicSettings 中的 SimpleMode 字段
- 移除 setting_handler 中的简易模式切换逻辑
- 移除 userService 依赖(不再需要自动设置管理员并发数)

前端变更:
- 移除 appStore.simpleMode 状态
- 移除设置页面的"使用模式"设置区块
- 移除 GroupsView 中的简易模式相关逻辑
- 移除相关国际化文案
This commit is contained in:
shaw
2025-12-29 09:17:00 +08:00
parent 1f5ced7069
commit 31fef105c7
14 changed files with 10 additions and 193 deletions

View File

@@ -34,8 +34,6 @@ export interface SystemSettings {
turnstile_enabled: boolean
turnstile_site_key: string
turnstile_secret_key: string
// Usage mode
simple_mode: boolean
}
/**

View File

@@ -1413,16 +1413,6 @@ export default {
securityWarning: 'Warning: This key provides full admin access. Keep it secure.',
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',
saving: 'Saving...',
settingsSaved: 'Settings saved successfully',

View File

@@ -1610,16 +1610,6 @@ export default {
securityWarning: '警告:此密钥拥有完整的管理员权限,请妥善保管。',
usage: '使用方法:在请求头中添加 x-api-key: <your-admin-api-key>'
},
usageMode: {
title: '使用模式',
description: '切换简单模式以简化界面',
simpleMode: '简单模式',
simpleModeHint: '隐藏多用户管理功能,适合个人使用',
simpleModeWarning: '启用后将隐藏用户管理、兑换码管理等菜单,关闭用户注册功能,并将管理员并发数设为无限制',
confirmTitle: '确认切换使用模式',
confirmEnableMessage: '确定要启用简单模式吗?启用后将隐藏多用户管理相关菜单、关闭用户注册功能,并将管理员并发数设为 99999无限制。',
confirmDisableMessage: '确定要关闭简单模式吗?关闭后将恢复显示所有管理菜单。'
},
saveSettings: '保存设置',
saving: '保存中...',
settingsSaved: '设置保存成功',

View File

@@ -30,7 +30,6 @@ export const useAppStore = defineStore('app', () => {
const contactInfo = ref<string>('')
const apiBaseUrl = ref<string>('')
const docUrl = ref<string>('')
const simpleMode = ref<boolean>(false)
// Version cache state
const versionLoaded = ref<boolean>(false)
@@ -297,8 +296,7 @@ export const useAppStore = defineStore('app', () => {
api_base_url: apiBaseUrl.value,
contact_info: contactInfo.value,
doc_url: docUrl.value,
version: siteVersion.value,
simple_mode: simpleMode.value
version: siteVersion.value
}
}
@@ -316,7 +314,6 @@ export const useAppStore = defineStore('app', () => {
contactInfo.value = data.contact_info || ''
apiBaseUrl.value = data.api_base_url || ''
docUrl.value = data.doc_url || ''
simpleMode.value = data.simple_mode || false
publicSettingsLoaded.value = true
return data
} catch (error) {
@@ -351,7 +348,6 @@ export const useAppStore = defineStore('app', () => {
contactInfo,
apiBaseUrl,
docUrl,
simpleMode,
// Version state
versionLoaded,

View File

@@ -55,7 +55,6 @@ export interface PublicSettings {
contact_info: string
doc_url: string
version: string
simple_mode: boolean
}
export interface AuthResponse {

View File

@@ -683,18 +683,10 @@ const editStatusOptions = computed(() => [
{ value: 'inactive', label: t('common.inactive') }
])
const subscriptionTypeOptions = computed(() => {
// 简单模式下只显示订阅模式(配额模式)
if (appStore.simpleMode) {
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 subscriptionTypeOptions = computed(() => [
{ value: 'standard', label: t('admin.groups.subscription.standard') },
{ value: 'subscription', label: t('admin.groups.subscription.subscription') }
])
const groups = ref<Group[]>([])
const loading = ref(false)
@@ -804,7 +796,7 @@ const closeCreateModal = () => {
createForm.platform = 'anthropic'
createForm.rate_multiplier = 1.0
createForm.is_exclusive = false
createForm.subscription_type = appStore.simpleMode ? 'subscription' : 'standard'
createForm.subscription_type = 'standard'
createForm.daily_limit_usd = null
createForm.weekly_limit_usd = null
createForm.monthly_limit_usd = null
@@ -895,9 +887,5 @@ watch(
onMounted(() => {
loadGroups()
// 简单模式下默认使用订阅模式
if (appStore.simpleMode) {
createForm.subscription_type = 'subscription'
}
})
</script>

View File

@@ -153,58 +153,6 @@
</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 -->
<div class="card">
<div class="border-b border-gray-100 px-6 py-4 dark:border-dark-700">
@@ -758,19 +706,6 @@
</div>
</form>
</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>
</template>
@@ -781,7 +716,6 @@ import { adminAPI } from '@/api'
import type { SystemSettings } from '@/api/admin/settings'
import AppLayout from '@/components/layout/AppLayout.vue'
import Toggle from '@/components/common/Toggle.vue'
import ConfirmDialog from '@/components/common/ConfirmDialog.vue'
import { useAppStore } from '@/stores'
const { t } = useI18n()
@@ -794,10 +728,6 @@ const sendingTestEmail = ref(false)
const testEmailAddress = ref('')
const logoError = ref('')
// Simple mode confirmation dialog
const showSimpleModeConfirm = ref(false)
const pendingSimpleModeValue = ref(false)
// Admin API Key 状态
const adminApiKeyLoading = ref(true)
const adminApiKeyExists = ref(false)
@@ -826,9 +756,7 @@ const form = reactive<SystemSettings>({
// Cloudflare Turnstile
turnstile_enabled: false,
turnstile_site_key: '',
turnstile_secret_key: '',
// Usage mode
simple_mode: false
turnstile_secret_key: ''
})
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() {
testingSmtp.value = true
try {