Skip to content

Commit

Permalink
feat: 增加禁用 searchEntryConfig.area 选项
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed May 13, 2024
1 parent d6adfc1 commit 3a184f0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion resource/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@
"urlTip": "The full address of the website, such as: https:\/\/www.github.com\/",
"passkey": "Passkey",
"passkeyTip": "The key is only used to copy the download address operation. If you do not need this function, please leave it blank.",
"allowSearch": "Allow Search",
"allowSearch": "Allow search",
"disableSearchTransform": "Disable search transform",
"allowGetUserInfo": "Allow access to user information (Beta)",
"cdn": "Site CDN list",
"cdnTip": "If you use a different URL than the system definition, you can fill in the currently used website address, fill in one address per line, the first one will be used as the address used for the search.",
Expand Down
1 change: 1 addition & 0 deletions resource/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@
"passkey": "密钥",
"passkeyTip": "密钥仅用于复制下载地址操作,如果不需要用到此功能,请留空",
"allowSearch": "允许搜索",
"disableSearchTransform": "禁用搜索替换",
"allowGetUserInfo": "允许获取用户信息(Beta)",
"cdn": "站点CDN列表",
"cdnTip": "如您使用的网址和系统定义的不同,可在此填写当前使用的网站地址,每行填写一个地址,第一个将做为搜索时使用的地址",
Expand Down
4 changes: 3 additions & 1 deletion src/background/searcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Searcher {
searchEntryConfigQueryString = searchEntryConfig.queryString + "";

// 搜索区域
if (searchEntryConfig.area) {
if (searchEntryConfig.area && !site.disableSearchTransform) {
searchEntryConfig.area.some((area: SearchEntryConfigArea) => {
// 是否有自动匹配关键字的正则
if (
Expand Down Expand Up @@ -277,10 +277,12 @@ export class Searcher {

// 替换关键字
if (area.replaceKey) {
const old = key;
key = key.replace(
new RegExp(area.replaceKey[0], "g"),
area.replaceKey[1]
);
console.log(`[${site.name}] "${old}" => "${key}"`);
}

// 解析脚本,最终返回搜索关键字,可调用 payload 里的数据进行关键字替换
Expand Down
1 change: 1 addition & 0 deletions src/interface/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export interface Site {
defaultClientId?: string;
plugins?: any[];
allowSearch?: boolean;
disableSearchTransform?: boolean;
securityKeys?: object;
searchEntryConfig?: SearchEntryConfig;
searchEntry?: SearchEntry[];
Expand Down
14 changes: 11 additions & 3 deletions src/options/views/settings/Sites/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@
:disabled="!site.tokenRequired" :rules="site.tokenRequired ? rules.require : []"
:label="$t('settings.sites.editor.authToken')"
:placeholder="$t('settings.sites.editor.authTokenTip')"
></v-text-field>
></v-text-field>

<!-- 站点已离线(停机/关闭) -->
<v-switch :label="$t('settings.sites.editor.offline')" v-model="site.offline" />

<!-- 允许获取用户信息 -->
<v-switch
:label="$t('settings.sites.editor.allowGetUserInfo')"
Expand Down Expand Up @@ -192,8 +196,12 @@
</v-container>
</template>

<!-- 站点已离线(停机/关闭) -->
<v-switch :label="$t('settings.sites.editor.offline')" v-model="site.offline"></v-switch>
<!-- 禁用搜索替换 -->
<v-switch
v-model="site.disableSearchTransform"
:disabled="!site.allowSearch || site.offline"
:label="$t('settings.sites.editor.disableSearchTransform')"
/>

<!-- 消息提醒开关 -->
<v-switch :label="$t('settings.sites.editor.disableMessageCount')" v-model="site.disableMessageCount"></v-switch>
Expand Down

0 comments on commit 3a184f0

Please sign in to comment.