chore: coding style (#4644)

This commit is contained in:
Kevin Wan
2025-02-12 23:48:39 +08:00
committed by GitHub
parent 7a4818da59
commit f113d512e8
5 changed files with 22 additions and 20 deletions

View File

@@ -10,10 +10,10 @@ const (
import 'package:shared_preferences/shared_preferences.dart';
import '../data/tokens.dart';
/// 保存tokens到本地
/// store tokens to local
///
/// 传入null则删除本地tokens
/// 返回true设置成功 false:设置失败
/// pass null will clean local stored tokens
/// returns true if success, otherwise false
Future<bool> setTokens(Tokens tokens) async {
var sp = await SharedPreferences.getInstance();
if (tokens == null) {
@@ -23,9 +23,9 @@ Future<bool> setTokens(Tokens tokens) async {
return await sp.setString('tokens', jsonEncode(tokens.toJson()));
}
/// 获取本地存储的tokens
/// get local stored tokens
///
/// 如果没有,则返回null
/// if no, returns null
Future<Tokens> getTokens() async {
try {
var sp = await SharedPreferences.getInstance();
@@ -82,7 +82,8 @@ func genVars(dir string, isLegacy bool, scheme string, hostname string) error {
}
if !fileExists(dir + "vars.dart") {
err = os.WriteFile(dir+"vars.dart", []byte(fmt.Sprintf(`const serverHost='%s://%s';`, scheme, hostname)), 0o644)
err = os.WriteFile(dir+"vars.dart", []byte(fmt.Sprintf(`const serverHost='%s://%s';`,
scheme, hostname)), 0o644)
if err != nil {
return err
}

View File

@@ -59,11 +59,11 @@ type (
// Member describes the field of a structure
Member struct {
Name string
// 数据类型字面值,如:string、map[int]string、[]int64、[]*User
// data type, for example, string、map[int]string、[]int64、[]*User
Type Type
Tag string
Comment string
// 成员头顶注释说明
// document for the field
Docs Doc
IsInline bool
}

View File

@@ -13,10 +13,12 @@ import (
)
var (
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
userFieldNames = builder.RawFieldNames(&User{})
userRows = strings.Join(userFieldNames, ",")
userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames,
"`id`", "`create_time`", "`update_time`"), ",")
userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames,
"`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type (
@@ -39,12 +41,12 @@ type (
// User defines an data structure for mysql
User struct {
ID int64 `db:"id"`
User string `db:"user"` // 用户
Name string `db:"name"` // 用户名称
Password string `db:"password"` // 用户密码
Mobile string `db:"mobile"` // 手机号
Gender string `db:"gender"` // 男|女|未公开
Nickname string `db:"nickname"` // 用户昵称
User string `db:"user"` // user
Name string `db:"name"` // user name
Password string `db:"password"` // user password
Mobile string `db:"mobile"` // user mobile
Gender string `db:"gender"` // male | female | unknown
Nickname string `db:"nickname"` // user nickname
CreateTime time.Time `db:"create_time"`
UpdateTime time.Time `db:"update_time"`
}