Skip to content

Commit

Permalink
release v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
doufen-org committed Sep 10, 2019
1 parent afefd94 commit 24979a5
Show file tree
Hide file tree
Showing 20 changed files with 1,101 additions and 320 deletions.
105 changes: 105 additions & 0 deletions chrome/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# File generated at : 10:51:06, Thu 29 Aug
# Converted Project : ChromeLauncher.vcxproj
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

##################### Variables ############################
# Change if you want modify path or other values #
############################################################

# Project
get_filename_component(PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
set(DEPENDENCIES_DIR ${PROJECT_DIR}/dependencies)
set(PROJECT_NAME ChromeLauncher)


# Outputs
set(OUTPUT_DEBUG ${PROJECT_DIR}/bin)
set(OUTPUT_RELEASE ${PROJECT_DIR}/bin)

################# CMake Project ############################
# The main options of project #
############################################################

project(${PROJECT_NAME} C)

# Define Release by default.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: Use Release by default.")
endif(NOT CMAKE_BUILD_TYPE)

############## Artefacts Output ############################
# Defines outputs , depending BUILD TYPE #
############################################################

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_DEBUG}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_DEBUG}")
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_DEBUG}")
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_RELEASE}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_RELEASE}")
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${PROJECT_DIR}/${OUTPUT_RELEASE}")
endif()

# Messages
message("${PROJECT_NAME}: MAIN PROJECT: ${CMAKE_PROJECT_NAME}")
message("${PROJECT_NAME}: CURR PROJECT: ${CMAKE_CURRENT_SOURCE_DIR}")
message("${PROJECT_NAME}: CURR BIN DIR: ${CMAKE_CURRENT_BINARY_DIR}")

############### Files & Targets ############################
# Files of project and target to build #
############################################################

# Source Files
set(SRC_FILES
./main.c
)
source_group("Sources" FILES ${SRC_FILES})

# Header Files
set(HEADERS_FILES
)
source_group("Headers" FILES ${HEADERS_FILES})

# Add executable to build.
add_executable(${PROJECT_NAME}
${SRC_FILES} ${HEADERS_FILES}
)

######################### Flags ############################
# Defines Flags for Windows and Linux #
############################################################

if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif(NOT MSVC)

# Preprocessor definitions
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(${PROJECT_NAME} PRIVATE
-D_DEBUG
-D_WINDOWS
)
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /MD /MDd /Od /Zi /EHsc)
endif()
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(${PROJECT_NAME} PRIVATE
-DNDEBUG
-D_WINDOWS
)
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /Zi /EHsc)
endif()
endif()

########### Link & Dependencies ############################
# Add project dependencies and Link to project #
############################################################

Empty file removed chrome/Makefile
Empty file.
2 changes: 1 addition & 1 deletion extension/backup.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<div class="field">
<p class="control">
<label class="checkbox">
<input type="checkbox" class="other-user"> 备份其他用户
<input type="checkbox" class="enable-target-user"> 备份其他用户
</label>
</p>
</div>
Expand Down
22 changes: 11 additions & 11 deletions extension/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TaskModal {
});
});

modal.element.querySelector('.other-user').addEventListener('click', event => {
modal.element.querySelector('.enable-target-user').addEventListener('click', event => {
let doumailCheckbox = modal.element.querySelector('input[value="Doumail"]');
let blacklistCheckbox = modal.element.querySelector('input[value="Blacklist"]');
if (event.target.checked) {
Expand All @@ -126,15 +126,15 @@ class TaskModal {
});

modal.element.querySelector('.button.new').addEventListener('click', async () => {
let otherUserId = null;
if (modal.useOtherUser) {
otherUserId = modal.otherUserId;
if (!otherUserId) {
let targetUserId = null;
if (modal.enableTargetUser) {
targetUserId = modal.targetUserId;
if (!targetUserId) {
alert('请输入正确的用户主页地址。');
return false;
}
}
let job = await modal.createJob(otherUserId);
let job = await modal.createJob(targetUserId);
if (job) {
modal.close();
window.open(chrome.extension.getURL('options.html#service'));
Expand All @@ -144,7 +144,7 @@ class TaskModal {
return modal;
}

async createJob(userId = null) {
async createJob(targetUserId = null) {
let service = (await new Promise(resolve => {
chrome.runtime.getBackgroundPage(resolve);
})).service;
Expand All @@ -159,7 +159,7 @@ class TaskModal {
name: checkedTasks[i].value,
};
}
let job = await service.createJob(userId, tasks);
let job = await service.createJob(targetUserId, null, tasks);
return job;
}

Expand All @@ -171,16 +171,16 @@ class TaskModal {
this.element.classList.remove('is-active');
}

get otherUserId() {
get targetUserId() {
let matches = this.userHomepageInput.value.match(/^https:\/\/www\.douban\.com\/people\/([^\/]+)\/?$/);
if (matches) {
return matches[1];
}
return null;
}

get useOtherUser() {
return this.element.querySelector('.other-user').checked;
get enableTargetUser() {
return this.element.querySelector('.enable-target-user').checked;
}
}

Expand Down
107 changes: 106 additions & 1 deletion extension/explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@
</span>
<span>返回</span>
</a>
<a class="button" name="export">
<a class="button" name="export" title="将该用户数据导出到 Excel 文件中">
<span class="icon">
<i class="fas fa-file-export"></i>
</span>
<span>导出数据</span>
</a>
<a class="button" name="migrate" title="将该用户数据迁移到我的豆瓣账号中">
<span class="icon">
<i class="fas fa-exchange-alt"></i>
</span>
<span>迁移数据</span>
</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -404,6 +410,105 @@
</div>
</div>

<div class="modal" id="migrate-modal">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">迁移数据</p>
<button class="delete cancel"></button>
</header>
<section class="modal-card-body">
<div class="content">
<p>该功能可以将此备份数据导入到你<a href="options.html#account" target="_blank">当前登录</a>的豆瓣账号中。另外,请在<a href="https://www.douban.com/settings/" target="_blank">广播设置</a>中关闭各事件广播,以免扰邻。</p>
</div>
<div class="level">
<div class="level-left">
<div class="level-item">
<label>选择迁移的项目:</label>
</div>
</div>
<div class="level-left">
<div class="level-item">
<label class="checkbox">
<input type="checkbox" class="select-all"> 全选
</label>
</div>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="task" value="Interest"> 影/音/书/游/剧
</label>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="task" value="Annotation"> 笔记
</label>
</div>
</div>
</div>
<div class="column">
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="task" value="Follow"> 关注
</label>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="task" value="Blacklist"> 黑名单
</label>
</div>
</div>
</div>
<div class="column">
<div class="field is-hidden">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" name="task" value="Note" disabled> 日记
</label>
</div>
</div>
<div class="field is-hidden">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" name="task" value="Photo" disabled> 相册
</label>
</div>
</div>
</div>
<div class="column">
<div class="field is-hidden">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" name="task" value="Doulist" disabled> 豆列
</label>
</div>
</div>
<div class="field is-hidden">
<div class="control">
<label class="checkbox" disabled>
<input type="checkbox" name="task" value="Review" disabled> 评论
</label>
</div>
</div>
</div>
</div>
</section>
<footer class="modal-card-foot">
<button class="button is-link" name="migrate">迁移</button>
<button class="button cancel">取消</button>
</footer>
</div>
</div>

<script type="module" src="explorer.js"></script>
</body>

Expand Down
66 changes: 66 additions & 0 deletions extension/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,73 @@ class Exporter {
}


/**
* Class MigrateModal
*/
class MigrateModal {
constructor(selector) {
this.element = document.querySelector(selector);
}

static init() {
let modal = new MigrateModal('#migrate-modal');

modal.element.querySelectorAll('.cancel').forEach(item => {
item.addEventListener('click', () => modal.close());
});
$('.button[name="migrate"]').click(() => modal.open());

modal.element.querySelector('.select-all').addEventListener('change', event => {
modal.element.querySelectorAll('input[name="task"]').forEach(item => {
if (!item.hasAttribute('disabled')) {
item.checked = event.target.checked;
}
});
});

modal.element.querySelector('.button[name="migrate"]').addEventListener('click', async () => {
let localUserId = parseInt(location.search.substr(1));
let job = await modal.createJob(localUserId);
if (job) {
modal.close();
window.open(chrome.extension.getURL('options.html#service'));
}
});

return modal;
}

async createJob(localUserId) {
let service = (await new Promise(resolve => {
chrome.runtime.getBackgroundPage(resolve);
})).service;
let checkedTasks = this.element.querySelectorAll('input[name="task"]:checked');
if (checkedTasks.length == 0) {
alert('请勾选要迁移的项目。');
return null;
}
let tasks = new Array(checkedTasks.length);
for (let i = 0; i < checkedTasks.length; i ++) {
tasks[i] = {
name: 'migrate/' + checkedTasks[i].value,
};
}
let job = await service.createJob(null, localUserId, tasks);
return job;
}

open() {
this.element.classList.add('is-active');
}

close() {
this.element.classList.remove('is-active');
}
}


let tab = TabPanel.render();
tab.addEventListener('toggle', async event => await Panel.render(event.target.activeTab));
Panel.render(tab.activeTab);
ExportModal.init();
MigrateModal.init();
Loading

0 comments on commit 24979a5

Please sign in to comment.