静态文件和API使用相对路径

pull/109/head
ouqiang 6 years ago
parent 370645fca8
commit ea18109b92

@ -74,7 +74,7 @@ docker run --name gocron -p 5920:5920 -d ouqg/gocron
1. 安装Go1.9+, Node.js, Yarn
2. 安装前端依赖 `make install-vue`
3. 启动gocron, gocron-node `make run`
4. 启动node server `cd web/vue && yarn run dev`, 访问地址 http://localhost:8080
4. 启动node server `make run-vue`, 访问地址 http://localhost:8080
访问http://localhost:8080, API请求会转发给gocron

@ -5,9 +5,9 @@ import (
"fmt"
"strconv"
"github.com/go-macaron/binding"
"github.com/go-sql-driver/mysql"
"github.com/lib/pq"
"github.com/go-macaron/binding"
"github.com/ouqiang/gocron/internal/models"
"github.com/ouqiang/gocron/internal/modules/app"
"github.com/ouqiang/gocron/internal/modules/setting"
@ -150,21 +150,19 @@ func testDbConnection(form InstallForm) error {
defer db.Close()
err = db.Ping()
if s.Db.Engine == "postgres" && err != nil {
msg := "数据库连接失败"
pgError, _ := err.(*pq.Error)
if pgError.Code == "3D000" {
msg = "数据库不存在"
}
return errors.New(msg)
pgError, ok := err.(*pq.Error)
if ok && pgError.Code == "3D000" {
err = errors.New("数据库不存在")
}
return err
}
if s.Db.Engine == "mysql" && err != nil {
msg := "数据库连接失败"
mysqlError, _ := err.(*mysql.MySQLError)
if mysqlError.Number == 1049 {
msg = "数据库不存在"
mysqlError, ok := err.(*mysql.MySQLError)
if ok && mysqlError.Number == 1049 {
err = errors.New("数据库不存在")
}
return errors.New(msg)
return err
}
return err

File diff suppressed because one or more lines are too long

@ -52,6 +52,10 @@ build-vue:
install-vue:
cd web/vue && yarn install
.PHONY: run-vue
run-vue:
cd web/vue && yarn run dev
.PHONY: statik
statik:
go get github.com/rakyll/statik

@ -58,7 +58,7 @@ module.exports = {
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/public/',
assetsPublicPath: 'public/',
/**
* Source Maps

@ -12,7 +12,7 @@ const AUTH_ERROR_CODE = 401
// 应用未安装
const APP_NOT_INSTALL_CODE = 801
axios.defaults.baseURL = '/api'
axios.defaults.baseURL = 'api'
axios.defaults.timeout = 10000
axios.defaults.responseType = 'json'
axios.interceptors.request.use(config => {

Loading…
Cancel
Save