添加登录默认配置

This commit is contained in:
2026-04-20 14:52:22 +08:00
parent 33586d3f80
commit 8d9aa4718d
2 changed files with 31 additions and 2 deletions

View File

@@ -8,7 +8,7 @@
<NoticeBar />
<!-- 登录页面 -->
<LoginPage v-if="currentPage === 'login'" @login-success="currentPage = 'browser'" class="animate-fadeIn" />
<LoginPage v-if="currentPage === 'login'" @login-success="handleLoginSuccess" class="animate-fadeIn" />
<template v-else>
<!-- 配置页面 - 使用 v-show 保持状态 -->
@@ -47,6 +47,7 @@ import UpdateNotification from './components/UpdateNotification.vue'
import NoticeBar from './components/NoticeBar.vue'
import { useNoticeStore } from './stores/noticeStore'
import { ElMessage } from 'element-plus'
import { getPermissions } from './utils/storage'
// Constants
const USER_KEY = 'user_data'
@@ -104,6 +105,7 @@ onMounted(() => {
const user = JSON.parse(userData)
if (user && user.tokenValue) {
currentPage.value = 'browser'
void syncAutotkPermissionLimit()
}
}
} catch { } // eslint-disable-line no-empty
@@ -206,12 +208,32 @@ const handleStorageChange = (e) => {
}
}
const syncAutotkPermissionLimit = async () => {
if (!isElectron()) return
try {
const permissions = getPermissions()
if (permissions?.autotk === 1) return
await window.electronAPI.updateAutomationConfig({
filters: {
maxAnchorCount: 1
}
})
} catch (e) {
console.warn('[App] 同步 autotk 权限限制失败:', e)
}
}
const clearLoginState = () => {
localStorage.removeItem(USER_KEY)
localStorage.removeItem('user')
localStorage.removeItem('token')
}
const handleLoginSuccess = async () => {
currentPage.value = 'browser'
await syncAutotkPermissionLimit()
}
// 处理配置更新事件
const handleConfigUpdate = () => {
console.log('[App] 收到配置更新事件,重新加载配置')

View File

@@ -257,6 +257,7 @@
<script setup>
import { ref, computed, watch, onMounted } from 'vue'
import { isElectron } from '../utils/electronBridge'
import { getPermissions } from '@/utils/storage'
const props = defineProps({
visible: { type: Boolean, required: true }
@@ -318,6 +319,11 @@ const maxCount = ref()
const selectedLevels = ref(new Set())
const showLevelDropdown = ref(false)
const resolveRestrictedMaxAnchorCount = (fallbackValue = 9999999) => {
const permissions = getPermissions()
return permissions?.autotk === 1 ? fallbackValue : 0
}
// 添加主播弹窗状态
const showAddDialog = ref(false)
const addLoading = ref(false)
@@ -398,6 +404,7 @@ watch(() => filters.value, async (newFilters) => {
ordinary: newFilters.ordinary,
minOnlineFans: newFilters.minOnlineFans ? parseInt(newFilters.minOnlineFans) : 0,
maxOnlineFans: newFilters.maxOnlineFans ? parseInt(newFilters.maxOnlineFans) : 0,
maxAnchorCount: resolveRestrictedMaxAnchorCount(maxCount.value || 9999999),
}
})
console.log('[HostListDialog] 过滤配置已同步:', newFilters)
@@ -531,7 +538,7 @@ const updateMaxCount = async (value) => {
if (!isElectron()) return
try {
// 如果不填写,传 9999999 表示无限制
const maxAnchorCount = value || 9999999
const maxAnchorCount = resolveRestrictedMaxAnchorCount(value || 9999999)
await window.electronAPI.updateAutomationConfig({
filters: { maxAnchorCount }
})