diff --git a/app/scripts/reactVirtual/interface.ts b/app/scripts/reactVirtual/interface.ts
index a4cd9be..23769f1 100644
--- a/app/scripts/reactVirtual/interface.ts
+++ b/app/scripts/reactVirtual/interface.ts
@@ -17,4 +17,5 @@ export enum WeiboPopType {
typeSelect = `typeSelect`,
saving = `saving`,
stop = `stop`,
+ completed = `completed`,
}
diff --git a/app/scripts/reactVirtual/modules/SavingWeiboPopup.tsx b/app/scripts/reactVirtual/modules/SavingWeiboPopup.tsx
index 254fba2..4194dd9 100644
--- a/app/scripts/reactVirtual/modules/SavingWeiboPopup.tsx
+++ b/app/scripts/reactVirtual/modules/SavingWeiboPopup.tsx
@@ -29,6 +29,8 @@ const SavingWeiboPopup = () => {
dispatch(
updateState({
stopSaving: true,
+ totalCountSaveingWeibo: 0,
+ currentSavingWeiboCount: 0,
showWeiboPop: WeiboPopType.hidden,
})
)
@@ -47,6 +49,8 @@ const SavingWeiboPopup = () => {
dispatch(
updateState({
stopSaving: true,
+ totalCountSaveingWeibo: 0,
+ currentSavingWeiboCount: 0,
showWeiboPop: WeiboPopType.hidden,
})
)
@@ -183,6 +187,36 @@ const SavingWeiboPopup = () => {
)
}
+ if (showWeiboPop == WeiboPopType.completed) {
+ return (
+
+
+
+ {`已备份完成`}
+
+
+
+
+ {currentSavingWeiboCount
+ ? `共备份${currentSavingWeiboCount}条微博`
+ : `备份微博总数:未知`}
+
+
+
+
+
+
+ )
+ }
if (showWeiboPop == WeiboPopType.saving) {
return (
diff --git a/app/scripts/reactVirtual/slice.ts b/app/scripts/reactVirtual/slice.ts
index da304ce..6f08b46 100644
--- a/app/scripts/reactVirtual/slice.ts
+++ b/app/scripts/reactVirtual/slice.ts
@@ -270,6 +270,7 @@ export const saveWeiboQueue = createAsyncThunk(
updateState({
stopSaving: false,
showWeiboPop: WeiboPopType.saving,
+ currentSavingWeiboCount: 0,
totalCountSaveingWeibo: 0,
})
)
@@ -306,8 +307,8 @@ export const saveWeiboQueue = createAsyncThunk(
if (_.isEmpty(onePageList)) {
dispatch(
updateState({
- showWeiboPop: WeiboPopType.hidden,
- currentSavingWeiboCount: 0,
+ showWeiboPop: WeiboPopType.completed,
+ // currentSavingWeiboCount: 0,
currentSavingWeiboPicCount: 0,
currentSavingWeiboVideoCount: 0,
})
@@ -342,8 +343,8 @@ export const saveWeiboQueue = createAsyncThunk(
if (isEnd || stopSaving) {
dispatch(
updateState({
- showWeiboPop: WeiboPopType.hidden,
- currentSavingWeiboCount: 0,
+ showWeiboPop: WeiboPopType.completed,
+ // currentSavingWeiboCount: 0,
currentSavingWeiboPicCount: 0,
currentSavingWeiboVideoCount: 0,
})
diff --git a/app/scripts/utils/tools.ts b/app/scripts/utils/tools.ts
index e6a2734..7e78eb2 100644
--- a/app/scripts/utils/tools.ts
+++ b/app/scripts/utils/tools.ts
@@ -116,6 +116,7 @@ const convertBlogList = async ({
}: ISaveBlogToZipProps & { zipContainer: JSZip; eachCallback?: (info: any) => void }): Promise
=> {
const imageFolder = zipContainer.folder('image')
const videoFolder = zipContainer.folder('video')
+ const userInfo = myBlog?.[0]?.user || {}
let totalPicShowList: { picName: string; url: string }[] = []
let finalList: typeof myBlog = []
let _count = 0
@@ -160,7 +161,7 @@ const convertBlogList = async ({
const url = picInfo?.large?.url || undefined
if (!url) return undefined
return {
- picName: url.match(/\/([\da-zA-Z]+\.[a-z]{3,4})$/)?.[1] || `${picKey}.jpg`,
+ picName: matchImageFromUrl(url) || `${picKey}.jpg`,
url,
}
})
@@ -171,7 +172,7 @@ const convertBlogList = async ({
if (type == `pic`) {
const url = data?.large?.url || undefined
picShows.push({
- picName: url.match(/\/([\da-zA-Z]+\.[a-z]{3,4})$/)?.[1] || `${data?.pic_id}.jpg`,
+ picName: matchImageFromUrl(url) || `${data?.pic_id}.jpg`,
url,
})
}
@@ -215,7 +216,7 @@ const convertBlogList = async ({
const url = picInfo?.large?.url || undefined
if (!url) return undefined
return {
- picName: url.match(/\/([\da-zA-Z]+\.[a-z]{3,4})$/)?.[1] || `${picKey}.jpg`,
+ picName: matchImageFromUrl(url) || `${picKey}.jpg`,
url,
}
})
@@ -226,7 +227,7 @@ const convertBlogList = async ({
if (type == `pic`) {
const url = data?.large?.url || undefined
retweeted_status_picShows.push({
- picName: url.match(/\/([\da-zA-Z]+\.[a-z]{3,4})$/)?.[1] || `${data?.pic_id}.jpg`,
+ picName: matchImageFromUrl(url) || `${data?.pic_id}.jpg`,
url,
})
}
@@ -350,7 +351,19 @@ const convertBlogList = async ({
})
}
- zipContainer.file('myblog.js', `window.myblog={"list": ${JSON.stringify(finalList)}}`)
+ // 下载用户头像
+ const userPicUrl = userInfo?.avatar_hd || userInfo?.profile_image_url || userInfo?.avatar_large || undefined
+ if (userPicUrl) {
+ userInfo.picShow = matchImageFromUrl(userPicUrl)
+ const picBlob = await fetchToGetImageBlob({ imageUrl: userPicUrl })
+ if (picBlob) {
+ imageFolder?.file(userInfo.picShow, picBlob)
+ }
+ }
+ zipContainer.file(
+ 'myblog.js',
+ `window.myblog={"user": ${JSON.stringify(userInfo)},"list": ${JSON.stringify(finalList)}}`
+ )
// if (!_.isEmpty(totalPicShowList)) {
// const imageFolder = zipContainer.folder('image')
@@ -393,3 +406,7 @@ const getFileStringFromExtension = async (): Promise => {
})
})
}
+
+const matchImageFromUrl = (url: string) => {
+ return url?.match(/\/([\da-zA-Z]+\.[a-z]{3,4})(\?|$)/)?.[1] || ''
+}
diff --git a/weiboSave/index.html b/weiboSave/index.html
index 9094b91..7f0a553 100644
--- a/weiboSave/index.html
+++ b/weiboSave/index.html
@@ -13,11 +13,11 @@