Skip to content

Commit afe3579

Browse files
committed
feat: 移除源引擎选项并调整相关描述
源引擎是不必要的——谁会费劲巴拉把一个搜索引擎加入进来但是不启用呢?
1 parent 2f79fd8 commit afe3579

8 files changed

Lines changed: 20 additions & 92 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,12 @@ jobs:
189189
zip-path: web-ext-artifacts/*.zip
190190
client-id: ${{ secrets.EDGE_CLIENT_ID }}
191191
api-key: ${{ secrets.EDGE_API_KEY }}
192+
193+
- name: Publish to Chrome Web Store
194+
uses: wdzeng/chrome-extension@v1
195+
with:
196+
extension-id: 'kldhhobmmeolcaliogenmnaalciifjoh'
197+
zip-path: web-ext-artifacts/*.zip
198+
client-id: ${{ secrets.CHROME_CLIENT_ID }}
199+
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
200+
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}

‎src/_locales/en/messages.json‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"message": "Search Engine Management"
4949
},
5050
"engineManagementDesc": {
51-
"message": "Manage all search engines. Configure whether each engine can be a \"Target Engine\" (redirect to) or \"Source Engine\" (extract keywords from)."
51+
"message": "Manage all search engines. Configure whether each engine can be a \"Target Engine\" (redirect to). All engines are \"Source Engines\" (extract keywords from) by default."
5252
},
5353
"addEditEngine": {
5454
"message": "Add/Edit Engine"
@@ -98,12 +98,6 @@
9898
"isTargetEngineHint": {
9999
"message": "When checked, this engine will appear in dropdown menu and context menu for redirection"
100100
},
101-
"isSourceEngine": {
102-
"message": "As Source Engine"
103-
},
104-
"isSourceEngineHint": {
105-
"message": "When checked, keywords can be extracted from this engine's search result pages"
106-
},
107101
"addEngineBtn": {
108102
"message": "Add Engine"
109103
},
@@ -128,9 +122,6 @@
128122
"gridColumnParam": {
129123
"message": "Parameter"
130124
},
131-
"gridColumnSource": {
132-
"message": "Source"
133-
},
134125
"gridColumnTarget": {
135126
"message": "Target"
136127
},
@@ -182,9 +173,6 @@
182173
"errorUrlPlaceholder": {
183174
"message": "URL must contain %s as keyword placeholder"
184175
},
185-
"errorEngineRole": {
186-
"message": "At least one role (Target or Source) must be selected"
187-
},
188176
"confirmDelete": {
189177
"message": "Are you sure you want to delete this engine?"
190178
},

‎src/_locales/zh_CN/messages.json‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"message": "搜索引擎管理"
4949
},
5050
"engineManagementDesc": {
51-
"message": "管理所有搜索引擎。可设置每个引擎是否作为\"目标引擎\"(可跳转到)或\"源引擎\"(可从其提取关键词)。"
51+
"message": "管理所有搜索引擎。可设置每个引擎是否作为\"目标引擎\"(可跳转到)。默认所有引擎都可作为\"源引擎\"(可从其提取关键词)。"
5252
},
5353
"addEditEngine": {
5454
"message": "添加/编辑引擎"
@@ -98,12 +98,6 @@
9898
"isTargetEngineHint": {
9999
"message": "勾选后可在下拉菜单和右键菜单中选择跳转到此引擎"
100100
},
101-
"isSourceEngine": {
102-
"message": "作为源引擎"
103-
},
104-
"isSourceEngineHint": {
105-
"message": "勾选后可从此引擎的搜索结果页面提取关键词"
106-
},
107101
"addEngineBtn": {
108102
"message": "添加引擎"
109103
},
@@ -128,9 +122,6 @@
128122
"gridColumnParam": {
129123
"message": "参数"
130124
},
131-
"gridColumnSource": {
132-
"message": "源引擎"
133-
},
134125
"gridColumnTarget": {
135126
"message": "目标引擎"
136127
},
@@ -182,9 +173,6 @@
182173
"errorUrlPlaceholder": {
183174
"message": "URL 必须包含 %s 作为关键词占位符"
184175
},
185-
"errorEngineRole": {
186-
"message": "至少需要勾选一个角色(目标引擎或源引擎)"
187-
},
188176
"confirmDelete": {
189177
"message": "确定要删除此引擎吗?"
190178
},

‎src/background.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ async function extractKeywordFromUrl(urlString) {
369369
const allEngines = engines || DEFAULT_ENGINES
370370

371371
// 筛选出作为源引擎的引擎
372-
const sourceEngines = allEngines.filter((e) => e.isSource)
372+
const sourceEngines = allEngines
373373

374374
for (const engine of sourceEngines) {
375375
if (

‎src/config.js‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export const DEFAULT_ENGINES = [
1010
domain: 'google.com',
1111
param: 'q',
1212
isTarget: true,
13-
isSource: true,
1413
},
1514
{
1615
id: 'baidu',
@@ -20,7 +19,6 @@ export const DEFAULT_ENGINES = [
2019
domain: 'baidu.com',
2120
param: 'wd,word',
2221
isTarget: true,
23-
isSource: true,
2422
},
2523
{
2624
id: 'bing',
@@ -30,7 +28,6 @@ export const DEFAULT_ENGINES = [
3028
domain: 'bing.com',
3129
param: 'q',
3230
isTarget: true,
33-
isSource: true,
3431
},
3532
{
3633
id: 'bing_cn',
@@ -40,7 +37,6 @@ export const DEFAULT_ENGINES = [
4037
domain: 'cn.bing.com',
4138
param: 'q',
4239
isTarget: false,
43-
isSource: true,
4440
},
4541
{
4642
id: 'duckduckgo',
@@ -50,7 +46,6 @@ export const DEFAULT_ENGINES = [
5046
domain: 'duckduckgo.com',
5147
param: 'q',
5248
isTarget: true,
53-
isSource: true,
5449
},
5550
{
5651
id: 'sogou',
@@ -60,7 +55,6 @@ export const DEFAULT_ENGINES = [
6055
domain: 'sogou.com',
6156
param: 'query',
6257
isTarget: false,
63-
isSource: true,
6458
},
6559
{
6660
id: '360so',
@@ -70,7 +64,6 @@ export const DEFAULT_ENGINES = [
7064
domain: 'so.com',
7165
param: 'q',
7266
isTarget: false,
73-
isSource: true,
7467
},
7568
{
7669
id: 'yandex',
@@ -80,7 +73,6 @@ export const DEFAULT_ENGINES = [
8073
domain: 'yandex.com',
8174
param: 'text',
8275
isTarget: false,
83-
isSource: true,
8476
},
8577
{
8678
id: 'yahoo',
@@ -90,7 +82,6 @@ export const DEFAULT_ENGINES = [
9082
domain: 'search.yahoo.com',
9183
param: 'p',
9284
isTarget: false,
93-
isSource: true,
9485
},
9586
{
9687
id: 'bilibili',
@@ -100,7 +91,6 @@ export const DEFAULT_ENGINES = [
10091
domain: 'search.bilibili.com',
10192
param: 'keyword',
10293
isTarget: false,
103-
isSource: true,
10494
},
10595
{
10696
id: 'github',
@@ -110,7 +100,6 @@ export const DEFAULT_ENGINES = [
110100
domain: 'github.com',
111101
param: 'q',
112102
isTarget: false,
113-
isSource: true,
114103
},
115104
{
116105
id: 'google_translate',
@@ -120,7 +109,6 @@ export const DEFAULT_ENGINES = [
120109
domain: 'translate.google.com',
121110
param: 'text',
122111
isTarget: false,
123-
isSource: true,
124112
},
125113
{
126114
id: 'baidu_translate',
@@ -130,6 +118,5 @@ export const DEFAULT_ENGINES = [
130118
domain: 'fanyi.baidu.com',
131119
param: 'text',
132120
isTarget: false,
133-
isSource: true,
134121
},
135122
]

‎src/options.css‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,6 @@ details[open] .toggle-icon {
448448
}
449449

450450
/* 特定列居中对齐 */
451-
th[data-column-id='isSource'],
452-
td[data-column-id='isSource'],
453451
th[data-column-id='isTarget'],
454452
td[data-column-id='isTarget'],
455453
th[data-column-id='actions'],
@@ -458,14 +456,12 @@ td[data-column-id='actions'] {
458456
}
459457

460458
/* 禁用特定列的调整大小手柄 */
461-
th[data-column-id='isSource'] .gridjs-resizable,
462459
th[data-column-id='isTarget'] .gridjs-resizable,
463460
th[data-column-id='actions'] .gridjs-resizable {
464461
display: none !important;
465462
}
466463

467464
/* Grid内复选框样式 */
468-
.chk-source,
469465
.chk-target {
470466
width: 18px;
471467
height: 18px;

‎src/options.html‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ <h1>
2323

2424
<!-- 目标搜索引擎选择 -->
2525
<section class="card">
26-
<h2 data-i18n="currentTargetEngine">当前目标引擎</h2>
26+
<h2 data-i18n="currentTargetEngine">默认目标引擎</h2>
2727
<p class="description" data-i18n="currentTargetEngineDesc">
28-
选择点击插件图标时要跳转到的搜索引擎
28+
点击插件图标后将使用该搜索引擎执行搜索
2929
</p>
3030

3131
<div class="form-group">
@@ -55,7 +55,7 @@ <h2 data-i18n="currentTargetEngine">当前目标引擎</h2>
5555
<section class="card">
5656
<h2 data-i18n="engineManagement">搜索引擎管理</h2>
5757
<p class="description" data-i18n="engineManagementDesc">
58-
管理所有搜索引擎。可设置每个引擎是否作为"目标引擎"(可跳转到)或"源引擎"(可从其提取关键词)。
58+
管理所有搜索引擎。可设置每个引擎是否作为"目标引擎"(可用于搜索)
5959
</p>
6060

6161
<!-- 引擎列表 -->
@@ -155,20 +155,10 @@ <h3 data-i18n="addEditEngine">添加/编辑引擎</h3>
155155
>
156156
</label>
157157
<p class="hint" data-i18n="isTargetEngineHint">
158-
勾选后可在下拉菜单和右键菜单中选择跳转到此引擎
159-
</p>
160-
</div>
161-
<div class="form-group checkbox-group">
162-
<label class="checkbox-container">
163-
<input type="checkbox" id="newEngineIsSource" />
164-
<span class="checkbox-label" data-i18n="isSourceEngine"
165-
>作为源引擎</span
166-
>
167-
</label>
168-
<p class="hint" data-i18n="isSourceEngineHint">
169-
勾选后可从此引擎的搜索结果页面提取关键词
158+
勾选后可在下拉菜单和右键菜单中使用该引擎搜索
170159
</p>
171160
</div>
161+
172162
</div>
173163
<div class="btn-group">
174164
<button

‎src/options.js‎

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const elements = {
2727
newEngineDomain: document.getElementById('newEngineDomain'),
2828
newEngineParam: document.getElementById('newEngineParam'),
2929
newEngineIsTarget: document.getElementById('newEngineIsTarget'),
30-
newEngineIsSource: document.getElementById('newEngineIsSource'),
3130
addEngine: document.getElementById('addEngine'),
3231
cancelEditEngine: document.getElementById('cancelEditEngine'),
3332
enginesGrid: document.getElementById('engines-grid'),
@@ -164,28 +163,13 @@ function initGrid() {
164163
),
165164
},
166165
{ id: 'param', name: i18n('gridColumnParam'), width: '100px' },
167-
{
168-
id: 'isSource',
169-
name: i18n('gridColumnSource'),
170-
sort: true,
171-
width: '9%',
172-
formatter: (cell, row) => {
173-
const id = row.cells[7].data // 获取隐藏的 ID 列
174-
return gridjs.html(`
175-
<input type="checkbox"
176-
class="chk-source"
177-
data-id="${id}"
178-
${cell ? 'checked' : ''} />
179-
`)
180-
},
181-
},
182166
{
183167
id: 'isTarget',
184168
name: i18n('gridColumnTarget'),
185169
sort: true,
186170
width: '10.5%',
187171
formatter: (cell, row) => {
188-
const id = row.cells[7].data // 获取隐藏的 ID 列
172+
const id = row.cells[5].data // 获取隐藏的 ID 列
189173
return gridjs.html(`
190174
<input type="checkbox"
191175
class="chk-target"
@@ -200,7 +184,7 @@ function initGrid() {
200184
sort: false,
201185
width: '8%',
202186
formatter: (cell, row) => {
203-
const id = row.cells[7].data
187+
const id = row.cells[5].data
204188
const editTitle = i18n('editTooltip')
205189
const deleteTitle = i18n('deleteTooltip')
206190
const deleteIcon = `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z"/></svg>`
@@ -254,7 +238,6 @@ function renderEnginesGrid() {
254238
badge: e.badge,
255239
url: e.url,
256240
param: e.param || '',
257-
isSource: e.isSource,
258241
isTarget: e.isTarget,
259242
id: e.id,
260243
}))
@@ -329,11 +312,7 @@ function handleGridClick(e) {
329312
* 处理 Grid 变更事件 (Checkbox)
330313
*/
331314
async function handleGridChange(e) {
332-
if (e.target.classList.contains('chk-source')) {
333-
const id = e.target.dataset.id
334-
const checked = e.target.checked
335-
await updateEngineState(id, { isSource: checked })
336-
} else if (e.target.classList.contains('chk-target')) {
315+
if (e.target.classList.contains('chk-target')) {
337316
const id = e.target.dataset.id
338317
const checked = e.target.checked
339318
await updateEngineState(id, { isTarget: checked })
@@ -477,7 +456,6 @@ async function handleEngineSubmit() {
477456
const domain = elements.newEngineDomain.value.trim()
478457
const param = elements.newEngineParam.value.trim()
479458
const isTarget = elements.newEngineIsTarget.checked
480-
const isSource = elements.newEngineIsSource.checked
481459

482460
// 验证输入
483461
if (!name) {
@@ -498,19 +476,13 @@ async function handleEngineSubmit() {
498476
return
499477
}
500478

501-
if (!isTarget && !isSource) {
502-
showStatus(i18n('errorEngineRole'), true)
503-
return
504-
}
505-
506479
const engineData = {
507480
name,
508481
badge,
509482
url,
510483
domain,
511484
param,
512485
isTarget,
513-
isSource,
514486
}
515487

516488
if (editingEngineId === null) {
@@ -559,7 +531,6 @@ function startEditEngine(id) {
559531
elements.newEngineDomain.value = engine.domain || ''
560532
elements.newEngineParam.value = engine.param || ''
561533
elements.newEngineIsTarget.checked = engine.isTarget
562-
elements.newEngineIsSource.checked = engine.isSource
563534

564535
// 更新按钮状态
565536
elements.addEngine.textContent = i18n('saveChangesBtn')
@@ -583,7 +554,6 @@ function resetEditState() {
583554
elements.newEngineDomain.value = ''
584555
elements.newEngineParam.value = ''
585556
elements.newEngineIsTarget.checked = true
586-
elements.newEngineIsSource.checked = false
587557

588558
// 恢复按钮状态
589559
elements.addEngine.textContent = i18n('addEngineBtn')

0 commit comments

Comments
 (0)