mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 19:41:31 +08:00
🎨 搜索区分大小写根据配置项单独建立索引 Fix https://github.com/siyuan-note/siyuan/issues/5889
This commit is contained in:
parent
ef095fe3d6
commit
0db807cea8
@ -134,8 +134,6 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
|||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<button id="includeChildCheck" class="b3-button b3-button--small${(notebookId && localData.idPath && !localData.idPath.endsWith(".sy")) ? "" : " b3-button--cancel"}">${window.siyuan.languages.includeChildDoc}</button>
|
<button id="includeChildCheck" class="b3-button b3-button--small${(notebookId && localData.idPath && !localData.idPath.endsWith(".sy")) ? "" : " b3-button--cancel"}">${window.siyuan.languages.includeChildDoc}</button>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<button id="searchCaseCheck" class="b3-button b3-button--small${window.siyuan.config.search.caseSensitive ? "" : " b3-button--cancel"}">${window.siyuan.languages.searchCaseSensitive}</button>
|
|
||||||
<span class="fn__space"></span>
|
|
||||||
<button id="searchSyntaxCheck" class="b3-button b3-button--small${localData.querySyntax ? "" : " b3-button--cancel"}">${window.siyuan.languages.querySyntax}</button>
|
<button id="searchSyntaxCheck" class="b3-button b3-button--small${localData.querySyntax ? "" : " b3-button--cancel"}">${window.siyuan.languages.querySyntax}</button>
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<span aria-label="${window.siyuan.languages.type}" class="b3-tooltips b3-tooltips__nw">
|
<span aria-label="${window.siyuan.languages.type}" class="b3-tooltips b3-tooltips__nw">
|
||||||
@ -306,14 +304,6 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
|||||||
inputEvent();
|
inputEvent();
|
||||||
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(localData));
|
localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(localData));
|
||||||
});
|
});
|
||||||
const searchCaseElement = dialog.element.querySelector("#searchCaseCheck");
|
|
||||||
searchCaseElement.addEventListener("click", () => {
|
|
||||||
searchCaseElement.classList.toggle("b3-button--cancel");
|
|
||||||
fetchPost("/api/setting/setSearchCaseSensitive", {caseSensitive: !searchCaseElement.classList.contains("b3-button--cancel")}, () => {
|
|
||||||
inputEvent();
|
|
||||||
window.siyuan.config.search.caseSensitive = !searchCaseElement.classList.contains("b3-button--cancel");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const searchPanelElement = dialog.element.querySelector("#searchList");
|
const searchPanelElement = dialog.element.querySelector("#searchList");
|
||||||
const searchInputElement = dialog.element.querySelector("#searchInput") as HTMLInputElement;
|
const searchInputElement = dialog.element.querySelector("#searchInput") as HTMLInputElement;
|
||||||
const replaceInputElement = dialog.element.querySelector("#replaceInput") as HTMLInputElement;
|
const replaceInputElement = dialog.element.querySelector("#replaceInput") as HTMLInputElement;
|
||||||
|
@ -228,7 +228,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/setting/getCustomCSS", model.CheckAuth, getCustomCSS)
|
ginServer.Handle("POST", "/api/setting/getCustomCSS", model.CheckAuth, getCustomCSS)
|
||||||
ginServer.Handle("POST", "/api/setting/setCustomCSS", model.CheckAuth, setCustomCSS)
|
ginServer.Handle("POST", "/api/setting/setCustomCSS", model.CheckAuth, setCustomCSS)
|
||||||
ginServer.Handle("POST", "/api/setting/setEmoji", model.CheckAuth, setEmoji)
|
ginServer.Handle("POST", "/api/setting/setEmoji", model.CheckAuth, setEmoji)
|
||||||
ginServer.Handle("POST", "/api/setting/setSearchCaseSensitive", model.CheckAuth, setSearchCaseSensitive)
|
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/graph/resetGraph", model.CheckAuth, resetGraph)
|
ginServer.Handle("POST", "/api/graph/resetGraph", model.CheckAuth, resetGraph)
|
||||||
ginServer.Handle("POST", "/api/graph/resetLocalGraph", model.CheckAuth, resetLocalGraph)
|
ginServer.Handle("POST", "/api/graph/resetLocalGraph", model.CheckAuth, resetLocalGraph)
|
||||||
|
@ -207,9 +207,14 @@ func setSearch(c *gin.Context) {
|
|||||||
s.Limit = 32
|
s.Limit = 32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldCaseSensitive := model.Conf.Search.CaseSensitive
|
||||||
|
|
||||||
model.Conf.Search = s
|
model.Conf.Search = s
|
||||||
model.Conf.Save()
|
model.Conf.Save()
|
||||||
sql.SetCaseSensitive(s.CaseSensitive)
|
sql.SetCaseSensitive(s.CaseSensitive)
|
||||||
|
if s.CaseSensitive != oldCaseSensitive {
|
||||||
|
model.RefreshFileTree()
|
||||||
|
}
|
||||||
sql.ClearVirtualRefKeywords()
|
sql.ClearVirtualRefKeywords()
|
||||||
ret.Data = s
|
ret.Data = s
|
||||||
}
|
}
|
||||||
@ -375,18 +380,3 @@ func setEmoji(c *gin.Context) {
|
|||||||
|
|
||||||
model.Conf.Editor.Emoji = emoji
|
model.Conf.Editor.Emoji = emoji
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSearchCaseSensitive(c *gin.Context) {
|
|
||||||
ret := gulu.Ret.NewResult()
|
|
||||||
defer c.JSON(http.StatusOK, ret)
|
|
||||||
|
|
||||||
arg, ok := util.JsonArg(c, ret)
|
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
caseSensitive := arg["caseSensitive"].(bool)
|
|
||||||
model.Conf.Search.CaseSensitive = caseSensitive
|
|
||||||
model.Conf.Save()
|
|
||||||
sql.SetCaseSensitive(caseSensitive)
|
|
||||||
}
|
|
||||||
|
@ -252,7 +252,10 @@ func initDBConnection() {
|
|||||||
db.SetConnMaxLifetime(365 * 24 * time.Hour)
|
db.SetConnMaxLifetime(365 * 24 * time.Hour)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var caseSensitive bool
|
||||||
|
|
||||||
func SetCaseSensitive(b bool) {
|
func SetCaseSensitive(b bool) {
|
||||||
|
caseSensitive = b
|
||||||
if b {
|
if b {
|
||||||
db.Exec("PRAGMA case_sensitive_like = ON;")
|
db.Exec("PRAGMA case_sensitive_like = ON;")
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,9 +124,12 @@ func insertBlocks0(tx *sql.Tx, bulk []*Block) (err error) {
|
|||||||
if err = prepareExecInsertTx(tx, stmt, valueArgs); nil != err {
|
if err = prepareExecInsertTx(tx, stmt, valueArgs); nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stmt = fmt.Sprintf(BlocksFTSCaseInsensitiveInsert, strings.Join(valueStrings, ","))
|
|
||||||
if err = prepareExecInsertTx(tx, stmt, valueArgs); nil != err {
|
if !caseSensitive {
|
||||||
return
|
stmt = fmt.Sprintf(BlocksFTSCaseInsensitiveInsert, strings.Join(valueStrings, ","))
|
||||||
|
if err = prepareExecInsertTx(tx, stmt, valueArgs); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user