Skip to content

Commit

Permalink
优化搜索后的列表名称显示;修复搜索标签后跳转搜索仓库无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiandanin committed Aug 18, 2020
1 parent 1b530ad commit 044d004
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 23 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[停止更新,正常维护]

# GithubTags

给 Github 项目添加标签的 Chrome 插件,支持按标签搜索,数据支持云同步
Expand All @@ -16,7 +14,7 @@

#### 项目详情

<img src="screenshot/2.png" width = 600/>
<img src="screenshot/2.jpg" width = 600/>

#### 个人主页

Expand Down
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-tags",
"version": "1.1.6",
"version": "1.1.7",
"description": "A Vue.js web extension",
"author": "denghaha <denghahae@gmail.com>",
"scripts": {
Expand Down
51 changes: 35 additions & 16 deletions plugin/src/content_scripts/js/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,33 @@ var _create_search_dom = function(el) {
input.autocomplete = 'off';
input.value = getUrlParams('q');

var button = document.createElement('button');
var search_function = function() {
var url = window.location.href;
if (url.indexOf('&q') != -1) {
window.location.href = url.substring(0, url.indexOf('&q')) + '&q=' + input.value;
} else {
window.location.href = url + '&utf8=✓&q=' + input.value;
}
};
button.onclick = search_function;
button.className = 'btn';
button.innerHTML =
'<svg class="octicon octicon-search" style="margin-right: 10px;vertical-align:middle" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"></path></svg>搜索';
var button = new Vue({
data: {},
render: function(h) {
var that = this;
return h('button', {
attrs: {
class: 'btn',
href: 'button',
style: 'margin-right:8px;',
},
domProps: {
innerHTML:
'<svg class="octicon octicon-search" style="margin-right: 10px;vertical-align:middle" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M15.7 13.3l-3.81-3.83A5.93 5.93 0 0 0 13 6c0-3.31-2.69-6-6-6S1 2.69 1 6s2.69 6 6 6c1.3 0 2.48-.41 3.47-1.11l3.83 3.81c.19.2.45.3.7.3.25 0 .52-.09.7-.3a.996.996 0 0 0 0-1.41v.01zM7 10.7c-2.59 0-4.7-2.11-4.7-4.7 0-2.59 2.11-4.7 4.7-4.7 2.59 0 4.7 2.11 4.7 4.7 0 2.59-2.11 4.7-4.7 4.7z"></path></svg>搜索',
},
on: {
click: function(event) {
var url = window.location.href;
if (url.indexOf('&q') != -1) {
window.location.href = url.substring(0, url.indexOf('&q')) + '&q=' + input.value;
} else {
window.location.href = url + '&utf8=✓&q=' + input.value;
}
},
},
});
},
});

input.addEventListener('keypress', function() {
if (event.keyCode == 13) {
Expand Down Expand Up @@ -189,7 +203,7 @@ var _create_search_dom = function(el) {
div.appendChild(input);
div.appendChild(vue.$mount().$el);
div.appendChild(vue_all.$mount().$el);
div.appendChild(button);
div.appendChild(button.$mount().$el);
el.parentNode.insertBefore(div, el);

return false;
Expand All @@ -213,7 +227,12 @@ var _create_search_list_dom = function(keyword) {
var that = this;
searchTags(keyword, function(rsp) {
console.log('搜索结果:\n' + JSON.stringify(rsp, null, 2));
that.items = rsp;
that.items = rsp.map(it => {
if (it.project_name.indexOf('/') === 0) {
it.project_name = it.project_name.substring(1);
}
return it;
});
});
},
render: function(h) {
Expand Down Expand Up @@ -356,7 +375,7 @@ var _bind_project_remarks = function() {
}

requestTagsByRepo(project_name, function(rsp) {
_create_project_remark_dom(project.parentNode.parentNode, rsp ? rsp : { _id: project_name }, 'git_remarks_plugin__input git_remarks_plugin__detail container-lg px-3', false);
_create_project_remark_dom(project.parentNode.parentNode, rsp ? rsp : { _id: project_name }, 'git_remarks_plugin__input git_remarks_plugin__detail px-3 px-lg-5', false);
});
return;
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "GithubTags",
"description": "给Github项目添加标签,支持按标签搜索,支持数据云同步",
"version": "1.1.6",
"version": "1.1.7",
"manifest_version": 2,
"icons": {
"48": "icons/icon.png",
Expand Down
Binary file modified screenshot/10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshot/2.png
Binary file not shown.
Binary file removed screenshot/3.png
Binary file not shown.
Binary file removed screenshot/4.png
Binary file not shown.
Binary file removed screenshot/5.png
Binary file not shown.
Binary file removed screenshot/6.png
Binary file not shown.
Binary file removed screenshot/7.png
Binary file not shown.
4 changes: 2 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.6",
"message": "修复样式异常",
"version": "1.1.7",
"message": "适配最新版页面",
"link": "https://github.com/xiandanin/github-tags#%E6%9B%B4%E6%96%B0%E8%AF%B4%E6%98%8E"
}

0 comments on commit 044d004

Please sign in to comment.