Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ShunCai committed Nov 21, 2020
2 parents 12f1370 + 9734d2a commit 30003fd
Show file tree
Hide file tree
Showing 27 changed files with 2,871 additions and 654 deletions.
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QQ空间导出助手

> QQ空间导出助手,用于备份QQ空间的说说、日志、私密日记、相册、视频、留言板、QQ好友、收藏夹为文件,便于迁移与保存。
> QQ空间导出助手,用于备份QQ空间的说说、日志、私密日记、相册、视频、留言板、QQ好友、收藏夹、分享为文件,便于迁移与保存。
## 简介

Expand All @@ -16,16 +16,6 @@
[![我是往事随风。你好,我是轻舞飞扬。](https://s1.ax1x.com/2020/05/16/YcekPP.gif)](https://v.qq.com/x/page/f08719wqfd0.html)

## 安装
#### 在线安装
- [Chrome浏览器](https://chrome.google.com/webstore/detail/aofadimegphfgllgjblddapiaojbglhf)

- [Microsoft Edge](https://microsoftedge.microsoft.com/addons/detail/djfalpkpjgpkfnkfmnegbalnicdoljcn)

- [360极速浏览器](https://ext.chrome.360.cn/webstore/detail/dboplopmhoafmbcbmcecapkmcodhcegh)

- [360安全浏览器](https://ext.se.360.cn/webstore/detail/dboplopmhoafmbcbmcecapkmcodhcegh)

- 其他Chromium内核浏览器请移步->[离线安装](#离线安装)

#### 在线安装
- [Chrome浏览器](https://chrome.google.com/webstore/detail/aofadimegphfgllgjblddapiaojbglhf)
Expand All @@ -46,7 +36,7 @@
4. 勾选开发者模式
5. 点击[加载已解压的扩展程序]按钮
6. 选择ZIP包解压文件夹
7. 更多问题点击[这里](https://baidu.lvshuncai.com/?q=Q2hyb21lIOWuieijhSDnprvnur/lronoo4Ug5omp5bGVIENSWA==)
7. 更多问题点击[这里](https://baidu.lvshuncai.com/?q=Q2hyb21lIOWuieijhSDnprvnur/lronoo4Ug5omp5bGVIFpJUA==)

##### 方式②:CRX安装
1. [下载CRX包](https://github.com/ShunCai/QZoneExport/releases/latest)
Expand All @@ -56,7 +46,7 @@

#### 版本要求
未测试,建议Chromium内核版本在70以上。
理论上基于Chromium内核版本均可正常使用,但不保证均可使用。
理论上基于Chromium内核版本的浏览器均可正常使用,但不保证均可使用。
点击这里进行[浏览器内核版本检测](https://liulanmi.com/labs/core.html)


Expand Down Expand Up @@ -104,6 +94,8 @@
![QQ空间备份-留言板](https://s1.ax1x.com/2020/05/16/YcZSkq.png)
#### 收藏夹
![QQ空间备份-收藏夹](https://s1.ax1x.com/2020/05/16/YcZpt0.png)
#### 分享
![QQ空间备份-分享](https://i.loli.net/2020/11/21/TLDtf5IGAMqYk3l.png)

## 依赖
- [Blob.js](https://note.youdao.com/)
Expand Down
88 changes: 88 additions & 0 deletions src/export/js/boards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* 单条HTML模板
*/
const ITEM_TPL = `
<div class="card border p-2 mt-1">
<div class="card-body">
<div class="p-1 comments">
<div class="container comment m-1 p-0">
<a class="me-a avatar p-0 m-0" target="_blank" href="<%:=API.Common.getUserUrl(board.uin)%>">
<img class="lazyload w-100 h-100 border rounded-circle" src="<%:=API.Common.getUserLogoUrl(board.uin)%>">
</a>
<div class="ml-4">
<div class="container ml-4">
<a class="author">
<a target="_blank" href="<%:=API.Common.getUserUrl(board.uin)%>">
<span><%:=API.Common.formatContent(board.nickname)%></span>
</a>
<br>
<span class="text-muted small"><%:=API.Utils.formatDate(board.pubtime)%></span>
</a>
</div>
<div class="messageText ml-4 container m-2">
<%:=API.Common.formatContent(board.htmlContent,'HTML', false, true)%>
</div>
<%if(board.replyList){%>
<div class="p-1 comments m-3">
<%for (var reply of board.replyList) {%>
<div class="container comment m-3 p-0">
<a class="me-a avatar p-0 m-0 " target="_blank" href="<%:=API.Common.getUserUrl(reply.uin)%>">
<img class="lazyload w-100 h-100 border rounded-circle" src="<%:=API.Common.getUserLogoUrl(reply.uin)%>">
</a>
<div class=" ml-4 ">
<div class="container ml-4">
<a class="author">
<a target="_blank" href="<%:=API.Common.getUserUrl(reply.uin)%>">
<span class="text-info"><%:=API.Common.formatContent(reply.nick)%></span>
</a>
<br>
<span class="text-muted small"><%:=API.Utils.formatDate(reply.time)%></span>
</a>
</div>
<div class="messageText ml-4 container m-2"><%:=API.Common.formatContent(reply.content)%></div>
</div>
</div>
<%}%>
</div>
<%}%>
</div>
</div>
</div>
</div>
</div>
`;

/**
* 那年今日模板
*/
const YEAR_ITEMS = `
<%if (yearMaps && yearMaps.size > 0) {%>
<h3 class="sidebar-h1" data-tag="h1" data-sidebar="那年今日">那年今日</h3>
<%for (const [year, yearItems] of yearMaps) {%>
<%if (yearItems && yearItems.length > 0) {%>
<span class="sidebar-h2" data-tag="h2" data-sidebar="<%:=year%>年"></span>
<%for (const board of yearItems) {%>
`+ ITEM_TPL +`
<%}%>
<%}%>
<%}%>
<hr>
<%}%>
`;

$(function () {

// 那年今日
const _yearMaps = API.Common.getOldYearData(dataList, "pubtime");

// 那年今日HTML
const items_html = template(YEAR_ITEMS, { yearMaps: _yearMaps });
$('#boards_html').prepend(items_html);

// 重新渲染左侧目录
initSidebar();

// 图片懒加载
lazyload();

});
177 changes: 174 additions & 3 deletions src/export/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,27 @@ API.Utils = {
return ret;
},

/**
* 通过参数构建URL
* @param {string} url
* @param {object} params
*/
toUrl(url, params) {
let paramsArr = [];
if (params) {
Object.keys(params).forEach(item => {
paramsArr.push(item + '=' + params[item]);
})
if (url.search(/\?/) === -1) {
url += '?' + paramsArr.join('&');
} else {
url += '&' + paramsArr.join('&');
}

}
return url;
},

/**
* 转换时间
* @param {integer} time
Expand Down Expand Up @@ -320,7 +341,7 @@ API.Common = {
* 获取用户空间的头像地址
*/
getUserLogoUrl(uin) {
return "http://qlogo{host}.store.qq.com/qzone/{uin}/{uin}/{size}".format({
return "https://qlogo{host}.store.qq.com/qzone/{uin}/{uin}/{size}".format({
host: uin % 4 || 1,
uin: uin,
size: 100
Expand Down Expand Up @@ -431,12 +452,22 @@ API.Common = {
if (typeof contet === 'object') {
return format(contet);
}
return contet = contet.replace(/@\{uin:([^\}]*),nick:([^\}]*?)(?:,who:([^\}]*))?(?:,auto:([^\}]*))?\}/g, function (str, uin, name) {

// 先处理一遍正常的@的内容
contet = contet.replace(/@\{uin:([^\}]*),nick:([^\}]*?)(?:,who:([^\}]*))?(?:,auto:([^\}]*))?\}/g, function (str, uin, name) {
return format({
uin: uin,
name: name
});
})

// 如果处理后,仍包含uin、nick、who,则表示是特殊情况(即nick存的是内容),再处理一遍
if (contet.indexOf('uin') > -1 && contet.indexOf('nick') > -1 && contet.indexOf('who') > -1) {
contet = contet.replace(/\{uin:([^\}]*),nick:([^\}]*?)(?:,who:([^\}]*))\}/g, function (str, uin, name) {
return name;
})
}
return contet;
},

/**
Expand Down Expand Up @@ -721,6 +752,41 @@ API.Common = {

// 显示窗口
$('#comments_win').modal('show');
},

/**
* 获取那年今日的数据
* @param {Array} dataList 数组
* @param {string} field 时间字段
*/
getOldYearData(dataList, field) {
// 时间分组
// 时间分组
const yearMaps = API.Utils.groupedByTime(dataList, field, 'all');
const date = new Date();
// 当前年份跳过
const currentYear = date.getFullYear();
const currentMonthDay = date.format('-MM-dd');
const _yearMaps = new Map();
if (yearMaps) {
// 移除今年数据
yearMaps.delete(currentYear);
}
for (const [year, yearItemMaps] of yearMaps) {
for (const [month, monthItems] of yearItemMaps) {
const monthDayItems = [];
for (const item of monthItems) {
const targetTime = API.Utils.formatDate(item[field]);
if (targetTime.indexOf(currentMonthDay) > -1) {
monthDayItems.push(item);
}
}
if (monthDayItems.length > 0) {
_yearMaps.set(year, monthDayItems);
}
}
}
return _yearMaps;
}
}

Expand Down Expand Up @@ -773,6 +839,111 @@ API.Messages = {
}
}

/**
* 分享模块API
*/
API.Shares = {

/**
* 获取类型
*/
getDisplayType(innerType) {
const Share_Types = {
1: '日志',
2: '相册',
3: "照片",
4: "网页",
5: '视频',
10: '商品',
13: '新闻',
17: '微博',
18: "音乐"
}
return Share_Types[innerType] || "其它";
}
}


/**
* 视频模块API
*/
API.Videos = {

/**
* 是否腾讯视频(判断不严谨,先临时判断)
* @param {object} 视频信息
*/
isTencentVideo(video) {
let url2 = video.url2 || '';
let url3 = video.url3 || '';
if (!url2 || url3.indexOf('.mp4') > -1) {
// 如果URL都没有值,或者地址含有.mp4,肯定是空间视频?
return false;
}
if (url3.indexOf('tencentvideo') > -1) {
// 该判断不严谨,但是不知道怎么判断的好
return true;
}
return false;
},

/**
* 是否外部视频(判断不严谨,先临时判断)
* @param {object} 视频信息
*/
isExternalVideo(video) {
let url3 = video.url3 || '';
const isTencentTV = API.Videos.isTencentVideo(video);
if (isTencentTV) {
return true;
}
if (url3.indexOf('.swf') > -1) {
// Flash地址肯定是外部视频?
return true;
}
return false;
},

/**
* 获取视频连接
* @param {object} 视频信息
*/
getVideoUrl(video) {
// URL3个人相册视频?
let url = video.url3 || video.url;
if (video.source_type == "share") {
// 分享视频连接?
url = video.rt_url;
}
if (API.Videos.isTencentVideo(video)) {
// 腾讯视频
url = API.Videos.getTencentVideoUrl(video.video_id);
}
// 其他第三方视频
return url;
},

/**
* 获取腾讯视频的播放地址
* @param {string} vid 视频ID
*/
getTencentVideoUrl(vid) {
let params = {
"origin": "https://user.qzone.qq.com",
"vid": vid,
"autoplay": true,
"volume": 1,
"disableplugin": "IframeBottomOpenClientBar",
"additionplugin": "IframeUiSearch",
"platId": "qzone_feed",
"show1080p": true,
"isDebugIframe": false
}
return API.Utils.toUrl('https://v.qq.com/txp/iframe/player.html', params);
}
}


/**
* 模板常量
*/
Expand Down Expand Up @@ -833,7 +1004,7 @@ const TPL = {
<%}%>
</div>
`,

/**
* 最近访问
*/
Expand Down
1 change: 1 addition & 0 deletions src/export/js/friends.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $(function () {
title: '头像',
align: 'center',
formatter: (value, row) => {
value = value || API.Common.getUserLogoUrl(row.uin);
return API.Utils.getImageHTML(API.Common.getMediaPath(value, row.custom_avatar, "Friends_HTML"));
}
}, {
Expand Down
Loading

0 comments on commit 30003fd

Please sign in to comment.