Skip to content

Commit

Permalink
Merge pull request mindoc-org#790 from gsw945/master
Browse files Browse the repository at this point in the history
添加企业微信登录支持
  • Loading branch information
gsw945 authored May 9, 2022
2 parents dbc9fd9 + a5dfdb4 commit c090e6c
Show file tree
Hide file tree
Showing 17 changed files with 1,199 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ _cgo_export.*
_testmain.go

*.exe
*.exe~
mindoc
database
*.test
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dist: focal

language: go
go:
- "1.13"
- "1.18.1"

arch:
- amd64
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ RUN apt install -y --no-install-recommends tzdata
RUN dpkg-reconfigure --frontend noninteractive tzdata

# 安装 calibre 依赖的包
RUN apt install -y libgl-dev libnss3-dev libxcomposite-dev libxrandr-dev libxi-dev
RUN apt install -y libgl-dev libnss3-dev libxcomposite-dev libxrandr-dev libxi-dev libxdamage-dev
# 安装文泉驿字体
RUN apt install -y fonts-wqy-microhei fonts-wqy-zenhei
# 安装中文语言包
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MinDoc 简介

[![Build Status](https://travis-ci.com/mindoc-org/mindoc.svg?branch=master)](https://travis-ci.com/mindoc-org/mindoc)
[![Build status](https://ci.appveyor.com/api/projects/status/o3lcfmf5iy2cp9m6?svg=true)](https://ci.appveyor.com/project/gsw945/mindoc)
[![Build status](https://ci.appveyor.com/api/projects/status/7680ia6mu29m12wx?svg=true)](https://ci.appveyor.com/project/mindoc-org/mindoc)

MinDoc 是一款针对IT团队开发的简单好用的文档管理系统。

Expand Down Expand Up @@ -41,7 +41,7 @@ MinDoc 的前身是 [SmartWiki](https://github.com/lifei6671/SmartWiki) 文档

对于没有Golang使用经验的用户,可以从 [https://github.com/mindoc-org/mindoc/releases](https://github.com/mindoc-org/mindoc/releases) 这里下载编译完的程序。

如果有Golang开发经验,建议通过编译安装,要求golang版本不小于1.13(需支持`CGO``go mod`)。
如果有Golang开发经验,建议通过编译安装,要求golang版本不小于1.18.1(需支持`CGO``go mod`)。
> 注意: CentOS7上GLibC版本低,需要源码编译, 编译好的二进制文件无法运行。
## 常规编译
Expand All @@ -51,11 +51,13 @@ git clone https://github.com/mindoc-org/mindoc.git
# go包安装
go mod tidy
# 编译(sqlite需要CGO支持)
go build -ldflags "-w"
go build -ldflags "-w" -o mindoc.exe main.go
# 数据库初始化(此步骤执行之前,需配置`conf/app.conf`)
./mindoc install
# 执行
./mindoc
# 开发阶段运行
bee run
```

MinDoc 如果使用MySQL储存数据,则编码必须是`utf8mb4_general_ci`。请在安装前,把数据库配置填充到项目目录下的 `conf/app.conf` 中。
Expand Down
31 changes: 24 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@ version: 1.0.{build}
branches:
only:
- master
image: Visual Studio 2015
image: Visual Studio 2022
clone_folder: c:\gopath\src\github.com\mindoc-org\mindoc
init:
- cmd: >-
if [%tbs_arch%]==[x86] SET PATH=C:\MinGW\bin;%PATH%
if [%tbs_arch%]==[x64] SET PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
if [%tbs_arch%]==[x86] SET PATH=C:\msys64\mingw32\bin;%PATH%
if [%tbs_arch%]==[x64] SET PATH=C:\msys64\mingw64\bin;%PATH%
SET PATH=%GOPATH%\bin;%GOBIN%;%PATH%
FOR /f "delims=" %%i IN ('go version') DO (SET GO_VERSION=%%i)
git config --global --add safe.directory /cygdrive/c/gopath/src/github.com/mindoc-org/mindoc
environment:
GOPATH: c:\gopath
GOBIN: c:\gobin
Expand All @@ -18,25 +23,37 @@ environment:
matrix:
- tbs_arch: x86
GOARCH: 386
job_name: job_x86
- tbs_arch: x64
GOARCH: amd64
job_name: job_x64
install:
- cmd: >-
echo %PATH%
echo %GO_VERSION%
go env
where gcc
where g++
build_script:
- cmd: >-
cd c:\gopath\src\github.com\mindoc-org\mindoc
go mod tidy
go build -ldflags "-w"
go mod tidy -v
go build -v -o "mindoc_windows_%GOARCH%.exe" -ldflags="-w -X github.com/mindoc-org/mindoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=%date% %time%' -X 'conf.GO_VERSION=%GO_VERSION%'"
7z a -t7z -r mindoc_windows_%GOARCH%.7z conf/*.conf* static/* mindoc_windows_%GOARCH%.exe views/* uploads/*
7z a -t7z -r mindoc_windows_%GOARCH%.7z conf/*.conf* conf/lang/* static/* mindoc_windows_%GOARCH%.exe views/* uploads/*
test_script:
- cmd: >-
cd c:\gopath\src\github.com\mindoc-org\mindoc
xcopy conf\app.conf.example conf\app.conf /F /Y
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& {Copy-Item -Force -Path 'conf\app.conf.example' -Destination 'conf\app.conf'}"
mindoc_windows_%GOARCH%.exe version
artifacts:
- path: mindoc_windows_*.7z
deploy: off
4 changes: 3 additions & 1 deletion commands/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strconv"
"strings"
"time"
_ "time/tzdata"

"bytes"
"encoding/json"
Expand Down Expand Up @@ -110,7 +111,8 @@ func RegisterModel() {
new(models.TeamMember),
new(models.TeamRelationship),
new(models.Itemsets),
new(models.Comment),
new(models.Comment),
new(models.WorkWeixinAccount),
)
gob.Register(models.Blog{})
gob.Register(models.Document{})
Expand Down
16 changes: 14 additions & 2 deletions conf/app.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,19 @@ dingtalk_qr_key="${MINDOC_DINGTALK_QRKEY}"
# 钉钉扫码登录Secret
dingtalk_qr_secret="${MINDOC_DINGTALK_QRSECRET}"

# i18n config
default_lang="zh-cn"
########企业微信登录配置##############

# 企业ID
workweixin_corpid="${MINDOC_WORKWEIXIN_CORPID}"

# 应用ID
workweixin_agentid="${MINDOC_WORKWEIXIN_AGENTID}"

# 应用密钥
workweixin_secret="${MINDOC_WORKWEIXIN_SECRET}"

# 通讯录密钥
workweixin_contact_secret="${MINDOC_WORKWEIXIN_CONTACT_SECRET}"

# i18n config
default_lang="zh-cn"
27 changes: 27 additions & 0 deletions conf/workweixin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package conf

import (
"github.com/beego/beego/v2/server/web"
)

type WorkWeixinConf struct {
CorpId string // 企业ID
AgentId string // 应用ID
Secret string // 应用密钥
ContactSecret string // 通讯录密钥
}

func GetWorkWeixinConfig() *WorkWeixinConf {
corpid, _ := web.AppConfig.String("workweixin_corpid")
agentid, _ := web.AppConfig.String("workweixin_agentid")
secret, _ := web.AppConfig.String("workweixin_secret")
contact_secret, _ := web.AppConfig.String("workweixin_contact_secret")

c := &WorkWeixinConf{
CorpId: corpid,
AgentId: agentid,
Secret: secret,
ContactSecret: contact_secret,
}
return c
}
Loading

0 comments on commit c090e6c

Please sign in to comment.