From c5922f9b08f1fc57ace2d1aef0acc1781cf93e20 Mon Sep 17 00:00:00 2001 From: jianzhichu Date: Tue, 16 Jun 2026 22:09:22 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=8D=9A=E4=B8=BB=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=202=E3=80=81=E4=BB=85=E4=B8=8B=E8=BD=BD=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=97=B6-=E4=B8=80=E7=9B=B4=E9=87=8D=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E8=BD=BDBUG=E4=BF=AE=E5=A4=8D=203=E3=80=81cookie=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/pages/cok/CookieTable.vue | 325 +++++---------------------- app/vite.config.ts | 4 +- job/DouyinBasicSyncJob.cs | 8 +- repository/DouyinFollowRepository.cs | 48 ++++ 4 files changed, 113 insertions(+), 272 deletions(-) diff --git a/app/src/pages/cok/CookieTable.vue b/app/src/pages/cok/CookieTable.vue index 171ee83..6f04a75 100644 --- a/app/src/pages/cok/CookieTable.vue +++ b/app/src/pages/cok/CookieTable.vue @@ -29,16 +29,13 @@ columns.value = [ { title: '收藏路径', dataIndex: 'savePath' }, { title: '喜欢路径', dataIndex: 'favSavePath' }, { title: '博主路径', dataIndex: 'upSavePath' }, - // { title: '图文视频', dataIndex: 'imgSavePath' }, - // { title: 'Cookie', dataIndex: 'cookies' }, { title: '状态', dataIndex: 'status', width: 180 }, - { title: '操作', dataIndex: 'edit', width: 200 }, // 加宽操作列宽度 + { title: '操作', dataIndex: 'edit', width: 200 }, ]; -// 定义数组中单个对象的类型:包含uper和uid字段(可选字符串类型,根据实际需求调整是否可选) interface UpSecUserIdItem { - uper?: string; // 若要求必填,可去掉问号 `uper: string;` - uid?: string; // 同上,必填则去掉问号 + uper?: string; + uid?: string; syncAll: boolean; } @@ -54,8 +51,6 @@ type DataItem = { upSecUserIdsJson?: UpSecUserIdItem[]; upSecUserIds?: string; upSavePath?: string; - // imgSavePath?: string; - // useSinglePath?: boolean; // 新增:是否全部用一个地址 useCollectFolder?: boolean; downMix?: boolean; downSeries?: boolean; @@ -118,17 +113,15 @@ const newCookie = (cookie?: DataItem) => { cookie.savePath = undefined; cookie.favSavePath = undefined; cookie.secUserId = undefined; - cookie.status = 0; // 0=关闭,1=开启 + cookie.status = 0; cookie.id = '0'; cookie.upSecUserIdsJson = undefined; cookie.upSavePath = undefined; - // cookie.imgSavePath = undefined; - // cookie.useSinglePath = false; // 新增:默认不使用单一路径 - cookie.useCollectFolder = false; //是否按收藏夹来下载。 - cookie.downMix = false; //是否下载收藏夹的合集 - cookie.downSeries = false; //是否下载短剧 - cookie.mixPath = undefined; //合集存储路径 - cookie.seriesPath = undefined; //短剧存储路径 + cookie.useCollectFolder = false; + cookie.downMix = false; + cookie.downSeries = false; + cookie.mixPath = undefined; + cookie.seriesPath = undefined; cookie.downCollect = false; cookie.downFavorite = false; cookie.downFollowd = false; @@ -144,19 +137,6 @@ const copyObject = (target: any, source?: any) => { const form = reactive(newCookie()); -// 新增:监听收藏路径变化,当启用单一路径时同步到其他路径 -// watch( -// [() => form.savePath, () => form.useSinglePath], -// ([newSavePath, useSinglePath]) => { -// // if (useSinglePath && newSavePath) { -// // form.favSavePath = newSavePath; -// // form.upSavePath = newSavePath; -// // // form.imgSavePath = newSavePath; -// // } -// }, -// { immediate: true } -// ); - function reset() { return newCookie(form); } @@ -177,7 +157,6 @@ function submit() { ?.validateFields() .then((resData: DataItem) => { if (form._isNew) { - // authors.push({ ...res }); } else { copyObject(editRecord.value, resData); } @@ -236,17 +215,10 @@ function edit(record: DataItem) { editRecord.value = record; console.log(record); copyObject(form, record); - // 确保useSinglePath有默认值 - // if (form.useSinglePath === undefined) { - // form.useSinglePath = false; - // } showModal.value = true; } -// 新增:切换同步状态方法 - const switchSyncStatus = (record: DataItem) => { - // 保存原始状态,用于弹窗取消后还原 const statusText = record.status === 1 ? '开启' : '停止'; const title = `确认${statusText}同步`; const content = `确定要${statusText}【${record.userName || '该'}】Cookie的同步任务吗?`; @@ -267,7 +239,7 @@ const switchSyncStatus = (record: DataItem) => { loading.value = false; if (res.code === 0) { message.success(`${statusText}同步成功`); - GetRecords(); // 刷新列表,更新 switch 状态 + GetRecords(); } else { message.error(`${statusText}同步失败:${res.message || '未知错误'}`); record.status = record.status === 1 ? 0 : 1; @@ -292,19 +264,6 @@ const StatusDict = { }; const dataSource = ref(datas); -const showCookiesModal = ref(false); -let showCookiesData = ''; -const showCookies = (recode: DataItem) => { - showCookiesModal.value = true; - showCookiesData = recode.cookies; -}; - -const showUpersModal = ref(false); -let showUpersData = ''; -const showUpers = (recode: DataItem) => { - showUpersModal.value = true; - showUpersData = recode.upSecUserIds; -}; const addRow = () => { if (!form.upSecUserIdsJson) { @@ -319,47 +278,38 @@ const removeRow = (index: number) => { }; const rowCount = 10; -// 组件挂载时获取配置 onMounted(() => { GetRecords(); }); -// ========== 抽屉相关响应式数据 ========== -// 抽屉显示状态 const showDrawer = ref(false); -// 抽屉类型(区分收藏夹/合集/短剧) type DrawerType = 'collect' | 'mix' | 'series'; const cookieId = ref(''); const cateType = ref(5); const drawerType = ref('collect'); -// 抽屉滚动容器引用(用于监听触底分页) const drawerScrollRef = ref(null); -// 抽屉数据列表 const drawerDataList = ref([]); -// 抽屉分页配置 const drawerPagination = reactive({ current: 1, pageSize: 10, total: 0, loading: false, - hasMore: true, // 是否还有更多数据 + hasMore: true, }); -// ========== 定义抽屉数据项接口 ========== interface DrawerItem { - id: string; // 不显示 - name: string; // 名称 - saveFolder: string; // 保存文件夹 - sync: boolean; // 是否同步 - coverUrl: string; // 封面 - cookieId: string; // 不显示 - xId: string; // 不显示 + id: string; + name: string; + saveFolder: string; + sync: boolean; + coverUrl: string; + cookieId: string; + xId: string; total: number; } -// ========== 3个打开抽屉的方法 ========== const openCollectFolderSetModal = () => { drawerType.value = 'collect'; cateType.value = 5; @@ -378,16 +328,13 @@ const openSeriesDownSetModal = () => { openCommonDrawer(); }; -// ========== 公用抽屉打开逻辑(替换原来的) ========== const openCommonDrawer = () => { - // 重置抽屉状态 drawerDataList.value = []; drawerPagination.current = 1; drawerPagination.total = 0; drawerPagination.hasMore = true; showDrawer.value = true; - // 确保DOM渲染后再加载 + 绑定事件 nextTick() .then(() => { loadDrawerData(); @@ -395,54 +342,24 @@ const openCommonDrawer = () => { }) .catch(() => {}); }; -// ========== 绑定抽屉滚动触底事件 ========== -// const bindDrawerScrollEvent = () => { -// const scrollContainer = drawerScrollRef.value; -// if (!scrollContainer) return; -// // 先移除原有事件,避免重复绑定 -// scrollContainer.removeEventListener('scroll', handleDrawerScroll); -// // 添加滚动事件 -// scrollContainer.addEventListener('scroll', handleDrawerScroll); -// }; -// ========== 绑定抽屉滚动触底事件(替换原来的) ========== const bindDrawerScrollEvent = () => { const scrollContainer = drawerScrollRef.value; if (!scrollContainer) { - // 延迟重试绑定,确保DOM渲染完成 setTimeout(() => { bindDrawerScrollEvent(); }, 100); return; } - // 先清除所有旧事件 scrollContainer.removeEventListener('scroll', handleDrawerScroll); - // 重新绑定 scrollContainer.addEventListener('scroll', handleDrawerScroll); - // 额外:首次加载如果内容不足一屏,自动加载下一页 setTimeout(() => { handleDrawerScroll(); }, 200); }; -// ========== 滚动触底处理逻辑 ========== -// const handleDrawerScroll = () => { -// const scrollContainer = drawerScrollRef.value; -// if (!scrollContainer || drawerPagination.loading || !drawerPagination.hasMore) return; -// // 计算滚动位置(触底阈值20px,避免精准触底才触发) -// const { scrollTop, clientHeight, scrollHeight } = scrollContainer; -// const isBottom = scrollTop + clientHeight >= scrollHeight - 20; - -// if (isBottom) { -// // 加载下一页 -// drawerPagination.current += 1; -// loadDrawerData(); -// } -// }; - -// 防抖函数(防止滚动触发太频繁) const debounce = (func: Function, delay = 100) => { let timeoutId: any; return (...args: any[]) => { @@ -450,14 +367,13 @@ const debounce = (func: Function, delay = 100) => { timeoutId = setTimeout(() => func.apply(this, args), delay); }; }; -// ========== 滚动触底处理逻辑(替换原来的) ========== + const handleDrawerScroll = debounce(() => { const scrollContainer = drawerScrollRef.value; if (!scrollContainer) return; if (drawerPagination.loading || !drawerPagination.hasMore) return; const { scrollTop, scrollHeight, clientHeight } = scrollContainer; - // 兼容所有设备的触底判断(距离底部 50px 就触发) const isBottom = scrollTop + clientHeight + 50 >= scrollHeight; if (isBottom) { @@ -465,9 +381,8 @@ const handleDrawerScroll = debounce(() => { drawerPagination.current += 1; loadDrawerData(); } -}, 100); // 100ms 防抖 +}, 100); -// ========== 加载抽屉数据(替换原来的) ========== const loadDrawerData = () => { if (drawerPagination.loading || !drawerPagination.hasMore) { console.log('🚫 阻止重复加载'); @@ -488,10 +403,8 @@ const loadDrawerData = () => { drawerDataList.value = [...drawerDataList.value, ...newData]; drawerPagination.total = res.data.total || 0; - // 判断是否还有更多 drawerPagination.hasMore = drawerDataList.value.length < drawerPagination.total; - // 加载完成后立刻检查是否需要继续加载(适配大屏) setTimeout(() => { handleDrawerScroll(); }, 100); @@ -507,7 +420,6 @@ const loadDrawerData = () => { }); }; -// ========== 获取抽屉类型名称(用于页面展示) ========== const getDrawerTypeName = () => { switch (drawerType.value) { case 'collect': @@ -521,24 +433,21 @@ const getDrawerTypeName = () => { } }; -// ========== 切换同步状态(可根据需求对接真实接口) ========== const toggleDrawerItemSync = (item: DrawerItem, index: number) => { if (drawerDataList.value[index]) { drawerDataList.value[index].sync = !item.sync; console.log(`切换${getDrawerTypeName()}【${item.name}】的同步状态为:${!item.sync}`); } }; -// ========== 关闭抽屉清理资源 ========== + const closeDrawer = () => { showDrawer.value = false; - // 移除滚动事件监听 const scrollContainer = drawerScrollRef.value; if (scrollContainer) { scrollContainer.removeEventListener('scroll', handleDrawerScroll); } }; -// 2. 新增:抽屉右上角保存按钮的点击方法(仅抽屉相关,不影响其他逻辑) const saveDrawerData = () => { if (drawerDataList.value.length === 0) { message.info('暂无需要保存的配置数据'); @@ -587,12 +496,10 @@ const switchdownCollect = (e: any) => { -
- @@ -603,7 +510,6 @@ const switchdownCollect = (e: any) => {
-
@@ -619,7 +525,6 @@ const switchdownCollect = (e: any) => {
-
@@ -637,7 +542,6 @@ const switchdownCollect = (e: any) => {
-
@@ -655,7 +559,6 @@ const switchdownCollect = (e: any) => {
-
@@ -673,7 +576,6 @@ const switchdownCollect = (e: any) => {
-
@@ -687,12 +589,10 @@ const switchdownCollect = (e: any) => {
- +
-
@@ -702,9 +602,7 @@ const switchdownCollect = (e: any) => { - -