Skip to content

Commit

Permalink
add 允许设置搜索地址
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinsir committed Dec 9, 2018
1 parent 62a8ff6 commit 8928008
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
- 搜索历史改成cookie保存方式,默认保存7天✔
- 完善UI布局界面✔
- 基础功能优化
- 增加网络错误提示 回调函数错误处理。。。
- 增加网络错误提示 ✔
- 可以修改爬虫地址
- 添加可设置代理
- 可以获取搜索内容的更多页数
- 导入百度云盘
Expand Down
22 changes: 20 additions & 2 deletions src/main/module/SearchOne.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
} from './Crawler'
import {
GET_SEARCH_LIST,
GET_SEARCH_DETAIL
GET_SEARCH_DETAIL,
SET_SEARCH_ADDR
} from '@/message'
import jq from 'cheerio'
const baseUrl = 'https://btsow.pw/search/'
// let baseUrl = 'https://btsow.pw/search/'
let baseUrl = ''
export default () => {
// get list ...
ipcMain.on(GET_SEARCH_LIST, (event, agrs) => {
Expand All @@ -31,6 +33,22 @@ export default () => {
event.sender.send(GET_SEARCH_DETAIL, data)
})
})

// set baseUrl ...
ipcMain.on(SET_SEARCH_ADDR, (event, agrs) => {
console.log('setSearchAddr...', agrs.method)

switch (agrs.method) {
case 'SET':
baseUrl = agrs.data
event.sender.send(SET_SEARCH_ADDR, baseUrl)
// localStorage.setItem('SEARCH_ADDR', baseUrl)
break
case 'GET':
event.sender.send(SET_SEARCH_ADDR, baseUrl)
break
}
})
}
function getSearchDetail ($) {
let data = {}
Expand Down
1 change: 1 addition & 0 deletions src/message.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const GET_SEARCH_LIST = 'GET_SEARCH_LIST'
export const GET_SEARCH_DETAIL = 'GET_SEARCH_DETAIL'
export const SET_SEARCH_ADDR = 'SET_SEARCH_ADDR'
export const LOGIN_BAIDUYUN = 'LOGIN_BAIDUYUN'
53 changes: 50 additions & 3 deletions src/renderer/view/search/components/SearchSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,38 @@
:visible.sync="SettingVisible"
title="设置">
<el-form>
<el-form-item label="临时设置BOTSOW搜索地址">
<el-input
class="item-input"
placeholder="example: btsow.pw"
v-model="searchAddr">
<template slot="append">
<el-button @click="handleSaveSearchAddr" type="primary">保存</el-button>
</template>
</el-input>
</el-form-item>
<el-form-item label="显示搜索历史">
<div class="item-input">
<el-switch v-model="histroyDelivery"></el-switch>
</div>
</el-form-item>
<el-form-item label="清空搜索历史">
<div class="item-input">
<el-button @click="handleClearHistory">清空</el-button>
</div>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script>
import Cookie from 'js-cookie'
import { SET_SEARCH_ADDR } from '@/../message'
import { ipcRenderer } from 'electron'
export default{
data () {
return {
histroyDelivery: localStorage.getItem('HISTORY_SAVE') === 'true'
histroyDelivery: localStorage.getItem('HISTORY_SAVE') === 'true',
searchAddr: 'https://btsow.pw/search/'
}
},
computed: {
Expand All @@ -29,12 +46,25 @@ export default{
this.$emit('update:showSetting', val)
}
}
},
mounted () {
this.bindMessage()
ipcRenderer.send(SET_SEARCH_ADDR, {method: 'SET', data: this.searchAddr})
},
methods: {
handleClearHistory () {
Cookie.remove('HISTORY_LIST', {expires: ''})
this.$message.success('已清空')
},
handleSaveSearchAddr () {
ipcRenderer.send(SET_SEARCH_ADDR, {method: 'SET', data: this.searchAddr})
this.$message.success('修改成功!')
},
bindMessage () {
// listen SET_SEARCH_ADDR
ipcRenderer.on(SET_SEARCH_ADDR, (event, resp) => {
this.searchAddr = resp
})
}
},
watch: {
Expand All @@ -47,4 +77,21 @@ export default{
showSetting: Boolean
}
}
</script>
</script>
<style lang="scss" scoped>
/deep/.item-input{
float: right;
width: 50%;
text-align: center;
.el-button--primary{
padding: 12px 10px;
}
.el-input__inner{
height: 25px;
font-size: 12px;
}
}
/deep/.el-form{
padding-right: 40px;
}
</style>

0 comments on commit 8928008

Please sign in to comment.