Merge branch 'dev' into dev-user

This commit is contained in:
Aqr-K
2024-10-18 11:03:01 +08:00
committed by GitHub
20 changed files with 1111 additions and 429 deletions

View File

@@ -334,7 +334,7 @@ const getPosterUrl: Ref<string> = computed(() => {
return `${import.meta.env.VITE_API_BASE_URL}system/cache/image?url=${encodeURIComponent(url)}`
// 如果地址中包含douban则使用中转代理
if (url.includes('doubanio.com'))
return `${import.meta.env.VITE_API_BASE_URL}douban/img?imgurl=${encodeURIComponent(url)}`
return `${import.meta.env.VITE_API_BASE_URL}system/img/0?imgurl=${encodeURIComponent(url)}`
return url
})

View File

@@ -63,7 +63,6 @@ async function saveStorages() {
// 修改后生效
async function updatedStorage() {
await saveStorages()
loadStorages()
}
@@ -98,9 +97,9 @@ async function saveDirectories() {
// 添加媒体库目录
function addDirectory() {
let name = `目录${directories.value.length + 1}`;
let name = `目录${directories.value.length + 1}`
while (directories.value.some(item => item.name === name)) {
name = `目录${parseInt(name.split('目录')[1]) + 1}`;
name = `目录${parseInt(name.split('目录')[1]) + 1}`
}
directories.value.push({
name: name,

View File

@@ -25,9 +25,10 @@ const $toast = useToast()
// 种子优先规则下拉框
const TorrentPriorityItems = [
{ title: '站点排序优先', value: 'site' },
{ title: '站点上传量优先', value: 'upload' },
{ title: '资源做种数优先', value: 'seeder' },
{ title: '资源优先', value: 'torrent' },
{ title: '站点优先', value: 'site' },
{ title: '站点上传量', value: 'upload' },
{ title: '资源做种数', value: 'seeder' },
]
// 调用API查询自动分类配置
@@ -52,13 +53,13 @@ async function saveCustomRules() {
// 添加自定义规则
function addCustomRule() {
let id = `RULE${customRules.value.length + 1}`;
let id = `RULE${customRules.value.length + 1}`
while (customRules.value.some(item => item.id === id)) {
id = `RULE${parseInt(id.split('RULE')[1]) + 1}`;
id = `RULE${parseInt(id.split('RULE')[1]) + 1}`
}
let name = `规则${customRules.value.length + 1}`;
let name = `规则${customRules.value.length + 1}`
while (customRules.value.some(item => item.name === name)) {
name = `规则${parseInt(name.split('规则')[1]) + 1}`;
name = `规则${parseInt(name.split('规则')[1]) + 1}`
}
customRules.value.push({
id: id,
@@ -97,9 +98,9 @@ async function saveFilterRuleGroups() {
// 添加规则组
function addFilterRuleGroup() {
let name = `规则组${filterRuleGroups.value.length + 1}`;
let name = `规则组${filterRuleGroups.value.length + 1}`
while (filterRuleGroups.value.some(item => item.name === name)) {
name = `规则组${parseInt(name.split('规则组')[1]) + 1}`;
name = `规则组${parseInt(name.split('规则组')[1]) + 1}`
}
filterRuleGroups.value.push({
name: name,
@@ -245,7 +246,7 @@ onMounted(() => {
<VCard>
<VCardItem>
<VCardTitle>下载规则</VCardTitle>
<VCardSubtitle>按站点或做种数量优先下载</VCardSubtitle>
<VCardSubtitle>同时命中多个资源时择优下载</VCardSubtitle>
</VCardItem>
<VCardText>
<VForm>
@@ -254,8 +255,10 @@ onMounted(() => {
<VSelect
v-model="selectedTorrentPriority"
:items="TorrentPriorityItems"
multiple
chips
label="当前使用下载优先规则"
hint="同时命中多个站点的多个资源时下载的优先规则"
hint="排在前面的优先级越高,未选择的项不纳入排序"
persistent-hint
/>
</VCol>

View File

@@ -14,6 +14,8 @@ const resetSitesText = ref('重置站点数据')
// 站点重置按钮可用状态
const resetSitesDisabled = ref(false)
const isPasswordVisible = ref(false)
// CookieCloud设置项
const siteSetting = ref({
COOKIECLOUD_HOST: '',
@@ -155,7 +157,9 @@ onMounted(() => {
<VCol cols="12" md="6">
<VTextField
v-model="siteSetting.COOKIECLOUD_PASSWORD"
type="password"
:type="isPasswordVisible ? 'text' : 'password'"
:append-inner-icon="isPasswordVisible ? 'mdi-eye-off-outline' : 'mdi-eye-outline'"
@click:append-inner="isPasswordVisible = !isPasswordVisible"
label="端对端加密密码"
hint="CookieCloud浏览器插件生成的端对端加密密码"
persistent-hint

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import api from '@/api'
import type { Site } from '@/api/types'
import type { Site, SiteUserData } from '@/api/types'
import SiteCard from '@/components/cards/SiteCard.vue'
import NoDataFound from '@/components/NoDataFound.vue'
import SiteAddEditDialog from '@/components/dialog/SiteAddEditDialog.vue'
@@ -15,8 +15,11 @@ const appMode = computed(() => {
return localStorage.getItem('MP_APPMODE') != '0' && display.mdAndDown.value
})
// 数据列表
const dataList = ref<Site[]>([])
// 站点列表
const siteList = ref<Site[]>([])
// 站点数据列表
const userDataList = ref<SiteUserData[]>([])
// 是否刷新过
const isRefreshed = ref(false)
@@ -31,7 +34,7 @@ const siteAddDialog = ref(false)
async function fetchData() {
try {
loading.value = true
dataList.value = await api.get('site/')
siteList.value = await api.get('site/')
loading.value = false
isRefreshed.value = true
} catch (error) {
@@ -39,10 +42,19 @@ async function fetchData() {
}
}
// 获取站点最新数据
async function fetchUserData() {
try {
userDataList.value = await api.get('site/userdata/latest')
} catch (error) {
console.error(error)
}
}
// 保存站点排序
async function savaSitesPriority() {
// 重新排序
const priorities = dataList.value.map((site, index) => ({ id: site.id, pri: index + 1 }))
const priorities = siteList.value.map((site, index) => ({ id: site.id, pri: index + 1 }))
try {
const result: { [key: string]: any } = await api.post('site/priorities', priorities)
if (result.success) {
@@ -53,12 +65,27 @@ async function savaSitesPriority() {
}
}
// 根据站点ID获取站点数据
function getUserData(domain: string) {
return userDataList.value.find(userData => userData.domain === domain)
}
// 更新站点事件时
function onSiteSave() {
siteAddDialog.value = false
fetchData()
}
// 加载时获取数据
onBeforeMount(fetchData)
onBeforeMount(() => {
fetchData()
fetchUserData()
})
onActivated(() => {
if (!loading.value) {
fetchData()
fetchUserData()
}
})
</script>
@@ -67,8 +94,8 @@ onActivated(() => {
<LoadingBanner v-if="!isRefreshed" class="mt-12" />
<div>
<draggable
v-if="dataList.length > 0"
v-model="dataList"
v-if="siteList.length > 0"
v-model="siteList"
@end="savaSitesPriority"
handle=".cursor-move"
item-key="id"
@@ -76,12 +103,12 @@ onActivated(() => {
:component-data="{ 'class': 'grid gap-3 grid-site-card' }"
>
<template #item="{ element }">
<SiteCard :site="element" @remove="fetchData" @update="fetchData" />
<SiteCard :site="element" :data="getUserData(element.domain)" @remove="fetchData" @update="fetchData" />
</template>
</draggable>
</div>
<NoDataFound
v-if="dataList.length === 0 && isRefreshed"
v-if="siteList.length === 0 && isRefreshed"
error-code="404"
error-title="没有站点"
error-description="已添加并支持的站点将会在这里显示"
@@ -102,12 +129,7 @@ onActivated(() => {
v-if="siteAddDialog"
v-model="siteAddDialog"
oper="add"
@save="
() => {
siteAddDialog = false
fetchData()
}
"
@save="onSiteSave"
@close="siteAddDialog = false"
/>
</template>

View File

@@ -229,9 +229,12 @@ onMounted(() => {
})
// 监听 localStorage 中的用户头像变化
watch(() => store.state.auth.avatar, () => {
currentAvatar.value = store.state.auth.avatar
})
watch(
() => store.state.auth.avatar,
() => {
currentAvatar.value = store.state.auth.avatar
},
)
</script>
<template>
@@ -271,7 +274,7 @@ watch(() => store.state.auth.avatar, () => {
</VBtn>
<VBtn
:color="accountInfo.is_otp ? 'error' : 'info'"
:color="accountInfo.is_otp ? 'warning' : 'success'"
variant="tonal"
@click.stop="accountInfo.is_otp ? disableOtp() : getOtpUri()"
>