Vuepress 2从0-1保姆级入门教程——主题与部署

该文章提供Vuepress2的详细教程,包括从环境配置、安装流程到文档配置和范例部署的保姆级指南。进阶部分涉及全文搜索和主题美化。此外,介绍了多种部署方案,如deploy.sh脚本和GitHubActions,并提供了主题案例供参考。

在这里插入图片描述

Vuepress 2 专栏目录【已完结】

1. 入门阶段

  1. Vuepress 2从0-1保姆级入门教程——环境配置篇
  2. Vuepress 2从0-1保姆级入门教程——安装流程篇
  3. Vuepress 2从0-1保姆级入门教程——文档配置篇
  4. Vuepress 2从0-1保姆级入门教程——主题与部署

2.进阶阶段

  1. Vuepress 2从0-1保姆级进阶教程——全文搜索篇
  2. Vuepress 2从0-1保姆级进阶教程——美化与模版
  3. Vuepress 2从0-1保姆级进阶教程——标准化流程

一、主题欣赏

厌倦了默认主题样式,又不想自己DIY,个人搜集整理的各大主题案例,方便大家参考

在这里插入图片描述

(一)Reco主题

🔗Reco主题文档查看

在这里插入图片描述

以下为截图展示

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(二)Hope主题

🔎 Hope主题文档了解详情

在这里插入图片描述

在这里插入图片描述

(三)Plume主题

🔍 访问Plume主题文档了解详情

在这里插入图片描述

二、部署

可选Vuepress 2标准化流程里的commit工具

方案1 Github Page

手动推送

1️⃣ 根目录新建deploy.sh,名字任取

#空项目预置环境

# 确保脚本抛出遇到的错误
set -e

# 生成静态文件
pnpm docs:build

# 进入生成的文件夹
cd dist

# 如果是发布到自定义域名
# echo 'www.example.com' > CNAME

git init
git add -A

git commit -m "your commit"
# 如果发布到 https://<USERNAME>.github.io
git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master

# 如果发布到 https://<USERNAME>.github.io/<REPO>
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages

cd -

2️⃣ 终端打开Git,输入./deploy.sh

在这里插入图片描述

自动推送

vuepress2自动安装时如果跳过添加GitHub action,可在根目录新建 📁 .github,里面新建docs.yml 输入


name: Deploy Blog

on:
  push:
    branches:
      # make sure this is the branch you are using
      - master

permissions:
  contents: write

jobs:
  deploy-gh-pages:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          # if your docs needs submodules, uncomment the following line
          # submodules: true

      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          version: 8
          run_install: true


      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: pnpm


      - name: Build Docs
        env:
          NODE_OPTIONS: --max_old_space_size=8192
        run: |-
          pnpm run docs:build
          > src/.vuepress/dist/.nojekyll

      - name: Deploy Docs
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          # This is the branch where the docs are deployed to
          branch: deploy
          folder: docs/.vuepress/dist

方案2 serverless

方案3 docs:build

利用ftp软件手动部署到服务器

pnpm docs:build

如果没有更改过默认设置,输出文件夹通常在📁.vuepress里面,直接复制文件夹内容到需要的位置

### 部署 RuoYi-Vue-Plus 项目的详细步骤 #### 环境准备 在部署 RuoYi-Vue-Plus 项目之前,确保以下环境和工具已正确安装: - **Java JDK**:安装 Java 8 或更高版本。 - **Maven**:用于后端项目的依赖管理和构建。 - **Node.js**:前端项目依赖 Node.js 环境,推荐版本为 14.x 或更高。 - **Git**:用于克隆项目代码。 - **数据库**:支持 MySQL、Oracle 等数据库,推荐使用 MySQL 8.x。 - **IDE**:如 IntelliJ IDEA、VS Code 等,用于代码编辑和调试。 #### 后端部署步骤 1. **克隆项目代码** ```bash git clone https://github.com/JavaLionLi/RuoYi-Vue-Plus.git cd RuoYi-Vue-Plus ``` 2. **配置数据库** - 创建数据库并导入 SQL 文件: ```sql CREATE DATABASE ruoyi_vue_plus; USE ruoyi_vue_plus; SOURCE path_to_sql_file.sql; ``` - 修改数据库连接配置(`application.yml` 文件): ```yaml spring: datasource: url: jdbc:mysql://localhost:3306/ruoyi_vue_plus?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: your_password ``` 3. **构建后端项目** - 使用 Maven 构建项目: ```bash mvn clean install ``` - 运行项目: ```bash java -jar target/ruoyi-admin.jar ``` #### 前端部署步骤 1. **进入前端目录** ```bash cd ruoyi-ui ``` 2. **安装依赖** ```bash npm install ``` 3. **配置环境变量** - 修改 `vue.config.js` 文件中的代理配置以匹配后端地址: ```javascript module.exports = { devServer: { proxy: { '/api': { target: 'http://localhost:8080', changeOrigin: true, pathRewrite: { '^/api': '' } } } } } ``` 4. **启动开发服务器** ```bash npm run dev ``` 5. **构建生产环境代码** ```bash npm run build ``` 6. **部署前端代码** - 将生成的 `dist` 目录内容部署到 Nginx 或其他 Web 服务器。 #### Nginx 配置示例 1. **Nginx 配置文件** ```nginx server { listen 80; server_name your_domain; location / { root /path/to/dist; index index.html; try_files $uri $uri/ =404; } location /api { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ``` 2. **重启 Nginx** ```bash sudo systemctl restart nginx ``` #### 验证部署 - 打开浏览器访问 `http://your_domain`,输入默认账号和密码(如 `admin/admin123`)登录系统。 - 检查接口是否正常调用,确保所有功能模块可用。 #### 常见问题解决方案 - **数据库连接失败**:检查数据库服务是否启动,验证 `application.yml` 中的数据库配置。 - **前端无法访问后端接口**:确认代理配置是否正确,检查跨域设置。 - **权限问题**:确保 Sa-Token 的配置实际环境匹配,检查 JWT 密钥是否正确。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值