Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-10-27 11:33:34 +08:00
commit 49e0dec799
5 changed files with 30 additions and 9 deletions

View file

@ -427,4 +427,7 @@ export abstract class Constants {
// third
"yul", "solidity", "abap",
];
// Google Analytics 事件
public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig";
}

View file

@ -160,9 +160,23 @@ export const onGetConfig = (isStart: boolean) => {
mountHelp();
}
window.gtag("event", "config", {
let para = {
"version": Constants.SIYUAN_VERSION,
});
"isLoggedIn": "false",
"subscriptionStatus": "-1",
"subscriptionPlan": "-1",
"subscriptionType": "-1",
}
if (window.siyuan.user) {
para.isLoggedIn = "true";
if (0 === window.siyuan.user.userSiYuanSubscriptionStatus) {
console.log(window.siyuan.user)
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus.toString();
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan.toString();
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType.toString();
}
}
window.gtag("event", Constants.ANALYTICS_EVT_ON_GET_CONFIG, para);
};
const initBar = () => {

View file

@ -126,9 +126,11 @@ func removeSnippet(c *gin.Context) {
}
id := arg["id"].(string)
if err := model.RemoveSnippet(id); nil != err {
snippet, err := model.RemoveSnippet(id)
if nil != err {
ret.Code = -1
ret.Msg = "remove snippet failed: " + err.Error()
return
}
}
ret.Data = snippet
}

View file

@ -36,6 +36,7 @@ type User struct {
UserTrafficTime float64 `json:"userTrafficTime"`
UserSiYuanSubscriptionPlan float64 `json:"userSiYuanSubscriptionPlan"` // -2未订阅-1试用0标准订阅1教育订阅
UserSiYuanSubscriptionStatus float64 `json:"userSiYuanSubscriptionStatus"` // -1未订阅0订阅可用1订阅封禁2订阅过期
UserSiYuanSubscriptionType float64 `json:"userSiYuanSubscriptionType"` // 0 年付1 终生2 月付
}
type UserTitle struct {

View file

@ -29,7 +29,7 @@ import (
var snippetsLock = sync.Mutex{}
func RemoveSnippet(id string) (err error) {
func RemoveSnippet(id string) (ret *conf.Snippet, err error) {
snippetsLock.Lock()
defer snippetsLock.Unlock()
@ -40,6 +40,7 @@ func RemoveSnippet(id string) (err error) {
for i, s := range snippets {
if s.ID == id {
ret = s
snippets = append(snippets[:i], snippets[i+1:]...)
break
}
@ -48,7 +49,7 @@ func RemoveSnippet(id string) (err error) {
return
}
func SetSnippet(id, name, typ, content string, enabled bool) (snippet *conf.Snippet, err error) {
func SetSnippet(id, name, typ, content string, enabled bool) (ret *conf.Snippet, err error) {
snippetsLock.Lock()
defer snippetsLock.Unlock()
@ -64,15 +65,15 @@ func SetSnippet(id, name, typ, content string, enabled bool) (snippet *conf.Snip
s.Type = typ
s.Content = content
s.Enabled = enabled
snippet = s
ret = s
isUpdate = true
break
}
}
if !isUpdate {
snippet = &conf.Snippet{ID: id, Name: name, Type: typ, Content: content, Enabled: enabled}
snippets = append(snippets, snippet)
ret = &conf.Snippet{ID: id, Name: name, Type: typ, Content: content, Enabled: enabled}
snippets = append(snippets, ret)
}
err = writeSnippetsConf(snippets)
return