Skip to content

Commit

Permalink
feat: add onePageCount setting
Browse files Browse the repository at this point in the history
  • Loading branch information
loo-y committed Dec 27, 2023
1 parent a34fb09 commit 321aebf
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/scripts/reactVirtual/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface WeiboExtendState extends Record<string, any> {
showRemoveFans?: boolean
showBlockOtherFans?: boolean
showFloatingPopup?: boolean

onePageCount?: number
showWeiboPop: WeiboPopType
}

Expand Down
82 changes: 53 additions & 29 deletions app/scripts/reactVirtual/modules/SavingWeiboPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client'
import type { ChangeEvent } from 'react'
import React, { useEffect, useState } from 'react'
import _ from 'lodash'
import DatepickerComp from '../components/DatepickerComp'
Expand All @@ -17,6 +18,7 @@ const SavingWeiboPopup = () => {
currentSavingWeiboPicCount,
currentSavingWeiboVideoCount,
savingUid,
onePageCount,
} = state || {}
const [savingStartDate, setSavingStartDate] = useState<Date | undefined>(undefined)
const [savingEndDate, setSavingEndDate] = useState<Date | undefined>(undefined)
Expand Down Expand Up @@ -101,45 +103,67 @@ const SavingWeiboPopup = () => {
setSavingEndDate(endDate)
}

const handleChangeOnePageCount = (event: ChangeEvent<HTMLInputElement>) => {
const value = event?.currentTarget?.value
dispatch(
updateState({
onePageCount: Number(value),
})
)
}

if (showWeiboPop == WeiboPopType.typeSelect) {
return (
<div className="flex fixed p-4 inset-0 bg-black bg-opacity-30 z-[9999]">
<div className="bg-white absolute right-[5rem] top-[5rem] rounded-xl h-[14rem] w-[28rem] py-4 pl-8 pr-6 flex flex-col text-gray-500 gap-2">
<div className="title flex w-full text-lg font-bold flex-row gap-2 mt-2">
<span className="">{`备份微博`}</span>
</div>
<div className="flex flex-row text-sm gap-5 mt-2">
<div className="flex items-center ">
<input
type="radio"
className="cursor-pointer"
name="saving_type"
id="saving_type_all"
value="0"
checked={savingType == 0}
onChange={() => {
handleSelectSaveingType(0)
}}
></input>
<label htmlFor="saving_type_all" className="ml-1 cursor-pointer">
全部
</label>
<div className="flex flex-row w-full items-center mt-2">
<div className="flex w-1/2 flex-row text-sm gap-5 ">
<div className="flex items-center ">
<input
type="radio"
className="cursor-pointer"
name="saving_type"
id="saving_type_all"
value="0"
checked={savingType == 0}
onChange={() => {
handleSelectSaveingType(0)
}}
></input>
<label htmlFor="saving_type_all" className="ml-1 cursor-pointer">
全部
</label>
</div>
<div className="flex items-center">
<input
type="radio"
className="cursor-pointer"
name="saving_type"
id="saving_type_bydate"
value="1"
checked={savingType == 1}
onChange={() => {
handleSelectSaveingType(1)
}}
></input>
<label htmlFor="saving_type_bydate" className="ml-1 cursor-pointer">
按日期
</label>
</div>
</div>
<div className="flex items-center">
<div className="flex w-1/2 text-sm items-center justify-end flex-row text-right">
<span className="text-sm inline-block w-28">单次打包条数:</span>
<input
type="radio"
className="cursor-pointer"
name="saving_type"
id="saving_type_bydate"
value="1"
checked={savingType == 1}
onChange={() => {
handleSelectSaveingType(1)
}}
type="number"
className="inline-block w-12 border text-right"
defaultValue={onePageCount}
step={20}
max={1000}
onChange={handleChangeOnePageCount}
></input>
<label htmlFor="saving_type_bydate" className="ml-1 cursor-pointer">
按日期
</label>
</div>
</div>
{savingType == 1 ? (
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/reactVirtual/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const initialState: WeiboExtendState & Record<string, any> = {
showFloatingPopup: false,
followersRemoved: [],
showWeiboPop: WeiboPopType.hidden,
onePageCount: 100,
}

type RequestCombo = {
Expand Down Expand Up @@ -298,7 +299,10 @@ export const saveWeiboQueue = createAsyncThunk(
const endTimeShortSpan = (endDate && dayjs(endDate).add(1, 'day').unix()) || undefined
let isEnd = false
// 获取单次保存的列表
const onePageCount = 100
const onePageCount =
(weiboExtendState.onePageCount && weiboExtendState.onePageCount > 0
? weiboExtendState.onePageCount
: 100) || 100
let onePageList: Record<string, any>[] = []
let totalCountSaveingWeibo = 0
for (let count = 0; count < onePageCount; ) {
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "微博扩展",
"description": "微博扩展插件 - 支持一键拉黑点赞",
"version": "1.6",
"version": "1.7",
"permissions": ["scripting"],
"host_permissions": ["https://weibo.com/*", "https://*.weibo.com/*"],
"icons": {
Expand Down

0 comments on commit 321aebf

Please sign in to comment.