Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion inc/core-rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ function ajax_get_all_posts_callback() {
$rows = tryGetValue( 'rows', 10 );
$page = tryGetValue( 'page', 1 );

$sticky_ids = get_option('sticky_posts');
$sticky_posts = []; //置顶文章
if( ($type === 'all' || $type === 'post') && count($sticky_ids)>0 && $page <= 1 ){
$args = array(
'post__in' => $sticky_ids,
'posts_per_page' => 4,
'ignore_sticky_posts' => 1
);
$sticky_posts = query_posts($args);
}else{
$sticky_posts = [];
}

// 查询条件
$args = [
'post_type' => $type,
Expand All @@ -35,6 +48,7 @@ function ajax_get_all_posts_callback() {
'order' => 'DESC',
'author' => get_current_user_id(),
'tax_query' => [],
'post__not_in' => $sticky_ids,
// 'has_password' => false,
];

Expand Down Expand Up @@ -89,6 +103,7 @@ function ajax_get_all_posts_callback() {
}

$posts = get_posts( $args ); // 文章
$posts = array_merge($sticky_posts, $posts);

$args['posts_per_page'] = - 1;
$args['fields'] = 'ids';
Expand Down Expand Up @@ -144,7 +159,8 @@ function ajax_get_all_posts_callback() {
}

$post->thumbnail = replace_domain( $post->thumbnail );

$sticky_ids = get_option('sticky_posts');
$post->is_sticky = is_array($sticky_ids) && in_array($post->id, $sticky_ids);//是否置顶
return $post;
}, $posts );

Expand Down
5 changes: 5 additions & 0 deletions static/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ class Language {
"zh_TC": "全部儲存",
"ja": "全部を保存"
},
"Sticky": {
"zh_SC": "置顶",
"zh_TC": "置頂",
"ja": "上"
},
}
}

Expand Down
15 changes: 8 additions & 7 deletions static/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const $modules = new function () {
<div class="tile-title text-ellipsis">{{ author.display_name }}</div>
<small class="text-gray d-block">{{ author.description }}</small>
</div>

<div class="tile-action flex-center">
<button class="btn btn-action btn-link text-gray flex-center mx-1" @click="handlePraise" :class="{ 'text-error': praise }">
<i :class="'czs-heart' + (praise ? '' : '-l')"></i>
Expand Down Expand Up @@ -196,11 +196,11 @@ const $modules = new function () {
>
<p><br></p>
</div>

<input v-if="features.includes('upload')" ref="upload" class="d-none" type="file" multiple @change="handleUpload" />

<attachment-chips v-if="files.length" v-bind="{ attachments: files, showClose: true }" @remove="handleRemoveFile" style="margin: 0" />

<div class="editor-footer flex-center justify-between">
<div class="editor-tool d-flex">
<slot name="tool">
Expand Down Expand Up @@ -541,7 +541,7 @@ const $modules = new function () {
<div v-if="metas.length" class="comment-metas flex-center justify-start mt-1">
<span v-for="item of metas" :key="item.name" :class="['text-gray mr-2', { tooltip: !!item.tooltip }]" :data-tooltip="item.tooltip">{{ item.name }}</span>
</div>

<template v-if="showReply">
<div class="divider"></div>
<div class="text-tiny">
Expand Down Expand Up @@ -842,6 +842,7 @@ const $modules = new function () {
<div class="tile d-block">
<div class="tile-header flex-center justify-between">
<div class="article-header text-gray text-tiny d-flex align-center">
<span v-if="note.is_sticky"class="sticky-icon mt-2">{{ $lang.translate('Sticky') }}</span>
<h3 v-if="isPost" class="text-dark h5 mt-2 mb-0">
<a :href="note.permalink">{{ note.title }}</a>
</h3>
Expand All @@ -856,7 +857,7 @@ const $modules = new function () {
<span v-if="note.status === 'private'" class="chip bg-gray text-gray">{{ note.status.toLocaleUpperCase() }}</span>
</div>
</div>

<slot name="right-icon">
<div v-if="!isPost && logged" class="dropdown mr-1" hover-show>
<a href="javascript:void(0);" class="btn btn-link btn-action btn-sm flex-center dropdown-toggle text-gray" tabindex="0">
Expand Down Expand Up @@ -901,7 +902,7 @@ const $modules = new function () {
<i class="czs-talk mr-1"></i> {{ note.comment_count }}
</button>
</div>

<a v-if="isPost" class="btn btn-link btn-sm text-gray d-flex align-center" :href="note.permalink">
{{ $lang.translate('Read Article') }} <i class="dashicons dashicons-arrow-right-alt ml-1"></i>
</a>
Expand Down
12 changes: 12 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,18 @@ body .layout #notes .notes-list {
body .layout #notes .notes-item {
border-radius: 0.5rem;
}

body .layout #notes .notes-item .sticky-icon {
padding: .2rem .4rem;
font-size: .6rem;
background-color: #3366ff;
color: #fff;
border-radius: 4px;
display: inline-block;
position: relative;
margin-right: .4rem;
}

body .layout #notes .notes-item:not(:last-child) .divider {
margin: 1rem 0;
}
Expand Down