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 Oct 5, 2020
2 parents 2fe9a6e + ced5960 commit ba7a859
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 20 deletions.
6 changes: 6 additions & 0 deletions src/export/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,10 @@ body {
pre {
font: inherit !important;
white-space: pre-wrap;
}

#friends-table img{
width: 50px;
height: 50px;
border-radius: 50px;
}
21 changes: 21 additions & 0 deletions src/export/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ API.Utils = {
return '![{0}]({1})'.format(title || '', url);
},

/**
* 获取HTML的图片内容
* @param {string} url 图片地址
*/
getImageHTML(url) {
return "<img src='{0}' >".format(url);
},

/**
* Base64编码
* @param {string} str 原始字符串
Expand Down Expand Up @@ -525,6 +533,16 @@ API.Common = {
return API.Utils.getLink(this.getUserUrl(uin), nickName, type);
},

/**
* 获取用户头像超链接
* @param {string} uin 目标QQ号
* @param {string} nickName 目标昵称
* @param {string} type 类型
*/
getUserImageLink(uin) {
return API.Utils.getImageHTML(API.Common.getUserLogoLocalUrl(uin));
},

/**
* 获取唤起QQ聊天地址
* @param {string} uin 目标QQ号
Expand Down Expand Up @@ -564,6 +582,9 @@ API.Common = {
case 'Videos_HTML':
res = '../' + res;
break;
case 'Friends_HTML':
res = '../' + res;
break;
default:
break;
}
Expand Down
9 changes: 8 additions & 1 deletion src/export/js/friends.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ $(function () {
checkbox: true,
clickToSelect: true,
width: "50"
}, {
field: 'avatar',
title: '头像',
align: 'center',
formatter: (value, row) => {
return API.Utils.getImageHTML(API.Common.getMediaPath(value, row.custom_avatar, "Friends_HTML"));
}
}, {
field: 'uin',
title: 'QQ号',
align: 'center',
sortable: true,
formatter: (value) => {
formatter: (value, row) => {
return API.Common.getUserLink(value, value);
}
}, {
Expand Down
10 changes: 5 additions & 5 deletions src/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ <h5 style="color:cadetblue">其他选项:</h5>
<input type="checkbox" name="QZone_Config.Messages.Visitor.isGet" class="custom-control-input" id="messages_has_visitor" data-hidden="true" data-target-link="messages_visitor_link">
<label style="margin-left: 14px;" class="custom-control-label" for="messages_has_visitor" aria-describedby="messages_visitor_help"></label>
</div>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份赞</small>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份</small>
</div>
<div class="form-group row" data-link="messages_visitor_link">
<label class="col-sm-1 col-form-label">查询间隔:</label>
Expand Down Expand Up @@ -397,7 +397,7 @@ <h5 style="color:cadetblue">其他选项:</h5>
<input type="checkbox" name="QZone_Config.Blogs.Visitor.isGet" class="custom-control-input" id="blogs_has_visitor" data-hidden="true" data-target-link="blogs_visitor_link">
<label style="margin-left: 14px;" class="custom-control-label" for="blogs_has_visitor" aria-describedby="blogs_visitor_help"></label>
</div>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份赞</small>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份</small>
</div>
<div class="form-group row" data-link="blogs_visitor_link">
<label class="col-sm-1 col-form-label">查询间隔:</label>
Expand Down Expand Up @@ -589,7 +589,7 @@ <h5 style="color:cadetblue">相册选项:</h5>
<input type="checkbox" name="QZone_Config.Photos.Visitor.isGet" class="custom-control-input" id="albums_has_visitor" data-hidden="true" data-target-link="albums_visitor_link">
<label style="margin-left: 14px;" class="custom-control-label" for="albums_has_visitor" aria-describedby="albums_visitor_help"></label>
</div>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份赞</small>
<small class="text-muted">默认不获取最近访问,勾选获取,理论上仅支持获取最近1000条访问记录(开通黄钻情况下),仅在备份类型为HTML、JSON时备份</small>
</div>
<div class="form-group row" data-link="albums_visitor_link">
<label class="col-sm-1 col-form-label">查询间隔:</label>
Expand Down Expand Up @@ -881,12 +881,12 @@ <h5 style="color:cadetblue">其他选项:</h5>
<small class="text-muted mt-2">HTML可直接用浏览器打开查看,MD用Markdown编辑器打开,Excel用WPS或Office打开,JSON适用于开发者数据迁移</small>
</div>
<div class="form-group row">
<div class="col-sm-1">添加时间</div>
<div class="col-sm-1">详细信息</div>
<div class="col-sm-2 custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="friends_has_add_time">
<label style="margin-left: 14px;" class="custom-control-label" for="friends_has_add_time" aria-describedby="friends_has_add_time_help"></label>
</div>
<small id="friends_has_add_time_help" class="text-muted">默认不获取好友添加时间,勾选则获取,时间来源QQ空间,时间仅供参考</small>
<small id="friends_has_add_time_help" class="text-muted">默认不获取好友详细信息,勾选则获取,详细信息主要包括:好友添加时间、亲密度、共同好友、共同群组,添加时间来源于QQ空间,不是来源于QQ,仅供参考</small>
</div>
<div class="form-group row">
<div class="col-sm-1">增量备份:</div>
Expand Down
2 changes: 1 addition & 1 deletion src/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ API.Common = {
*/
getUserLogoLocalUrl(uin) {
// 头像默认PNG格式
return "Common/images/{uin}.jfif".format({
return "Common/images/{uin}".format({
uin: uin
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ const MAX_MSG = {
'请稍后...'
],
Friends_Time: [
'正在获取好友添加时间',
'正在获取好友详细信息',
'已获取 <span style="color: #1ca5fc;">{downloaded}</span> 个',
'已跳过 <span style="color: #1ca5fc;">{skip}</span> 个',
'总共 <span style="color: #1ca5fc;">{total}</span> 个',
Expand Down
41 changes: 35 additions & 6 deletions src/js/modules/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ API.Common.initUserInfo = async () => {
userInfo = Object.assign(QZone.Common.Target, userInfo);

// 添加目标头像下载任务
API.Utils.newDownloadTask(API.Common.getUserLogoUrl(userInfo.uin), 'Common/images', userInfo.uin + ".jfif", userInfo);

if(QZone.Common.Target.uin !== QZone.Common.Owner.uin){
// 如果是备份他人空间,再添加自身的图片头像下载
API.Utils.newDownloadTask(API.Common.getUserLogoUrl(QZone.Common.Owner.uin), 'Common/images', QZone.Common.Owner.uin + ".jfif", QZone.Common.Owner);
}
API.Common.downloadUserAvatars([QZone.Common.Target, QZone.Common.Owner]);

// 更换用户图片
userInfo.avatar = API.Common.getUserLogoLocalUrl(userInfo.uin);
Expand Down Expand Up @@ -936,4 +931,38 @@ API.Common.getModulesLikeList = async (item, moduleConfig) => {
}
item.likeTotal = item.likes.length;
return item.likes;
}

/**
* 添加QQ空间用户的头像下载
* @param {Object} user 用户
*/
API.Common.downloadUserAvatar = (user) => {
if (!user || !user.uin) {
return;
}
const avatarUrl = API.Common.getUserLogoUrl(user.uin);
if (QZone.Common.FILE_URLS.has(avatarUrl)) {
// 添加过下载任务则跳过
return;
}

API.Utils.newDownloadTask(avatarUrl, 'Common/images', user.uin + '', user);
user.avatar = API.Common.getUserLogoUrl(user.uin);
user.custom_avatar = API.Common.getUserLogoLocalUrl(user.uin);

QZone.Common.FILE_URLS.set(avatarUrl, 'Common/images/' + user.uin);
}

/**
* 添加QQ空间用户的头像下载
* @param {Array} users 用户列表
*/
API.Common.downloadUserAvatars = (users) => {
if (!users) {
return;
}
for (const user of users) {
API.Common.downloadUserAvatar(user);
}
}
36 changes: 33 additions & 3 deletions src/js/modules/friends.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ API.Friends.export = async () => {
// 获取所有的QQ好友
let friends = await API.Friends.getAllList();

// 添加QQ好友的头像下载
API.Common.downloadUserAvatars(friends);

// 根据分组名称(非分组ID)进行排序
friends = API.Utils.sort(friends, 'groupName');
console.info('排序后', friends, QZone.Friends.Data)
Expand Down Expand Up @@ -88,9 +91,16 @@ API.Friends.getFriendsTime = async (data, friends) => {
}
// 遍历
for (const friend of friends) {
// 设置默认值
friend.groupName = groupMap.get(friend.groupid) || "默认分组";
if (friend.uin === QZone.Common.Owner.uin || !API.Friends.isNewItem(friend)) {
const isMe = friend.uin === QZone.Common.Owner.uin;
if (isMe || !API.Friends.isNewItem(friend)) {
// 好友号为自己号或非新好友,跳过
if (isMe) {
friend.addFriendTime = "自己啦";
friend.intimacyScore = "这要看您多爱护自己啦";
friend.common = {};
}
indicator.addSkip(friend);
continue;
}
Expand Down Expand Up @@ -170,15 +180,35 @@ API.Friends.exportToExcel = async (friends) => {

// Excel数据
let ws_data = [
["QQ号", "备注名称", "QQ昵称", "所在分组", "添加时间", "用户主页", "即时消息"]
["QQ号", "备注名称", "QQ昵称", "所在分组", "相识时间", "亲密度", "共同好友", "共同群组", "用户主页", "即时消息"]
];

for (const friend of friends) {
// QQ空间超链接
const user_qzone_url = { t: 's', v: "QQ空间", l: { Target: API.Common.getUserUrl(friend.uin), Tooltip: "QQ空间" } };
// QQ聊天超链接
const user_message_url = { t: 's', v: "QQ聊天", l: { Target: API.Common.getMessageUrl(friend.uin), Tooltip: "QQ聊天" } };
let rowData = [friend.uin, friend.remark, friend.name, friend.groupName, friend.addFriendTime, user_qzone_url, user_message_url];

// 共同信息
friend.common = friend.common || {};
friend.common.friend = friend.common.friend || [];
friend.common.group = friend.common.group || [];
const groups = [];
for (const group of friend.common.group) {
groups.push(group.name);
}
const rowData = [
friend.uin,
friend.remark,
friend.name,
friend.groupName,
friend.addFriendTime,
friend.intimacyScore,
friend.common.friend.length,
groups.join('\n'),
user_qzone_url,
user_message_url
];
ws_data.push(rowData);
}

Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "QQ空间导出助手",
"description": "QQ空间导出助手,用于导出备份QQ空间的说说、日志、私密日记、相册、视频、留言板、QQ好友、收藏夹为文件,便于迁移与保存",
"version": "1.0.9",
"version": "1.1.0",
"icons": {
"128": "img/icon-128.png"
},
Expand Down
2 changes: 1 addition & 1 deletion src/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="container">
<div id="index_html" class="header">
<div class="head-avatar">
<img src="<%:=user.avatar%>" class="user-avatar border">
<img src="<%:=user.custom_avatar || user.avatar%>" class="user-avatar border">
</div>
<div class="head-info">
<h3 class="head-title" id="top_head_title">
Expand Down
2 changes: 1 addition & 1 deletion src/templates/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
<%:=API.Common.formatContent(message.custom_create_time)%>
<span class="border-primary border rounded text-primary small p-1 float-right" title="当前楼层">#<%:=total + 1 %></span>
<span class="text-primary p-1 float-right fa fa-thumbs-up mr-2 cursor viewlikes" title="点赞列表" data-field="tid" data-target="<%:=message.tid%>"><%:=message.likeTotal || 0 %></span>
<span class="text-primary p-1 float-right fa fa-eye mr-2 cursor viewVisitors" title="最近访问" data-field="tid" data-target="<%:=message.tid%>"><%:=message.custom_visitor.viewCount || 0 %></span>
<span class="text-primary p-1 float-right fa fa-eye mr-2 cursor viewVisitors" title="最近访问" data-field="tid" data-target="<%:=message.tid%>"><%:=message.custom_visitor && message.custom_visitor.viewCount || 0 %></span>
</div>
</div>
<%}%>
Expand Down

0 comments on commit ba7a859

Please sign in to comment.