feat(admin): 添加 LinuxDO OAuth 回调地址快速设置按钮
- 在设置页面添加"使用当前站点生成并复制"按钮 - 自动填充回调地址并复制到剪贴板 - 添加中英文国际化支持 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1782,7 +1782,9 @@ export default {
|
||||
redirectUrl: 'Redirect URL',
|
||||
redirectUrlPlaceholder: 'https://your-domain.com/api/v1/auth/oauth/linuxdo/callback',
|
||||
redirectUrlHint:
|
||||
'Must match the redirect URL configured in Connect.Linux.Do (must be an absolute http(s) URL)'
|
||||
'Must match the redirect URL configured in Connect.Linux.Do (must be an absolute http(s) URL)',
|
||||
quickSetCopy: 'Generate & Copy (current site)',
|
||||
redirectUrlSetAndCopied: 'Redirect URL generated and copied to clipboard'
|
||||
},
|
||||
defaults: {
|
||||
title: 'Default User Settings',
|
||||
|
||||
@@ -1926,7 +1926,9 @@ export default {
|
||||
clientSecretConfiguredHint: '密钥已配置,留空以保留当前值。',
|
||||
redirectUrl: '回调地址(Redirect URL)',
|
||||
redirectUrlPlaceholder: 'https://your-domain.com/api/v1/auth/oauth/linuxdo/callback',
|
||||
redirectUrlHint: '需与 Connect.Linux.Do 中配置的回调地址一致(必须是 http(s) 完整 URL)'
|
||||
redirectUrlHint: '需与 Connect.Linux.Do 中配置的回调地址一致(必须是 http(s) 完整 URL)',
|
||||
quickSetCopy: '使用当前站点生成并复制',
|
||||
redirectUrlSetAndCopied: '已使用当前站点生成回调地址并复制到剪贴板'
|
||||
},
|
||||
defaults: {
|
||||
title: '用户默认设置',
|
||||
|
||||
@@ -337,6 +337,21 @@
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="t('admin.settings.linuxdo.redirectUrlPlaceholder')"
|
||||
/>
|
||||
<div class="mt-2 flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary btn-sm w-fit"
|
||||
@click="setAndCopyLinuxdoRedirectUrl"
|
||||
>
|
||||
{{ t('admin.settings.linuxdo.quickSetCopy') }}
|
||||
</button>
|
||||
<code
|
||||
v-if="linuxdoRedirectUrlSuggestion"
|
||||
class="select-all break-all rounded bg-gray-50 px-2 py-1 font-mono text-xs text-gray-600 dark:bg-dark-800 dark:text-gray-300"
|
||||
>
|
||||
{{ linuxdoRedirectUrlSuggestion }}
|
||||
</code>
|
||||
</div>
|
||||
<p class="mt-1.5 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.settings.linuxdo.redirectUrlHint') }}
|
||||
</p>
|
||||
@@ -777,17 +792,19 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { adminAPI } from '@/api'
|
||||
import type { SystemSettings, UpdateSettingsRequest } from '@/api/admin/settings'
|
||||
import AppLayout from '@/components/layout/AppLayout.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import Toggle from '@/components/common/Toggle.vue'
|
||||
import { useClipboard } from '@/composables/useClipboard'
|
||||
import { useAppStore } from '@/stores'
|
||||
|
||||
const { t } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
const { copyToClipboard } = useClipboard()
|
||||
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
@@ -844,6 +861,21 @@ const form = reactive<SettingsForm>({
|
||||
identity_patch_prompt: ''
|
||||
})
|
||||
|
||||
const linuxdoRedirectUrlSuggestion = computed(() => {
|
||||
if (typeof window === 'undefined') return ''
|
||||
const origin =
|
||||
window.location.origin || `${window.location.protocol}//${window.location.host}`
|
||||
return `${origin}/api/v1/auth/oauth/linuxdo/callback`
|
||||
})
|
||||
|
||||
async function setAndCopyLinuxdoRedirectUrl() {
|
||||
const url = linuxdoRedirectUrlSuggestion.value
|
||||
if (!url) return
|
||||
|
||||
form.linuxdo_connect_redirect_url = url
|
||||
await copyToClipboard(url, t('admin.settings.linuxdo.redirectUrlSetAndCopied'))
|
||||
}
|
||||
|
||||
function handleLogoUpload(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
|
||||
Reference in New Issue
Block a user