Whalebird-desktop-client-ma.../src/renderer/components/TimelineSpace/Contents/Search.vue

109 lines
2.5 KiB
Vue
Raw Normal View History

2018-04-15 13:22:27 +02:00
<template>
2018-04-15 16:06:59 +02:00
<div id="search" :style="theme">
<div class="search-header">
<el-form :inline="true">
<el-select v-model="target" placeholder="search" class="search-target">
<el-option
v-for="item in searchTargets"
:key="item.target"
:label="item.label"
:value="item.target">
</el-option>
</el-select>
2018-04-15 16:58:24 +02:00
<input v-model="query" placeholder="keyword" class="search-keyword" v-shortkey="['enter']" @shortkey="search" autofocus></input>
2018-04-15 16:06:59 +02:00
<div class="clearfix"></div>
</el-form>
</div>
2018-04-16 01:19:29 +02:00
<div class="search-result">
<search-account></search-account>
</div>
2018-04-15 13:22:27 +02:00
</div>
</template>
<script>
2018-04-15 16:06:59 +02:00
import { mapState } from 'vuex'
2018-04-16 01:19:29 +02:00
import SearchAccount from './Search/Account'
2018-04-15 16:06:59 +02:00
2018-04-15 13:22:27 +02:00
export default {
2018-04-15 16:06:59 +02:00
name: 'search',
2018-04-16 01:19:29 +02:00
components: { SearchAccount },
2018-04-15 16:06:59 +02:00
data () {
return {
target: 'account',
searchTargets: [
{
target: 'account',
label: 'Account'
}
2018-04-15 16:58:24 +02:00
],
query: ''
2018-04-15 16:06:59 +02:00
}
},
computed: {
...mapState({
theme: (state) => {
return {
'--theme-background-color': state.App.theme.background_color,
'--theme-selected-background-color': state.App.theme.selected_background_color,
'--theme-primary-color': state.App.theme.primary_color
}
}
})
2018-04-15 16:58:24 +02:00
},
methods: {
search () {
switch (this.target) {
case 'account':
this.$store.dispatch('TimelineSpace/Contents/Search/Account/search', this.query)
break
default:
break
}
}
2018-04-15 16:06:59 +02:00
}
2018-04-15 13:22:27 +02:00
}
</script>
2018-04-15 16:06:59 +02:00
<style lang="scss" scoped>
#search {
--theme-background-color: #ffffff;
--theme-selected-background-color: #f2f6fc;
--theme-primary-color: #303133;
--theme-border-color: #ebeef5;
border-top: 1px solid var(--theme-border-color);
.search-header {
background-color: var(--theme-selected-background-color);
padding: 8px 12px;
.search-target /deep/ {
float: left;
width: 20%;
.el-input__inner {
background-color: var(--theme-background-color);
border: none;
border-radius: 4px 0 0 4px;
color: var(--theme-primary-color);
}
}
2018-04-15 16:58:24 +02:00
.search-keyword {
2018-04-15 16:06:59 +02:00
float: left;
width: 80%;
2018-04-15 16:58:24 +02:00
background-color: var(--theme-background-color);
border: none;
border-radius: 0 4px 4px 0;
color: var(--theme-primary-color);
line-height: 40px;
height: 40px;
padding: 0 15px;
outline: 0;
font-size: 14px;
box-sizing: border-box;
2018-04-15 16:06:59 +02:00
}
}
}
2018-04-15 13:22:27 +02:00
</style>