go-element-admin 是一个后台前端解决方案,它基于 vue 、 element-ui、golang、gorm、casbin实现。它使用了最新的前端技术栈,内置了动态路由,权限验证以及接口验证,并提供了简单的后端API服务,开箱即用,帮助你快速构建前后端分离动态路由和权限模型。
本项目通过vue-element-admin精简改造,移除了大部分组件,如需要其他组件,可前往搬运。
你需要在本地安装 node 、git 和 mysql。本项目技术栈基于 ES2015+、vue、vuex、vue-router 、vue-cli 、axios 、 element-ui 和 golang,提前了解和学习这些知识会对使用本项目有很大的帮助。
- 登录 / 注销
- 系统管理
- 用户管理
- 菜单管理
- 接口管理
- 角色管理
- 登录日志
- 系统工具
- 接口文档
- 表单生成器
环境
-
Golang版本:1.13.8
-
包管理器:go module
-
MySQL: 5.7
新建go-element-admin数据库,然后把go-element-admin/server/go-element-admin.sql文件导入到数据库中。
cd go-element-admin/server
go build main.go
main.exe
需要热更新可以使用bee启动。
SET GOARCH=amd64
SET GOOD=linux
go build main.go
生成的main文件放到服务器项目目录下,添加执行权限:chmod +x main后,执行./main即可启动服务,或者用pm2启动。
location /api/ {
proxy_pass http://127.0.0.1:8001/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~/chat {
://github.com/Unitech/pm2roxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:8001/chat;
proxy_redirect off;
}
location /swagger/ {
proxy_pass http://127.0.0.1:8001;
}
{
"apps" : [{
"name": "go-element-admin-api",
"script": "./main",
"cwd": "./",
"error_file":"./log.txt",
"out_file":"./log.txt",
"merge_logs": true,
"instances": 1,
"autorestart": true,
"watch": [
"configs",
],
"max_memory_restart": "1G",
}]
}
# 克隆项目
git clone https://github.com/bigfool-cn/go-element-admin.git
# 进入项目目录
cd go-element-admin
# 安装依赖
npm install
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
npm install --registry=https://registry.npm.taobao.org
# 启动服务
npm run dev
浏览器访问 http://localhost:9527
# 构建测试环境
npm run build:stage
# 构建生产环境
npm run build:prod
# 预览发布环境效果
npm run preview
# 预览发布环境效果 + 静态资源分析
npm run preview -- --report
# 代码格式检查
npm run lint
# 代码格式检查并自动修复
npm run lint -- --fix
如果你觉得这个项目帮助到了你,你可以请作者吃一杯冰阔乐表示鼓励🍹:
Modern browsers and Internet Explorer 10+.
IE / Edge | Firefox | Chrome | Safari |
---|---|---|---|
IE10, IE11, Edge | last 2 versions | last 2 versions | last 2 versions |
Copyright (c) 2020-present bigfool-cn