🎨 Official data sync counts the number of cloud storage API calls https://github.com/siyuan-note/siyuan/issues/8048

This commit is contained in:
Liang Ding 2023-04-20 10:30:31 +08:00
parent 9a975b6cc7
commit 78a5c05d28
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 12 additions and 2 deletions

View file

@ -176,6 +176,8 @@ const bindProviderEvent = () => {
<ul class="b3-list"> <ul class="b3-list">
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.upload}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficUploadSize}</span></li> <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.upload}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficUploadSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.download}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficDownloadSize}</span></li> <li class="b3-list-item" style="cursor: auto;">${window.siyuan.languages.download}<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficDownloadSize}</span></li>
<li class="b3-list-item" style="cursor: auto;">API GET<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIGet}</span></li>
<li class="b3-list-item" style="cursor: auto;">API PUT<span class="fn__space"></span><span class="ft__on-surface">${response.data.hTrafficAPIPut}</span></li>
</ul> </ul>
</div> </div>
</div>`; </div>`;

View file

@ -83,7 +83,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, hSize, hAssetSize, hTotalSize, exchangeSize, hTrafficUploadSize, hTrafficDownloadSize, err := model.GetCloudSpace() sync, backup, hSize, hAssetSize, hTotalSize, exchangeSize, hTrafficUploadSize, hTrafficDownloadSize, htrafficAPIGet, hTrafficAPIPut, err := model.GetCloudSpace()
if nil != err { if nil != err {
ret.Code = 1 ret.Code = 1
ret.Msg = err.Error() ret.Msg = err.Error()
@ -100,6 +100,8 @@ func getCloudSpace(c *gin.Context) {
"hExchangeSize": exchangeSize, "hExchangeSize": exchangeSize,
"hTrafficUploadSize": hTrafficUploadSize, "hTrafficUploadSize": hTrafficUploadSize,
"hTrafficDownloadSize": hTrafficDownloadSize, "hTrafficDownloadSize": hTrafficDownloadSize,
"hTrafficAPIGet": htrafficAPIGet,
"hTrafficAPIPut": hTrafficAPIPut,
} }
} }

View file

@ -34,6 +34,8 @@ type User struct {
UserSiYuanAssetSize float64 `json:"userSiYuanAssetSize"` UserSiYuanAssetSize float64 `json:"userSiYuanAssetSize"`
UserTrafficUpload float64 `json:"userTrafficUpload"` UserTrafficUpload float64 `json:"userTrafficUpload"`
UserTrafficDownload float64 `json:"userTrafficDownload"` UserTrafficDownload float64 `json:"userTrafficDownload"`
UserTrafficAPIGet float64 `json:"userTrafficAPIGet"`
UserTrafficAPIPut float64 `json:"userTrafficAPIPut"`
UserTrafficTime float64 `json:"userTrafficTime"` UserTrafficTime float64 `json:"userTrafficTime"`
UserSiYuanSubscriptionPlan float64 `json:"userSiYuanSubscriptionPlan"` // -1未订阅0标准订阅1教育订阅2试用 UserSiYuanSubscriptionPlan float64 `json:"userSiYuanSubscriptionPlan"` // -1未订阅0标准订阅1教育订阅2试用
UserSiYuanSubscriptionStatus float64 `json:"userSiYuanSubscriptionStatus"` // -1未订阅0订阅可用1订阅封禁2订阅过期 UserSiYuanSubscriptionStatus float64 `json:"userSiYuanSubscriptionStatus"` // -1未订阅0订阅可用1订阅封禁2订阅过期

View file

@ -1599,7 +1599,7 @@ type Sync struct {
SaveDir string `json:"saveDir"` // 本地同步数据存放目录路径 SaveDir string `json:"saveDir"` // 本地同步数据存放目录路径
} }
func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize, hExchangeSize, hTrafficUploadSize, hTrafficDownloadSize string, err error) { func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize, hExchangeSize, hTrafficUploadSize, hTrafficDownloadSize, hTrafficAPIGet, hTrafficAPIPut string, err error) {
stat, err := getCloudSpaceOSS() stat, err := getCloudSpaceOSS()
if nil != err { if nil != err {
err = errors.New(Conf.Language(30) + " " + err.Error()) err = errors.New(Conf.Language(30) + " " + err.Error())
@ -1630,6 +1630,8 @@ func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize, hExchan
hExchangeSize = "-" hExchangeSize = "-"
hTrafficUploadSize = "-" hTrafficUploadSize = "-"
hTrafficDownloadSize = "-" hTrafficDownloadSize = "-"
hTrafficAPIGet = "-"
hTrafficAPIPut = "-"
if conf.ProviderSiYuan == Conf.Sync.Provider { if conf.ProviderSiYuan == Conf.Sync.Provider {
s.HSize = humanize.Bytes(uint64(syncSize)) s.HSize = humanize.Bytes(uint64(syncSize))
b.HSize = humanize.Bytes(uint64(backupSize)) b.HSize = humanize.Bytes(uint64(backupSize))
@ -1639,6 +1641,8 @@ func GetCloudSpace() (s *Sync, b *Backup, hSize, hAssetSize, hTotalSize, hExchan
hExchangeSize = humanize.Bytes(uint64(Conf.User.UserSiYuanPointExchangeRepoSize)) hExchangeSize = humanize.Bytes(uint64(Conf.User.UserSiYuanPointExchangeRepoSize))
hTrafficUploadSize = humanize.Bytes(uint64(Conf.User.UserTrafficUpload)) hTrafficUploadSize = humanize.Bytes(uint64(Conf.User.UserTrafficUpload))
hTrafficDownloadSize = humanize.Bytes(uint64(Conf.User.UserTrafficDownload)) hTrafficDownloadSize = humanize.Bytes(uint64(Conf.User.UserTrafficDownload))
hTrafficAPIGet = fmt.Sprintf("%d", int(Conf.User.UserTrafficAPIGet))
hTrafficAPIPut = fmt.Sprintf("%d", int(Conf.User.UserTrafficAPIPut))
} }
return return
} }