mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 00:36:41 +08:00
refactor(setting): 移除防抖时间
This commit is contained in:
@@ -6,7 +6,6 @@ import api from '@/api'
|
|||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
import avatar1 from '@images/avatars/avatar-1.png'
|
import avatar1 from '@images/avatars/avatar-1.png'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { debounce } from 'lodash'
|
|
||||||
|
|
||||||
// 显示器宽度
|
// 显示器宽度
|
||||||
const display = useDisplay()
|
const display = useDisplay()
|
||||||
@@ -24,9 +23,6 @@ const props = defineProps({
|
|||||||
oper: String,
|
oper: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 当前登录用户名称
|
// 当前登录用户名称
|
||||||
const currentLoginUser = store.state.auth.userName
|
const currentLoginUser = store.state.auth.userName
|
||||||
|
|
||||||
@@ -87,8 +83,8 @@ function changeAvatar(file: Event) {
|
|||||||
const maxSize = 800 * 1024
|
const maxSize = 800 * 1024
|
||||||
// 检查文件是否为图片
|
// 检查文件是否为图片
|
||||||
if (!allowedTypes.includes(selectedFile.type)) {
|
if (!allowedTypes.includes(selectedFile.type)) {
|
||||||
$toast.error('上传的文件不符合要求,请重新选择头像');
|
$toast.error('上传的文件不符合要求,请重新选择头像')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
// 检查文件大小
|
// 检查文件大小
|
||||||
if (selectedFile.size > maxSize) {
|
if (selectedFile.size > maxSize) {
|
||||||
@@ -133,7 +129,7 @@ async function fetchUserInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API 新增用户
|
// 调用API 新增用户
|
||||||
const addUser = debounce(async () => {
|
async function addUser() {
|
||||||
if (isAdding.value) {
|
if (isAdding.value) {
|
||||||
$toast.error(`正在创建【${userForm.value.name}】用户,请稍后`)
|
$toast.error(`正在创建【${userForm.value.name}】用户,请稍后`)
|
||||||
return
|
return
|
||||||
@@ -172,10 +168,10 @@ const addUser = debounce(async () => {
|
|||||||
}
|
}
|
||||||
doneNProgress()
|
doneNProgress()
|
||||||
isAdding.value = false
|
isAdding.value = false
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 调用API更新用户信息
|
// 调用API更新用户信息
|
||||||
const updateUser = debounce(async () => {
|
async function updateUser() {
|
||||||
if (isUpdating.value) {
|
if (isUpdating.value) {
|
||||||
$toast.error(`正在更新【${userForm.value.name}】用户,请稍后`)
|
$toast.error(`正在更新【${userForm.value.name}】用户,请稍后`)
|
||||||
return
|
return
|
||||||
@@ -232,7 +228,7 @@ const updateUser = debounce(async () => {
|
|||||||
}
|
}
|
||||||
doneNProgress()
|
doneNProgress()
|
||||||
isUpdating.value = false
|
isUpdating.value = false
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 用户状态转换,true/false转换为1/0
|
// 用户状态转换,true/false转换为1/0
|
||||||
const userStatus = computed({
|
const userStatus = computed({
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ import api from '@/api'
|
|||||||
import { TransferDirectoryConf, StorageConf } from '@/api/types'
|
import { TransferDirectoryConf, StorageConf } from '@/api/types'
|
||||||
import DirectoryCard from '@/components/cards/DirectoryCard.vue'
|
import DirectoryCard from '@/components/cards/DirectoryCard.vue'
|
||||||
import StorageCard from '@/components/cards/StorageCard.vue'
|
import StorageCard from '@/components/cards/StorageCard.vue'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 所有下载目录
|
// 所有下载目录
|
||||||
const directories = ref<TransferDirectoryConf[]>([])
|
const directories = ref<TransferDirectoryConf[]>([])
|
||||||
@@ -55,7 +51,7 @@ async function loadStorages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存存储
|
// 保存存储
|
||||||
const saveStorages = debounce(async () => {
|
async function saveStorages() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/setting/Storages', storages.value)
|
const result: { [key: string]: any } = await api.post('system/setting/Storages', storages.value)
|
||||||
if (result.success) $toast.success('存储设置保存成功')
|
if (result.success) $toast.success('存储设置保存成功')
|
||||||
@@ -63,7 +59,7 @@ const saveStorages = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 修改后生效
|
// 修改后生效
|
||||||
async function updatedStorage() {
|
async function updatedStorage() {
|
||||||
@@ -81,7 +77,7 @@ async function loadDirectories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存目录
|
// 保存目录
|
||||||
const saveDirectories = debounce(async () => {
|
async function saveDirectories() {
|
||||||
orderDirectoryCards()
|
orderDirectoryCards()
|
||||||
try {
|
try {
|
||||||
const names = directories.value.map(item => item.name)
|
const names = directories.value.map(item => item.name)
|
||||||
@@ -97,10 +93,10 @@ const saveDirectories = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 添加媒体库目录
|
// 添加媒体库目录
|
||||||
const addDirectory = debounce(() => {
|
function addDirectory() {
|
||||||
let name = `目录${directories.value.length + 1}`
|
let name = `目录${directories.value.length + 1}`
|
||||||
while (directories.value.some(item => item.name === name)) {
|
while (directories.value.some(item => item.name === name)) {
|
||||||
name = `目录${parseInt(name.split('目录')[1]) + 1}`
|
name = `目录${parseInt(name.split('目录')[1]) + 1}`
|
||||||
@@ -115,15 +111,15 @@ const addDirectory = debounce(() => {
|
|||||||
media_category: '',
|
media_category: '',
|
||||||
})
|
})
|
||||||
orderDirectoryCards()
|
orderDirectoryCards()
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 移除媒体库目录
|
// 移除媒体库目录
|
||||||
const removeDirectory = debounce((directory: TransferDirectoryConf) => {
|
function removeDirectory(directory: TransferDirectoryConf) {
|
||||||
const index = directories.value.indexOf(directory)
|
const index = directories.value.indexOf(directory)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
directories.value.splice(index, 1)
|
directories.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 调用API查询自动分类配置
|
// 调用API查询自动分类配置
|
||||||
async function loadMediaCategories() {
|
async function loadMediaCategories() {
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ import api from '@/api'
|
|||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
import type { NotificationConf, NotificationSwitchConf } from '@/api/types'
|
import type { NotificationConf, NotificationSwitchConf } from '@/api/types'
|
||||||
import NotificationChannelCard from '@/components/cards/NotificationChannelCard.vue'
|
import NotificationChannelCard from '@/components/cards/NotificationChannelCard.vue'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 所有消息渠道
|
// 所有消息渠道
|
||||||
const notifications = ref<NotificationConf[]>([])
|
const notifications = ref<NotificationConf[]>([])
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
|
|
||||||
@@ -63,10 +59,10 @@ async function reloadSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加通知渠道
|
// 添加通知渠道
|
||||||
const addNotification = debounce((notification: string) => {
|
function addNotification(notification: string) {
|
||||||
let name = `通知${notifications.value.length + 1}`;
|
let name = `通知${notifications.value.length + 1}`
|
||||||
while (notifications.value.some(item => item.name === name)) {
|
while (notifications.value.some(item => item.name === name)) {
|
||||||
name = `通知${parseInt(name.split('通知')[1]) + 1}`;
|
name = `通知${parseInt(name.split('通知')[1]) + 1}`
|
||||||
}
|
}
|
||||||
notifications.value.push({
|
notifications.value.push({
|
||||||
name: name,
|
name: name,
|
||||||
@@ -74,7 +70,7 @@ const addNotification = debounce((notification: string) => {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
config: {},
|
config: {},
|
||||||
})
|
})
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 移除通知渠道
|
// 移除通知渠道
|
||||||
function removeNotification(notification: NotificationConf) {
|
function removeNotification(notification: NotificationConf) {
|
||||||
@@ -93,7 +89,7 @@ async function loadNotificationSetting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存通知设置
|
// 调用API保存通知设置
|
||||||
const saveNotificationSetting = debounce(async () => {
|
async function saveNotificationSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/setting/Notifications', notifications.value)
|
const result: { [key: string]: any } = await api.post('system/setting/Notifications', notifications.value)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -103,7 +99,7 @@ const saveNotificationSetting = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 通知渠道设置变化时赋值
|
// 通知渠道设置变化时赋值
|
||||||
function changNotificationSetting(notification: NotificationConf, name: string) {
|
function changNotificationSetting(notification: NotificationConf, name: string) {
|
||||||
@@ -122,7 +118,7 @@ async function loadNotificationSwitchs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存消息类型开关
|
// 保存消息类型开关
|
||||||
const saveNotificationSwitchs = debounce(async () => {
|
async function saveNotificationSwitchs() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post(
|
const result: { [key: string]: any } = await api.post(
|
||||||
'system/setting/NotificationSwitchs',
|
'system/setting/NotificationSwitchs',
|
||||||
@@ -133,7 +129,7 @@ const saveNotificationSwitchs = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ import { CustomRule, FilterRuleGroup } from '@/api/types'
|
|||||||
import CustomerRuleCard from '@/components/cards/CustomRuleCard.vue'
|
import CustomerRuleCard from '@/components/cards/CustomRuleCard.vue'
|
||||||
import FilterRuleGroupCard from '@/components/cards/FilterRuleGroupCard.vue'
|
import FilterRuleGroupCard from '@/components/cards/FilterRuleGroupCard.vue'
|
||||||
import ImportCodeDialog from '@/components/dialog/ImportCodeDialog.vue'
|
import ImportCodeDialog from '@/components/dialog/ImportCodeDialog.vue'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 1
|
|
||||||
|
|
||||||
// 自定义规则列表
|
// 自定义规则列表
|
||||||
const customRules = ref<CustomRule[]>([])
|
const customRules = ref<CustomRule[]>([])
|
||||||
@@ -56,7 +52,7 @@ async function loadMediaCategories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存自定义规则
|
// 保存自定义规则
|
||||||
const saveCustomRules = debounce(async () => {
|
async function saveCustomRules() {
|
||||||
// 检查是否存在空id规则
|
// 检查是否存在空id规则
|
||||||
if (customRules.value.some(item => !item.id)) {
|
if (customRules.value.some(item => !item.id)) {
|
||||||
$toast.error('存在空ID的规则,无法保存,请修改!')
|
$toast.error('存在空ID的规则,无法保存,请修改!')
|
||||||
@@ -87,10 +83,10 @@ const saveCustomRules = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 添加自定义规则
|
// 添加自定义规则
|
||||||
const addCustomRule = debounce(async () => {
|
async function addCustomRule() {
|
||||||
let id = `RULE${customRules.value.length + 1}`
|
let id = `RULE${customRules.value.length + 1}`
|
||||||
while (customRules.value.some(item => item.id === id)) {
|
while (customRules.value.some(item => item.id === id)) {
|
||||||
id = `RULE${parseInt(id.split('RULE')[1]) + 1}`
|
id = `RULE${parseInt(id.split('RULE')[1]) + 1}`
|
||||||
@@ -105,7 +101,7 @@ const addCustomRule = debounce(async () => {
|
|||||||
include: '',
|
include: '',
|
||||||
exclude: '',
|
exclude: '',
|
||||||
})
|
})
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 移除自定义规则
|
// 移除自定义规则
|
||||||
function removeCustomRule(rule: CustomRule) {
|
function removeCustomRule(rule: CustomRule) {
|
||||||
@@ -124,7 +120,7 @@ async function queryFilterRuleGroups() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存规则组
|
// 保存规则组
|
||||||
const saveFilterRuleGroups = debounce(async () => {
|
async function saveFilterRuleGroups() {
|
||||||
// 检查是否存在空的规则组名称
|
// 检查是否存在空的规则组名称
|
||||||
if (filterRuleGroups.value.some(item => !item.name)) {
|
if (filterRuleGroups.value.some(item => !item.name)) {
|
||||||
$toast.error('存在空名字的规则组!无法保存,请修改!')
|
$toast.error('存在空名字的规则组!无法保存,请修改!')
|
||||||
@@ -143,10 +139,10 @@ const saveFilterRuleGroups = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 添加规则组
|
// 添加规则组
|
||||||
const addFilterRuleGroup = debounce(() => {
|
function addFilterRuleGroup() {
|
||||||
let name = `规则组${filterRuleGroups.value.length + 1}`
|
let name = `规则组${filterRuleGroups.value.length + 1}`
|
||||||
while (filterRuleGroups.value.some(item => item.name === name)) {
|
while (filterRuleGroups.value.some(item => item.name === name)) {
|
||||||
name = `规则组${parseInt(name.split('规则组')[1]) + 1}`
|
name = `规则组${parseInt(name.split('规则组')[1]) + 1}`
|
||||||
@@ -157,10 +153,10 @@ const addFilterRuleGroup = debounce(() => {
|
|||||||
media_type: '',
|
media_type: '',
|
||||||
category: '',
|
category: '',
|
||||||
})
|
})
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 分享规则
|
// 分享规则
|
||||||
const shareRules = debounce((rules: CustomRule[] | FilterRuleGroup[]) => {
|
function shareRules(rules: CustomRule[] | FilterRuleGroup[]) {
|
||||||
if (!rules || rules.length === 0) return
|
if (!rules || rules.length === 0) return
|
||||||
|
|
||||||
// 将卡片规则接装为字符串
|
// 将卡片规则接装为字符串
|
||||||
@@ -173,7 +169,7 @@ const shareRules = debounce((rules: CustomRule[] | FilterRuleGroup[]) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
$toast.error('优先级规则复制失败!')
|
$toast.error('优先级规则复制失败!')
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 导入规则
|
// 导入规则
|
||||||
async function importRules(ruleType: string) {
|
async function importRules(ruleType: string) {
|
||||||
@@ -256,7 +252,7 @@ async function queryCustomRules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存种子优先规则
|
// 保存种子优先规则
|
||||||
const saveTorrentPriority = debounce(async () => {
|
async function saveTorrentPriority() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post(
|
const result: { [key: string]: any } = await api.post(
|
||||||
'system/setting/TorrentsPriority',
|
'system/setting/TorrentsPriority',
|
||||||
@@ -267,7 +263,7 @@ const saveTorrentPriority = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -2,10 +2,6 @@
|
|||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { FilterRuleGroup, Site } from '@/api/types'
|
import type { FilterRuleGroup, Site } from '@/api/types'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
@@ -18,9 +14,7 @@ const selectedSites = ref<number[]>([])
|
|||||||
|
|
||||||
// 系统设置
|
// 系统设置
|
||||||
const SystemSettings = ref<any>({
|
const SystemSettings = ref<any>({
|
||||||
Basis: {
|
Basis: {},
|
||||||
|
|
||||||
},
|
|
||||||
Advanced: {
|
Advanced: {
|
||||||
SEARCH_MULTIPLE_NAME: false,
|
SEARCH_MULTIPLE_NAME: false,
|
||||||
DOWNLOAD_SUBTITLE: false,
|
DOWNLOAD_SUBTITLE: false,
|
||||||
@@ -95,7 +89,7 @@ async function querySelectedSites() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存用户选中的站点
|
// 保存用户选中的站点
|
||||||
const saveSelectedSites = debounce(async () => {
|
async function saveSelectedSites() {
|
||||||
try {
|
try {
|
||||||
// 用户名密码
|
// 用户名密码
|
||||||
const result: { [key: string]: any } = await api.post('system/setting/IndexerSites', selectedSites.value)
|
const result: { [key: string]: any } = await api.post('system/setting/IndexerSites', selectedSites.value)
|
||||||
@@ -105,7 +99,7 @@ const saveSelectedSites = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 调用API查询设置
|
// 调用API查询设置
|
||||||
async function loadSearchSetting() {
|
async function loadSearchSetting() {
|
||||||
@@ -120,7 +114,7 @@ async function loadSearchSetting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存设置
|
// 调用API保存设置
|
||||||
const saveSearchSetting = debounce(async () => {
|
async function saveSearchSetting() {
|
||||||
try {
|
try {
|
||||||
const result1: { [key: string]: any } = await api.post(
|
const result1: { [key: string]: any } = await api.post(
|
||||||
'system/setting/SEARCH_SOURCE',
|
'system/setting/SEARCH_SOURCE',
|
||||||
@@ -141,7 +135,7 @@ const saveSearchSetting = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载系统设置
|
// 加载系统设置
|
||||||
async function loadSystemSettings() {
|
async function loadSystemSettings() {
|
||||||
@@ -158,7 +152,7 @@ async function loadSystemSettings() {
|
|||||||
if (v === '') {
|
if (v === '') {
|
||||||
v = null
|
v = null
|
||||||
}
|
}
|
||||||
(SystemSettings.value[sectionKey] as any)[key] = v
|
;(SystemSettings.value[sectionKey] as any)[key] = v
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -169,7 +163,7 @@ async function loadSystemSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存设置
|
// 保存设置
|
||||||
const saveSystemSettings = debounce(async (value: any) => {
|
async function saveSystemSettings(value: any) {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/env', value)
|
const result: { [key: string]: any } = await api.post('system/env', value)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -182,7 +176,7 @@ const saveSystemSettings = debounce(async (value: any) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 重载系统生效配置
|
// 重载系统生效配置
|
||||||
async function reloadSystem() {
|
async function reloadSystem() {
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ import api from '@/api'
|
|||||||
import { DownloaderConf, MediaServerConf } from '@/api/types'
|
import { DownloaderConf, MediaServerConf } from '@/api/types'
|
||||||
import DownloaderCard from '@/components/cards/DownloaderCard.vue'
|
import DownloaderCard from '@/components/cards/DownloaderCard.vue'
|
||||||
import MediaServerCard from '@/components/cards/MediaServerCard.vue'
|
import MediaServerCard from '@/components/cards/MediaServerCard.vue'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 系统设置项
|
// 系统设置项
|
||||||
const SystemSettings = ref<any>({
|
const SystemSettings = ref<any>({
|
||||||
@@ -51,13 +47,13 @@ async function reloadSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存下载器设置
|
// 调用API保存下载器设置
|
||||||
const saveDownloaderSetting = debounce(async () => {
|
async function saveDownloaderSetting() {
|
||||||
try {
|
try {
|
||||||
// 提取启用的下载器
|
// 提取启用的下载器
|
||||||
const enabledDownloaders = downloaders.value.filter(item => item.enabled);
|
const enabledDownloaders = downloaders.value.filter(item => item.enabled)
|
||||||
// 有启动的下载器时
|
// 有启动的下载器时
|
||||||
if (enabledDownloaders.length > 0) {
|
if (enabledDownloaders.length > 0) {
|
||||||
downloaders.value = handleDefaultDownloaders(enabledDownloaders, downloaders.value);
|
downloaders.value = handleDefaultDownloaders(enabledDownloaders, downloaders.value)
|
||||||
}
|
}
|
||||||
const result: { [key: string]: any } = await api.post('system/setting/Downloaders', downloaders.value)
|
const result: { [key: string]: any } = await api.post('system/setting/Downloaders', downloaders.value)
|
||||||
if (result.success) $toast.success('下载器设置保存成功')
|
if (result.success) $toast.success('下载器设置保存成功')
|
||||||
@@ -68,22 +64,22 @@ const saveDownloaderSetting = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 处理默认下载器状态
|
// 处理默认下载器状态
|
||||||
function handleDefaultDownloaders(enabledDownloaders: any[], downloaders: any[]) {
|
function handleDefaultDownloaders(enabledDownloaders: any[], downloaders: any[]) {
|
||||||
const enabledDefaultDownloader = enabledDownloaders.find(item => item.default);
|
const enabledDefaultDownloader = enabledDownloaders.find(item => item.default)
|
||||||
if (enabledDownloaders.length > 0 && !enabledDefaultDownloader) {
|
if (enabledDownloaders.length > 0 && !enabledDefaultDownloader) {
|
||||||
downloaders = downloaders.map(item => {
|
downloaders = downloaders.map(item => {
|
||||||
if (item === enabledDownloaders[0]) {
|
if (item === enabledDownloaders[0]) {
|
||||||
$toast.info(`未设置默认下载器,已将【${item.name}】作为默认下载器`);
|
$toast.info(`未设置默认下载器,已将【${item.name}】作为默认下载器`)
|
||||||
return {...item, default: true };
|
return { ...item, default: true }
|
||||||
}
|
}
|
||||||
// 清除其他下载器的默认下载器状态
|
// 清除其他下载器的默认下载器状态
|
||||||
return {...item, default: false };
|
return { ...item, default: false }
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
return downloaders;
|
return downloaders
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调用API查询媒体服务器设置
|
// 调用API查询媒体服务器设置
|
||||||
@@ -97,7 +93,7 @@ async function loadMediaServerSetting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存媒体服务器设置
|
// 调用API保存媒体服务器设置
|
||||||
const saveMediaServerSetting = debounce(async () => {
|
async function saveMediaServerSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/setting/MediaServers', mediaServers.value)
|
const result: { [key: string]: any } = await api.post('system/setting/MediaServers', mediaServers.value)
|
||||||
if (result.success) $toast.success('媒体服务器设置保存成功')
|
if (result.success) $toast.success('媒体服务器设置保存成功')
|
||||||
@@ -108,16 +104,14 @@ const saveMediaServerSetting = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载系统设置
|
// 加载系统设置
|
||||||
async function loadSystemSettings() {
|
async function loadSystemSettings() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/env')
|
const result: { [key: string]: any } = await api.get('system/env')
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const {
|
const { MEDIASERVER_SYNC_INTERVAL } = result.data
|
||||||
MEDIASERVER_SYNC_INTERVAL,
|
|
||||||
} = result.data
|
|
||||||
SystemSettings.value = {
|
SystemSettings.value = {
|
||||||
MEDIASERVER_SYNC_INTERVAL,
|
MEDIASERVER_SYNC_INTERVAL,
|
||||||
}
|
}
|
||||||
@@ -128,7 +122,7 @@ async function loadSystemSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存系统设置
|
// 调用API保存系统设置
|
||||||
const saveSystemSetting = debounce(async () => {
|
async function saveSystemSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/env', SystemSettings.value)
|
const result: { [key: string]: any } = await api.post('system/env', SystemSettings.value)
|
||||||
|
|
||||||
@@ -137,13 +131,13 @@ const saveSystemSetting = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 添加下载器
|
// 添加下载器
|
||||||
function addDownloader(downloader: string) {
|
function addDownloader(downloader: string) {
|
||||||
let name = `下载器${downloaders.value.length + 1}`;
|
let name = `下载器${downloaders.value.length + 1}`
|
||||||
while (downloaders.value.some(item => item.name === name)) {
|
while (downloaders.value.some(item => item.name === name)) {
|
||||||
name = `下载器${parseInt(name.split('下载器')[1]) + 1}`;
|
name = `下载器${parseInt(name.split('下载器')[1]) + 1}`
|
||||||
}
|
}
|
||||||
downloaders.value.push({
|
downloaders.value.push({
|
||||||
name: name,
|
name: name,
|
||||||
@@ -155,10 +149,10 @@ function addDownloader(downloader: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 删除下载器
|
// 删除下载器
|
||||||
const removeDownloader = debounce((ele: DownloaderConf) => {
|
function removeDownloader(ele: DownloaderConf) {
|
||||||
const index = downloaders.value.indexOf(ele)
|
const index = downloaders.value.indexOf(ele)
|
||||||
downloaders.value.splice(index, 1)
|
downloaders.value.splice(index, 1)
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 下载器变化
|
// 下载器变化
|
||||||
function onDownloaderChange(downloader: DownloaderConf, name: string) {
|
function onDownloaderChange(downloader: DownloaderConf, name: string) {
|
||||||
@@ -167,10 +161,10 @@ function onDownloaderChange(downloader: DownloaderConf, name: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加媒体服务器
|
// 添加媒体服务器
|
||||||
const addMediaServer = debounce( (mediaserver: string) => {
|
function addMediaServer(mediaserver: string) {
|
||||||
let name = `服务器${mediaServers.value.length + 1}`;
|
let name = `服务器${mediaServers.value.length + 1}`
|
||||||
while (mediaServers.value.some(item => item.name === name)) {
|
while (mediaServers.value.some(item => item.name === name)) {
|
||||||
name = `服务器${parseInt(name.split('服务器')[1]) + 1}`;
|
name = `服务器${parseInt(name.split('服务器')[1]) + 1}`
|
||||||
}
|
}
|
||||||
mediaServers.value.push({
|
mediaServers.value.push({
|
||||||
name: name,
|
name: name,
|
||||||
@@ -178,13 +172,13 @@ const addMediaServer = debounce( (mediaserver: string) => {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
config: {},
|
config: {},
|
||||||
})
|
})
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 删除媒体服务器
|
// 删除媒体服务器
|
||||||
const removeMediaServer = debounce((ele: MediaServerConf) => {
|
function removeMediaServer(ele: MediaServerConf) {
|
||||||
const index = mediaServers.value.indexOf(ele)
|
const index = mediaServers.value.indexOf(ele)
|
||||||
if (index !== -1) mediaServers.value.splice(index, 1)
|
if (index !== -1) mediaServers.value.splice(index, 1)
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 变更媒体服务器
|
// 变更媒体服务器
|
||||||
function onMediaServerChange(mediaserver: MediaServerConf, name: string) {
|
function onMediaServerChange(mediaserver: MediaServerConf, name: string) {
|
||||||
@@ -229,11 +223,11 @@ onDeactivated(() => {
|
|||||||
suffix="小时"
|
suffix="小时"
|
||||||
type="number"
|
type="number"
|
||||||
min="1"
|
min="1"
|
||||||
style="width: fit-content"
|
style="inline-size: fit-content"
|
||||||
:rules="[
|
:rules="[
|
||||||
v => !!v || '必选项,请勿留空',
|
(v: any) => !!v || '必选项,请勿留空',
|
||||||
v => !isNaN(v) || '仅支持输入数字,请勿输入其他字符',
|
(v: any) => !isNaN(v) || '仅支持输入数字,请勿输入其他字符',
|
||||||
v => v >= 1 || '间隔不能小于1个小时',
|
(v: any) => v >= 1 || '间隔不能小于1个小时',
|
||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
@@ -31,9 +27,9 @@ const siteSetting = ref<any>({
|
|||||||
COOKIECLOUD_ENABLE_LOCAL: false,
|
COOKIECLOUD_ENABLE_LOCAL: false,
|
||||||
COOKIECLOUD_BLACKLIST: '',
|
COOKIECLOUD_BLACKLIST: '',
|
||||||
},
|
},
|
||||||
Site:{
|
Site: {
|
||||||
SITEDATA_REFRESH_INTERVAL: 0,
|
SITEDATA_REFRESH_INTERVAL: 0,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// 同步间隔下拉框
|
// 同步间隔下拉框
|
||||||
@@ -58,7 +54,7 @@ const SiteDataRefreshIntervalItems = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
// 重置站点
|
// 重置站点
|
||||||
const resetSites = debounce(async () => {
|
async function resetSites() {
|
||||||
try {
|
try {
|
||||||
resetSitesDisabled.value = true
|
resetSitesDisabled.value = true
|
||||||
resetSitesText.value = '正在重置...'
|
resetSitesText.value = '正在重置...'
|
||||||
@@ -72,7 +68,7 @@ const resetSites = debounce(async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载站点设置
|
// 加载站点设置
|
||||||
async function loadSiteSettings() {
|
async function loadSiteSettings() {
|
||||||
@@ -86,8 +82,10 @@ async function loadSiteSettings() {
|
|||||||
if (result.data.hasOwnProperty(key)) {
|
if (result.data.hasOwnProperty(key)) {
|
||||||
v = result.data[key]
|
v = result.data[key]
|
||||||
// 空字符串转为null,避免空字符串导致前端显示问题
|
// 空字符串转为null,避免空字符串导致前端显示问题
|
||||||
if (v === '') { v = null }
|
if (v === '') {
|
||||||
(siteSetting.value[sectionKey] as any)[key] = v
|
v = null
|
||||||
|
}
|
||||||
|
;(siteSetting.value[sectionKey] as any)[key] = v
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -98,7 +96,7 @@ async function loadSiteSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 调用API保存设置
|
// 调用API保存设置
|
||||||
const saveSiteSetting = debounce(async (value: { [key: string]: any }) => {
|
async function saveSiteSetting(value: { [key: string]: any }) {
|
||||||
console.log(`正在保存设置:${JSON.stringify(value)}`)
|
console.log(`正在保存设置:${JSON.stringify(value)}`)
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/env', value)
|
const result: { [key: string]: any } = await api.post('system/env', value)
|
||||||
@@ -109,7 +107,7 @@ const saveSiteSetting = debounce(async (value: { [key: string]: any }) => {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
$toast.error('保存设置失败!')
|
$toast.error('保存设置失败!')
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -197,7 +195,7 @@ onMounted(() => {
|
|||||||
</VForm>
|
</VForm>
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardText>
|
<VCardText>
|
||||||
<VForm @submit.prevent="() => {}">
|
<VForm @submit.prevent="() => {}">
|
||||||
<div class="d-flex flex-wrap gap-4 mt-4">
|
<div class="d-flex flex-wrap gap-4 mt-4">
|
||||||
<VBtn type="submit" @click="saveSiteSetting(siteSetting.CookieCloud)"> 保存 </VBtn>
|
<VBtn type="submit" @click="saveSiteSetting(siteSetting.CookieCloud)"> 保存 </VBtn>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -44,9 +44,6 @@ const SystemSettings = ref<any>({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 高级设置弹窗
|
// 高级设置弹窗
|
||||||
const isAdvancedSystemSettingsDialogOpen = ref(false)
|
const isAdvancedSystemSettingsDialogOpen = ref(false)
|
||||||
const isAdvancedNetworkSettingsDialogOpen = ref(false)
|
const isAdvancedNetworkSettingsDialogOpen = ref(false)
|
||||||
@@ -110,18 +107,18 @@ async function saveSystemSetting(value: { [key: string]: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存系统设置
|
// 保存系统设置
|
||||||
const saveSystemSettings = debounce(async () => {
|
async function saveSystemSettings() {
|
||||||
const Settings = { ...SystemSettings.value.Basis, ...SystemSettings.value.Advanced }
|
const Settings = { ...SystemSettings.value.Basis, ...SystemSettings.value.Advanced }
|
||||||
await saveSystemSetting(Settings)
|
await saveSystemSetting(Settings)
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 保存网络设置
|
// 保存网络设置
|
||||||
const saveNetworkSettings = debounce(async () => {
|
async function saveNetworkSettings() {
|
||||||
const Settings = { ...SystemSettings.value.Network, ...SystemSettings.value.AdvancedNetwork }
|
const Settings = { ...SystemSettings.value.Network, ...SystemSettings.value.AdvancedNetwork }
|
||||||
// 查找PROXY_HOST,并删除,避免意外覆盖
|
// 查找PROXY_HOST,并删除,避免意外覆盖
|
||||||
if (Settings.PROXY_HOST) delete Settings.PROXY_HOST
|
if (Settings.PROXY_HOST) delete Settings.PROXY_HOST
|
||||||
await saveSystemSetting(Settings)
|
await saveSystemSetting(Settings)
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 高级设置变化,等待保存
|
// 高级设置变化,等待保存
|
||||||
function saveAdvancedSettings(Settings: any, key: string) {
|
function saveAdvancedSettings(Settings: any, key: string) {
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {useToast} from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import api from "@/api"
|
import api from '@/api'
|
||||||
import debounce from 'lodash/debounce'
|
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
@@ -36,7 +32,7 @@ async function loadSystemSettings() {
|
|||||||
if (v === '') {
|
if (v === '') {
|
||||||
v = null
|
v = null
|
||||||
}
|
}
|
||||||
(SystemSettings.value[sectionKey] as any)[key] = v
|
;(SystemSettings.value[sectionKey] as any)[key] = v
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -47,7 +43,7 @@ async function loadSystemSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存设置
|
// 保存设置
|
||||||
const saveSystemSettings = debounce(async (value: any) => {
|
async function saveSystemSettings(value: any) {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('system/env', value)
|
const result: { [key: string]: any } = await api.post('system/env', value)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -58,7 +54,7 @@ const saveSystemSettings = debounce(async (value: any) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 重载系统生效配置
|
// 重载系统生效配置
|
||||||
async function reloadSystem() {
|
async function reloadSystem() {
|
||||||
@@ -74,19 +70,21 @@ async function reloadSystem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 恢复电影设置默认值
|
// 恢复电影设置默认值
|
||||||
const loadDefaultMovieSetting = debounce(async () => {
|
async function loadDefaultMovieSetting() {
|
||||||
SystemSettings.value.Basis.MOVIE_RENAME_FORMAT = '{{title}}{% if year %} ({{year}}){% endif %}/{{title}}{% if year %} ({{year}}){% endif %}{% if part %}-{{part}}{% endif %}{% if videoFormat %} - {{videoFormat}}{% endif %}{{fileExt}}'
|
SystemSettings.value.Basis.MOVIE_RENAME_FORMAT =
|
||||||
}, debounceTime)
|
'{{title}}{% if year %} ({{year}}){% endif %}/{{title}}{% if year %} ({{year}}){% endif %}{% if part %}-{{part}}{% endif %}{% if videoFormat %} - {{videoFormat}}{% endif %}{{fileExt}}'
|
||||||
|
}
|
||||||
|
|
||||||
// 恢复电视剧设置默认值
|
// 恢复电视剧设置默认值
|
||||||
const loadDefaultTVSetting = debounce(async () => {
|
async function loadDefaultTVSetting() {
|
||||||
SystemSettings.value.Basis.TV_RENAME_FORMAT = '{{title}}{% if year %} ({{year}}){% endif %}/Season {{season}}/{{title}} - {{season_episode}}{% if part %}-{{part}}{% endif %}{% if episode %} - 第 {{episode}} 集{% endif %}{{fileExt}}'
|
SystemSettings.value.Basis.TV_RENAME_FORMAT =
|
||||||
}, debounceTime)
|
'{{title}}{% if year %} ({{year}}){% endif %}/Season {{season}}/{{title}} - {{season_episode}}{% if part %}-{{part}}{% endif %}{% if episode %} - 第 {{episode}} 集{% endif %}{{fileExt}}'
|
||||||
|
}
|
||||||
|
|
||||||
// 数据源
|
// 数据源
|
||||||
const sourceItems = [
|
const sourceItems = [
|
||||||
{ "title": "TheMovieDb", "value": "themoviedb"},
|
{ 'title': 'TheMovieDb', 'value': 'themoviedb' },
|
||||||
{ "title": "豆瓣", "value": "douban" }
|
{ 'title': '豆瓣', 'value': 'douban' },
|
||||||
]
|
]
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
@@ -140,10 +138,7 @@ onMounted(() => {
|
|||||||
min="0"
|
min="0"
|
||||||
type="number"
|
type="number"
|
||||||
suffix="小时"
|
suffix="小时"
|
||||||
:rules="[
|
:rules="[(v: any) => v === 0 || !!v || '请输入元数据缓存时间', (v: any) => v >= 0 || '元数据缓存时间必须大于等于0']"
|
||||||
v => v === 0 || !!v || '请输入元数据缓存时间',
|
|
||||||
v => v >= 0 || '元数据缓存时间必须大于等于0'
|
|
||||||
]"
|
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12">
|
<VCol cols="12">
|
||||||
@@ -191,4 +186,3 @@ onMounted(() => {
|
|||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import type { User } from '@/api/types'
|
|||||||
import avatar1 from '@images/avatars/avatar-1.png'
|
import avatar1 from '@images/avatars/avatar-1.png'
|
||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { debounce } from 'lodash'
|
|
||||||
|
|
||||||
// 显示器宽度
|
// 显示器宽度
|
||||||
const display = useDisplay()
|
const display = useDisplay()
|
||||||
@@ -22,9 +21,6 @@ const $toast = useToast()
|
|||||||
|
|
||||||
const refInputEl = ref<HTMLElement>()
|
const refInputEl = ref<HTMLElement>()
|
||||||
|
|
||||||
// 防抖时间
|
|
||||||
const debounceTime = 500
|
|
||||||
|
|
||||||
// 正在保存
|
// 正在保存
|
||||||
const isSaving = ref(false)
|
const isSaving = ref(false)
|
||||||
|
|
||||||
@@ -79,8 +75,8 @@ function changeAvatar(file: Event) {
|
|||||||
const maxSize = 800 * 1024
|
const maxSize = 800 * 1024
|
||||||
// 检查文件是否为图片
|
// 检查文件是否为图片
|
||||||
if (!allowedTypes.includes(selectedFile.type)) {
|
if (!allowedTypes.includes(selectedFile.type)) {
|
||||||
$toast.error('上传的文件不符合要求,请重新选择头像');
|
$toast.error('上传的文件不符合要求,请重新选择头像')
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
// 检查文件大小
|
// 检查文件大小
|
||||||
if (selectedFile.size > maxSize) {
|
if (selectedFile.size > maxSize) {
|
||||||
@@ -118,15 +114,15 @@ async function loadAccountInfo() {
|
|||||||
if (!accountInfo.value.avatar) {
|
if (!accountInfo.value.avatar) {
|
||||||
accountInfo.value.avatar = avatar1
|
accountInfo.value.avatar = avatar1
|
||||||
}
|
}
|
||||||
currentAvatar.value = accountInfo.value.avatar
|
currentAvatar.value = accountInfo.value.avatar
|
||||||
currentUserName.value = accountInfo.value.name
|
currentUserName.value = accountInfo.value.name
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存用户信息
|
// 保存用户信息
|
||||||
const saveAccountInfo = debounce(async () => {
|
async function saveAccountInfo() {
|
||||||
if (isSaving.value) {
|
if (isSaving.value) {
|
||||||
$toast.error('正在保存中,请稍后...')
|
$toast.error('正在保存中,请稍后...')
|
||||||
return
|
return
|
||||||
@@ -177,7 +173,7 @@ const saveAccountInfo = debounce(async () => {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
isSaving.value = false
|
isSaving.value = false
|
||||||
}, debounceTime)
|
}
|
||||||
|
|
||||||
// 为当前用户获取Otp Uri
|
// 为当前用户获取Otp Uri
|
||||||
async function getOtpUri() {
|
async function getOtpUri() {
|
||||||
@@ -245,7 +241,7 @@ watch(
|
|||||||
() => store.state.auth.avatar,
|
() => store.state.auth.avatar,
|
||||||
() => {
|
() => {
|
||||||
currentAvatar.value = store.state.auth.avatar
|
currentAvatar.value = store.state.auth.avatar
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -306,21 +302,10 @@ watch(
|
|||||||
<VForm class="mt-6">
|
<VForm class="mt-6">
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol md="6" cols="12">
|
<VCol md="6" cols="12">
|
||||||
<VTextField
|
<VTextField v-model="currentUserName" density="comfortable" readonly label="用户名" />
|
||||||
v-model="currentUserName"
|
|
||||||
density="comfortable"
|
|
||||||
readonly
|
|
||||||
label="用户名"
|
|
||||||
/>
|
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12" md="6">
|
<VCol cols="12" md="6">
|
||||||
<VTextField
|
<VTextField v-model="accountInfo.email" density="comfortable" clearable label="邮箱" type="email" />
|
||||||
v-model="accountInfo.email"
|
|
||||||
density="comfortable"
|
|
||||||
clearable
|
|
||||||
label="邮箱"
|
|
||||||
type="email"
|
|
||||||
/>
|
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12" md="6">
|
<VCol cols="12" md="6">
|
||||||
<VTextField
|
<VTextField
|
||||||
@@ -397,10 +382,7 @@ watch(
|
|||||||
<VRow>
|
<VRow>
|
||||||
<!-- 👉 Form Actions -->
|
<!-- 👉 Form Actions -->
|
||||||
<VCol cols="12" class="d-flex flex-wrap gap-4">
|
<VCol cols="12" class="d-flex flex-wrap gap-4">
|
||||||
<VBtn
|
<VBtn @click="saveAccountInfo" :disabled="isSaving">
|
||||||
@click="saveAccountInfo"
|
|
||||||
:disabled="isSaving"
|
|
||||||
>
|
|
||||||
<span v-if="isSaving">保存中...</span>
|
<span v-if="isSaving">保存中...</span>
|
||||||
<span v-else>保存</span>
|
<span v-else>保存</span>
|
||||||
</VBtn>
|
</VBtn>
|
||||||
|
|||||||
Reference in New Issue
Block a user