diff --git a/README-zh.md b/README-zh.md index 43b441a6..4b662f23 100644 --- a/README-zh.md +++ b/README-zh.md @@ -2,7 +2,7 @@
-
-
+
diff --git a/README.md b/README.md
index 636bd198..0ca2a772 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
+
diff --git a/backend/conf/config.yml b/backend/conf/config.yml
index 321860a2..32fce297 100644
--- a/backend/conf/config.yml
+++ b/backend/conf/config.yml
@@ -38,6 +38,7 @@ other:
version: 0.4.7
setting:
allowRegister: "N"
+ enableTutorial: "N"
notification:
mail:
server: ''
diff --git a/backend/entity/doc.go b/backend/entity/doc.go
new file mode 100644
index 00000000..b356d38a
--- /dev/null
+++ b/backend/entity/doc.go
@@ -0,0 +1,8 @@
+package entity
+
+type DocItem struct {
+ Title string `json:"title"`
+ Url string `json:"url"`
+ Path string `json:"path"`
+ Children []DocItem `json:"children"`
+}
diff --git a/backend/main.go b/backend/main.go
index a35291ca..ea9c30df 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -135,6 +135,8 @@ func main() {
// release版本
anonymousGroup.GET("/version", routes.GetVersion) // 获取发布的版本
anonymousGroup.GET("/releases/latest", routes.GetLatestRelease) // 获取最近发布的版本
+ // 文档
+ anonymousGroup.GET("/docs", routes.GetDocs) // 获取文档数据
}
authGroup := app.Group("/", middlewares.AuthorizationMiddleware())
{
@@ -259,7 +261,6 @@ func main() {
authGroup.GET("/git/branches", routes.GetGitBranches) // 获取 Git 分支
authGroup.GET("/git/public-key", routes.GetGitSshPublicKey) // 获取 SSH 公钥
}
-
}
// 路由ping
diff --git a/backend/routes/doc.go b/backend/routes/doc.go
new file mode 100644
index 00000000..6426cdcc
--- /dev/null
+++ b/backend/routes/doc.go
@@ -0,0 +1,25 @@
+package routes
+
+import (
+ "crawlab/services"
+ "github.com/apex/log"
+ "github.com/gin-gonic/gin"
+ "net/http"
+ "runtime/debug"
+)
+
+func GetDocs(c *gin.Context) {
+ type ResData struct {
+ String string `json:"string"`
+ }
+ data, err := services.GetDocs()
+ if err != nil {
+ log.Errorf(err.Error())
+ debug.PrintStack()
+ }
+ c.JSON(http.StatusOK, Response{
+ Status: "ok",
+ Message: "success",
+ Data: ResData{String:data},
+ })
+}
diff --git a/backend/routes/setting.go b/backend/routes/setting.go
index 4429873e..83976455 100644
--- a/backend/routes/setting.go
+++ b/backend/routes/setting.go
@@ -7,7 +7,8 @@ import (
)
type SettingBody struct {
- AllowRegister string `json:"allow_register"`
+ AllowRegister string `json:"allow_register"`
+ EnableTutorial string `json:"enable_tutorial"`
}
func GetVersion(c *gin.Context) {
@@ -21,9 +22,10 @@ func GetVersion(c *gin.Context) {
}
func GetSetting(c *gin.Context) {
- allowRegister := viper.GetString("setting.allowRegister")
-
- body := SettingBody{AllowRegister: allowRegister}
+ body := SettingBody{
+ AllowRegister: viper.GetString("setting.allowRegister"),
+ EnableTutorial: viper.GetString("setting.enableTutorial"),
+ }
c.JSON(http.StatusOK, Response{
Status: "ok",
diff --git a/backend/services/doc.go b/backend/services/doc.go
new file mode 100644
index 00000000..572e5cb4
--- /dev/null
+++ b/backend/services/doc.go
@@ -0,0 +1,27 @@
+package services
+
+import (
+ "github.com/apex/log"
+ "github.com/imroc/req"
+ "runtime/debug"
+)
+
+func GetDocs() (data string, err error) {
+ // 获取远端数据
+ res, err := req.Get("https://docs.crawlab.cn/search_plus_index.json")
+ if err != nil {
+ log.Errorf(err.Error())
+ debug.PrintStack()
+ return data, err
+ }
+
+ // 反序列化
+ data, err = res.ToString()
+ if err != nil {
+ log.Errorf(err.Error())
+ debug.PrintStack()
+ return data, err
+ }
+
+ return data, nil
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index 9d5acbb3..affdf7bb 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -24,6 +24,7 @@ services:
# CRAWLAB_TASK_WORKERS: 4 # number of task executors 任务执行器个数(并行执行任务数)
# CRAWLAB_SERVER_LANG_NODE: "Y" # whether to pre-install Node.js 预安装 Node.js 语言环境
# CRAWLAB_SETTING_ALLOWREGISTER: "N" # whether to allow user registration 是否允许用户注册
+ # CRAWLAB_SETTING_ENABLETUTORIAL: "N" # whether to enable tutorial 是否启用教程
# CRAWLAB_NOTIFICATION_MAIL_SERVER: smtp.exmaple.com # STMP server address STMP 服务器地址
# CRAWLAB_NOTIFICATION_MAIL_PORT: 465 # STMP server port STMP 服务器端口
# CRAWLAB_NOTIFICATION_MAIL_SENDEREMAIL: admin@exmaple.com # sender email 发送者邮箱
@@ -47,6 +48,9 @@ services:
depends_on:
- mongo
- redis
+ # environment:
+ # MONGO_INITDB_ROOT_USERNAME: username
+ # MONGO_INITDB_ROOT_PASSWORD: password
# volumes:
# - "/var/crawlab/log:/var/logs/crawlab" # log persistent 日志持久化
mongo:
diff --git a/frontend/.env.development b/frontend/.env.development
index ba21c0c6..275af85c 100644
--- a/frontend/.env.development
+++ b/frontend/.env.development
@@ -1,3 +1,4 @@
NODE_ENV='development'
VUE_APP_BASE_URL=http://localhost:8000
-VUE_APP_CRAWLAB_BASE_URL=https://api.crawlab.cn
\ No newline at end of file
+VUE_APP_CRAWLAB_BASE_URL=https://api.crawlab.cn
+VUE_APP_DOC_URL=http://docs.crawlab.cn
diff --git a/frontend/.env.production b/frontend/.env.production
index d01edd25..7cca0821 100644
--- a/frontend/.env.production
+++ b/frontend/.env.production
@@ -1,3 +1,4 @@
NODE_ENV='production'
VUE_APP_BASE_URL=/api
VUE_APP_CRAWLAB_BASE_URL=https://api.crawlab.cn
+VUE_APP_DOC_URL=http://docs.crawlab.cn
diff --git a/frontend/.env.test b/frontend/.env.test
index e9aeafc9..f29b1cd3 100644
--- a/frontend/.env.test
+++ b/frontend/.env.test
@@ -1,3 +1,4 @@
NODE_ENV='test'
VUE_APP_BASE_URL='http://localhost:8000'
VUE_APP_CRAWLAB_BASE_URL=https://api.crawlab.cn
+VUE_APP_DOC_URL=http://docs.crawlab.cn
diff --git a/frontend/src/components/Documentation/Documentation.vue b/frontend/src/components/Documentation/Documentation.vue
new file mode 100644
index 00000000..9abde012
--- /dev/null
+++ b/frontend/src/components/Documentation/Documentation.vue
@@ -0,0 +1,114 @@
+
+