sif: Make some user/ui preferences configurable
people wants to change them Signed-off-by: Yuan Si <do4suki@gmail.com>
This commit is contained in:
+26
-2
@@ -9,8 +9,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AppConfigs struct {
|
type AppConfigs struct {
|
||||||
AppName string `json:"app_name"`
|
AppName string `json:"app_name"`
|
||||||
Settings Settings `json:"settings"`
|
Settings Settings `json:"settings"`
|
||||||
|
UserPrefs UserPrefs `json:"user_prefs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
@@ -18,6 +19,18 @@ type Settings struct {
|
|||||||
AsCdnServer string `json:"as_cdn_server"`
|
AsCdnServer string `json:"as_cdn_server"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserPrefs struct {
|
||||||
|
Name string `json:"name"` // 用户名
|
||||||
|
Level int `json:"level"` // 用户等级
|
||||||
|
ExpNumerator int `json:"exp_numerator"` // Exp 分子
|
||||||
|
ExpDenominator int `json:"exp_denominator"` // Exp 分母
|
||||||
|
GameCoin int `json:"game_coin"` // 游戏金币
|
||||||
|
SnsCoin int `json:"sns_coin"` // 游戏爱心
|
||||||
|
EnergyMax int `json:"energy_max"` // 体力上限
|
||||||
|
OverMaxEnergy int `json:"over_max_energy"` // 实际体力,为 0 时与 EnergyMax 一致
|
||||||
|
InviteCode string `json:"invite_code"` // 用户 ID
|
||||||
|
}
|
||||||
|
|
||||||
func DefaultConfigs() *AppConfigs {
|
func DefaultConfigs() *AppConfigs {
|
||||||
return &AppConfigs{
|
return &AppConfigs{
|
||||||
AppName: "honoka-chan",
|
AppName: "honoka-chan",
|
||||||
@@ -25,6 +38,17 @@ func DefaultConfigs() *AppConfigs {
|
|||||||
SifCdnServer: "http://192.168.1.123/static",
|
SifCdnServer: "http://192.168.1.123/static",
|
||||||
AsCdnServer: "http://192.168.1.123/static",
|
AsCdnServer: "http://192.168.1.123/static",
|
||||||
},
|
},
|
||||||
|
UserPrefs: UserPrefs{
|
||||||
|
Name: "梦路 @bilibili",
|
||||||
|
Level: 1028,
|
||||||
|
ExpNumerator: 1089696,
|
||||||
|
ExpDenominator: 1207185,
|
||||||
|
GameCoin: 112124104,
|
||||||
|
SnsCoin: 0,
|
||||||
|
EnergyMax: 417,
|
||||||
|
OverMaxEnergy: 0,
|
||||||
|
InviteCode: "377385143",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-4
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"honoka-chan/config"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
"honoka-chan/tools"
|
"honoka-chan/tools"
|
||||||
@@ -975,18 +976,20 @@ func Api(ctx *gin.Context) {
|
|||||||
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
Cols("unit_removable_skill_id").Find(&removeSkillIds)
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
|
userId, err := strconv.Atoi(config.Conf.UserPrefs.InviteCode)
|
||||||
|
CheckErr(err)
|
||||||
profileResp := model.ProfileResp{
|
profileResp := model.ProfileResp{
|
||||||
Result: model.ProfileRes{
|
Result: model.ProfileRes{
|
||||||
UserInfo: model.ProfileUserInfo{
|
UserInfo: model.ProfileUserInfo{
|
||||||
UserID: pref.UserID,
|
UserID: userId,
|
||||||
Name: pref.UserName,
|
Name: pref.UserName,
|
||||||
Level: pref.UserLevel,
|
Level: config.Conf.UserPrefs.Level,
|
||||||
CostMax: 100,
|
CostMax: 100,
|
||||||
UnitMax: 5000,
|
UnitMax: 5000,
|
||||||
EnergyMax: 1000,
|
EnergyMax: config.Conf.UserPrefs.EnergyMax,
|
||||||
FriendMax: 99,
|
FriendMax: 99,
|
||||||
UnitCnt: int(commonUnit + userUnit),
|
UnitCnt: int(commonUnit + userUnit),
|
||||||
InviteCode: strconv.Itoa(pref.UserID),
|
InviteCode: config.Conf.UserPrefs.InviteCode,
|
||||||
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
ElapsedTimeFromLogin: "14\u5c0f\u65f6\u524d",
|
||||||
Introduction: pref.UserDesc,
|
Introduction: pref.UserDesc,
|
||||||
},
|
},
|
||||||
|
|||||||
+20
-10
@@ -4,8 +4,10 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"honoka-chan/config"
|
||||||
"honoka-chan/encrypt"
|
"honoka-chan/encrypt"
|
||||||
"honoka-chan/model"
|
"honoka-chan/model"
|
||||||
|
"honoka-chan/tools"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -17,31 +19,39 @@ func UserInfo(ctx *gin.Context) {
|
|||||||
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
userId, err := strconv.Atoi(ctx.GetString("userid"))
|
||||||
CheckErr(err)
|
CheckErr(err)
|
||||||
|
|
||||||
|
pref := tools.UserPref{}
|
||||||
|
exists, err := UserEng.Table("user_preference_m").Where("user_id = ?", userId).Get(&pref)
|
||||||
|
CheckErr(err)
|
||||||
|
if !exists {
|
||||||
|
ctx.String(http.StatusForbidden, ErrorMsg)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
userResp := model.UserInfoResp{
|
userResp := model.UserInfoResp{
|
||||||
ResponseData: model.UserInfoRes{
|
ResponseData: model.UserInfoRes{
|
||||||
User: model.UserInfo{
|
User: model.UserInfo{
|
||||||
UserID: userId,
|
UserID: userId,
|
||||||
Name: "\u68a6\u8def @\u65c5\u7acb\u3061\u306e\u65e5\u306b",
|
Name: pref.UserName,
|
||||||
Level: 1028,
|
Level: config.Conf.UserPrefs.Level,
|
||||||
Exp: 28824396,
|
Exp: config.Conf.UserPrefs.ExpNumerator,
|
||||||
PreviousExp: 27734700,
|
PreviousExp: 0,
|
||||||
NextExp: 28941885,
|
NextExp: config.Conf.UserPrefs.ExpDenominator,
|
||||||
GameCoin: 112124104,
|
GameCoin: config.Conf.UserPrefs.GameCoin,
|
||||||
SnsCoin: 0,
|
SnsCoin: config.Conf.UserPrefs.SnsCoin,
|
||||||
FreeSnsCoin: 0,
|
FreeSnsCoin: 0,
|
||||||
PaidSnsCoin: 0,
|
PaidSnsCoin: 0,
|
||||||
SocialPoint: 1438395,
|
SocialPoint: 1438395,
|
||||||
UnitMax: 5000,
|
UnitMax: 5000,
|
||||||
WaitingUnitMax: 1000,
|
WaitingUnitMax: 1000,
|
||||||
EnergyMax: 417,
|
EnergyMax: config.Conf.UserPrefs.EnergyMax,
|
||||||
EnergyFullTime: "2023-03-20 03:58:55",
|
EnergyFullTime: "2023-03-20 03:58:55",
|
||||||
LicenseLiveEnergyRecoverlyTime: 60,
|
LicenseLiveEnergyRecoverlyTime: 60,
|
||||||
EnergyFullNeedTime: 0,
|
EnergyFullNeedTime: 0,
|
||||||
OverMaxEnergy: 0,
|
OverMaxEnergy: config.Conf.UserPrefs.OverMaxEnergy,
|
||||||
TrainingEnergy: 100,
|
TrainingEnergy: 100,
|
||||||
TrainingEnergyMax: 100,
|
TrainingEnergyMax: 100,
|
||||||
FriendMax: 99,
|
FriendMax: 99,
|
||||||
InviteCode: "377385143",
|
InviteCode: config.Conf.UserPrefs.InviteCode,
|
||||||
InsertDate: "2015-08-10 18:58:30",
|
InsertDate: "2015-08-10 18:58:30",
|
||||||
UpdateDate: "2018-08-09 18:13:12",
|
UpdateDate: "2018-08-09 18:13:12",
|
||||||
TutorialState: -1,
|
TutorialState: -1,
|
||||||
|
|||||||
Reference in New Issue
Block a user