mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 08:46:40 +08:00
feat(AliyunAuthDialog): 添加配置支持,允许自定义refreshToken和保存设置
This commit is contained in:
@@ -144,6 +144,7 @@ onMounted(() => {
|
|||||||
<AliyunAuthDialog
|
<AliyunAuthDialog
|
||||||
v-if="aliyunAuthDialog"
|
v-if="aliyunAuthDialog"
|
||||||
v-model="aliyunAuthDialog"
|
v-model="aliyunAuthDialog"
|
||||||
|
:conf="props.storage.config || {}"
|
||||||
@close="aliyunAuthDialog = false"
|
@close="aliyunAuthDialog = false"
|
||||||
@done="handleDone"
|
@done="handleDone"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,6 +2,14 @@
|
|||||||
import QrcodeVue from 'qrcode.vue'
|
import QrcodeVue from 'qrcode.vue'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
|
|
||||||
|
// 定义输入
|
||||||
|
const props = defineProps({
|
||||||
|
conf: {
|
||||||
|
type: Object as PropType<{ [key: string]: any }>,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// 定义事件
|
// 定义事件
|
||||||
const emit = defineEmits(['done', 'close'])
|
const emit = defineEmits(['done', 'close'])
|
||||||
|
|
||||||
@@ -25,6 +33,10 @@ let timeoutTimer: NodeJS.Timeout | undefined = undefined
|
|||||||
|
|
||||||
// 完成
|
// 完成
|
||||||
async function handleDone() {
|
async function handleDone() {
|
||||||
|
clearTimeout(timeoutTimer)
|
||||||
|
if (props.conf?.refreshToken) {
|
||||||
|
await savaAliPanConfig()
|
||||||
|
}
|
||||||
emit('done')
|
emit('done')
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +87,15 @@ async function checkQrcode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 保存cookie设置
|
||||||
|
async function savaAliPanConfig() {
|
||||||
|
try {
|
||||||
|
await api.post(`storage/save/alipan`, props.conf)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getQrcode()
|
await getQrcode()
|
||||||
timeoutTimer = setTimeout(checkQrcode, 3000)
|
timeoutTimer = setTimeout(checkQrcode, 3000)
|
||||||
@@ -97,6 +118,13 @@ onUnmounted(() => {
|
|||||||
<template #prepend />
|
<template #prepend />
|
||||||
</VAlert>
|
</VAlert>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
|
<VCardText>
|
||||||
|
<VRow>
|
||||||
|
<VCol class="mt-2">
|
||||||
|
<VTextField label="自定义refreshToken" v-model="props.conf.refreshToken" outlined dense />
|
||||||
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
</VCardText>
|
||||||
<VCardActions>
|
<VCardActions>
|
||||||
<VSpacer />
|
<VSpacer />
|
||||||
<VBtn variant="elevated" @click="handleDone" prepend-icon="mdi-check" class="px-5 me-3"> 完成 </VBtn>
|
<VBtn variant="elevated" @click="handleDone" prepend-icon="mdi-check" class="px-5 me-3"> 完成 </VBtn>
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ let timeoutTimer: NodeJS.Timeout | undefined = undefined
|
|||||||
|
|
||||||
// 完成
|
// 完成
|
||||||
async function handleDone() {
|
async function handleDone() {
|
||||||
|
clearTimeout(timeoutTimer)
|
||||||
if (props.conf?.cookie) {
|
if (props.conf?.cookie) {
|
||||||
await savaAlistConfig()
|
await savaU115Config()
|
||||||
}
|
}
|
||||||
emit('done')
|
emit('done')
|
||||||
}
|
}
|
||||||
@@ -84,7 +85,7 @@ async function checkQrcode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存cookie设置
|
// 保存cookie设置
|
||||||
async function savaAlistConfig() {
|
async function savaU115Config() {
|
||||||
try {
|
try {
|
||||||
await api.post(`storage/save/u115`, props.conf)
|
await api.post(`storage/save/u115`, props.conf)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { isNullOrEmptyObject } from '@/@core/utils'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
|
|
||||||
@@ -61,7 +62,10 @@ async function loadLastAuthParams() {
|
|||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get(`system/setting/UserSiteAuthParams`)
|
const result: { [key: string]: any } = await api.get(`system/setting/UserSiteAuthParams`)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
authForm.value = result.data?.value || { site: null, params: {} }
|
const ret = result.data?.value
|
||||||
|
if (ret && !isNullOrEmptyObject(ret.params)) {
|
||||||
|
authForm.value = ret
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
@@ -84,6 +88,22 @@ async function handleDone() {
|
|||||||
|
|
||||||
// 认证处理
|
// 认证处理
|
||||||
async function checkUser() {
|
async function checkUser() {
|
||||||
|
if (!authForm.value.site) {
|
||||||
|
$toast.error('请选择认证站点!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!authSites.value[authForm.value.site]) {
|
||||||
|
$toast.error('站点配置不存在!')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (formFields.value.length > 0) {
|
||||||
|
for (const field of formFields.value) {
|
||||||
|
if (!authForm.value.params[field.site.toUpperCase() + '_' + field.key.toUpperCase()]) {
|
||||||
|
$toast.error(`请输入${field.name}!`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post(`site/auth`, authForm.value)
|
const result: { [key: string]: any } = await api.post(`site/auth`, authForm.value)
|
||||||
|
|||||||
Reference in New Issue
Block a user