Skip to content

Commit

Permalink
🎨 重置数据仓库 Fix #5212
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jun 18, 2022
1 parent f23764f commit 0361de4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/appearance/langs/en_US.json
@@ -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",
"dataSnapshot": "Data snapshot",
"copyKey": "Copy key string",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/fr_FR.json
@@ -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é",
"dataSnapshot": "Instantané de données",
"copyKey": "Copier la chaîne de clé",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/zh_CHT.json
@@ -1,4 +1,6 @@
{
"resetRepoTip": "重置數據倉庫會徹底刪除密鑰和所有快照,確定進行重置嗎?",
"resetRepo": "重置數據倉庫",
"createSnapshot": "創建快照",
"dataSnapshot": "數據快照",
"copyKey": "複製密鑰字符串",
Expand Down
2 changes: 2 additions & 0 deletions app/appearance/langs/zh_CN.json
@@ -1,4 +1,6 @@
{
"resetRepoTip": "重置数据仓库会彻底删除密钥和所有快照,确定进行重置吗?",
"resetRepo": "重置数据仓库",
"createSnapshot": "创建快照",
"dataSnapshot": "数据快照",
"copyKey": "复制密钥字符串",
Expand Down
8 changes: 4 additions & 4 deletions app/src/config/about.ts
Expand Up @@ -104,8 +104,8 @@ export const about = {
<svg><use xlink:href="#iconCopy"></use></svg>${window.siyuan.languages.copyKey}
</button>
<div class="fn__hr"></div>
<button class="b3-button b3-button--outline fn__size200" id="removeKey">
<svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.remove}
<button class="b3-button b3-button--outline fn__size200" id="resetRepo">
<svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.resetRepo}
</button>
</div>
</div>
Expand Down Expand Up @@ -249,8 +249,8 @@ export const about = {
showMessage(window.siyuan.languages.copied);
writeText(window.siyuan.config.repo.key);
});
about.element.querySelector("#removeKey").addEventListener("click", () => {
confirmDialog(window.siyuan.languages.remove, "", () => {
about.element.querySelector("#resetRepo").addEventListener("click", () => {
confirmDialog("⚠️ " + window.siyuan.languages.resetRepo, window.siyuan.languages.resetRepoTip, () => {
fetchPost("/api/repo/resetRepo", {}, () => {
window.siyuan.config.repo.key = "";
importKeyElement.parentElement.classList.remove("fn__none");
Expand Down
4 changes: 2 additions & 2 deletions kernel/api/repo.go
Expand Up @@ -93,8 +93,8 @@ func importRepoKey(c *gin.Context) {
return
}

hexKey := arg["key"].(string)
if err := model.ImportRepoKey(hexKey); nil != err {
base64Key := arg["key"].(string)
if err := model.ImportRepoKey(base64Key); nil != err {
ret.Code = -1
ret.Msg = model.Conf.Language(137)
return
Expand Down
6 changes: 3 additions & 3 deletions kernel/model/repository.go
Expand Up @@ -18,7 +18,7 @@ package model

import (
"crypto/rand"
"encoding/hex"
"encoding/base64"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -59,10 +59,10 @@ func GetRepoIndexLogs(page int) (logs []*dejavu.Log, pageCount, totalCount int,
return
}

func ImportRepoKey(hexKey string) (err error) {
func ImportRepoKey(base64Key string) (err error) {
msgId := util.PushMsg(Conf.Language(136), 1000*7)

key, err := hex.DecodeString(hexKey)
key, err := base64.StdEncoding.DecodeString(base64Key)
if nil != err {
return
}
Expand Down

0 comments on commit 0361de4

Please sign in to comment.