mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
This commit is contained in:
parent
177b42c1ef
commit
e4b712547f
9 changed files with 22 additions and 14 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"dataRepo": "Data repo",
|
||||||
"newSubDoc": "Create sub doc",
|
"newSubDoc": "Create sub doc",
|
||||||
"newDocBelow": "Create doc below",
|
"newDocBelow": "Create doc below",
|
||||||
"newDocAbove": "Create doc above",
|
"newDocAbove": "Create doc above",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"dataRepo": "Repositorio de datos",
|
||||||
"newSubDoc": "Crear subdocumento",
|
"newSubDoc": "Crear subdocumento",
|
||||||
"newDocBelow": "Crear documento a continuación",
|
"newDocBelow": "Crear documento a continuación",
|
||||||
"newDocAbove": "Crear documento arriba",
|
"newDocAbove": "Crear documento arriba",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"dataRepo": "Dépôt de données",
|
||||||
"newSubDoc": "Créer un sous-doc",
|
"newSubDoc": "Créer un sous-doc",
|
||||||
"newDocBelow": "Créer un document ci-dessous",
|
"newDocBelow": "Créer un document ci-dessous",
|
||||||
"newDocAbove": "Créer un document ci-dessus",
|
"newDocAbove": "Créer un document ci-dessus",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"dataRepo": "數據倉庫",
|
||||||
"newSubDoc": "新建子文檔",
|
"newSubDoc": "新建子文檔",
|
||||||
"newDocBelow": "在下方新建文檔",
|
"newDocBelow": "在下方新建文檔",
|
||||||
"newDocAbove": "在上方新建文檔",
|
"newDocAbove": "在上方新建文檔",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"dataRepo": "数据仓库",
|
||||||
"newSubDoc": "新建子文档",
|
"newSubDoc": "新建子文档",
|
||||||
"newDocBelow": "在下方新建文档",
|
"newDocBelow": "在下方新建文档",
|
||||||
"newDocAbove": "在上方新建文档",
|
"newDocAbove": "在上方新建文档",
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ const renderCloudBackup = () => {
|
||||||
<ul class="b3-list">
|
<ul class="b3-list">
|
||||||
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sync}<span class="b3-list-item__meta">${response.data.sync ? response.data.sync.hSize : "0B"}</span></li>
|
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sync}<span class="b3-list-item__meta">${response.data.sync ? response.data.sync.hSize : "0B"}</span></li>
|
||||||
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.backup}<span class="b3-list-item__meta">${response.data.backup ? response.data.backup.hSize : "0B"}</span></li>
|
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.backup}<span class="b3-list-item__meta">${response.data.backup ? response.data.backup.hSize : "0B"}</span></li>
|
||||||
|
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.dataRepo}<span class="b3-list-item__meta">${response.data.hRepoSize}</span></li>
|
||||||
<li class="b3-list-item" style="cursor: auto;"><a href="https://ld246.com/settings/file?type=3" target="_blank">${window.siyuan.languages.cdn}</a><span class="b3-list-item__meta">${response.data.hAssetSize}</span></li>
|
<li class="b3-list-item" style="cursor: auto;"><a href="https://ld246.com/settings/file?type=3" target="_blank">${window.siyuan.languages.cdn}</a><span class="b3-list-item__meta">${response.data.hAssetSize}</span></li>
|
||||||
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.total}<span class="b3-list-item__meta">${response.data.hSize}</span></li>
|
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.total}<span class="b3-list-item__meta">${response.data.hSize}</span></li>
|
||||||
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sizeLimit}<span class="b3-list-item__meta">${response.data.hTotalSize}</span></li>
|
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.sizeLimit}<span class="b3-list-item__meta">${response.data.hTotalSize}</span></li>
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ func getCloudSpace(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
sync, backup, size, assetSize, totalSize, err := model.GetCloudSpace()
|
sync, backup, size, assetSize, repoSize, totalSize, err := model.GetCloudSpace()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
ret.Code = 1
|
ret.Code = 1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
|
|
@ -121,6 +121,7 @@ func getCloudSpace(c *gin.Context) {
|
||||||
"sync": sync,
|
"sync": sync,
|
||||||
"backup": backup,
|
"backup": backup,
|
||||||
"hAssetSize": assetSize,
|
"hAssetSize": assetSize,
|
||||||
|
"hRepoSize": repoSize,
|
||||||
"hSize": size,
|
"hSize": size,
|
||||||
"hTotalSize": totalSize,
|
"hTotalSize": totalSize,
|
||||||
"hTrafficUploadSize": hTrafficUploadSize,
|
"hTrafficUploadSize": hTrafficUploadSize,
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,7 @@ func RemoveCloudBackup() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCloudAvailableBackupSize() (size int64, err error) {
|
func getCloudAvailableBackupSize() (size int64, err error) {
|
||||||
var sync map[string]interface{}
|
sync, _, assetSize, repoSize, err := getCloudSpaceOSS()
|
||||||
var assetSize int64
|
|
||||||
sync, _, assetSize, err = getCloudSpaceOSS()
|
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -70,16 +68,15 @@ func getCloudAvailableBackupSize() (size int64, err error) {
|
||||||
if nil != sync {
|
if nil != sync {
|
||||||
syncSize = int64(sync["size"].(float64))
|
syncSize = int64(sync["size"].(float64))
|
||||||
}
|
}
|
||||||
size = int64(Conf.User.UserSiYuanRepoSize) - syncSize - assetSize
|
size = int64(Conf.User.UserSiYuanRepoSize) - syncSize - assetSize - repoSize
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize string, err error) {
|
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hRepoSize, hTotalSize string, err error) {
|
||||||
var sync, backup map[string]interface{}
|
sync, backup, assetSize, repoSize, err := getCloudSpaceOSS()
|
||||||
var assetSize int64
|
|
||||||
sync, backup, assetSize, err = getCloudSpaceOSS()
|
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return nil, nil, "", "", "", errors.New(Conf.Language(30) + " " + err.Error())
|
err = errors.New(Conf.Language(30) + " " + err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var totalSize, syncSize, backupSize int64
|
var totalSize, syncSize, backupSize int64
|
||||||
|
|
@ -103,8 +100,9 @@ func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize string,
|
||||||
HSize: humanize.Bytes(uint64(backupSize)),
|
HSize: humanize.Bytes(uint64(backupSize)),
|
||||||
Updated: backupUpdated,
|
Updated: backupUpdated,
|
||||||
}
|
}
|
||||||
totalSize = syncSize + backupSize + assetSize
|
totalSize = syncSize + backupSize + assetSize + repoSize
|
||||||
hAssetSize = humanize.Bytes(uint64(assetSize))
|
hAssetSize = humanize.Bytes(uint64(assetSize))
|
||||||
|
hRepoSize = humanize.Bytes(uint64(repoSize))
|
||||||
hSize = humanize.Bytes(uint64(totalSize))
|
hSize = humanize.Bytes(uint64(totalSize))
|
||||||
hTotalSize = byteCountSI(int64(Conf.User.UserSiYuanRepoSize))
|
hTotalSize = byteCountSI(int64(Conf.User.UserSiYuanRepoSize))
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, err error) {
|
func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize, repoSize int64, err error) {
|
||||||
result := map[string]interface{}{}
|
result := map[string]interface{}{}
|
||||||
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
request := httpclient.NewCloudRequest(Conf.System.NetworkProxy.String())
|
||||||
resp, err := request.
|
resp, err := request.
|
||||||
|
|
@ -47,7 +47,8 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
||||||
Post(util.AliyunServer + "/apis/siyuan/data/getSiYuanWorkspace?uid=" + Conf.User.UserId)
|
Post(util.AliyunServer + "/apis/siyuan/data/getSiYuanWorkspace?uid=" + Conf.User.UserId)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
util.LogErrorf("get cloud space failed: %s", err)
|
util.LogErrorf("get cloud space failed: %s", err)
|
||||||
return nil, nil, 0, ErrFailedToConnectCloudServer
|
err = ErrFailedToConnectCloudServer
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if 401 == resp.StatusCode {
|
if 401 == resp.StatusCode {
|
||||||
|
|
@ -58,13 +59,15 @@ func getCloudSpaceOSS() (sync, backup map[string]interface{}, assetSize int64, e
|
||||||
code := result["code"].(float64)
|
code := result["code"].(float64)
|
||||||
if 0 != code {
|
if 0 != code {
|
||||||
util.LogErrorf("get cloud space failed: %s", result["msg"])
|
util.LogErrorf("get cloud space failed: %s", result["msg"])
|
||||||
return nil, nil, 0, errors.New(result["msg"].(string))
|
err = errors.New(result["msg"].(string))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data := result["data"].(map[string]interface{})
|
data := result["data"].(map[string]interface{})
|
||||||
sync = data["sync"].(map[string]interface{})
|
sync = data["sync"].(map[string]interface{})
|
||||||
backup = data["backup"].(map[string]interface{})
|
backup = data["backup"].(map[string]interface{})
|
||||||
assetSize = int64(data["assetSize"].(float64))
|
assetSize = int64(data["assetSize"].(float64))
|
||||||
|
repoSize = int64(data["repoSize"].(float64))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue