Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 调整搜索方案默认搜索逻辑, 可在 通用配置-搜索 中调整 #1561

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dev.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## PTPP 开发指引

* https://github.com/pt-plugins/PT-Plugin-Plus/wiki/develop
* https://github.com/pt-plugins/PT-Plugin-Plus/wiki/developer

## PTPP 后端日志查看

Expand All @@ -11,7 +11,9 @@

![img](./docs/images/1.png)

5. 从项目结构上说 `src/background` 的日志将会输出到 背景页。`src/options` 里面的日志,将会输出到 `index.html`。打开F12即可看见。
5. 从项目结构上来说, 打开F12即可看见日志。
1. `src/background` 的日志将会输出到 `背景页`。
2. `src/options` 里面的日志,将会输出到 `index.html`。

```
.
Expand Down
1 change: 1 addition & 0 deletions resource/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
"saveSearchKey": "Save historical search keyword records",
"showMoiveInfoCardOnSearch": "Show movie and rating information when searching by IMDb number",
"getMovieInformationBeforeSearching": "When entering a search keyword, load relevant information from Douban for pre-selection",
"autoSearchWhenSwitchSolution": "When changing search solution, re-search immediately",
"maxMovieInformationCount": "Maximum display number of entries (1-20):",
"searchModeForItem": "When clicking on a pre-selected item:",
"showToolbarOnContentPage": "Enable site page plugin icons and toolbars (such as one-click downloads, etc.)",
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 @@ -493,6 +493,7 @@
"saveSearchKey": "保存搜索关键字",
"showMoiveInfoCardOnSearch": "当以 IMDb 编号搜索时显示电影及评分信息",
"getMovieInformationBeforeSearching": "当输入搜索关键字时,从豆瓣加载相关信息以供预选",
"autoSearchWhenSwitchSolution": "当搜索方案切换时,立即触发搜索",
"maxMovieInformationCount": "最多显示条目(1-20):",
"searchModeForItem": "当点击预选条目时:",
"showToolbarOnContentPage": "启用站点页面助手图标和工具栏(如一键下载等)",
Expand Down
2 changes: 2 additions & 0 deletions src/interface/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export interface Options {
showMoiveInfoCardOnSearch?: boolean;
// 在搜索之前一些选项配置
beforeSearchingOptions?: BeforeSearching;
// 搜索方案切换的时候是否自动搜索
autoSearchWhenSwitchSolution?: boolean;
// 在页面中显示工具栏
showToolbarOnContentPage?: boolean;
// 当前语言
Expand Down
13 changes: 7 additions & 6 deletions src/options/components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,15 @@ export default Vue.extend({

searchTorrent(key?: string) {
key = key || this.searchKey;
console.log(`searchTorrent: key: ${key}, searchKey: ${this.searchKey}`)
if (!key) {
return;
}
const targetRoute = {name: "search-torrent", params: {key,},}
if (key === this.searchKey && this.$router.currentRoute.name === targetRoute.name) {
console.log(`skip same searchTorrent: key: ${key}, searchKey: ${this.searchKey}`)
return;
}
Comment on lines +406 to +409
Copy link
Member Author

@IITII IITII Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里判了 route name, 你可以在这里通过自己加 event 触发搜索. 目前过滤掉就好了 @Meng-Lan
反正直接刷新网页, 刷新后会搜索


this.showMenu = false;
clearTimeout(this.timer);
Expand All @@ -409,12 +415,7 @@ export default Vue.extend({
lastSearchKey: this.searchKey,
});

this.$router.push({
name: "search-torrent",
params: {
key: key,
},
});
this.$router.push(targetRoute);
},
changeSearchSolution(solution?: SearchSolution) {
let defaultSearchSolutionId = "";
Expand Down
9 changes: 8 additions & 1 deletion src/options/views/search/SearchTorrent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@ export default Vue.extend({
watch: {
key(newValue, oldValue) {
if (newValue && newValue != oldValue) {
console.log('watch search key', newValue, oldValue)
this.doSearch();
}
},
host(newValue, oldValue) {
if (newValue && newValue != oldValue) {
console.log('watch search host', newValue, oldValue)
this.doSearch();
}
},
Expand All @@ -221,9 +223,14 @@ export default Vue.extend({
this.haveError = this.errorMsg != "";
},
"$store.state.options.defaultSearchSolutionId"(newValue, oldValue) {
console.log('watch search defaultSearchSolutionId', newValue, oldValue)
// 设置为<默认>时,newValue 为空,故与 key, host 处理方式不同
if (newValue != oldValue) {
this.doSearch();
if (this.$store.state.options.autoSearchWhenSwitchSolution) {
this.doSearch();
} else {
console.log(`切换搜索方案 - 跳过搜索, 可在 常规设置 - 搜索 中开启自动搜索`)
}
}
},
loading() {
Expand Down
9 changes: 8 additions & 1 deletion src/options/views/settings/Base/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@
:label="$t('settings.base.showMoiveInfoCardOnSearch')"
></v-switch>

<!-- 搜索方案切换的时候是否自动搜索 -->
<v-switch
color="success"
v-model="options.autoSearchWhenSwitchSolution"
:label="$t('settings.base.autoSearchWhenSwitchSolution')"
></v-switch>

<!-- 在搜索之前一些选项配置 -->
<v-switch
color="success"
Expand Down Expand Up @@ -789,7 +796,7 @@ export default Vue.extend({
).toString();
}
},
watch: {
watch: {
successMsg: {
handler() {
this.haveSuccess = this.successMsg != "";
Expand Down