mirror of
https://shylinux.com/x/community
synced 2025-04-25 09:38:06 +08:00
opt portal
This commit is contained in:
parent
b67174b201
commit
ad2bba6611
5
Makefile
5
Makefile
@ -1,12 +1,13 @@
|
||||
binarys = bin/ice.bin
|
||||
version = src/version.go
|
||||
binpack = src/binpack.go
|
||||
option = src/option.go
|
||||
flags = -ldflags "-w -s" -v
|
||||
|
||||
all: def
|
||||
@date +"%Y-%m-%d %H:%M:%S"
|
||||
go build ${flags} -o ${binarys} src/main.go ${version} ${binpack} && ./${binarys} forever restart &>/dev/null
|
||||
go build ${flags} -o ${binarys} src/main.go ${option} ${version} ${binpack} && ./${binarys} forever restart &>/dev/null
|
||||
|
||||
def:
|
||||
@[ -f ${version} ] || echo "package main">${version}
|
||||
@[ -f ${binpack} ] || echo "package main">${binpack}
|
||||
@[ -f ${binpack} ] || echo "package main">${binpack}
|
||||
|
10
README.md
10
README.md
@ -1,11 +1,11 @@
|
||||
# Contexts
|
||||
Contexts 通过模块化、集群化、自动化的方式,只用一个 20M 大小的程序文件,就可以在各种设备上,一键启动完整的云计算服务与云研发环境。
|
||||
# Community
|
||||
Community 通过模块化、集群化、自动化的方式,只用一个 20M 大小的程序文件,就可以在各种设备上,一键启动完整的云计算服务与云研发环境。
|
||||
|
||||
## 源码安装
|
||||
### 克隆编译
|
||||
```sh
|
||||
git clone https://shylinux.com/x/contexts
|
||||
cd contexts; source etc/miss.sh
|
||||
git clone https://shylinux.com/x/community
|
||||
cd community; source etc/miss.sh
|
||||
```
|
||||
|
||||
### 启动服务
|
||||
@ -16,4 +16,4 @@ ish_miss_serve
|
||||
### 访问网页
|
||||
```sh
|
||||
open http://localhost:9020
|
||||
```
|
||||
```
|
||||
|
7
go.mod
7
go.mod
@ -1,5 +1,8 @@
|
||||
module shylinux.com/x/community
|
||||
|
||||
go 1.13
|
||||
go 1.20
|
||||
|
||||
require shylinux.com/x/ice v1.5.40 // indirect
|
||||
require (
|
||||
shylinux.com/x/ice v1.5.41 // indirect
|
||||
shylinux.com/x/mysql-story v0.6.14 // indirect
|
||||
)
|
||||
|
55
go.sum
55
go.sum
@ -1,13 +1,68 @@
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
||||
gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.7-0.20240204074919-46816ad31dde/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
|
||||
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
shylinux.com/x/go-git/v5 v5.6.7 h1:WD5QSco7m3QooPCgdvQ6/GyGIFPun8C+hex5N41LYlk=
|
||||
shylinux.com/x/go-git/v5 v5.6.7/go.mod h1:Qb0lA+uIrofZg8NQerhYcJHgGWixFqvS6p3aJ/L5Nlk=
|
||||
shylinux.com/x/go-qrcode v0.0.3 h1:RMo+Vidbgq3HatLBj7DDXcTbTLFUwzis5K7TqBkD38U=
|
||||
shylinux.com/x/go-qrcode v0.0.3/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/go-sql-mysql v0.0.2/go.mod h1:lHjRMZz5Lii6U+49fhkbCWgsnL+yux54SYJYWqASN8Y=
|
||||
shylinux.com/x/ice v1.5.40 h1:OC++Fb1CxOU1R0Vlrfm+J9pf1mg5uH1n1trXFIHQHaw=
|
||||
shylinux.com/x/ice v1.5.40/go.mod h1:nYLBfYfOacaxvIRgD4ryknBJTqUIZD0zkV72it7iHqU=
|
||||
shylinux.com/x/ice v1.5.41 h1:kqu+OOxT+CHkgEAuM+gby6lVZV33rYUM+Vk2UBDlefg=
|
||||
shylinux.com/x/ice v1.5.41/go.mod h1:hMhVMhUlsimwFcsPIH+J/tO8O8I0WEqg1NYyqdhULxE=
|
||||
shylinux.com/x/icebergs v1.9.38 h1:LS4n8KE3qV8uvdpWwnrgStgkU90f6Ww6prSpv7Eztyw=
|
||||
shylinux.com/x/icebergs v1.9.38/go.mod h1:zLsVvLKuFEyFRwKoa3li75nSqbJo/GVIYacAQVdTsxA=
|
||||
shylinux.com/x/icebergs v1.9.39 h1:EAAWxEBWFF0CtO7Tm1pX+s/fi0lk0RMbe9EJV/aLuWo=
|
||||
shylinux.com/x/icebergs v1.9.39/go.mod h1:rUqDj1pzd6uPj7+klEn+doqXiWlb/24/batRyBB5ppo=
|
||||
shylinux.com/x/mysql-story v0.6.14 h1:qf5dj+k9o13mCLUXpgGE42n4nfXVI0S0hNmrYdrMXtc=
|
||||
shylinux.com/x/mysql-story v0.6.14/go.mod h1:AvzKCyuN/zYMYRky3YjCsX1RLwCZFAL4zuQ5jzZidsM=
|
||||
shylinux.com/x/toolkits v0.7.10/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/toolkits v1.0.12 h1:dwskBNtOLBfis1XtjEGfJhrjBXiwga3M/wNCERsXsyo=
|
||||
shylinux.com/x/toolkits v1.0.12/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/toolkits v1.0.13 h1:oXuXNnsP8/iDCqJmsa5HJew7NZoPd8aMTuJkCZdpOlQ=
|
||||
shylinux.com/x/toolkits v1.0.13/go.mod h1:CHDJarGlDkg60kVsvMLYL/a5hAnRLEOShiEsMOuEp0Q=
|
||||
shylinux.com/x/websocket v0.0.4 h1:AJpwblePoOpiE6C8NrvgNYpKTotXMLrDDX2chTvx44Q=
|
||||
shylinux.com/x/websocket v0.0.4/go.mod h1:3UGWkjTu3ie5NAZen7J+uLPBrO7DFeKloj6Jxo13Oiw=
|
||||
|
11
src/gonganxitong/common.go
Normal file
11
src/gonganxitong/common.go
Normal file
@ -0,0 +1,11 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/mysql-story/src/db"
|
||||
)
|
||||
|
||||
type Table struct{ db.Table }
|
||||
|
||||
func prefixKey() string { return kit.Keys("web.team", kit.PathName(-1), kit.FileName(-1)) }
|
23
src/gonganxitong/email.go
Normal file
23
src/gonganxitong/email.go
Normal file
@ -0,0 +1,23 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/community/src/gonganxitong/model"
|
||||
)
|
||||
|
||||
type email struct {
|
||||
user user
|
||||
portal portal
|
||||
list string `name:"list auto" help:"邮箱配置"`
|
||||
}
|
||||
|
||||
func (s email) Init(m *ice.Message, arg ...string) {
|
||||
m.GoSleep("30ms", func() { s.portal.Show(m) })
|
||||
}
|
||||
func (s email) List(m *ice.Message, arg ...string) {
|
||||
m.FieldsSetDetail()
|
||||
m.Cmdy(s.user, s.user.Select, model.UID, s.user.UserUID(m))
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), email{}) }
|
57
src/gonganxitong/model/model.go
Normal file
57
src/gonganxitong/model/model.go
Normal file
@ -0,0 +1,57 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/mysql-story/src/db"
|
||||
)
|
||||
|
||||
const (
|
||||
UID = "uid"
|
||||
NAME = "name"
|
||||
AVATAR = "avatar"
|
||||
OPENID = "openid"
|
||||
OPEN_ID = "open_id"
|
||||
ADDRESS = "address"
|
||||
USER_UID = "user_uid"
|
||||
USER_NAME = "user_name"
|
||||
PLACE_UID = "place_uid"
|
||||
PLACE_ADDRESS = "place_address"
|
||||
STREET_UID = "street_uid"
|
||||
STREET_NAME = "street_name"
|
||||
)
|
||||
|
||||
type Sess struct {
|
||||
db.ModelWithUID
|
||||
UserUID string `gorm:"type:char(32)"`
|
||||
IP string `gorm:"type:char(16)"`
|
||||
Agent string `gorm:"size:char(256)"`
|
||||
}
|
||||
type User struct {
|
||||
db.ModelWithUID
|
||||
OpenID string `gorm:"type:char(32)";index`
|
||||
Avatar string `gorm:"size:char(256)"`
|
||||
Name string `gorm:"type:char(32)"`
|
||||
Email string `gorm:"type:char(32)"`
|
||||
}
|
||||
type UserPlace struct {
|
||||
db.Model
|
||||
UserUID string `gorm:"type:char(32);index"`
|
||||
PlaceUID string `gorm:"type:char(32)"`
|
||||
}
|
||||
type Place struct {
|
||||
db.ModelWithUID
|
||||
StreetUID string `gorm:"type:char(32)"`
|
||||
Address string `gorm:"size:char(256)"`
|
||||
}
|
||||
type Street struct {
|
||||
db.ModelWithUID
|
||||
Name string `gorm:"type:char(32)"`
|
||||
}
|
||||
|
||||
type models struct{ db.Models }
|
||||
|
||||
func (s models) Init(m *ice.Message, arg ...string) {
|
||||
s.Models.Register(m, "gonganxitong", &Sess{}, &User{}, &UserPlace{}, &Place{}, &Street{})
|
||||
}
|
||||
|
||||
func init() { ice.Cmd("web.team.community.gonganxitong.models", models{}) }
|
1
src/gonganxitong/model/model.sql
Normal file
1
src/gonganxitong/model/model.sql
Normal file
@ -0,0 +1 @@
|
||||
CREATE DATABASE IF NOT EXISTS gonganxitong CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
10
src/gonganxitong/place.go
Normal file
10
src/gonganxitong/place.go
Normal file
@ -0,0 +1,10 @@
|
||||
package gonganxitong
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type place struct {
|
||||
Table
|
||||
create string `name:"create street_uid* address*"`
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), place{}) }
|
25
src/gonganxitong/portal.css
Normal file
25
src/gonganxitong/portal.css
Normal file
@ -0,0 +1,25 @@
|
||||
$output { background-color:var(--plugin-bg-color); }
|
||||
$output>div.list { border-radius:10px; background-color:var(--output-bg-color); padding:10px; margin:10px; overflow-x:hidden; position:relative; }
|
||||
$output>div.list>div.title { font-weight:bold; display:flex; align-items:center; }
|
||||
$output>div.list>div.title div.action div.item.button.icons input { display:none; }
|
||||
$output>div.list>div.title span:first-child { flex-grow:1; }
|
||||
$output>div.list>div.item.card { position:relative; display:flex; align-items:center; }
|
||||
$output>div.list>div.item.card div.action { position:absolute; right:0; }
|
||||
$output>div.list>div.item.card div.output { padding:10px 0; width:100%; display:flex; transition:left .2s; }
|
||||
$output>div.list>div.item.card div.output { background-color:var(--output-bg-color); }
|
||||
$output>div.list>div.item.card.select div.output { transition:left .5s; }
|
||||
$output>div.list>div.item.card.select div.title { font-weight:bold; }
|
||||
$output>div.list>div.item.card img { height:36px; }
|
||||
$output>div.list>div.item.card div.title { font-size:16px; }
|
||||
$output>div.list>div.item.card div.title span { margin-right:5px; }
|
||||
$output>div.list>div.item.card div.status { color:var(--disable-fg-color); font-size:12px; color:gray; }
|
||||
$output>div.list>div.item.card div.status span { margin-right:5px; }
|
||||
$output>div.list>div.item.card div.info { width:100%; }
|
||||
$output>div.list>div.item.index { padding:10px; display:flex; flex-direction:column; align-items:center; float:left; }
|
||||
$output>div.list>div.item.index img { width:100%; }
|
||||
$output>div.list>div.action { display:flex; justify-content:center; }
|
||||
$output>div.list>div.action input[type=button] { color:var(--notice-bg-color); }
|
||||
$output>div.list>div.action i { display:none; }
|
||||
$output>div.action div.item.button { margin-right:5px; }
|
||||
$output>div.action div.item.button input { border:none; color:var(--notice-bg-color); min-width:80px; float:left; }
|
||||
$output>div.action div.item.button span { display:none; }
|
84
src/gonganxitong/portal.go
Normal file
84
src/gonganxitong/portal.go
Normal file
@ -0,0 +1,84 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/community/src/gonganxitong/model"
|
||||
)
|
||||
|
||||
const (
|
||||
EVENT_PLACE_CREATE = "web.team.community.place.create"
|
||||
EVENT_PLACE_REMOVE = "web.team.community.place.remove"
|
||||
)
|
||||
|
||||
type portal struct {
|
||||
ice.Hash
|
||||
user user
|
||||
userPlace userPlace
|
||||
place place
|
||||
export string `data:"true"`
|
||||
short string `data:"index"`
|
||||
field string `data:"time,name,icons,index,order,enable"`
|
||||
list string `name:"list place_uid index uid auto" role:"void"`
|
||||
placeCreate string `name:"placeCreate street_uid* address*" role:"void"`
|
||||
placeRemove string `name:"placeRemove place_uid*" role:"void"`
|
||||
}
|
||||
|
||||
func (s portal) Inputs(m *ice.Message, arg ...string) {
|
||||
s.place.Inputs(m, arg...)
|
||||
}
|
||||
func (s portal) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(s.userPlace, s.userPlace.MyPlace, s.user.UserUID(m)).Action(s.PlaceCreate).PushAction(s.PlaceRemove)
|
||||
kit.If(m.Length() == 0, func() { m.EchoInfoButton(m.Trans("Please Create Your Place", "请添加场所"), s.PlaceCreate) })
|
||||
} else if len(arg) == 1 {
|
||||
s.Hash.List(m, arg[1:]...).SortInt(mdb.ORDER)
|
||||
} else if len(arg) == 2 {
|
||||
m.Cmdy(ctx.COMMAND, arg[1]).Push(ctx.ARGS, arg[0])
|
||||
} else {
|
||||
m.FieldsSetDetail().Cmdy(arg[1], mdb.SELECT, model.UID, arg[2]).PushAction().Action()
|
||||
}
|
||||
m.Display("").DisplayCSS("")
|
||||
}
|
||||
func (s portal) PlaceCreate(m *ice.Message, arg ...string) {
|
||||
m.ToastProcess()
|
||||
msg := m.Cmd(s.place, s.place.Select, model.UID, m.Option(model.STREET_UID))
|
||||
if !m.WarnNotFound(msg.Length() == 0, "street") {
|
||||
if !m.Cmdy(s.place, s.place.Create, arg).IsErr() {
|
||||
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Result())
|
||||
m.Cmdy(s.userPlace, s.userPlace.Create, args)
|
||||
m.Event(EVENT_PLACE_CREATE, args, model.PLACE_ADDRESS, m.Option(model.ADDRESS))
|
||||
m.ProcessRefresh().ToastSuccess()
|
||||
}
|
||||
}
|
||||
}
|
||||
func (s portal) PlaceRemove(m *ice.Message, arg ...string) {
|
||||
m.ToastProcess()
|
||||
args := kit.Simple(model.USER_UID, s.user.UserUID(m), model.PLACE_UID, m.Option(model.PLACE_UID))
|
||||
msg := m.Cmd(s.userPlace, s.userPlace.Select, args)
|
||||
if !m.WarnNotFound(msg.Length() == 0, "place") {
|
||||
m.Cmdy(s.userPlace, s.userPlace.Delete, args)
|
||||
m.Cmdy(s.place, s.place.Delete, model.UID, m.Option(model.PLACE_UID))
|
||||
m.Event(EVENT_PLACE_REMOVE, args)
|
||||
m.ProcessRefresh().ToastSuccess()
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), portal{}) }
|
||||
|
||||
type Portal struct {
|
||||
portal
|
||||
export string `data:"true"`
|
||||
short string `data:"index"`
|
||||
field string `data:"time,name,icons,index,order,enable"`
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), Portal{}) }
|
||||
|
||||
func (s portal) Show(m *ice.Message, arg ...string) {
|
||||
cmd := m.GetCommand()
|
||||
m.Cmd(s, s.Create, mdb.NAME, cmd.Help, mdb.ICONS, cmd.Icon, ctx.INDEX, m.PrefixKey())
|
||||
}
|
104
src/gonganxitong/portal.js
Normal file
104
src/gonganxitong/portal.js
Normal file
@ -0,0 +1,104 @@
|
||||
var UID = "uid", PLACE_UID = "place_uid", PLACE_NAME = "place_name"
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
can.onimport.myPortal(can, msg, PLACE_UID, PLACE_NAME, "我的场所")
|
||||
},
|
||||
myValue: function(can, value) {
|
||||
return [
|
||||
{view: html.TITLE, list: [{text: value.place_address}]},
|
||||
{view: html.STATUS, list: [{text: value[PLACE_UID].slice(0, 8)}, {text: value.street_name}]},
|
||||
]
|
||||
},
|
||||
myPortal: function(can, msg, PLACE_UID, PLACE_NAME, title) { can.user.isMobile && can.isCmdMode() && can.onappend.style(can, html.OUTPUT)
|
||||
if (can.Option(PLACE_UID) == "") {
|
||||
if (can.db.hash.length > 1 && can.db.hash[0]) { return can.Option(PLACE_UID, can.db.hash[0]), can.Option(ctx.INDEX, can.db.hash[1]), can.Update() }
|
||||
can.db.hash[0] && can.onexport.session(can, PLACE_UID, can.db.hash[0])
|
||||
can.ui = can.page.Append(can, can._output, ["myplace.list", "myindex.list"])
|
||||
can.page.Append(can, can.ui.myplace, [{view: html.TITLE, list: [
|
||||
{text: can.user.trans(can, "My Place", title)}
|
||||
], _init: function(target) {
|
||||
can.page.Append(can, target, [{view: html.ACTION, _init: function(target) {
|
||||
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
|
||||
}}])
|
||||
}}])
|
||||
can.run({}, [can.onimport.myPlace(can, msg, can.ui.myplace, PLACE_UID, PLACE_NAME)], function(msg) {
|
||||
can.page.Append(can, can.ui.myindex, [{view: html.TITLE, list: [{text: can.user.trans(can, "My Index", "我的应用")}]}])
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
can.onimport.myIndex(can, msg, can.ui.myindex, PLACE_UID)
|
||||
})
|
||||
} else {
|
||||
can.onimport.myData(can, msg, can._output, PLACE_UID)
|
||||
}
|
||||
},
|
||||
myPlace: function(can, msg, target, PLACE_UID, PLACE_NAME) { var place_uid
|
||||
can.page.Append(can, target||can._output, msg.Table(function(value) {
|
||||
place_uid = place_uid||value[PLACE_UID], can.base.isIn(value[PLACE_UID], can.onexport.session(can, PLACE_UID)||"", can.db.hash[0]||"") && (place_uid = value[PLACE_UID])
|
||||
place_uid == value[PLACE_UID] && can.onexport.title(can, value[PLACE_NAME])
|
||||
return {view: [[html.ITEM_CARD, "uid-"+value[PLACE_UID]]], list: [
|
||||
{view: html.ACTION, _init: function(target) { target.innerHTML = value.action
|
||||
can.page.Select(can, target, html.INPUT_BUTTON, function(target) {
|
||||
var style = can.Conf("_style."+target.name); style && can.onappend.style(can, style, target)
|
||||
target.onclick = function(event) { can.Update(can.request(event, value), [ctx.ACTION, target.name]) }
|
||||
})
|
||||
}},
|
||||
{view: html.OUTPUT, list: [
|
||||
{img: can.misc.ResourceIcons(can, value.icon)},
|
||||
{view: ice.INFO, list: can.onimport.myValue(can, value)},
|
||||
], _init: function(target) {
|
||||
can.onmotion.slideAction(can, target)
|
||||
}},
|
||||
], onclick: function(event) {
|
||||
can.onmotion.select(can, target, html.DIV_ITEM, event.currentTarget)
|
||||
can.onexport.hash(can, value[PLACE_UID]), can.onexport.session(can, PLACE_UID, value[PLACE_UID])
|
||||
can.onexport.title(can, value[PLACE_NAME])
|
||||
// can.user.toastSuccess(can, "switch")
|
||||
can.user.agent.init(can, can.user.info.titles)
|
||||
}, _init: function(target) {}}
|
||||
}))
|
||||
can.page.Select(can, target, "div.item.card.uid-"+place_uid, function(_target) {
|
||||
can.onmotion.select(can, target, html.DIV_ITEM, _target)
|
||||
})
|
||||
can.page.Append(can, target, [{view: html.ACTION, _init: function(target) {
|
||||
msg.Option(ice.MSG_ACTION) && can.onappend._action(can, msg.Option(ice.MSG_ACTION), target)
|
||||
}}])
|
||||
can.onexport.hash(can, place_uid), can.onexport.session(can, PLACE_UID, place_uid); return place_uid
|
||||
},
|
||||
myIndex: function(can, msg, target, PLACE_UID) {
|
||||
can.page.Append(can, target||can._output, msg.Table(function(value) {
|
||||
var width; can.user.isMobile && !can.user.isLandscape() && (width = (can.ConfWidth()-40)/4)
|
||||
return {view: [[html.ITEM, ctx.INDEX]], style: {width: width}, list: [
|
||||
{img: can.misc.ResourceIcons(can, value.icon)}, {text: can.user.trans(can, value.index.split(".").pop(), value.name)},
|
||||
], onclick: function(event) {
|
||||
can.Option(PLACE_UID, can.onexport.session(can, PLACE_UID)), can.Option(ctx.INDEX, value.index), can.Update()
|
||||
}}
|
||||
}))
|
||||
},
|
||||
myData: function(can, msg, target, PLACE_UID) {
|
||||
msg.Table(function(value) { function back() {} function refresh() {}
|
||||
var list = [can.page.button(can, can.user.trans(can, "goback", "返回"), function(event) { back() }), can.page.button(can, can.user.trans(can, "reload", "刷新"), function(event) { refresh() })]
|
||||
var ui = can.page.Append(can, can._output, [{view: html.ACTION}])
|
||||
if (can.db.hash.length > 2 && can.db.hash[0] && can.db.hash[2]) { value.args = [can.db.hash[0], can.db.hash[2]] }
|
||||
value.style = html.OUTPUT, value.height = can.ConfHeight()-html.ACTION_HEIGHT
|
||||
can.onappend.plugin(can, value, function(sub) { refresh = function() { sub.Update() }
|
||||
sub.onexport.output = function(_sub, msg) { can.user.toastSuccess(can, "load", "", 1000)
|
||||
can.page.Appends(can, ui.action, list), msg.Option(ice.MSG_ACTION) && can.onappend._action(sub, msg.Option(ice.MSG_ACTION), ui.action, null, true)
|
||||
can.onexport.hash(can, can.Option(PLACE_UID), value.index, sub.Option(UID))
|
||||
back = function() {
|
||||
if (sub.Option(UID)) {
|
||||
can.onexport.hash(can, can.Option(PLACE_UID), can.Option(ctx.INDEX))
|
||||
sub.Option(UID, ""), sub.Update()
|
||||
} else {
|
||||
can.onexport.hash(can, "")
|
||||
can.Option(PLACE_UID, ""), can.Option(ctx.INDEX, ""), can.Update()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
24
src/gonganxitong/portal.json
Normal file
24
src/gonganxitong/portal.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"user": "用户",
|
||||
"place": "场所",
|
||||
"street": "街道",
|
||||
"placeCreate": "添加场所",
|
||||
"placeRemove": "删除场所",
|
||||
"portal": "公安系统",
|
||||
"email": "邮箱配置",
|
||||
"icons": {
|
||||
"placeCreate": "bi bi-plus-square-dotted"
|
||||
},
|
||||
"style": {
|
||||
"placeRemove": "danger"
|
||||
},
|
||||
"input": {
|
||||
"open_id": "外键",
|
||||
"user_uid": "用户",
|
||||
"user_name": "用户名",
|
||||
"place_uid": "场所",
|
||||
"place_address": "场所地址",
|
||||
"street_uid": "街道",
|
||||
"street_name": "街道名称"
|
||||
}
|
||||
}
|
27
src/gonganxitong/sess.go
Normal file
27
src/gonganxitong/sess.go
Normal file
@ -0,0 +1,27 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/community/src/gonganxitong/model"
|
||||
)
|
||||
|
||||
type sess struct {
|
||||
Table
|
||||
create string `name:"create user_uid*"`
|
||||
check string `name:"check uid*"`
|
||||
}
|
||||
|
||||
func (s sess) Create(m *ice.Message, arg ...string) {
|
||||
s.Table.Create(m, model.USER_UID, m.Option(model.USER_UID), aaa.IP, m.Option(ice.MSG_USERIP), web.AGENT, m.Option(ice.MSG_USERUA))
|
||||
m.ProcessCookie(ice.MSG_SESSID, kit.JoinWord(web.SPACE, m.Option(ice.MSG_USERPOD), m.PrefixKey(), aaa.CHECK, m.Result()), "-2")
|
||||
}
|
||||
func (s sess) Check(m *ice.Message, arg ...string) {
|
||||
msg := s.Table.Select(m.Spawn(), model.UID, arg[0])
|
||||
m.Option(ice.MSG_USERNAME, msg.Append(model.USER_UID))
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), sess{}) }
|
7
src/gonganxitong/street.go
Normal file
7
src/gonganxitong/street.go
Normal file
@ -0,0 +1,7 @@
|
||||
package gonganxitong
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type street struct{ Table }
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), street{}) }
|
51
src/gonganxitong/user.go
Normal file
51
src/gonganxitong/user.go
Normal file
@ -0,0 +1,51 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
|
||||
"shylinux.com/x/community/src/gonganxitong/model"
|
||||
)
|
||||
|
||||
type user struct {
|
||||
Table
|
||||
template string `data:"4b-Z_r8dZmm1pHdd2h4A10VVYX4OIHvemlLjsHKBj2s"`
|
||||
create string `name:"create openid*"`
|
||||
find string `name:"find uid*"`
|
||||
}
|
||||
|
||||
func (s user) Create(m *ice.Message, arg ...string) {
|
||||
if s.Table.Select(m, model.OPEN_ID, m.Option(model.OPENID)).Length() == 0 {
|
||||
s.Table.Create(m, model.OPEN_ID, m.Option(model.OPENID), model.AVATAR, m.Option("headimgurl"), model.NAME, m.Option("nickname"))
|
||||
m.Option(model.USER_UID, m.Result())
|
||||
} else {
|
||||
m.Option(model.USER_UID, m.Append(model.UID))
|
||||
}
|
||||
}
|
||||
func (s user) Find(m *ice.Message, arg ...string) {
|
||||
s.Select(m, arg...)
|
||||
}
|
||||
func (s user) List(m *ice.Message, arg ...string) {
|
||||
s.Table.List(m, arg...).Action(s.Create, s.Find)
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), user{}) }
|
||||
|
||||
func (s user) UserUID(m *ice.Message) string {
|
||||
msg := m.Cmd(s, s.Select, model.UID, m.Option(ice.MSG_USERNAME))
|
||||
m.Options(ice.MSG_USERNICK, msg.Append(mdb.NAME), model.OPEN_ID, msg.Append(model.OPEN_ID))
|
||||
return m.Option(model.USER_UID, msg.Append(model.UID))
|
||||
}
|
||||
func (s user) SendTemplate(m *ice.Message, arg ...string) { // url type name hash
|
||||
m.Cmd("web.chat.wx.template", "", m.Config("template"), m.Option(model.OPEN_ID), kit.Select("", arg, 0),
|
||||
"thing7", kit.Select("", arg, 1), "thing12", kit.Select("", arg, 2), "character_string2", kit.Select("", arg, 3),
|
||||
"time11", time.Now().Format("2006年01月02日 15:04"), "thing18", m.Option(ice.MSG_USERNICK),
|
||||
)
|
||||
}
|
||||
|
||||
type User struct{ user }
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), User{}) }
|
20
src/gonganxitong/userPlace.go
Normal file
20
src/gonganxitong/userPlace.go
Normal file
@ -0,0 +1,20 @@
|
||||
package gonganxitong
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
"shylinux.com/x/community/src/gonganxitong/model"
|
||||
)
|
||||
|
||||
type userPlace struct {
|
||||
Table
|
||||
place place
|
||||
street street
|
||||
}
|
||||
|
||||
func (s userPlace) MyPlace(m *ice.Message, arg ...string) {
|
||||
s.Fields(m, "places.created_at", model.STREET_NAME, "places.address as place_address", model.PLACE_UID, model.STREET_UID).Tables(m, s.place, s.street)
|
||||
s.Select(m, model.USER_UID, arg[0])
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), userPlace{}) }
|
@ -1,7 +1,11 @@
|
||||
package main
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
|
||||
_ "shylinux.com/x/community/src/gonganxitong"
|
||||
)
|
||||
|
||||
func main() { print(ice.Run()) }
|
||||
|
||||
func init() { ice.Info.Titles = "Community" }
|
||||
func init() { ice.Info.Titles = "云社区" }
|
||||
|
@ -1 +1 @@
|
||||
title "20240724-community"
|
||||
title "云社区"
|
||||
|
6
src/option.go
Normal file
6
src/option.go
Normal file
@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "shylinux.com/x/ice/devops"
|
||||
_ "shylinux.com/x/mysql-story/src/db/mysql"
|
||||
)
|
13
src/template/web.code.autogen/demo.go
Normal file
13
src/template/web.code.autogen/demo.go
Normal file
@ -0,0 +1,13 @@
|
||||
package {{.Option "zone"}}
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
|
||||
type {{.Option "name"}} struct {
|
||||
Table
|
||||
}
|
||||
|
||||
func (s {{.Option "name"}}) List(m *ice.Message, arg ...string) {
|
||||
s.Table.List(m, arg...)
|
||||
}
|
||||
|
||||
func init() { ice.Cmd(prefixKey(), {{.Option "name"}}{}) }
|
Loading…
x
Reference in New Issue
Block a user