diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 0000000..fdfcc80 --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,64 @@ +# 构建 VitePress 站点并将其部署到 GitHub Pages 的示例工作流程 +# +name: Deploy docs site to Pages + +on: + # 在针对 `main` 分支的推送上运行。如果你 + # 使用 `master` 分支作为默认分支,请将其更改为 `master` + push: + branches: [dev] + + # 允许你从 Actions 选项卡手动运行此工作流程 + workflow_dispatch: + +# 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# 只允许同时进行一次部署,跳过正在运行和最新队列之间的运行队列 +# 但是,不要取消正在进行的运行,因为我们希望允许这些生产部署完成 +concurrency: + group: pages + cancel-in-progress: false + +jobs: + # 构建工作 + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # 如果未启用 lastUpdated,则不需要 + - uses: pnpm/action-setup@v3 # 如果使用 pnpm,请取消注释 + # - uses: oven-sh/setup-bun@v1 # 如果使用 Bun,请取消注释 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm # 或 pnpm / yarn + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: Install dependencies + run: cd docs && pnpm install # 或 pnpm install / yarn install / bun install + - name: Build with VitePress + run: npm run docs:build # 或 pnpm docs:build / yarn docs:build / bun run docs:build + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: .vitepress/dist + + # 部署工作 + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest + name: Deploy + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/README.md b/README.md index 3657bcd..571123a 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,6 @@ 账号:admin 密码:123456 ## 开发部署文档 -0. [使用](./docs/0.使用.md) -1. [打包部署](./docs/1.go-打包部署.md) -2. [nginx配置.md](./docs/2.nginx配置.md) ## 简介 diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..c817e00 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,40 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +pnpm-lock.yaml +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +# unplugin-auto-import +auto-imports.d.ts +components.d.ts +.eslintrc-auto-import.json + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# .env +.env.development +.env.production +test.html + + +.vitepress/cache/ \ No newline at end of file diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts new file mode 100644 index 0000000..60c2fac --- /dev/null +++ b/docs/.vitepress/config.mts @@ -0,0 +1,42 @@ +import { defineConfig } from 'vitepress' + +// https://vitepress.dev/reference/site-config +export default defineConfig({ + // base:'/docs/', + title: "x_admin", + description: "x_admin 开发文档", + themeConfig: { + // https://vitepress.dev/reference/default-theme-config + nav: [ + { text: 'Home', link: '/' }, + { text: '后端', link: '/server/准备.md' }, + { text: '前端', link: '/admin/准备.md' } + ], + + sidebar: [ + { + text: '后端', + items: [ + // { text: '后端', link: '/markdown-examples' }, + // { text: '前端', link: '/api-examples' }, + + { text: '准备', link: '/server/准备.md' }, + { text: 'Go打包', link: '/server/部署Go.md' }, + { text: 'nginx配置', link: '/server/nginx配置.md' }, + ] + }, + { + text: '前端', + items: [ + { text: '准备', link: '/admin/准备.md' }, + + { text: 'nginx配置', link: '/admin/nginx配置.md' }, + ] + } + ], + + socialLinks: [ + { icon: 'github', link: 'https://github.com/adtkcn/x_admin' } + ] + } +}) diff --git a/docs/admin/nginx配置.md b/docs/admin/nginx配置.md new file mode 100644 index 0000000..c14cb53 --- /dev/null +++ b/docs/admin/nginx配置.md @@ -0,0 +1,11 @@ + +# nginx配置 + +``` +## 前端页面使用history模式需要重定向 +```nginx +location / { + index /index.html; + try_files $uri $uri/ /index.html; +} +``` \ No newline at end of file diff --git a/docs/admin/准备.md b/docs/admin/准备.md new file mode 100644 index 0000000..ed86d6d --- /dev/null +++ b/docs/admin/准备.md @@ -0,0 +1,30 @@ +# 前期准备 + +前端 +1. 安装 node +2. 安装 pnpm(推荐) +3. 安装 git + + +# 使用 + +### 下载项目 + +```bash +# 二选一 +git clone git@gitee.com:xiangheng/x_admin.git +git clone git@github.com:adtkcn/x_admin.git +``` + + +### 运行前端 +1. 复制并重命名`x_admin/admin/.env.development.example`为`x_admin/admin/.env.development`文件, +2. `.env.development`必须配置 `VITE_APP_BASE_URL`后端地址信息。 + +```bash +cd x_admin/admin +# 安装依赖 +pnpm install +# 运行 +pnpm run dev +``` \ No newline at end of file diff --git a/docs/api-examples.md b/docs/api-examples.md new file mode 100644 index 0000000..6bd8bb5 --- /dev/null +++ b/docs/api-examples.md @@ -0,0 +1,49 @@ +--- +outline: deep +--- + +# Runtime API Examples + +This page demonstrates usage of some of the runtime APIs provided by VitePress. + +The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files: + +```md + + +## Results + +### Theme Data +
{{ theme }}
+
+### Page Data
+{{ page }}
+
+### Page Frontmatter
+{{ frontmatter }}
+```
+
+
+
+## Results
+
+### Theme Data
+{{ theme }}
+
+### Page Data
+{{ page }}
+
+### Page Frontmatter
+{{ frontmatter }}
+
+## More
+
+Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..9ee84d3
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,25 @@
+---
+# https://vitepress.dev/reference/default-theme-home-page
+layout: home
+
+hero:
+ name: "x_admin"
+ text: "Go语言 通用管理后台"
+ tagline: x_admin是一套快速开发通用管理后台,使用流行的技术栈Go、TypeScript、Vue3、vite、Element Plus。一键生成前端、后端、uniapp代码
+ actions:
+ - theme: brand
+ text: 前端文档
+ link: /admin/准备.html
+ - theme: brand
+ text: 后端文档
+ link: /server/准备.html
+
+features:
+ - title: 方便部署
+ details: 未使用cgo,Go可以跨平台打包,不需要运行环境Sdk
+ - title: 轻量级
+ details: 运行时不到50M内存占用,暴打Java
+ - title: 快速生成CRUD代码
+ details: 通过已有数据库表生成CRUD代码,减少开发成本
+---
+
diff --git a/docs/markdown-examples.md b/docs/markdown-examples.md
new file mode 100644
index 0000000..f9258a5
--- /dev/null
+++ b/docs/markdown-examples.md
@@ -0,0 +1,85 @@
+# Markdown Extension Examples
+
+This page demonstrates some of the built-in markdown extensions provided by VitePress.
+
+## Syntax Highlighting
+
+VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
+
+**Input**
+
+````md
+```js{4}
+export default {
+ data () {
+ return {
+ msg: 'Highlighted!'
+ }
+ }
+}
+```
+````
+
+**Output**
+
+```js{4}
+export default {
+ data () {
+ return {
+ msg: 'Highlighted!'
+ }
+ }
+}
+```
+
+## Custom Containers
+
+**Input**
+
+```md
+::: info
+This is an info box.
+:::
+
+::: tip
+This is a tip.
+:::
+
+::: warning
+This is a warning.
+:::
+
+::: danger
+This is a dangerous warning.
+:::
+
+::: details
+This is a details block.
+:::
+```
+
+**Output**
+
+::: info
+This is an info box.
+:::
+
+::: tip
+This is a tip.
+:::
+
+::: warning
+This is a warning.
+:::
+
+::: danger
+This is a dangerous warning.
+:::
+
+::: details
+This is a details block.
+:::
+
+## More
+
+Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
diff --git a/docs/package.json b/docs/package.json
new file mode 100644
index 0000000..6c0da97
--- /dev/null
+++ b/docs/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "x_admin_docs",
+ "version": "1.0.0",
+ "description": "文档",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "docs:dev": "vitepress dev",
+ "docs:build": "vitepress build",
+ "docs:preview": "vitepress preview"
+ },
+ "author": "",
+ "license": "ISC",
+ "pnpm": {
+ "peerDependencyRules": {
+ "ignoreMissing": [
+ "@algolia/client-search",
+ "search-insights"
+ ]
+ }
+ },
+ "devDependencies": {
+ "vitepress": "^1.2.3",
+ "vue": "^3.4.30"
+ }
+}
\ No newline at end of file
diff --git a/docs/server/nginx配置.md b/docs/server/nginx配置.md
new file mode 100644
index 0000000..3f2d1e2
--- /dev/null
+++ b/docs/server/nginx配置.md
@@ -0,0 +1,19 @@
+
+# nginx配置
+## 反向代理接口
+```nginx
+location ^~ /api
+{
+ proxy_pass http://127.0.0.1:8001;
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header REMOTE-HOST $remote_addr;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection $connection_upgrade;
+ proxy_http_version 1.1;
+ # proxy_hide_header Upgrade;
+
+ add_header X-Cache $upstream_cache_status;
+
+}
\ No newline at end of file
diff --git a/docs/server/准备.md b/docs/server/准备.md
new file mode 100644
index 0000000..0b20f33
--- /dev/null
+++ b/docs/server/准备.md
@@ -0,0 +1,33 @@
+# 前期准备
+
+后端
+1. 安装 go
+2. 安装 mysql
+3. 安装 redis
+4. 安装 git
+5. 安装 swag: `go install github.com/swaggo/swag/cmd/swag@latest`
+
+
+# 使用
+
+### 1.下载项目
+
+```bash
+# 二选一
+git clone git@gitee.com:xiangheng/x_admin.git
+git clone git@github.com:adtkcn/x_admin.git
+```
+
+### 2.创建数据库并导入`x_admin/sql/`目录下 sql 文件
+
+### 3.运行后端
+1. 复制并重命名`x_admin/server/.env.example`为`x_admin/server/.env`文件,
+2. `.env`必须配置 `mysql` 和 `redis` 信息。
+```bash
+cd x_admin/server
+# 生成接口文档
+swag init
+# 运行, 在vscode中打开server目录中的文件,按F5即可运行
+go run .
+
+```
\ No newline at end of file
diff --git a/docs/server/环境变量.md b/docs/server/环境变量.md
new file mode 100644
index 0000000..e69de29
diff --git a/docs/1.go-打包部署.md b/docs/server/部署Go.md
similarity index 100%
rename from docs/1.go-打包部署.md
rename to docs/server/部署Go.md
diff --git a/server.code-workspace b/server.code-workspace
index f9fa505..a337fe3 100644
--- a/server.code-workspace
+++ b/server.code-workspace
@@ -11,6 +11,9 @@
},
{
"path": "x_admin_app"
+ },
+ {
+ "path": ".github"
}
]
}
\ No newline at end of file