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

@@ -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 {