This commit is contained in:
Liang Ding 2022-06-18 23:11:03 +08:00
parent f23764fee0
commit 0361de475f
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
7 changed files with 17 additions and 9 deletions

View File

@ -1,4 +1,6 @@
{ {
"resetRepoTip": "Resetting the data repository will completely delete the key and all snapshots, are you sure you want to reset?",
"resetRepo": "Reset data repo",
"createSnapshot": "Create snapshot", "createSnapshot": "Create snapshot",
"dataSnapshot": "Data snapshot", "dataSnapshot": "Data snapshot",
"copyKey": "Copy key string", "copyKey": "Copy key string",

View File

@ -1,4 +1,6 @@
{ {
"resetRepoTip": "La réinitialisation du référentiel de données supprimera complètement la clé et tous les instantanés, êtes-vous sûr de vouloir réinitialiser ?",
"resetRepo": "Réinitialiser le référentiel de données",
"createSnapshot": "Créer un instantané", "createSnapshot": "Créer un instantané",
"dataSnapshot": "Instantané de données", "dataSnapshot": "Instantané de données",
"copyKey": "Copier la chaîne de clé", "copyKey": "Copier la chaîne de clé",

View File

@ -1,4 +1,6 @@
{ {
"resetRepoTip": "重置數據倉庫會徹底刪除密鑰和所有快照,確定進行重置嗎?",
"resetRepo": "重置數據倉庫",
"createSnapshot": "創建快照", "createSnapshot": "創建快照",
"dataSnapshot": "數據快照", "dataSnapshot": "數據快照",
"copyKey": "複製密鑰字符串", "copyKey": "複製密鑰字符串",

View File

@ -1,4 +1,6 @@
{ {
"resetRepoTip": "重置数据仓库会彻底删除密钥和所有快照,确定进行重置吗?",
"resetRepo": "重置数据仓库",
"createSnapshot": "创建快照", "createSnapshot": "创建快照",
"dataSnapshot": "数据快照", "dataSnapshot": "数据快照",
"copyKey": "复制密钥字符串", "copyKey": "复制密钥字符串",

View File

@ -104,8 +104,8 @@ export const about = {
<svg><use xlink:href="#iconCopy"></use></svg>${window.siyuan.languages.copyKey} <svg><use xlink:href="#iconCopy"></use></svg>${window.siyuan.languages.copyKey}
</button> </button>
<div class="fn__hr"></div> <div class="fn__hr"></div>
<button class="b3-button b3-button--outline fn__size200" id="removeKey"> <button class="b3-button b3-button--outline fn__size200" id="resetRepo">
<svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.remove} <svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.resetRepo}
</button> </button>
</div> </div>
</div> </div>
@ -249,8 +249,8 @@ export const about = {
showMessage(window.siyuan.languages.copied); showMessage(window.siyuan.languages.copied);
writeText(window.siyuan.config.repo.key); writeText(window.siyuan.config.repo.key);
}); });
about.element.querySelector("#removeKey").addEventListener("click", () => { about.element.querySelector("#resetRepo").addEventListener("click", () => {
confirmDialog(window.siyuan.languages.remove, "", () => { confirmDialog("⚠️ " + window.siyuan.languages.resetRepo, window.siyuan.languages.resetRepoTip, () => {
fetchPost("/api/repo/resetRepo", {}, () => { fetchPost("/api/repo/resetRepo", {}, () => {
window.siyuan.config.repo.key = ""; window.siyuan.config.repo.key = "";
importKeyElement.parentElement.classList.remove("fn__none"); importKeyElement.parentElement.classList.remove("fn__none");

View File

@ -93,8 +93,8 @@ func importRepoKey(c *gin.Context) {
return return
} }
hexKey := arg["key"].(string) base64Key := arg["key"].(string)
if err := model.ImportRepoKey(hexKey); nil != err { if err := model.ImportRepoKey(base64Key); nil != err {
ret.Code = -1 ret.Code = -1
ret.Msg = model.Conf.Language(137) ret.Msg = model.Conf.Language(137)
return return

View File

@ -18,7 +18,7 @@ package model
import ( import (
"crypto/rand" "crypto/rand"
"encoding/hex" "encoding/base64"
"errors" "errors"
"fmt" "fmt"
"os" "os"
@ -59,10 +59,10 @@ func GetRepoIndexLogs(page int) (logs []*dejavu.Log, pageCount, totalCount int,
return return
} }
func ImportRepoKey(hexKey string) (err error) { func ImportRepoKey(base64Key string) (err error) {
msgId := util.PushMsg(Conf.Language(136), 1000*7) msgId := util.PushMsg(Conf.Language(136), 1000*7)
key, err := hex.DecodeString(hexKey) key, err := base64.StdEncoding.DecodeString(base64Key)
if nil != err { if nil != err {
return return
} }