Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:#33 排序 #41

Merged
merged 2 commits into from
Aug 29, 2022
Merged
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
20 changes: 14 additions & 6 deletions lib/metaweblog/metaWeblogApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ export class MetaWeblogApi {
// 错误处理
this.doFault(ret)

const postArray = ret.params.param.value.array.data.value || []
postArray.forEach((item: any) => {
const post = this.parsePost(item)
result.push(post)
})

let postArray = ret.params.param.value.array.data.value || []
if (ret.params.param.value.array.data.value instanceof Array) {
postArray.forEach((item: any) => {
const post = this.parsePost(item)
result.push(post)
})
} else {
const onePost = ret.params.param.value.array.data.value
if (onePost) {
const post = this.parsePost(onePost)
result.push(post)
}
}

logUtil.logInfo("result=>", result)
return result
}
Expand Down
3 changes: 2 additions & 1 deletion lib/siyuan/siYuanApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ async function getRootBlocks(page: number, pagesize: number, keyword: string) {
WHERE 1 = 1
and parent_id = ''
AND ((content LIKE '%${keyword}%') OR (tag LIKE '%${keyword}%'))
ORDER BY created DESC LIMIT ${page}, ${pagesize})`
ORDER BY created DESC LIMIT ${page}, ${pagesize})
ORDER BY created DESC`
let data = await sql(stmt)
return data
}
Expand Down