commit c9ffb52b7fda6cc75f4882691fe3d32776c0adea Author: Eg <1711788888@qq.com> Date: Tue Apr 7 09:03:48 2026 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..613bcd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,80 @@ +# ---> Go +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +go.work.sum + +# env file +.env + +# ---> Vue +# gitignore template for Vue.js projects +# +# Recommended template: Node.gitignore + +# TODO: where does this rule come from? +docs/_book + +# TODO: where does this rule come from? +test/ + +# ---> macOS +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk +.idea + +# ---> Server Files +logs +log +uploads +upload +server/config.yaml + +# ---> AI +.claude +.codex +.cursor +.gpt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9135c9a --- /dev/null +++ b/Makefile @@ -0,0 +1,75 @@ +SHELL = /bin/bash + +#SCRIPT_DIR = $(shell pwd)/etc/script +#请选择golang版本 +BUILD_IMAGE_SERVER = golang:1.22 +#请选择node版本 +BUILD_IMAGE_WEB = node:20 +#项目名称 +PROJECT_NAME = github.com/flipped-aurora/gin-vue-admin/server +#配置文件目录 +CONFIG_FILE = config.yaml +#镜像仓库命名空间 +IMAGE_NAME = gva +#镜像地址 +REPOSITORY = registry.cn-hangzhou.aliyuncs.com/${IMAGE_NAME} +#镜像版本 +TAGS_OPT ?= latest +PLUGIN ?= email + +#容器环境前后端共同打包 +build: build-web build-server + docker run --name build-local --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE_SERVER} make build-local + +#容器环境打包前端 +build-web: + docker run --name build-web-local --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE_WEB} make build-web-local + +#容器环境打包后端 +build-server: + docker run --name build-server-local --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE_SERVER} make build-server-local + +#构建web镜像 +build-image-web: + @cd web/ && docker build -t ${REPOSITORY}/web:${TAGS_OPT} . + +#构建server镜像 +build-image-server: + @cd server/ && docker build -t ${REPOSITORY}/server:${TAGS_OPT} . + +#本地环境打包前后端 +build-local: + if [ -d "build" ];then rm -rf build; else echo "OK!"; fi \ + && if [ -f "/.dockerenv" ];then echo "OK!"; else make build-web-local && make build-server-local; fi \ + && mkdir build && cp -r web/dist build/ && cp server/server build/ && cp -r server/resource build/resource + +#本地环境打包前端 +build-web-local: + @cd web/ && if [ -d "dist" ];then rm -rf dist; else echo "OK!"; fi \ + && yarn config set registry http://mirrors.cloud.tencent.com/npm/ && yarn install && yarn build + +#本地环境打包后端 +build-server-local: + @cd server/ && if [ -f "server" ];then rm -rf server; else echo "OK!"; fi \ + && go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct \ + && go env -w CGO_ENABLED=0 && go env && go mod tidy \ + && go build -ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${TAGS_OPT}" -v + +#打包前后端二合一镜像 +image: build + docker build -t ${REPOSITORY}/gin-vue-admin:${TAGS_OPT} -f deploy/docker/Dockerfile . + +#尝鲜版 +images: build build-image-web build-image-server + docker build -t ${REPOSITORY}/all:${TAGS_OPT} -f deploy/docker/Dockerfile . + +#swagger 文档生成 +doc: + @cd server && swag init + +#插件快捷打包: make plugin PLUGIN="这里是插件文件夹名称,默认为email" +plugin: + if [ -d ".plugin" ];then rm -rf .plugin ; else echo "OK!"; fi && mkdir -p .plugin/${PLUGIN}/{server/plugin,web/plugin} \ + && if [ -d "server/plugin/${PLUGIN}" ];then cp -r server/plugin/${PLUGIN} .plugin/${PLUGIN}/server/plugin/ ; else echo "OK!"; fi \ + && if [ -d "web/src/plugin/${PLUGIN}" ];then cp -r web/src/plugin/${PLUGIN} .plugin/${PLUGIN}/web/plugin/ ; else echo "OK!"; fi \ + && cd .plugin && zip -r ${PLUGIN}.zip ${PLUGIN} && mv ${PLUGIN}.zip ../ && cd .. diff --git a/README.md b/README.md new file mode 100644 index 0000000..cfae15a --- /dev/null +++ b/README.md @@ -0,0 +1,389 @@ + +
+|
+
+ 📄 创建基础模板 +🤖 AI生成结构 +⏰ 生成代码 +🏷️ 分配权限 +🎉 基础CURD生成完成 + |
+ + + | +
+
+
+
+## 1. 基本介绍
+
+### 1.1 项目介绍
+
+> Gin-vue-admin是一个基于 [vue](https://vuejs.org) 和 [gin](https://gin-gonic.com) 开发的全栈前后端分离的开发基础平台,集成jwt鉴权,动态路由,动态菜单,casbin鉴权,表单生成器,代码生成器等功能,提供多种示例文件,让您把更多时间专注在业务开发上。
+
+[在线预览](http://demo.gin-vue-admin.com): http://demo.gin-vue-admin.com
+
+测试用户名:admin
+
+测试密码:123456
+
+### 1.2 贡献指南
+Hi! 首先感谢你使用 gin-vue-admin。
+
+Gin-vue-admin 是一套为快速研发准备的一整套前后端分离架构式的开源框架,旨在快速搭建中小型项目。
+
+Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-admin 贡献代码或提供建议,请阅读以下内容。
+
+#### 1.2.1 Issue 规范
+- issue 仅用于提交 Bug 或 Feature 以及设计相关的内容,其它内容可能会被直接关闭。
+
+- 在提交 issue 之前,请搜索相关内容是否已被提出。
+
+#### 1.2.2 Pull Request 规范
+- 请先 fork 一份到自己的项目下,不要直接在仓库下建分支。
+
+- commit 信息要以`[文件名]: 描述信息` 的形式填写,例如 `README.md: fix xxx bug`。
+
+- 如果是修复 bug,请在 PR 中给出描述信息。
+
+- 合并代码需要两名维护人员参与:一人进行 review 后 approve,另一人再次 review,通过后即可合并。
+
+## 2. 使用说明
+
+```
+- node版本 > v18.16.0
+- golang版本 >= v1.22
+- IDE推荐:Goland
+```
+
+### 2.1 server项目
+
+使用 `Goland` 等编辑工具,打开server目录,不可以打开 gin-vue-admin 根目录
+
+```bash
+
+# 克隆项目
+git clone https://github.com/flipped-aurora/gin-vue-admin.git
+# 进入server文件夹
+cd server
+
+# 使用 go mod 并安装go依赖包
+go generate
+
+# 运行
+go run .
+
+```
+
+### 2.2 web项目
+
+```bash
+# 进入web文件夹
+cd web
+
+# 安装依赖
+npm install
+
+# 启动web项目
+npm run serve
+```
+
+### 2.3 swagger自动化API文档
+
+#### 2.3.1 安装 swagger
+
+``` shell
+go install github.com/swaggo/swag/cmd/swag@latest
+```
+
+#### 2.3.2 生成API文档
+
+```` shell
+cd server
+swag init
+````
+
+> 执行上面的命令后,server目录下会出现docs文件夹里的 `docs.go`, `swagger.json`, `swagger.yaml` 三个文件更新,启动go服务之后, 在浏览器输入 [http://localhost:8888/swagger/index.html](http://localhost:8888/swagger/index.html) 即可查看swagger文档
+
+### 2.4 VSCode工作区
+
+#### 2.4.1 开发
+
+使用`VSCode`打开根目录下的工作区文件`gin-vue-admin.code-workspace`,在边栏可以看到三个虚拟目录:`backend`、`frontend`、`root`。
+
+#### 2.4.2 运行/调试
+
+在运行和调试中也可以看到三个task:`Backend`、`Frontend`、`Both (Backend & Frontend)`。运行`Both (Backend & Frontend)`可以同时启动前后端项目。
+
+#### 2.4.3 settings
+
+在工作区配置文件中有`go.toolsEnvVars`字段,是用于`VSCode`自身的go工具环境变量。此外在多go版本的系统中,可以通过`gopath`、`go.goroot`指定运行版本。
+
+```json
+ "go.gopath": null,
+ "go.goroot": null,
+```
+
+## 3. 技术选型
+
+- 前端:用基于 [Vue](https://vuejs.org) 的 [Element](https://github.com/ElemeFE/element) 构建基础页面。
+- 后端:用 [Gin](https://gin-gonic.com/) 快速搭建基础restful风格API,[Gin](https://gin-gonic.com/) 是一个go语言编写的Web框架。
+- 数据库:采用`MySql` > (5.7) 版本 数据库引擎 InnoDB,使用 [gorm](http://gorm.cn) 实现对数据库的基本操作。
+- 缓存:使用`Redis`实现记录当前活跃用户的`jwt`令牌并实现多点登录限制。
+- API文档:使用`Swagger`构建自动化文档。
+- 配置文件:使用 [fsnotify](https://github.com/fsnotify/fsnotify) 和 [viper](https://github.com/spf13/viper) 实现`yaml`格式的配置文件。
+- 日志:使用 [zap](https://github.com/uber-go/zap) 实现日志记录。
+
+## 4. 项目架构
+
+### 4.1 系统架构图
+
+
+
+### 4.2 前端详细设计图 (提供者:baobeisuper)
+
+
+
+### 4.3 目录结构
+
+```
+ ├── server
+ ├── api (api层)
+ │ └── v1 (v1版本接口)
+ ├── config (配置包)
+ ├── core (核心文件)
+ ├── docs (swagger文档目录)
+ ├── global (全局对象)
+ ├── initialize (初始化)
+ │ └── internal (初始化内部函数)
+ ├── middleware (中间件层)
+ ├── model (模型层)
+ │ ├── request (入参结构体)
+ │ └── response (出参结构体)
+ ├── packfile (静态文件打包)
+ ├── resource (静态资源文件夹)
+ │ ├── excel (excel导入导出默认路径)
+ │ ├── page (表单生成器)
+ │ └── template (模板)
+ ├── router (路由层)
+ ├── service (service层)
+ ├── source (source层)
+ └── utils (工具包)
+ ├── timer (定时器接口封装)
+ └── upload (oss接口封装)
+
+ web
+ ├── babel.config.js
+ ├── Dockerfile
+ ├── favicon.ico
+ ├── index.html -- 主页面
+ ├── limit.js -- 助手代码
+ ├── package.json -- 包管理器代码
+ ├── src -- 源代码
+ │ ├── api -- api 组
+ │ ├── App.vue -- 主页面
+ │ ├── assets -- 静态资源
+ │ ├── components -- 全局组件
+ │ ├── core -- gva 组件包
+ │ │ ├── config.js -- gva网站配置文件
+ │ │ ├── gin-vue-admin.js -- 注册欢迎文件
+ │ │ └── global.js -- 统一导入文件
+ │ ├── directive -- v-auth 注册文件
+ │ ├── main.js -- 主文件
+ │ ├── permission.js -- 路由中间件
+ │ ├── pinia -- pinia 状态管理器,取代vuex
+ │ │ ├── index.js -- 入口文件
+ │ │ └── modules -- modules
+ │ │ ├── dictionary.js
+ │ │ ├── router.js
+ │ │ └── user.js
+ │ ├── router -- 路由声明文件
+ │ │ └── index.js
+ │ ├── style -- 全局样式
+ │ │ ├── base.scss
+ │ │ ├── basics.scss
+ │ │ ├── element_visiable.scss -- 此处可以全局覆盖 element-plus 样式
+ │ │ ├── iconfont.css -- 顶部几个icon的样式文件
+ │ │ ├── main.scss
+ │ │ ├── mobile.scss
+ │ │ └── newLogin.scss
+ │ ├── utils -- 方法包库
+ │ │ ├── asyncRouter.js -- 动态路由相关
+ │ │ ├── btnAuth.js -- 动态权限按钮相关
+ │ │ ├── bus.js -- 全局mitt声明文件
+ │ │ ├── date.js -- 日期相关
+ │ │ ├── dictionary.js -- 获取字典方法
+ │ │ ├── downloadImg.js -- 下载图片方法
+ │ │ ├── format.js -- 格式整理相关
+ │ │ ├── image.js -- 图片相关方法
+ │ │ ├── page.js -- 设置页面标题
+ │ │ ├── request.js -- 请求
+ │ │ └── stringFun.js -- 字符串文件
+ | ├── view -- 主要view代码
+ | | ├── about -- 关于我们
+ | | ├── dashboard -- 面板
+ | | ├── error -- 错误
+ | | ├── example --上传案例
+ | | ├── iconList -- icon列表
+ | | ├── init -- 初始化数据
+ | | | ├── index -- 新版本
+ | | | ├── init -- 旧版本
+ | | ├── layout -- layout约束页面
+ | | | ├── aside
+ | | | ├── bottomInfo -- bottomInfo
+ | | | ├── screenfull -- 全屏设置
+ | | | ├── setting -- 系统设置
+ | | | └── index.vue -- base 约束
+ | | ├── login --登录
+ | | ├── person --个人中心
+ | | ├── superAdmin -- 超级管理员操作
+ | | ├── system -- 系统检测页面
+ | | ├── systemTools -- 系统配置相关页面
+ | | └── routerHolder.vue -- page 入口页面
+ ├── vite.config.js -- vite 配置文件
+ └── yarn.lock
+
+```
+
+## 5. 主要功能
+
+- 权限管理:基于`jwt`和`casbin`实现的权限管理。
+- 文件上传下载:实现基于`七牛云`, `阿里云`, `腾讯云` 的文件上传操作(请开发自己去各个平台的申请对应 `token` 或者对应`key`)。
+- 分页封装:前端使用 `mixins` 封装分页,分页方法调用 `mixins` 即可。
+- 用户管理:系统管理员分配用户角色和角色权限。
+- 角色管理:创建权限控制的主要对象,可以给角色分配不同api权限和菜单权限。
+- 菜单管理:实现用户动态菜单配置,实现不同角色不同菜单。
+- api管理:不同用户可调用的api接口的权限不同。
+- 配置管理:配置文件可前台修改(在线体验站点不开放此功能)。
+- 条件搜索:增加条件搜索示例。
+- restful示例:可以参考用户管理模块中的示例API。
+ - 前端文件参考: [web/src/view/superAdmin/api/api.vue](https://github.com/flipped-aurora/gin-vue-admin/blob/master/web/src/view/superAdmin/api/api.vue)
+ - 后台文件参考: [server/router/sys_api.go](https://github.com/flipped-aurora/gin-vue-admin/blob/master/server/router/sys_api.go)
+- 多点登录限制:需要在`config.yaml`中把`system`中的`use-multipoint`修改为true(需要自行配置Redis和Config中的Redis参数,测试阶段,有bug请及时反馈)。
+- 分片上传:提供文件分片上传和大文件分片上传功能示例。
+- 表单生成器:表单生成器借助 [@Variant Form](https://github.com/vform666/variant-form) 。
+- 代码生成器:后台基础逻辑以及简单curd的代码生成器。
+
+## 6. 知识库
+
+## 6.1 团队博客
+
+> https://www.yuque.com/flipped-aurora
+>
+>内有前端框架教学视频。如果觉得项目对您有所帮助可以添加我的个人微信:shouzi_1994,欢迎您提出宝贵的需求。
+
+## 6.2 教学视频
+
+(1)手把手教学视频
+
+> https://www.bilibili.com/video/BV1Rg411u7xH/
+
+(2)后端目录结构调整介绍以及使用方法
+
+> https://www.bilibili.com/video/BV1x44y117TT/
+
+(3)golang基础教学视频
+
+> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=108884
+
+(4)gin框架基础教学
+
+> bilibili:https://space.bilibili.com/322210472/channel/detail?cid=126418&ctype=0
+
+(5)gin-vue-admin 版本更新介绍视频
+
+> bilibili:https://www.bilibili.com/video/BV1kv4y1g7nT
+
+## 7. 联系方式
+
+### 7.1 技术群
+
+### QQ交流群:971857775
+
+### 微信交流群
+| 微信 |
+| :---: |
+|
+
+防止广告进群,添加微信,输入以下代码执行结果(请勿转码为string)
+
+```
+str := "5Yqg5YWlR1ZB5Lqk5rWB576k"
+decodeBytes, err := base64.StdEncoding.DecodeString(str)
+fmt.Println(decodeBytes, err)
+```
+
+### [关于我们](https://www.gin-vue-admin.com/about/join.html)
+
+## 8. 贡献者
+
+感谢您对gin-vue-admin的贡献!
+
+
+ {item}
+
+ {JSON.stringify(value, null, 2)}
+
+ )
+ }
+
+ return String(value)
+}
+
+export function ServerStatePage() {
+ const [server, setServer] = useState
+ {JSON.stringify(config, null, 2)}
+
+ ),
+ },
+ ]}
+ />
+