Skip to content

Commit

Permalink
add search redirect, paste link
Browse files Browse the repository at this point in the history
  • Loading branch information
SchneeHertz committed Aug 14, 2024
1 parent 1fa5f13 commit c9d9981
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,14 @@ export default defineComponent({
_.assign(book, JSON.parse(text))
await this.saveBook(book)
},
async getMetadataFromClipboardLink (book) {
const text = await ipcRenderer.invoke('read-text-from-clipboard')
const url = text.trim()
if (url) {
book.url = url
this.getBookInfo(book)
}
},
// internal viewer
async useNewCover (filepath) {
Expand Down Expand Up @@ -2491,6 +2499,12 @@ export default defineComponent({
this.pasteTagClipboard(book)
}
},
{
label: this.$t('m.getMetadataFromClipboardLink'),
onClick: () => {
this.getMetadataFromClipboardLink(book)
}
},
]
})
},
Expand Down
33 changes: 31 additions & 2 deletions src/components/SearchDialog.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<el-dialog v-model="dialogVisibleEhSearch"
width="60%"
width="60vw"
:title="$t('m.search')"
destroy-on-close
class="dialog-search"
Expand All @@ -25,6 +25,12 @@
@click="getBookListFromWeb(bookDetail.hash.toUpperCase(), searchStringDialog, searchTypeDialog)"
/>
</el-form-item>
<el-form-item>
<el-button
type="primary" plain :icon="Link"
@click="redirectSearch(bookDetail.hash.toUpperCase(), searchStringDialog, searchTypeDialog)"
/>
</el-form-item>
</el-form>
<div v-loading="searchResultLoading">
<div class="search-result" v-if="ehSearchResultList.length > 0">
Expand All @@ -43,6 +49,7 @@
<script setup>
import { ref } from 'vue'
import { Search32Filled } from '@vicons/fluent'
import { Link } from '@element-plus/icons-vue'
const props = defineProps(['cookie', 'searchTypeList', 'setting'])
Expand Down Expand Up @@ -123,6 +130,28 @@ const getBookListFromWeb = async (bookHash, title, server = 'e-hentai') => {
return resultList
}
const redirectSearch = (bookHash, title, server = 'e-hentai') => {
let url
switch (server) {
case 'e-hentai':
url = `https://e-hentai.org/?f_shash=${bookHash}&fs_similar=on&fs_exp=on&f_cats=161`
break
case 'exhentai':
url = `https://exhentai.org/?f_shash=${bookHash}&fs_similar=on&fs_exp=on&f_cats=161`
break
case 'e-search':
url = `https://e-hentai.org/?f_search=${encodeURI(title)}&f_cats=161`
break
case 'exsearch':
url = `https://exhentai.org/?f_search=${encodeURI(title)}&f_cats=161`
break
case 'hentag':
url = `https://hentag.com/public/api/vault-search?t=${encodeURI(title)}`
break
}
ipcRenderer.invoke('open-url', url)
}
const resolveEhentaiResult = (htmlString) => {
try {
const resultNodes = new DOMParser().parseFromString(htmlString, 'text/html').querySelectorAll('.gl3c.glname')
Expand Down Expand Up @@ -180,7 +209,7 @@ defineExpose({
.el-form-item
margin-right: 4px
.search-input
width: calc(60vw - 106px)
width: calc(60vw - 152px)
.search-type-select
width: 160px
.search-result-ind
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"getTagbyUrl": "Get Tag by Url",
"copyTagClipboard": "Copy Tag to Clipboard",
"pasteTagClipboard": "Paste Tag from Clipboard",
"getMetadataFromClipboardLink": "Get Metadata from Copied Link",
"directEnter": "Click Cover To",
"detailPage": "Detail Page",
"internalViewer": "Internal Viewer",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"getTagbyUrl": "用网址获取元数据",
"copyTagClipboard": "复制标签信息到剪贴板",
"pasteTagClipboard": "从剪贴板粘贴标签信息",
"getMetadataFromClipboardLink": "从复制的链接获取元数据",
"directEnter": "点击封面进入",
"detailPage": "详情页",
"internalViewer": "内置阅读器",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"getTagbyUrl": "用網址獲取元數據",
"copyTagClipboard": "複製標籤資訊到剪貼簿",
"pasteTagClipboard": "從剪貼簿貼上標籤資訊",
"getMetadataFromClipboardLink": "從複製的連結獲取元數據",
"directEnter": "點擊封面進入",
"detailPage": "詳細頁面",
"internalViewer": "內置閱讀器",
Expand Down

0 comments on commit c9d9981

Please sign in to comment.