This commit is contained in:
IT 老营长 @云轩领航-创始人 2025-06-30 19:35:55 +08:00
parent 38b327496c
commit 05be2c3aa5
13 changed files with 135 additions and 31 deletions

View File

@ -1,6 +1,6 @@
~ssh
source local.shy
return
~web.chat.macos
desktop create index web.team.gonganxitong.recent name recent icon "src/gonganxitong/credit.png"
desktop create index web.team.gonganxitong.service name service icon "src/gonganxitong/setting.png"
desktop create index web.team.gonganxitong.recent score 1000 name recent text "最近访问" icon "src/gonganxitong/credit.png"
desktop create index web.team.gonganxitong.service score 1000 name service text "服务发现" icon "src/gonganxitong/setting.png"
return

View File

@ -69,7 +69,8 @@ func (s Table) LoadTrans(m *ice.Message, arg ...string) {
cmd := m.Target().Commands[m.CommandKey()]
cmd.Icon = m.Resource(p)
})
if path.Dir(h) != path.Dir(p) && m.CommandKey() != web.PORTAL {
// if path.Dir(h) != path.Dir(p) && m.CommandKey() != web.PORTAL {
if path.Dir(h) != path.Dir(p) {
ice.LoadTrans(m.Spawn(kit.Dict("_template", path.Join(path.Dir(h), "portal.json"))).Message, m.CommandKey(), m.GetCommand().Command)
}
}
@ -78,7 +79,14 @@ func (s Table) Init(m *ice.Message, arg ...string) {
s.Table.Init(m, arg...)
}
func (s Table) AfterInit(m *ice.Message, arg ...string) {
m.Cmd("applications", mdb.REMOVE, kit.Hashs(","+m.PrefixKey()+","))
if m.CommandKey() == "portal" {
cmd := m.GetCommand()
m.Cmd("applications", mdb.CREATE, web.SPACE, "", ctx.INDEX, m.PrefixKey(),
mdb.NAME, kit.Select("", strings.Split(m.PrefixKey(), "."), -2)+".portal",
mdb.TEXT, cmd.Help, mdb.ICON, kit.Select(ice.Info.NodeIcon, cmd.Icon), mdb.SCORE, "10000")
} else {
m.Cmd("applications", mdb.REMOVE, kit.Hashs(","+m.PrefixKey()+","))
}
}
func (s Table) AfterMigrate(m *ice.Message, arg ...string) {
kit.If(m.GetCommand().Icon, func() { Portal{}.Show(m) })
@ -224,6 +232,8 @@ func (s Table) RewriteAppend(m *ice.Message, arg ...string) *ice.Message {
value = MemberStatus(kit.Int(value)).String()
case model.PLACE_TYPE:
value = PlaceType(kit.Int(value)).String()
case model.USER_STATUS:
value = UserStatus(kit.Int(value)).String()
case model.AUTH_TYPE:
value = AuthType(kit.Int(value)).String()
case model.AUTH_STATUS:

View File

@ -27,6 +27,7 @@ type member struct {
setLanguage string `name:"setLanguage language" help:"语言" role:"worker"`
sessList string `name:"sessList" role:"leader"`
userInfo string `name:"userInfo" help:"个人主页" role:"void"`
userDisable string `name:"userDisable" help:"封号" style:"danger"`
}
func (s member) Remove(m *ice.Message, arg ...string) {
@ -56,13 +57,13 @@ func (s member) List(m *ice.Message, arg ...string) {
if len(arg) == 1 {
m.Cmdy(s.UserPlace, s.Select, s.Keys(s.Place, model.UID), arg[0]).Action()
defer s.Place.RewriteAppend(m)
defer m.Sort(kit.Fields(model.MEMBER_STATUS, USER_PLACE_ROLE, model.SCORE, model.AUTH_STATUS, model.CREATED_AT), ice.INT, ice.INT, ice.INT_R, ice.INT, ice.STR)
defer m.Sort(kit.Fields(model.USER_STATUS, model.MEMBER_STATUS, USER_PLACE_ROLE, model.SCORE, model.AUTH_STATUS, model.CREATED_AT), ice.INT, ice.INT, ice.INT, ice.INT_R, ice.INT, ice.STR)
} else if len(arg) == 2 {
m.FieldsSetDetail().Cmdy(s.UserPlace, s.Select, s.Keys(s.Place, model.UID), arg[0], s.Key(s.UserPlace, model.UID), arg[1]).Action()
} else {
return
}
s.SelectJoinUser(m, model.NAME, model.INFO, model.AVATAR, model.LANGUAGE, model.AUTH_UID)
s.SelectJoinUser(m, model.NAME, model.INFO, model.STATUS, model.AVATAR, model.LANGUAGE, model.AUTH_UID)
if s.SelectJoinAuth(m); s.IsLeader(m) {
s.SelectJoinSess(m)
s.OtherListCmd(m, s.SessList)
@ -76,6 +77,7 @@ func (s member) List(m *ice.Message, arg ...string) {
}
}
button := []ice.Any{}
defer func() { m.PushButton(button...) }()
if value[model.AUTH_UID] == "" {
if value[model.USER_UID] == user_uid {
button = append(button, s.Auth)
@ -95,6 +97,12 @@ func (s member) List(m *ice.Message, arg ...string) {
if value[model.USER_UID] != user_uid && m.IsTech() {
button = append(button, s.SetCookie)
}
if value[model.USER_UID] != user_uid && m.IsTech() {
if value[model.USER_STATUS] == "1" {
} else {
button = append(button, s.UserDisable)
}
}
if MemberStatus(kit.Int(value[model.MEMBER_STATUS])) == MemberNormal {
if isCreator {
switch kit.Int(value[USER_PLACE_ROLE]) {
@ -120,7 +128,6 @@ func (s member) List(m *ice.Message, arg ...string) {
}
}
}
m.PushButton(button...)
})
s.DisplayBase(m, "").DisplayCSS("")
}
@ -167,6 +174,10 @@ func (s member) SetCookie(m *ice.Message, arg ...string) {
m.Cmdy(s.UserPlace, s.Select, model.UID, m.Option(model.UID))
m.ProcessCookie(ice.MSG_USERUID, m.Append(model.USER_UID))
}
func (s member) UserDisable(m *ice.Message, arg ...string) {
msg := m.Cmd(s.UserPlace, s.Select, s.Keys(s.Place, model.UID), m.Option(model.PLACE_UID), s.Key(s.UserPlace, model.UID), m.Option(model.UID))
m.Cmdy(user{}, s.UpdateField, []string{model.STATUS, "1"}, model.UID, msg.Append(model.USER_UID))
}
func init() { ice.TeamCtxCmd(member{Tables: newTables()}) }

View File

@ -8,6 +8,7 @@ Volcanos(chat.ONIMPORT, {
can.onimport.spaceView(can, value),
can.onimport.unitView(can, value, "score", "星"),
can.onimport.textView(can, value, USER_PLACE_ROLE),
can.onimport.textView(can, value, "user_status"),
value.member_status != "normal" && can.onimport.textView(can, value, "member_status"),
]},
value.location && {view: html.STATUS, list: [value.location, value.system]},

View File

@ -23,6 +23,7 @@ const (
USER_UID = "user_uid"
USER_NAME = "user_name"
USER_INFO = "user_info"
USER_STATUS = "user_status"
USER_ROLE = "user_role"
USER_AVATAR = "user_avatar"
USER_BACKGROUND = "user_background"

View File

@ -19,7 +19,7 @@ $action div.item.user_info { padding:10px; }
$action div.item.user_info>div.name { display:flex; flex-direction:column; align-items:end; }
$action div.item.user_info>div.name>span.time { font-size:10px; color:var(--label-fg-color); }
$action div.item.space { flex-grow:1; background-color:transparent; cursor:default; }
$action div.item.place input { font-weight:bold; font-style:italic; }
body:not(.mobile) $action div.item.place input { font-weight:bold; font-style:italic; }
body:not(.mobile) $action div.item.scanQRCode { display:none; }
fieldset>div.output>div.tabs { display:flex; }
fieldset>div.output>div.tabs>div.item { padding:5px; line-height:20px; }
@ -78,6 +78,7 @@ $output div.item.card div.title span:first-child { word-break:break-all; }
body.mobile $output div.item.card div.title span:first-child { font-weight:bold; }
$output div.item.card div.title span.type { line-height:18px; }
$output div.item.card div.title span.status { line-height:18px; }
$output div.item.card div.title span.status.已封号 { color:var(--danger-bg-color); }
$output div.item.card div.title span.price { color:var(--danger-bg-color); }
body.width1 $output div.item.card div.title span.price { margin-left:auto; }
$output div.item.card div.title span.score { background-color:var(--hover-bg-color); color:var(--danger-bg-color); padding:0 5px; }

View File

@ -73,7 +73,7 @@ func (s Portal) Command(m *ice.Message, arg ...string) {
}
func (s Portal) Run(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_USERSTATUS) == "1" {
m.Echo("用户已禁用").Option("display.style", html.OUTPUT)
m.Echo("此用户已封号").Option("display.style", html.OUTPUT)
return
}
if m.Option(model.MESSAGE_UID) != "" {
@ -141,7 +141,7 @@ func (s Portal) Run(m *ice.Message, arg ...string) {
}
func (s Portal) List(m *ice.Message, arg ...string) {
if m.Option(ice.MSG_USERSTATUS) == "1" {
m.Echo("用户已禁用").Option("display.style", html.OUTPUT)
m.Echo("此用户已封号").Option("display.style", html.OUTPUT)
return
}
m.Option(model.USER_UID, m.Option(ice.MSG_USERUID))
@ -182,6 +182,7 @@ func (s Portal) List(m *ice.Message, arg ...string) {
p := kit.ExtChange(m.Resource(ctx.GetCmdFile(m.Message, m.PrefixKey())), "js")
defer func() { m.Option(ice.MSG_DISPLAY, p+","+m.Option(ice.MSG_DISPLAY)) }()
s.DisplayBase(m, "").DisplayCSS("")
m.Option("display.style", "portal")
}
func (s Portal) Create(m *ice.Message, arg ...string) {
@ -214,6 +215,9 @@ func (s Portal) Link(m *ice.Message, arg ...string) *ice.Message {
return m.Echo(p + "#" + h)
}
func (s Portal) PlaceUIDKey(m *ice.Message, arg ...string) {
m.Echo(s.Keys(s.Place, model.UID))
}
func (s Portal) PlaceCreate(m *ice.Message, arg ...string) {
m.OptionDefault(model.USER_UID, m.Option(ice.MSG_USERUID))
if s.city.FindOrCreateByName(m, arg...); m.IsErr() {

View File

@ -3,7 +3,14 @@ var USER_UID = "user_uid", USER_ROLE = "user_role", AUTH_UID = "auth_uid", AUTH_
var TYPE = "type", ROLE = "role", STATUS = "status"
Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
can.onappend.style(can, html.OUTPUT), can.onimport.myPortal(can, msg)
if (can.isCmdMode()) {
can.onappend.style(can, html.OUTPUT)
} else {
can.onmotion.hidden(can, can._option)
can.onmotion.hidden(can, can._action)
can.onmotion.hidden(can, can._status)
}
can.onimport.myPortal(can, msg)
can.misc.Cookie(can, "user_uid", "")
},
qrcode: function(can, msg, avatar, target) { target = target||can.ui.output, can.onappend.board(can, msg, target)

View File

@ -42,6 +42,7 @@
"My Place": "我的场景",
"user_uid": "用户",
"user_name": "用户昵称",
"user_status": "用户状态",
"user_info": "用户信息",
"user_avatar": "用户头像",
"user_background": "用户背景",

View File

@ -1,7 +1,10 @@
package gonganxitong
import (
"strings"
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/gonganxitong/model"
@ -16,6 +19,8 @@ type qrcode struct {
applyQRCode string `name:"applyQRCode" help:"邀请码" role:"void"`
placeQRCode string `name:"placeQRCode" help:"场景码" role:"void"`
scanQRCode string `name:"scanQRCode" help:"扫码" role:"void"`
enter string `name:"enter" help:"进入" role:"void"`
open string `name:"open" help:"打开" role:"void"`
}
func (s qrcode) ApplyQRCode(m *ice.Message, arg ...string) {
@ -29,11 +34,35 @@ func (s qrcode) PlaceQRCode(m *ice.Message, arg ...string) {
func (s qrcode) ScanQRCode(m *ice.Message, arg ...string) {
m.FieldsSetDetail()
for i := 0; i < len(arg); i += 2 {
m.Push(arg[i], arg[i+1])
if arg[i] != "_origin" {
m.Push(arg[i], arg[i+1])
}
}
if strings.HasPrefix(m.Append("text"), "http") {
msg := m.Spawn()
web.ParseURL(msg.Message, m.Append("text"))
m.Push("space", msg.Option("pod"))
if strings.Contains(m.Append("text"), "#") {
ls := strings.Split(strings.Split(m.Append("text"), "#")[1], ":")
m.Push("index", ls[1])
m.Push("args", strings.TrimSuffix(kit.Join([]string{ls[0], kit.Select("", ls, 2)}, ","), ","))
} else {
m.Push("index", msg.Option("cmd"))
m.Push("args", m.Append(m.Cmdx(web.SPACE, msg.Option("pod"), msg.Option("cmd"), "placeUIDKey")))
}
m.PushAction(s.Enter, s.Open, "copyText")
} else {
m.PushAction("copyText")
}
m.EchoQRCode(m.Append("text")).Action(s.ApplyQRCode, s.PlaceQRCode, s.ScanQRCode)
m.Display("/plugin/table.js")
}
func (s qrcode) Enter(m *ice.Message, arg ...string) {
m.ProcessPodCmd(m.Option("space"), m.Option("index"), kit.Split(m.Option("args")), arg...)
}
func (s qrcode) Open(m *ice.Message, arg ...string) {
m.ProcessOpen(m.Option("text"))
}
func (s qrcode) List(m *ice.Message, arg ...string) {
s.PlaceQRCode(m, arg[0])
}

View File

@ -2,6 +2,9 @@ package gonganxitong
import (
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/core/chat/macos"
kit "shylinux.com/x/toolkits"
"shylinux.com/x/community/src/api"
@ -121,6 +124,11 @@ func init() { ice.TeamCtxCmd(setting{Table: newTable()}) }
func (s Table) HashSelect(m *ice.Message, arg ...string) {
s.Hash.Select(m, arg...)
}
func (s Table) DesktopInsert(m *ice.Message, arg ...string) {
macos.DeskAppend(m.Message, m.Option("icons"), s.PrefixPortal(m), ctx.ARGS, m.Option(model.PLACE_UID),
mdb.TEXT, m.Option("place_name"), mdb.SCORE, m.OptionDefault(mdb.SCORE, "20000"),
)
}
func (s Table) SettingCreate(m *ice.Message, arg ...string) {
m.Cmdy(s.PrefixSetting(m), s.Create, model.NAME, arg[0],
model.TYPE, kit.Select(SETTING_RADIO, arg, 1),

View File

@ -4,22 +4,30 @@ Volcanos(chat.ONIMPORT, {
if (value.type == "title") { return {view: [[html.ITEM, html.TITLE], "", can.user.trans(can, value.name, value.help)]} }
return {view: [[html.ITEM, value.type, value.name]], list: [{text: [can.user.trans(can, value.name, value.help, "value.setting"), "", mdb.NAME]}, can.onimport[value.type](can, value)]}
}))
can.onappend.input(can, {type: html.BUTTON, name: "website", value: "进入官网", onclick: function() {
can.user.open("/")
}}, "", can._output)
can.user.isMobile && can.onappend.input(can, {type: html.BUTTON, name: "scan", value: "扫码识别", onclick: function(event) {
can.user.agent.scanQRCode(can, function(value) {
var data = can.misc.ParseURL(can, value.text)
can.onimport.myStory(can, {space: data.pod, index: data.cmd, opts: data})
can.page.Append(can, can._output, [{text: value.text, onclick: function(event) {
can.user.copy(event, can, value.text)
}}])
})
}}, "", can._output)
can.onappend.input(can, {type: html.BUTTON, name: "logout", value: "退出登录", style: "danger", onclick: function() {
if (can.user.confirm("请确认退出登录")) { can.misc.CookieSessid(can, ""), location.reload() }
}}, "", can._output)
can.user.trans(can, {
desktopInsert: "添加到桌面",
openAddress: "选择地址",
openLocation: "查看位置",
getLocation: "上报位置",
scan: "扫码",
portal: "进入官网",
logout: "退出登录",
})
can.core.List([
can.user.isTechOrRoot(can) && "desktopInsert",
can.user.isMobile && can.user.isWeiXin && "openAddress",
can.user.isMobile && can.user.isWeiXin && "openLocation",
can.user.isMobile && can.user.isWeiXin && "getLocation",
can.user.isMobile && can.user.isWeiXin && "scan",
"portal",
"logout",
], function(item) { if (!item) { return } typeof item == "string" && (item = {name: item})
item.type = item.type||html.BUTTON, item.onclick = function(event) {
var cb = can.onaction[item.name]; if (cb) { return cb(event, can, item.name) }
var cb = can.sup.onaction[item.name]; if (cb) { return cb(event, can.sup, item.name) }
can.runAction(event, item.name, [])
}, can.onappend.input(can, item, "", can._output)
})
if (!can.misc.isDebug(can)) { return }
can.user.isTechOrRoot(can) && can.onimport._plugin(can, {index: "can.cookie"})
localStorage.length && can.onimport._plugin(can, {index: "can.localStorage"})
@ -59,8 +67,24 @@ Volcanos(chat.ONIMPORT, {
}}
},
})
Volcanos(chat.ONIMPORT, {
Volcanos(chat.ONACTION, {
desktopInsert: function(event, can, button) {
var icons = ""; can.core.List(can._stacks_current, function(p) { if (!p.current) { return } icons = p.current.icons||p.ConfIcons()||can.misc.Resource(can, can._stacks_current[0].Conf("icon"), can._stacks_current[0].Conf("space"))||icons })
can.runAction(can.request(event, {icons: icons, score: "20000"}), button, [])
},
scan: function(event, can, button) {
can.user.agent.scanQRCode(can, function(value) {
var data = can.misc.ParseURL(can, value.text)
can.onimport.myStory(can, {space: data.pod, index: data.cmd, opts: data})
can.page.Append(can, can._output, [{text: value.text, onclick: function(event) {
can.user.copy(event, can, value.text)
}}])
})
},
portal: function(event, can, button) {
can.user.open("/")
},
logout: function(event, can, button) {
can.user.logout(can)
if (can.user.confirm("请确认退出登录")) { can.misc.CookieSessid(can, ""), location.reload() }
},
})

View File

@ -145,3 +145,10 @@ const (
UserEnabled UserStatus = iota
UserDisabled
)
var UserStatusList = map[UserStatus]string{
UserEnabled: "",
UserDisabled: "❌ 已封号",
}
func (s UserStatus) String() string { return UserStatusList[s] }