Skip to content

Commit

Permalink
v1.2.2 修复后台报错和一些优化
Browse files Browse the repository at this point in the history
  • Loading branch information
dubox authored and dubox committed Jul 26, 2019
1 parent 14457cf commit 6d95fc4
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 26 deletions.
2 changes: 1 addition & 1 deletion action/popup.js
Expand Up @@ -24,4 +24,4 @@ var pageInfo = {};
window.open(chrome.extension.getURL('/options/search.html'));
}

document.getElementById('cz').src=`http://www.jsearch.site/home/?p=popup&id=${chrome.runtime.id}`;
//document.getElementById('cz').src=`http://www.jsearch.site/home/?p=popup&id=${chrome.runtime.id}`;
4 changes: 2 additions & 2 deletions app.json
@@ -1,5 +1,5 @@
{
"version": "1.2.1",
"broadcast":"新版本推送|v1.2.1 带来【搜索结果自然排序】【搜索结果来源标识】【搜索历史】三大更新,<a href='https://github.com/dubox/jSearch/releases'> 查看详情 </a>|0",
"version": "1.2.2",
"broadcast":"发现新版本v1.2.2,<a href='https://github.com/dubox/jSearch/releases'> 查看详情 </a>|0",
"broadcast2":"通知|欢迎使用 jSearch(聚搜) !!!觉得不错就给个<a href='https://github.com/dubox/jSearch'> Star </a>吧!|0"
}
44 changes: 28 additions & 16 deletions bg/main.js
Expand Up @@ -58,19 +58,21 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
});

//监听 storage变化
chrome.storage.sync.onChanged.addListener(function(changes){
chrome.storage.onChanged.addListener(function(changes ,type){

//console.log(changes);
//console.log(type,changes);
if(type == 'sync'){

//广播搜索历史到各个页面
if(changes.searchHistory){
broadcast({dataType:'searchHistory',data:changes.searchHistory.newValue});
}
//广播搜索历史到各个页面
if(changes.searchHistory){
broadcast({dataType:'searchHistory',data:changes.searchHistory.newValue});
}

//更新后台运行时设置数据
if(changes.settings){
RunTime = changes.settings.newValue.BG;
broadcast({dataType:'settings',data:changes.settings.newValue});
//更新后台 运行时数据
if(changes.settings){
RunTime = changes.settings.newValue.BG;
broadcast({dataType:'settings',data:changes.settings.newValue});
}
}
});

Expand All @@ -81,12 +83,20 @@ chrome.storage.sync.onChanged.addListener(function(changes){
function broadcast(data){
chrome.tabs.getAllInWindow(function(tabs){
for(let i in tabs){
chrome.tabs.sendMessage(
tabs[i].id,
data,
function(response) {
//console.log(response);
});
if(tabs[i].url.indexOf('chrome://')===0)continue;

chrome.tabs.sendMessage(
tabs[i].id,
data
/** 这个回调会导致连接失败时 runtime.lastError 会报错;
* 目前导致连接失败的原因有:1.以chrome://开头的tab 是连不上的;2.在插件刷新之前就打开的tab页
,
function(response) {
//console.log(response);
return true;
} */
);

}

})
Expand Down Expand Up @@ -275,4 +285,6 @@ chrome.runtime.onInstalled.addListener(details => {

}

chrome.runtime.openOptionsPage();

});
6 changes: 3 additions & 3 deletions content/content.js
Expand Up @@ -77,9 +77,9 @@ function MessageListener(){
this.cbs = {};
var _this = this;
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
//sendResponse('ok');
//console.log(request);
_this.cbs[request.dataType](request.data);
sendResponse('ok');
if(typeof _this.cbs[request.dataType] == 'function')
_this.cbs[request.dataType](request.data);

});
}
Expand Down
2 changes: 1 addition & 1 deletion content/search_bar.js
Expand Up @@ -177,7 +177,7 @@ function jBar() {
let index = 0;
if(num){
index = runtime.historyIndex + num;
if(index < 0) index = runtime.history.length-1;
if(index < 0) index = 0;//runtime.history.length-1;
if(index >= runtime.history.length) index = 0;
}
runtime.historyIndex = index;
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Expand Up @@ -4,8 +4,8 @@
"name": "jSearch",
"short_name": "聚搜",
"description": "jSearch(聚搜)是一款专注内容的搜索扩展,一次搜索聚合多平台内容;",
"version": "1.2.1",
"update_url": "http://www.jsearch.site",
"version": "1.2.2",
"update_url": "http://upext.chrome.360.cn/intf.php?method=ExtUpdate.query",
"icons": {
"16": "public/icons/icon128.png",
"48": "public/icons/icon128.png",
Expand Down
9 changes: 8 additions & 1 deletion options/options.js
Expand Up @@ -432,7 +432,7 @@ var app = new Vue({
this.history(this.searchData.keyword);

if(document.getElementById('cz'))
document.getElementById('cz').src=`http://www.jsearch.site/home/?id=${chrome.runtime.id}&kw=${this.searchData.keyword}`;
document.getElementById('cz').src=`http://www.jsearch.site/home/?id=${chrome.runtime.id}`;
},
setKeyword() {
let hash = '';
Expand Down Expand Up @@ -666,6 +666,13 @@ var _czc = _czc || [];
//绑定siteid,请用您的siteid替换下方"XXXXXXXX"部分
_czc.push(["_setAccount", "1276484996"]);



/**test */




var aaa = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Access-Control-Allow-Credentials': 'true',
Expand Down

0 comments on commit 6d95fc4

Please sign in to comment.