更新
This commit is contained in:
		
							parent
							
								
									956c528b48
								
							
						
					
					
						commit
						2a01752312
					
				| @ -709,6 +709,10 @@ | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| .joe_list { | ||||
|      | ||||
| } | ||||
| 
 | ||||
| @keyframes progress { | ||||
|     0% { | ||||
|         background-position: 0 0; | ||||
|  | ||||
| @ -1 +1 @@ | ||||
| .joe_index{border-radius:8px;padding:0 15px;background:var(--background);box-shadow:var(--box-shadow);margin-bottom:15px}.joe_index__banner{padding-top:15px;display:flex}.joe_index__banner-recommend{width:270px;margin-left:15px;display:flex;flex-direction:column}.joe_index__banner-recommend.noswiper{width:100%;flex-direction:row;margin-left:0}.joe_index__banner-recommend.noswiper .item:first-child{margin-bottom:0;margin-right:7.5px}.joe_index__banner-recommend.noswiper .item:last-child{margin-left:7.5px}.joe_index__banner-recommend .item{position:relative;width:100%;height:160px;margin-bottom:15px;border-radius:5px;overflow:hidden}.joe_index__banner-recommend .item:last-child{margin-bottom:0}.joe_index__banner-recommend .item .thumbnail{display:block;width:100%;height:100%;transition:opacity 0.35s}.joe_index__banner-recommend .item .thumbnail img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}.joe_index__banner-recommend .item .thumbnail:hover{opacity:0.85}.joe_index__banner-recommend .item .information{display:flex;align-items:center;position:absolute;z-index:1;bottom:0;left:0;right:0;padding:8px;background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.5));color:#fff;line-height:20px}.joe_index__banner-recommend .item .information_type{background-image:linear-gradient(to right, #fc712a, #f84c39);background-color:#f84c39;padding:0 5px;height:20px;border-radius:2px;margin-right:5px;font-size:12px}.joe_index__banner-recommend .item .information_title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;font-size:14px}.swiper-container{min-width:0;flex:1;height:335px;--swiper-theme-color: #fff;border-radius:5px}.swiper-container .item{display:block;height:335px;border-radius:5px}.swiper-container .item .thumbnail{width:100%;height:100%;-o-object-fit:cover;object-fit:cover;transition:opacity 0.35s}.swiper-container .item .thumbnail:hover{opacity:0.85}.swiper-container .item .title{position:absolute;z-index:1;left:0;right:0;bottom:0;text-align:center;background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.45));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#fff;font-size:15px;padding:10px;font-weight:normal}.swiper-container .item .icon{position:absolute;z-index:1;top:10px;left:10px;width:18px;height:18px;fill:#fff;opacity:0.5}.swiper-container.swiper-container-horizontal .swiper-pagination-bullets{bottom:unset;left:unset;width:auto;right:10px;top:10px} | ||||
| .joe_index{border-radius:8px;padding:0 15px;background:var(--background);box-shadow:var(--box-shadow);margin-bottom:15px}.joe_index__banner{padding-top:15px;display:flex}.joe_index__banner-recommend{width:270px;margin-left:15px;display:flex;flex-direction:column}.joe_index__banner-recommend.noswiper{width:100%;flex-direction:row;margin-left:0}.joe_index__banner-recommend.noswiper .item:first-child{margin-bottom:0;margin-right:7.5px}.joe_index__banner-recommend.noswiper .item:last-child{margin-left:7.5px}.joe_index__banner-recommend .item{position:relative;width:100%;height:160px;margin-bottom:15px;border-radius:5px;overflow:hidden}.joe_index__banner-recommend .item:last-child{margin-bottom:0}.joe_index__banner-recommend .item .thumbnail{display:block;width:100%;height:100%;transition:opacity 0.35s}.joe_index__banner-recommend .item .thumbnail img{width:100%;height:100%;-o-object-fit:cover;object-fit:cover}.joe_index__banner-recommend .item .thumbnail:hover{opacity:0.85}.joe_index__banner-recommend .item .information{display:flex;align-items:center;position:absolute;z-index:1;bottom:0;left:0;right:0;padding:8px;background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.5));color:#fff;line-height:20px}.joe_index__banner-recommend .item .information_type{background-image:linear-gradient(to right, #fc712a, #f84c39);background-color:#f84c39;padding:0 5px;height:20px;border-radius:2px;margin-right:5px;font-size:12px}.joe_index__banner-recommend .item .information_title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;font-size:14px}.joe_index__hot{padding-top:15px}.joe_index__hot-list{display:flex;margin:0 -5px}.joe_index__hot-list .item{width:25%;padding:0 5px}.joe_index__hot-list .item .link{display:block}.joe_index__hot-list .item .link .inner{position:relative;cursor:pointer}.joe_index__hot-list .item .link .inner:hover .image{opacity:0.85}.joe_index__hot-list .item .link .inner:hover .title{background:var(--classC)}.joe_index__hot-list .item .link .inner .image{width:100%;height:125px;-o-object-fit:cover;object-fit:cover;border-radius:5px 5px 0 0;transition:opacity 0.35s}.joe_index__hot-list .item .link .inner .title{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center;padding:0 8px;line-height:32px;color:var(--minor);background:var(--classD);border-radius:0 0 5px 5px;transition:background 0.35s}.joe_index__hot-list .item .link .inner .views{display:flex;align-items:center;position:absolute;z-index:1;top:5px;right:5px;background-image:linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3);color:#fff;font-size:12px;height:18px;padding:0 8px;border-radius:2px;white-space:nowrap}.joe_index__title{display:flex;align-items:center;border-bottom:1px solid var(--classC)}.joe_index__title-title{position:relative;display:flex;align-items:center;color:var(--routine);font-weight:500;height:40px;line-height:40px}.joe_index__title-title .item{cursor:pointer;margin-right:20px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:color 0.35s}.joe_index__title-title .item.active{color:var(--theme)}.joe_index__title-title .line{position:absolute;bottom:-1px;left:0;height:2px;border-radius:1px;background:var(--theme);transition:left 0.35s, width 0.35s}.swiper-container{min-width:0;flex:1;height:335px;--swiper-theme-color: #fff;border-radius:5px}.swiper-container .item{display:block;height:335px;border-radius:5px}.swiper-container .item .thumbnail{width:100%;height:100%;-o-object-fit:cover;object-fit:cover;transition:opacity 0.35s}.swiper-container .item .thumbnail:hover{opacity:0.85}.swiper-container .item .title{position:absolute;z-index:1;left:0;right:0;bottom:0;text-align:center;background:linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.45));white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#fff;font-size:15px;padding:10px;font-weight:normal}.swiper-container .item .icon{position:absolute;z-index:1;top:10px;left:10px;width:18px;height:18px;fill:#fff;opacity:0.5}.swiper-container.swiper-container-horizontal .swiper-pagination-bullets{bottom:unset;left:unset;width:auto;right:10px;top:10px} | ||||
|  | ||||
| @ -80,6 +80,99 @@ | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     &__hot { | ||||
|         padding-top: 15px; | ||||
|         &-list { | ||||
|             display: flex; | ||||
|             margin: 0 -5px; | ||||
|             .item { | ||||
|                 width: 25%; | ||||
|                 padding: 0 5px; | ||||
|                 .link { | ||||
|                     display: block; | ||||
|                     .inner { | ||||
|                         position: relative; | ||||
|                         cursor: pointer; | ||||
|                         &:hover { | ||||
|                             .image { | ||||
|                                 opacity: 0.85; | ||||
|                             } | ||||
|                             .title { | ||||
|                                 background: var(--classC); | ||||
|                             } | ||||
|                         } | ||||
|                         .image { | ||||
|                             width: 100%; | ||||
|                             height: 125px; | ||||
|                             object-fit: cover; | ||||
|                             border-radius: 5px 5px 0 0; | ||||
|                             transition: opacity 0.35s; | ||||
|                         } | ||||
|                         .title { | ||||
|                             font-size: 13px; | ||||
|                             white-space: nowrap; | ||||
|                             overflow: hidden; | ||||
|                             text-overflow: ellipsis; | ||||
|                             text-align: center; | ||||
|                             padding: 0 8px; | ||||
|                             line-height: 32px; | ||||
|                             color: var(--minor); | ||||
|                             background: var(--classD); | ||||
|                             border-radius: 0 0 5px 5px; | ||||
|                             transition: background 0.35s; | ||||
|                         } | ||||
|                         .views { | ||||
|                             display: flex; | ||||
|                             align-items: center; | ||||
|                             position: absolute; | ||||
|                             z-index: 1; | ||||
|                             top: 5px; | ||||
|                             right: 5px; | ||||
|                             background-image: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); | ||||
|                             color: #fff; | ||||
|                             font-size: 12px; | ||||
|                             height: 18px; | ||||
|                             padding: 0 8px; | ||||
|                             border-radius: 2px; | ||||
|                             white-space: nowrap; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     &__title { | ||||
|         display: flex; | ||||
|         align-items: center; | ||||
|         border-bottom: 1px solid var(--classC); | ||||
|         &-title { | ||||
|             position: relative; | ||||
|             display: flex; | ||||
|             align-items: center; | ||||
|             color: var(--routine); | ||||
|             font-weight: 500; | ||||
|             height: 40px; | ||||
|             line-height: 40px; | ||||
|             .item { | ||||
|                 cursor: pointer; | ||||
|                 margin-right: 20px; | ||||
|                 user-select: none; | ||||
|                 transition: color 0.35s; | ||||
|                 &.active { | ||||
|                     color: var(--theme); | ||||
|                 } | ||||
|             } | ||||
|             .line { | ||||
|                 position: absolute; | ||||
|                 bottom: -1px; | ||||
|                 left: 0; | ||||
|                 height: 2px; | ||||
|                 border-radius: 1px; | ||||
|                 background: var(--theme); | ||||
|                 transition: left 0.35s, width 0.35s; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| .swiper-container { | ||||
|  | ||||
| @ -1,4 +1,6 @@ | ||||
| window.Joe = function () { | ||||
|     const BASE_API = '/index.php/joe/api'; | ||||
| 
 | ||||
|     let IsMobile = false; | ||||
|     if (/windows phone|iphone|android/gi.test(window.navigator.userAgent)) { | ||||
|         IsMobile = true; | ||||
| @ -103,7 +105,11 @@ window.Joe = function () { | ||||
|     /* Ranking */ | ||||
|     if ($('.joe_aside__item.ranking').length !== 0) { | ||||
|         $.ajax({ | ||||
|             url: '/index.php/action/ranking', | ||||
|             url: BASE_API, | ||||
|             type: 'POST', | ||||
|             data: { | ||||
|                 routeType: 'ranking' | ||||
|             }, | ||||
|             success(res) { | ||||
|                 $('.joe_aside__item.ranking .joe_aside__item-title .text').html(res.title); | ||||
|                 let htmlStr = ''; | ||||
| @ -131,6 +137,54 @@ window.Joe = function () { | ||||
|         new Swiper('.swiper-container', { direction, loop: true, autoplay: true, mousewheel: true, pagination: { el: '.swiper-pagination' } }); | ||||
|     } | ||||
| 
 | ||||
|     /* Index Title */ | ||||
|     if ($('.joe_index__list').length > 0) { | ||||
|         let queryData = { page: 1, pageSize: 10, type: 'created' }; | ||||
|         const initDom = () => { | ||||
|             $('.joe_index__list').html(''); | ||||
|             const activeItem = $(`.joe_index__title-title .item[data-type="${queryData.type}"]`); | ||||
|             const activeLine = $('.joe_index__title-title .line'); | ||||
|             activeItem.addClass('active').siblings().removeClass('active'); | ||||
|             activeLine.css({ left: activeItem.position().left, width: activeItem.width() }); | ||||
|         }; | ||||
|         const pushDom = () => { | ||||
|             $.ajax({ | ||||
|                 url: BASE_API, | ||||
|                 type: 'POST', | ||||
|                 data: { | ||||
|                     routeType: 'list', | ||||
|                     page: queryData.page, | ||||
|                     pageSize: queryData.pageSize, | ||||
|                     type: queryData.type | ||||
|                 }, | ||||
|                 success(res) { | ||||
|                     res.data.forEach(_ => { | ||||
|                         $('.joe_index__list').append(` | ||||
|                             <li class="joe_list__list"> | ||||
|                                 <div class="line"></div> | ||||
|                                 <a href="${_.permalink}" class="thumbnail" title="${_.title}"> | ||||
|                                     <img alt="" /> | ||||
|                                     <time datetime="${_.time}">${_.time}</time> | ||||
|                                     <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="20"> | ||||
|                                         <path d="M903.93077753 107.30625876H115.78633587C64.57261118 107.30625876 22.58166006 149.81138495 22.58166006 201.02510964v624.26547214c0 51.7240923 41.99095114 93.71694641 93.71694641 93.7169464h788.14444164c51.7202834 0 93.71694641-41.99285557 93.71694642-93.7169464v-624.26547214c-0.51227057-51.21372469-43.01739676-93.71885088-94.229217-93.71885088zM115.78633587 171.8333054h788.65671224c16.385041 0 29.70407483 13.31522639 29.70407484 29.70407482v390.22828696l-173.60830179-189.48107072c-12.80486025-13.82749697-30.21634542-21.50774542-48.14010264-19.97093513-17.92375723 1.02073227-34.82106734 10.75387344-46.60138495 26.11437327l-172.58185762 239.1598896-87.06123767-85.52061846c-12.28878076-11.78222353-27.65308802-17.92375723-44.03812902-17.92375577-16.3907529 0.50846167-31.75506163 7.67644101-43.52966736 20.48129978L86.59453164 821.70468765V202.04965083c-1.02454117-17.41529409 12.80486025-30.73052046 29.19180423-30.21634543zM903.93077753 855.50692718H141.90642105l222.25496164-245.81940722 87.0593347 86.03669649c12.80105134 12.80676323 30.21253651 18.95020139 47.11555999 17.4172 17.40958218-1.53871621 33.79652618-11.26614404 45.06267018-26.11818071l172.58376063-238.64762047 216.11152349 236.08817198 2.05098681-1.54062067v142.87778132c0.50846167 16.3907529-13.31522639 29.70597929-30.21444096 29.70597928z m0 0" p-id="1916"></path> | ||||
|                                         <path d="M318.07226687 509.82713538c79.88945091 0 144.41649754-65.03741277 144.41649754-144.41649753 0-79.37718032-64.52704663-144.92495923-144.41649754-144.92495922-79.89135536 0-144.41649754 64.52704663-144.41649756 144.41268862 0 79.89135536 64.52514218 144.92876814 144.41649756 144.92876813z m0-225.3266807c44.55230407 0 80.91208763 36.36168802 80.91208762 80.91018317 0 44.55611297-35.84751297 81.43007159-80.91208762 81.43007012-45.06838356 0-80.91589654-36.35978356-80.91589508-80.91589507 0-44.55611297 36.87205415-81.42435823 80.91589508-81.42435822z m0 0" p-id="1917"></path> | ||||
|                                     </svg> | ||||
|                                 </a> | ||||
|                             </li> | ||||
|                         `);
 | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|         }; | ||||
|         initDom(); | ||||
|         pushDom(); | ||||
|         $('.joe_index__title-title .item').on('click', function () { | ||||
|             queryData = { page: 1, pageSize: 10, type: $(this).attr('data-type') }; | ||||
|             initDom(); | ||||
|             pushDom(); | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     new LazyLoad('.lazyload'); | ||||
| }; | ||||
| 
 | ||||
|  | ||||
| @ -1,35 +1,19 @@ | ||||
| <?php | ||||
| 
 | ||||
| require_once('route.php'); | ||||
| 
 | ||||
| function themeInit($self) | ||||
| { | ||||
|     $path_info = $self->request->getPathinfo(); | ||||
|     switch ($path_info) { | ||||
|         case '/action/ranking': | ||||
|             _getRanking($self); | ||||
|             break; | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| function _getRanking($self) | ||||
| { | ||||
|     header("HTTP/1.1 200 OK"); | ||||
|     $ranking_txt = Helper::options()->JAside_Ranking; | ||||
|     $ranking_arr = explode("$", $ranking_txt); | ||||
|     $arrContextOptions = ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false,]]; | ||||
|     $json = file_get_contents("https://the.top/v1/{$ranking_arr[1]}/1/9", false, stream_context_create($arrContextOptions)); | ||||
|     $res = json_decode($json, TRUE); | ||||
|     if ($res['code'] === 0) { | ||||
|         $self->response->throwJson([ | ||||
|             "code" => 1, | ||||
|             "title" => $ranking_arr[0], | ||||
|             "data" => $res["data"] | ||||
|         ]); | ||||
|     } else { | ||||
|         $self->response->throwJson([ | ||||
|             "code" => 0, | ||||
|             "title" => $ranking_arr[0], | ||||
|             "data" => null | ||||
|         ]); | ||||
|     if ($path_info === "/joe/api") { | ||||
|         switch ($self->request->routeType) { | ||||
|             case 'ranking': | ||||
|                 _getRanking($self); | ||||
|                 break; | ||||
|             case 'list': | ||||
|                 _getPost($self); | ||||
|                 break; | ||||
|         }; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -76,7 +60,22 @@ function _getAsideAuthorMotto() | ||||
|     echo $JMottoRandom[array_rand($JMottoRandom, 1)]; | ||||
| } | ||||
| 
 | ||||
| function _getThumbnail($item) | ||||
| function _getAbstract($item, $type = true) | ||||
| { | ||||
|     $abstract = ""; | ||||
|     if ($item->fields->abstract) { | ||||
|         $abstract = $item->fields->abstract; | ||||
|     } else { | ||||
|         $abstract = $item->excerpt; | ||||
|     } | ||||
|     if ($type) { | ||||
|         echo $abstract; | ||||
|     } else { | ||||
|         return $abstract; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| function _getThumbnail($item, $type = true) | ||||
| { | ||||
|     $randomThumb = 'https://cdn.jsdelivr.net/npm/typecho_joe_theme@4.3.5/assets/img/random/' . rand(1, 25) . '.webp'; | ||||
|     $custom_thumbnail = Helper::options()->JThumbnail; | ||||
| @ -96,7 +95,11 @@ function _getThumbnail($item) | ||||
|     } elseif (preg_match_all($patternMDfoot, $item->content, $thumbUrl)) { | ||||
|         $randomThumb = $thumbUrl[1][0]; | ||||
|     } | ||||
|     echo $randomThumb; | ||||
|     if ($type) { | ||||
|         echo $randomThumb; | ||||
|     } else { | ||||
|         return $randomThumb; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| function _getViews($item) | ||||
| @ -209,6 +212,16 @@ function themeFields($layout) | ||||
|             3、若文章无图片,并且外观设置里填写了·自定义缩略图·选项,则取自定义缩略图图片' | ||||
|     ); | ||||
|     $layout->addItem($thumb); | ||||
| 
 | ||||
|     $abstract = new Typecho_Widget_Helper_Form_Element_Textarea( | ||||
|         'abstract', | ||||
|         NULL, | ||||
|         NULL, | ||||
|         '自定义文章摘要', | ||||
|         '填写时:将会显示填写的摘要 <br> | ||||
|          不填写时:默认取文章里的内容' | ||||
|     ); | ||||
|     $layout->addItem($abstract); | ||||
| } | ||||
| 
 | ||||
| class Widget_Contents_Hot extends Widget_Abstract_Contents | ||||
| @ -228,3 +241,22 @@ class Widget_Contents_Hot extends Widget_Abstract_Contents | ||||
|         ); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| class Widget_Contents_Sort extends Widget_Abstract_Contents | ||||
| { | ||||
|     public function execute() | ||||
|     { | ||||
|         $this->parameter->setDefault(array('page' => 1, 'pageSize' => 10, 'type' => 'created')); | ||||
|         $offset = $this->parameter->pageSize * ($this->parameter->page - 1); | ||||
|         $this->db->fetchAll( | ||||
|             $this->select() | ||||
|                 ->from('table.contents') | ||||
|                 ->where('table.contents.type = ?', 'post') | ||||
|                 ->where('table.contents.status = ?', 'publish') | ||||
|                 ->limit($this->parameter->pageSize) | ||||
|                 ->offset($offset) | ||||
|                 ->order($this->parameter->type, Typecho_Db::SORT_DESC), | ||||
|             array($this, 'push') | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										48
									
								
								core/route.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								core/route.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| <?php | ||||
| function _getRanking($self) | ||||
| { | ||||
|     header("HTTP/1.1 200 OK"); | ||||
|     $ranking_txt = Helper::options()->JAside_Ranking; | ||||
|     $ranking_arr = explode("$", $ranking_txt); | ||||
|     $arrContextOptions = ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false,]]; | ||||
|     $json = file_get_contents("https://the.top/v1/{$ranking_arr[1]}/1/9", false, stream_context_create($arrContextOptions)); | ||||
|     $res = json_decode($json, TRUE); | ||||
|     if ($res['code'] === 0) { | ||||
|         $self->response->throwJson([ | ||||
|             "code" => 1, | ||||
|             "title" => $ranking_arr[0], | ||||
|             "data" => $res["data"] | ||||
|         ]); | ||||
|     } else { | ||||
|         $self->response->throwJson([ | ||||
|             "code" => 0, | ||||
|             "title" => $ranking_arr[0], | ||||
|             "data" => null | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| function _getPost($self) | ||||
| { | ||||
|     header("HTTP/1.1 200 OK"); | ||||
|     $page = $self->request->page; | ||||
|     $pageSize = $self->request->pageSize; | ||||
|     $type = $self->request->type; | ||||
|     $result = []; | ||||
|     $self->widget('Widget_Contents_Sort', 'page=' . $page . '&pageSize=' . $pageSize . '&type=' . $type)->to($item); | ||||
|     while ($item->next()) { | ||||
|         $result[] = array( | ||||
|             "image" => _getThumbnail($item, false), | ||||
|             "time" => date('Y-m-d', $item->created), | ||||
|             "created" => date('Y年m月d日', $item->created), | ||||
|             "title" => $item->title, | ||||
|             "abstract" => _getAbstract($item, false), | ||||
|             "category" => $item->categories, | ||||
|             "views" => number_format($item->views), | ||||
|             "commentsNum" => number_format($item->commentsNum), | ||||
|             "agree" => number_format($item->agree), | ||||
|             "permalink" => $item->permalink, | ||||
|         ); | ||||
|     }; | ||||
|     $self->response->throwJson(array("data" => $result)); | ||||
| } | ||||
| @ -6,8 +6,8 @@ function themeConfig($form) | ||||
|     $_db = Typecho_Db::get(); | ||||
|     $_prefix = $_db->getPrefix(); | ||||
|     try { | ||||
|         if (!array_key_exists('view', $_db->fetchRow($_db->select()->from('table.contents')->page(1, 1)))) { | ||||
|             $_db->query('ALTER TABLE `' . $_prefix . 'contents` ADD `view` INT DEFAULT 0;'); | ||||
|         if (!array_key_exists('views', $_db->fetchRow($_db->select()->from('table.contents')->page(1, 1)))) { | ||||
|             $_db->query('ALTER TABLE `' . $_prefix . 'contents` ADD `views` INT DEFAULT 0;'); | ||||
|         } | ||||
|         if (!array_key_exists('agree', $_db->fetchRow($_db->select()->from('table.contents')->page(1, 1)))) { | ||||
|             $_db->query('ALTER TABLE `' . $_prefix . 'contents` ADD `agree` INT DEFAULT 0;'); | ||||
| @ -337,4 +337,14 @@ function themeConfig($form) | ||||
|     ); | ||||
|     $JIndex_Recommend->setAttribute('class', 'joe_content joe_index'); | ||||
|     $form->addInput($JIndex_Recommend); | ||||
| 
 | ||||
|     $JIndex_Hot = new Typecho_Widget_Helper_Form_Element_Radio( | ||||
|         'JIndex_Hot', | ||||
|         array('off' => '关闭(默认)', 'on' => '开启'), | ||||
|         'off', | ||||
|         '是否开启首页热门文章', | ||||
|         '介绍:开启后,网站首页将会显示浏览量最多的4篇热门文章' | ||||
|     ); | ||||
|     $JIndex_Hot->setAttribute('class', 'joe_content joe_index'); | ||||
|     $form->addInput($JIndex_Hot->multiMode()); | ||||
| } ?>
 | ||||
							
								
								
									
										32
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								index.php
									
									
									
									
									
								
							| @ -24,7 +24,6 @@ | ||||
|         <div class="joe_container"> | ||||
|             <div class="joe_main"> | ||||
|                 <div class="joe_index"> | ||||
| 
 | ||||
|                     <?php | ||||
|                     /* 轮播图 */ | ||||
|                     $carousel = []; | ||||
| @ -74,7 +73,7 @@ | ||||
|                                         <?php $this->widget('Widget_Archive', 'pageSize=1&type=post', 'cid=' . $cid)->to($item); ?>
 | ||||
|                                         <figure class="item"> | ||||
|                                             <a class="thumbnail" href="<?php $item->permalink() ?>" title="<?php $item->title() ?>"> | ||||
|                                                 <img class="lazyload" alt="<?php $item->title() ?>" width="100%" /> | ||||
|                                                 <img class="lazyload" src="<?php _getLazyload(); ?>" data-original="<?php _getThumbnail($item); ?>" alt="<?php $item->title() ?>" width="100%" /> | ||||
|                                             </a> | ||||
|                                             <figcaption class="information"> | ||||
|                                                 <span class="information_type">推荐</span> | ||||
| @ -86,7 +85,34 @@ | ||||
|                             <?php endif; ?>
 | ||||
|                         </div> | ||||
|                     <?php endif; ?>
 | ||||
| 
 | ||||
|                     <?php if ($this->options->JIndex_Hot === "on") : ?>
 | ||||
|                         <?php $this->widget('Widget_Contents_Hot@Index', 'pageSize=4')->to($item); ?>
 | ||||
|                         <div class="joe_index__hot"> | ||||
|                             <ul class="joe_index__hot-list"> | ||||
|                                 <?php while ($item->next()) : ?>
 | ||||
|                                     <li class="item"> | ||||
|                                         <a class="link" href="<?php $item->permalink(); ?>" title="<?php $item->title(); ?>"> | ||||
|                                             <figure class="inner"> | ||||
|                                                 <span class="views"><?php _getViews($item); ?></span>
 | ||||
|                                                 <img class="image lazyload" src="<?php _getLazyload(); ?>" data-original="<?php _getThumbnail($item); ?>" alt="<?php $item->title(); ?>" /> | ||||
|                                                 <figcaption class="title"><?php $item->title(); ?></figcaption>
 | ||||
|                                             </figure> | ||||
|                                         </a> | ||||
|                                     </li> | ||||
|                                 <?php endwhile; ?>
 | ||||
|                             </ul> | ||||
|                         </div> | ||||
|                     <?php endif; ?>
 | ||||
|                     <div class="joe_index__title"> | ||||
|                         <ul class="joe_index__title-title"> | ||||
|                             <li class="item" data-type="created">最新文章</li> | ||||
|                             <li class="item" data-type="commentsNum">评论最多</li> | ||||
|                             <li class="item" data-type="agree">点赞最多</li> | ||||
|                             <li class="item" data-type="views">浏览最多</li> | ||||
|                             <li class="line"></li> | ||||
|                         </ul> | ||||
|                     </div> | ||||
|                     <ul class="joe_list joe_index__list"></ul> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <?php $this->need('public/aside.php'); ?>
 | ||||
|  | ||||
| @ -51,7 +51,7 @@ | ||||
|                     <span class="text">热门文章</span> | ||||
|                     <span class="line"></span> | ||||
|                 </div> | ||||
|                 <?php $this->widget('Widget_Contents_Hot', 'pageSize=' . $this->options->JAside_Hot_Num)->to($item); ?>
 | ||||
|                 <?php $this->widget('Widget_Contents_Hot@Aside', 'pageSize=' . $this->options->JAside_Hot_Num)->to($item); ?>
 | ||||
|                 <ol class="joe_aside__item-contain"> | ||||
|                     <?php if ($item->have()) : ?>
 | ||||
|                         <?php $index = 1; ?>
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 杜恒
						杜恒