钉钉初步免登,移动端样式优化

pull/665/head
LawyZHENG 2021-03-18 15:02:19 +08:00
parent 545537ecf1
commit 3ca09b7cbf
10 changed files with 81 additions and 19 deletions

View File

@ -19,6 +19,8 @@ var (
ErrorMemberPasswordError = errors.New("用户密码错误")
//ErrorMemberAuthMethodInvalid 不支持此认证方式
ErrMemberAuthMethodInvalid = errors.New("不支持此认证方式")
//ErrHTTPServerFail
ErrHTTPServerFail = errors.New("系统内部异常")
//ErrLDAPConnect 无法连接到LDAP服务器
ErrLDAPConnect = errors.New("无法连接到LDAP服务器")
//ErrLDAPFirstBind 第一次LDAP绑定失败

View File

@ -185,14 +185,14 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
resp, err := http.PostForm(urlStr, val)
if err != nil {
beego.Error("通过接口登录失败 -> ", urlStr, account, err)
return nil, err
return nil, ErrHTTPServerFail
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
beego.Error("读取接口返回值失败 -> ", urlStr, account, err)
return nil, err
return nil, ErrHTTPServerFail
}
beego.Info("HTTP 登录接口返回数据 ->", string(body))
@ -200,7 +200,7 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
if err := json.Unmarshal(body, &result); err != nil {
beego.Error("解析接口返回值失败 -> ", urlStr, account, string(body))
return nil, errors.New("解析接口返回值失败")
return nil, ErrHTTPServerFail
}
if code, ok := result["errcode"]; !ok || code.(float64) != 200 {
@ -208,7 +208,7 @@ func (m *Member) httpLogin(account, password string) (*Member, error) {
if msg, ok := result["message"]; ok {
return nil, errors.New(msg.(string))
}
return nil, errors.New("接口返回值格式不正确")
return nil, ErrHTTPServerFail
}
if m.MemberId <= 0 {
member := NewMember()

View File

@ -1,10 +1,11 @@
package models
import (
"github.com/lifei6671/mindoc/conf"
"errors"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"github.com/lifei6671/mindoc/conf"
)
type TeamMember struct {
@ -204,16 +205,16 @@ func (m *TeamMember) FindNotJoinMemberByAccount(teamId int, account string, limi
}
o := orm.NewOrm()
sql := `select member.member_id,member.account,team.team_member_id
sql := `select member.member_id,member.account,member.real_name,team.team_member_id
from md_members as member
left join md_team_member as team on team.team_id = ? and member.member_id = team.member_id
where member.account like ? AND team_member_id IS NULL
where member.account like ? or member.real_name like ? AND team_member_id IS NULL
order by member.member_id desc
limit ?;`
members := make([]*Member, 0)
_, err := o.Raw(sql, teamId, "%"+account+"%", limit).QueryRows(&members)
_, err := o.Raw(sql, teamId, "%"+account+"%", "%"+account+"%", limit).QueryRows(&members)
if err != nil {
beego.Error("查询团队用户时出错 ->", err)
@ -226,7 +227,7 @@ limit ?;`
for _, member := range members {
item := KeyValueItem{}
item.Id = member.MemberId
item.Text = member.Account
item.Text = member.Account + "(" + member.RealName + ")"
items = append(items, item)
}
result.Result = items
@ -234,9 +235,9 @@ limit ?;`
return &result, err
}
func (m *TeamMember) FindByBookIdAndMemberId(bookId,memberId int) (*TeamMember, error) {
func (m *TeamMember) FindByBookIdAndMemberId(bookId, memberId int) (*TeamMember, error) {
if bookId <= 0 || memberId <= 0 {
return nil,ErrInvalidParameter
return nil, ErrInvalidParameter
}
//一个用户可能在多个团队中,且一个项目可能有多个团队参与。因此需要查询用户最大权限。
sql := `select *
@ -246,11 +247,11 @@ and team.member_id = ? order by team.role_id asc limit 1;`
o := orm.NewOrm()
err := o.Raw(sql,bookId,memberId).QueryRow(m)
err := o.Raw(sql, bookId, memberId).QueryRow(m)
if err != nil {
beego.Error("查询用户项目所在团队失败 ->bookId=",bookId," memberId=", memberId, err)
return nil,err
beego.Error("查询用户项目所在团队失败 ->bookId=", bookId, " memberId=", memberId, err)
return nil, err
}
return m,nil
return m, nil
}

View File

@ -1037,6 +1037,24 @@ textarea{
margin-left: 0;
}
}
.navbar-mobile {
display: inline-block;
padding: 10px 0;
font-size: 14px;
line-height: 30px;
color: #563d7c;
}
.navbar-mobile a {
padding-right: 5px;
}
@media (min-width: 768px) {
.navbar-mobile {
display: none !important;
}
}

File diff suppressed because one or more lines are too long

View File

@ -86,6 +86,28 @@
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript"></script>
<script src="{{cdnjs "/static/js/dingtalk-jsapi.js"}}" type="text/javascript"></script>
<!-- <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script> -->
<script type="text/javascript">
if (dd.env.platform !== "notInDingTalk"){
dd.ready(function() {
dd.runtime.permission.requestAuthCode({
corpId: "dingd55b04400e53d11cbc961a6cb783455b", // 企业id
onSuccess: function (info) {
$.post("http://192.168.0.51/token?action=AuthCorpUser", {"code": info.code}, function(rdata){
if (rdata.status == 0) {
$(window).attr('location', rdata.data.url)
}else{
alert(rdata.msg)
}
})
// alert(info.code) // 通过该免登授权码可以获取用户身份
}
});
});
}
</script>
<script type="text/javascript">
$(function () {
$("#account,#password,#code").on('focus', function () {

View File

@ -30,7 +30,7 @@
<div class="manual-list">
{{range $index,$item := .Lists}}
<div class="search-item">
<div class="title">{{if eq $item.BlogStatus "password"}}<span class="label">密</span>{{end}} <a href="{{urlfor "BlogController.Index" ":id" $item.BlogId}}" title="{{$item.BlogTitle}}" target="_blank">{{$item.BlogTitle}}</a> </div>
<div class="title">{{if eq $item.BlogStatus "password"}}<span class="label">密</span>{{end}} <a href="{{urlfor "BlogController.Index" ":id" $item.BlogId}}" title="{{$item.BlogTitle}}">{{$item.BlogTitle}}</a> </div>
<div class="description">
{{$item.BlogExcerpt}}
</div>

View File

@ -30,6 +30,19 @@
<link href="{{cdncss "/static/css/print.css" "version"}}" media="print" rel="stylesheet">
<script type="text/javascript">window.book={"identify":"{{.Model.Identify}}"};</script>
<style>
.btn-mobile {
position: absolute;
right: 10px;
top: 10px;
}
@media screen and (min-width: 840px) {
.btn-mobile{
display: none;
}
}
</style>
</head>
<body>
<div class="m-manual manual-mode-view manual-reader">
@ -40,6 +53,7 @@
<a href="{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" title="{{.Model.BookName}}" class="book-title">{{.Model.BookName}}</a>
<span style="font-size: 12px;font-weight: 100;"></span>
</div>
<a href="{{urlfor "HomeController.Index"}}" class="btn btn-default btn-mobile"> <i class="fa fa-home" aria-hidden="true"></i>首页</a>
<div class="navbar-header pull-right manual-menu">
<a href="javascript:window.print();" id="printSinglePage" class="btn btn-default" style="margin-right: 10px;"><i class="fa fa-print"></i> 打印</a>
{{if gt .Member.MemberId 0}}

View File

@ -26,12 +26,12 @@
<div class="list-item">
<dl class="manual-item-standard">
<dt>
<a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" title="{{$item.BookName}}-{{$item.CreateName}}" target="_blank">
<a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" title="{{$item.BookName}}-{{$item.CreateName}}">
<img src="{{cdnimg $item.Cover}}" class="cover" alt="{{$item.BookName}}-{{$item.CreateName}}" onerror="this.src='{{cdnimg "static/images/book.jpg"}}';">
</a>
</dt>
<dd>
<a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" class="name" title="{{$item.BookName}}-{{$item.CreateName}}" target="_blank">{{$item.BookName}}</a>
<a href="{{urlfor "DocumentController.Index" ":key" $item.Identify}}" class="name" title="{{$item.BookName}}-{{$item.CreateName}}">{{$item.BookName}}</a>
</dd>
<dd>
<span class="author">

View File

@ -29,6 +29,10 @@
</form>
</div>
</nav>
<div style="display: inline-block;" class="navbar-mobile">
<a href="{{urlfor "HomeController.Index" }}" title="首页">首页</a>
<a href="{{urlfor "BlogController.List" }}" title="文章">文章</a>
</div>
<div class="btn-group dropdown-menu-right pull-right slidebar visible-xs-inline-block visible-sm-inline-block">
<button class="btn btn-default dropdown-toggle hidden-lg" type="button" data-toggle="dropdown"><i class="fa fa-align-justify"></i></button>