🎨 文件历史支持按文档名搜索 Fix https://github.com/siyuan-note/siyuan/issues/6257

This commit is contained in:
Liang Ding 2022-10-18 18:27:35 +08:00
parent ae98a6dba5
commit 16e2bc6904
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 13 additions and 7 deletions

View file

@ -29,7 +29,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
const mdElement = element.querySelector('.history__text[data-type="mdPanel"]') as HTMLTextAreaElement;
docElement.classList.add("fn__none");
mdElement.classList.add("fn__none");
if (typeElement.value === "0") {
if (typeElement.value === "0" || typeElement.value === "1") {
opElement.removeAttribute("disabled");
notebookElement.removeAttribute("disabled");
assetElement.classList.add("fn__none");
@ -65,7 +65,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
if (item.items.length > 0) {
logsHTML += `<ul class="${index === 0 ? "" : "fn__none"}">`;
item.items.forEach((docItem) => {
logsHTML += `<li title="${escapeHtml(docItem.title)}" data-type="${typeElement.value === "1" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 32px">
logsHTML += `<li title="${escapeHtml(docItem.title)}" data-type="${typeElement.value === "2" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 32px">
<span class="b3-list-item__text">${escapeHtml(docItem.title)}</span>
<span class="fn__space"></span>
<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}">
@ -239,8 +239,9 @@ export const openHistory = () => {
</div>
<span class="fn__space"></span>
<select data-type="typeselect" class="b3-select" style="min-width: auto">
<option value="0" selected>${window.siyuan.languages.doc}</option>
<option value="1">${window.siyuan.languages.assets}</option>
<option value="0" selected>${window.siyuan.languages.docName}</option>
<option value="1">${window.siyuan.languages.doc}</option>
<option value="2">${window.siyuan.languages.assets}</option>
</select>
<span class="fn__space"></span>
<select data-type="opselect" class="b3-select" style="min-width: auto">

View file

@ -343,7 +343,11 @@ func FullTextSearchHistory(query, box, op string, typ, page int) (ret []*History
stmt += "1=1"
}
if HistoryTypeDoc == typ {
if HistoryTypeDocName == typ {
stmt = strings.ReplaceAll(stmt, "{title content}", "{title}")
}
if HistoryTypeDocName == typ || HistoryTypeDoc == typ {
if "all" != op {
stmt += " AND op = '" + op + "'"
}
@ -578,8 +582,9 @@ func ReindexHistory() (err error) {
var validOps = []string{HistoryOpClean, HistoryOpUpdate, HistoryOpDelete, HistoryOpFormat, HistoryOpSync}
const (
HistoryTypeDoc = 0
HistoryTypeAsset = 1
HistoryTypeDocName = 0
HistoryTypeDoc = 1
HistoryTypeAsset = 2
)
func indexHistoryDir(name string, luteEngine *lute.Lute) {