|
32 | 32 | <div class="header-div1"> |
33 | 33 | <a href="<?php echo site_url() ?>" style="display: inline-block;"><img src="<?php echo get_option('king_logo') ?>"></a> |
34 | 34 | <a href="<?php echo site_url() ?>/feed" style="display: inline-block;margin-top: 12px;margin-left: 15px;"><button type="button" class="btn btn-light" style="letter-spacing: 1px;font-weight: 500;">RSS订阅</button></a> |
35 | | - </div> |
| 35 | +<a style="margin-top: 12px;margin-left: 12px;"><button onclick="open_search();" type="button" class="btn btn-light" style="letter-spacing: 1px;font-weight: 500;">博客搜索</button></a> |
| 36 | +</div> |
36 | 37 | <?php }else{ ?> |
37 | 38 | <div class="header-div1-1"> |
38 | 39 | <a href="<?php echo site_url() ?>"><img src="<?php echo get_option('king_logo'); ?>"></a> |
| 40 | + <a style="margin-top: 12px;margin-left: 12px;"><button onclick="open_search();" type="button" class="btn btn-light" style="letter-spacing: 1px;font-weight: 500;">博客搜索</button></a> |
39 | 41 | </div> |
40 | 42 | <?php } ?> |
41 | 43 | <div class="header-div2"> |
|
75 | 77 | } |
76 | 78 | }); |
77 | 79 |
|
| 80 | + var open_search = function(){ |
| 81 | + $('#search_form').attr('class','search_form_play'); |
| 82 | + $('.search-bg-b').attr('style','display:block'); |
| 83 | + $('#search-div').attr('style','display:block'); |
| 84 | + } |
| 85 | + var close_search = function(){ |
| 86 | + $('#search_form').attr('class','search_form_dis'); |
| 87 | + $('.search-bg-b').attr('style','display:none'); |
| 88 | + $('#search-div').attr('style','display:none'); |
| 89 | + } |
| 90 | + |
78 | 91 | </script> |
79 | 92 |
|
80 | 93 |
|
|
103 | 116 | $("#jv-loadingbar").animate({width:"100%"},100,function(){ |
104 | 117 | $("#jv-loadingbar").fadeOut(1000,function(){$("#jv-loadingbar").css("width","0");}); |
105 | 118 | }); |
| 119 | +</script> |
| 120 | + |
| 121 | +<div id="search_form" class="search_form_dis"> |
| 122 | +<div class="search-bg-b"></div> |
| 123 | +<div class="search-bg" id="search-div"> |
| 124 | + <div class="search-div1"> |
| 125 | + <h3>搜索内容<button type="button" class="btn btn-primary" style="font-weight: 600;padding: 4px 14px;font-size: .9rem;margin-top: 6px;margin-left: 10px;float: right;" onclick="close_search();">关闭</button></h3> |
| 126 | + <p>从博客全部内容中搜索所需</p> |
| 127 | + <input class="uk-input" type="text" placeholder="请输入搜索内容并回车Enter..." v-on:keyup.enter="search_query" v-model.trim="search_key"> |
| 128 | + </div> |
| 129 | + <div class="search-div2"> |
| 130 | + <ul v-if="search_loading"> |
| 131 | + <template v-if="search_content.length !== 0"> |
| 132 | + <li v-for="search in search_content"> |
| 133 | + <a :href="search.link"> |
| 134 | + <h4 v-html="search.title.rendered"></h4> |
| 135 | + <p v-html="search.post_excerpt.four"></p> |
| 136 | + </a> |
| 137 | + </li> |
| 138 | + </template> |
| 139 | + <template v-else> |
| 140 | + <li> |
| 141 | + <h4 style="color:#777">无匹配文章</h4> |
| 142 | + <p>请尝试更换搜索词再试试吧...</p> |
| 143 | + </li> |
| 144 | + </template> |
| 145 | + </ul> |
| 146 | + <ul v-if="loading_ph"> |
| 147 | + <ul class="uk-animation-slide-bottom-small"> |
| 148 | + <li class="search-line" style="padding: 30px;background: #f1f2f3;border: none;"></li> |
| 149 | + <li class="search-line" style="padding: 30px;background: #f1f2f3;border: none;"></li> |
| 150 | + <li class="search-line" style="padding: 30px;background: #f1f2f3;border: none;"></li> |
| 151 | + </ul> |
| 152 | + </div> |
| 153 | +</div> |
| 154 | +</div> |
| 155 | + |
| 156 | +<script> |
| 157 | + var search_vue = new Vue({ |
| 158 | + el: '#search-div', |
| 159 | + data(){ |
| 160 | + return { |
| 161 | + search_content : null, |
| 162 | + search_key : null, |
| 163 | + search_loading : false, |
| 164 | + loading_ph : true, |
| 165 | + search_open : false |
| 166 | + } |
| 167 | + }, |
| 168 | + methods : { |
| 169 | + search_query : function(){ |
| 170 | + this.search_loading = false; |
| 171 | + this.loading_ph = true; |
| 172 | + |
| 173 | + var s = this.search_key; |
| 174 | + axios.get('<?php echo site_url() ?>/wp-json/wp/v2/posts?search='+ s +'<?php if(get_option('king_index_exclude')) echo '&categories_exclude='.get_option('king_index_exclude'); ?>') |
| 175 | + .then(response => { |
| 176 | + this.search_content = response.data; |
| 177 | + this.loading_ph = false; |
| 178 | + this.search_loading = true; |
| 179 | + }) |
| 180 | + } |
| 181 | + } |
| 182 | + }) |
106 | 183 | </script> |
107 | 184 | <main role="main"> |
108 | 185 | <div class="grid grid-centered" style="<?php if(!is_single() && !is_page()) echo 'max-width: 660px;padding: 0px 20px;margin-top: 80px;'; ?>"> |
|
0 commit comments