Skip to content

Commit

Permalink
更换存储
Browse files Browse the repository at this point in the history
  • Loading branch information
xiandanin committed Nov 28, 2018
1 parent f62ba5c commit b224fc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions javascript/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ var _bind_project_remarks = function () {
project_name = forkA[0].getAttribute('href');
createClass = "stars_list_fork";
}
}else{
} else {
project_name = projects[i].getElementsByTagName("a")[0].getAttribute('href');
}

Expand All @@ -312,6 +312,7 @@ var _bind_project_remarks = function () {
}
};


/**
* 读取配置项
* @param project_name 项目名称
Expand All @@ -320,7 +321,27 @@ var _bind_project_remarks = function () {
* @private
*/
var _get_project_remarks = function (project_name, username, callback) {
chrome.storage.sync.get('items', function (rsp) {
chrome.storage.local.get('items', function (rsp) {
if (JSON.stringify(rsp)!='{}') {
//有数据说明迁移过了 直接取本地
_get_project_remarks_v2(project_name, username, callback)
} else {
//没有数据说明未迁移 从同步迁移到本地
chrome.storage.sync.get('items', function (rsp) {
chrome.storage.local.set(rsp);
chrome.storage.sync.set({'items': null}, function () {

});

_get_project_remarks_v2(project_name, username, callback)
});
}

});
};

var _get_project_remarks_v2 = function (project_name, username, callback) {
chrome.storage.local.get('items', function (rsp) {
if (JSON.stringify(rsp) == '{}') {
var result = {}
result.project_name = project_name
Expand All @@ -332,7 +353,7 @@ var _get_project_remarks = function (project_name, username, callback) {
}
callback(rsp);
});
};
}

var _get_project_tags = function (project_name, username, callback) {
_get_project_remarks(project_name, username, function (rsp) {
Expand Down Expand Up @@ -402,7 +423,7 @@ var _save_project_remarks = function (project_name, username, value) {
rsp.items.push(result)
}
//console.log("保存成功\n" + JSON.stringify(rsp, null, 2))
chrome.storage.sync.set(rsp);
chrome.storage.local.set(rsp);
});
};

Expand Down
2 changes: 1 addition & 1 deletion javascript/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ window.onload = function () {
input.click()
}
document.getElementById("btn_export").onclick = function () {
chrome.storage.sync.get('items', function (rsp) {
chrome.storage.local.get('items', function (rsp) {
// 创建隐藏的可下载链接
var date = new Date();
var filename = "github-tags_" + date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + "_" + date.getHours() + "-" + date.getMinutes() + ".json";
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "GithubTags",
"version": "1.0.4",
"version": "1.0.5",
"description": "给Github项目添加标签",
"manifest_version": 2,
"icons": {
Expand Down

0 comments on commit b224fc8

Please sign in to comment.