ci(other): ci update
This commit is contained in:
158
.drone.yml
158
.drone.yml
@@ -1,158 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: default
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: 测试服-依赖安装&&编译打包
|
|
||||||
pull: if-not-exists
|
|
||||||
image: node:20-alpine
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- test
|
|
||||||
commands:
|
|
||||||
- npm config set registry https://registry.npmmirror.com/
|
|
||||||
- npm install -g pnpm
|
|
||||||
- pnpm install
|
|
||||||
- pnpm build:test
|
|
||||||
- rm -rf dist.tar
|
|
||||||
- rm -rf node_modules
|
|
||||||
- tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
|
|
||||||
|
|
||||||
- name: 正式服-依赖安装&&编译打包
|
|
||||||
pull: if-not-exists
|
|
||||||
image: node:20-alpine
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- main
|
|
||||||
commands:
|
|
||||||
- npm config set registry https://registry.npmmirror.com/
|
|
||||||
- npm install -g pnpm
|
|
||||||
- pnpm install
|
|
||||||
- pnpm build:prod
|
|
||||||
- rm -rf dist.tar
|
|
||||||
- rm -rf node_modules
|
|
||||||
- tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
|
|
||||||
|
|
||||||
- name: 测试服-产物上传
|
|
||||||
pull: if-not-exists
|
|
||||||
image: appleboy/drone-scp
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- test
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: HOST_DEV
|
|
||||||
username:
|
|
||||||
from_secret: USER_DEV
|
|
||||||
password:
|
|
||||||
from_secret: PWD_DEV
|
|
||||||
port: 22
|
|
||||||
strip_components: 1
|
|
||||||
target: /www/builder
|
|
||||||
source:
|
|
||||||
- ./dist.tar
|
|
||||||
|
|
||||||
- name: 测试服-部署
|
|
||||||
pull: if-not-exists
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- test
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: HOST_DEV
|
|
||||||
username:
|
|
||||||
from_secret: USER_DEV
|
|
||||||
password:
|
|
||||||
from_secret: PWD_DEV
|
|
||||||
port: 22
|
|
||||||
script:
|
|
||||||
- cd /www/builder
|
|
||||||
- mkdir jdt-mer-dev
|
|
||||||
- tar -xzvf dist.tar -C /www/builder/jdt-mer-dev
|
|
||||||
- rm -rf dist.tar
|
|
||||||
- cd jdt-mer-dev
|
|
||||||
- docker build -t jdt-mer-dev .
|
|
||||||
- docker stop jdt-mer-dev
|
|
||||||
- docker rm jdt-mer-dev
|
|
||||||
- docker run -d -p 8083:80 --restart=always --name jdt-mer-dev jdt-mer-dev
|
|
||||||
- cd ..
|
|
||||||
- rm -rf jdt-mer-dev
|
|
||||||
|
|
||||||
- name: 正式服-产物上传
|
|
||||||
pull: if-not-exists
|
|
||||||
image: appleboy/drone-scp
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- main
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: HOST_PROD
|
|
||||||
username:
|
|
||||||
from_secret: USER_PROD
|
|
||||||
password:
|
|
||||||
from_secret: PWD_PROD
|
|
||||||
port: 22
|
|
||||||
strip_components: 1
|
|
||||||
target: /www/builder
|
|
||||||
source:
|
|
||||||
- ./dist.tar
|
|
||||||
|
|
||||||
- name: 正式服-部署
|
|
||||||
pull: if-not-exists
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- main
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: HOST_PROD
|
|
||||||
username:
|
|
||||||
from_secret: USER_PROD
|
|
||||||
password:
|
|
||||||
from_secret: PWD_PROD
|
|
||||||
port: 22
|
|
||||||
script:
|
|
||||||
- cd /www/builder
|
|
||||||
- mkdir jdt-mer-prod
|
|
||||||
- tar -xzvf dist.tar -C /www/builder/jdt-mer-prod
|
|
||||||
- rm -rf dist.tar
|
|
||||||
- cd jdt-mer-prod
|
|
||||||
- docker build -t jdt-mer-prod .
|
|
||||||
- docker stop jdt-mer-prod
|
|
||||||
- docker rm jdt-mer-prod
|
|
||||||
- docker run -d -p 8083:80 --restart=always --name jdt-mer-prod jdt-mer-prod
|
|
||||||
- cd ..
|
|
||||||
- rm -rf jdt-mer-prod
|
|
||||||
|
|
||||||
- name: 企业微信通知
|
|
||||||
pull: if-not-exists
|
|
||||||
image: plugins/webhook
|
|
||||||
when:
|
|
||||||
branch:
|
|
||||||
- test
|
|
||||||
- main
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
- failure
|
|
||||||
settings:
|
|
||||||
urls: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a2065e21-4f92-4f5b-a432-2c0cd1d965b5
|
|
||||||
content_type: application/json
|
|
||||||
template: |
|
|
||||||
{
|
|
||||||
"msgtype": "markdown",
|
|
||||||
"markdown": {
|
|
||||||
"content": "{{#success build.status}}✅{{else}}❌{{/success}}**{{ repo.owner }}/{{ repo.name }}** (Build #{{build.number}})\n
|
|
||||||
>**构建结果**: {{ build.status }}
|
|
||||||
>**构建详情**: [点击查看]({{ build.link }})
|
|
||||||
>**代码分支**: {{ build.branch }}
|
|
||||||
>**提交标识**: {{ build.commit }}
|
|
||||||
>**提交发起**: {{ build.author }}
|
|
||||||
>**提交信息**: {{ build.message }}
|
|
||||||
"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
160
.gitea/workflows/ci.yaml
Normal file
160
.gitea/workflows/ci.yaml
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
name: CI Build & Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- test
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy-dev:
|
||||||
|
if: gitea.ref_name == 'test'
|
||||||
|
runs-on: gitea_act_runner
|
||||||
|
container:
|
||||||
|
image: node:24-alpine
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v3
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
run: |
|
||||||
|
npm config set registry https://registry.npmmirror.com/
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Build (test)
|
||||||
|
run: pnpm build:test
|
||||||
|
|
||||||
|
- name: Pack artifacts
|
||||||
|
run: |
|
||||||
|
rm -rf dist.tar
|
||||||
|
tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
|
||||||
|
|
||||||
|
- name: Upload artifacts to server
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.HOST_DEV }}
|
||||||
|
username: ${{ secrets.USER_DEV }}
|
||||||
|
password: ${{ secrets.PWD_DEV }}
|
||||||
|
port: 22
|
||||||
|
source: 'dist.tar'
|
||||||
|
target: '/www/builder'
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: Deploy over SSH
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.HOST_DEV }}
|
||||||
|
username: ${{ secrets.USER_DEV }}
|
||||||
|
password: ${{ secrets.PWD_DEV }}
|
||||||
|
port: 22
|
||||||
|
script: |
|
||||||
|
set -e
|
||||||
|
cd /www/builder
|
||||||
|
rm -rf jdt-mer-dev
|
||||||
|
mkdir -p jdt-mer-dev
|
||||||
|
tar -xzvf dist.tar -C /www/builder/jdt-mer-dev
|
||||||
|
rm -rf dist.tar
|
||||||
|
cd jdt-mer-dev
|
||||||
|
docker build -t jdt-mer-dev .
|
||||||
|
docker stop jdt-mer-dev || true
|
||||||
|
docker rm jdt-mer-dev || true
|
||||||
|
docker run -d -p 8083:80 --restart=always --name jdt-mer-dev jdt-mer-dev
|
||||||
|
cd ..
|
||||||
|
rm -rf jdt-mer-dev
|
||||||
|
|
||||||
|
- name: Notify WeCom (Dev)
|
||||||
|
if: always()
|
||||||
|
env:
|
||||||
|
WEBHOOK_KEY: ${{ secrets.QYWX_WEBHOOK_KEY }}
|
||||||
|
STATUS: ${{ job.status }}
|
||||||
|
REPO: ${{ gitea.repository }}
|
||||||
|
RUN_URL: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
BRANCH: ${{ gitea.ref_name }}
|
||||||
|
COMMIT: ${{ gitea.sha }}
|
||||||
|
ACTOR: ${{ gitea.actor }}
|
||||||
|
run: |
|
||||||
|
apk add --no-cache curl jq
|
||||||
|
EMOJI=$( [ "$STATUS" = "success" ] && echo "✅" || echo "❌" )
|
||||||
|
MSG="$(printf "%s**%s** (Run #%s)\n>**构建结果**: %s\n>**构建详情**: [点击查看](%s)\n>**代码分支**: %s\n>**提交标识**: %s\n>**提交发起**: %s\n" "$EMOJI" "$REPO" "${{ gitea.run_number }}" "$STATUS" "$RUN_URL" "$BRANCH" "$COMMIT" "$ACTOR")"
|
||||||
|
curl -sS -H 'Content-Type: application/json' -d "{\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"$MSG\"}}" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY}"
|
||||||
|
|
||||||
|
build-and-deploy-prod:
|
||||||
|
if: gitea.ref_name == 'main'
|
||||||
|
runs-on: gitea_act_runner
|
||||||
|
container:
|
||||||
|
image: node:24-alpine
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v3
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
run: |
|
||||||
|
npm config set registry https://registry.npmmirror.com/
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
- name: Build (prod)
|
||||||
|
run: pnpm build:prod
|
||||||
|
|
||||||
|
- name: Pack artifacts
|
||||||
|
run: |
|
||||||
|
rm -rf dist.tar
|
||||||
|
tar -zcvf dist.tar ./dist ./default.conf ./Dockerfile
|
||||||
|
|
||||||
|
- name: Upload artifacts to server
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.HOST_PROD }}
|
||||||
|
username: ${{ secrets.USER_PROD }}
|
||||||
|
password: ${{ secrets.PWD_PROD }}
|
||||||
|
port: 22
|
||||||
|
source: 'dist.tar'
|
||||||
|
target: '/www/builder'
|
||||||
|
strip_components: 0
|
||||||
|
|
||||||
|
- name: Deploy over SSH
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.HOST_PROD }}
|
||||||
|
username: ${{ secrets.USER_PROD }}
|
||||||
|
password: ${{ secrets.PWD_PROD }}
|
||||||
|
port: 22
|
||||||
|
script: |
|
||||||
|
set -e
|
||||||
|
cd /www/builder
|
||||||
|
rm -rf jdt-mer-prod
|
||||||
|
mkdir -p jdt-mer-prod
|
||||||
|
tar -xzvf dist.tar -C /www/builder/jdt-mer-prod
|
||||||
|
rm -rf dist.tar
|
||||||
|
cd jdt-mer-prod
|
||||||
|
docker build -t jdt-mer-prod .
|
||||||
|
docker stop jdt-mer-prod || true
|
||||||
|
docker rm jdt-mer-prod || true
|
||||||
|
docker run -d -p 8083:80 --restart=always --name jdt-mer-prod jdt-mer-prod
|
||||||
|
cd ..
|
||||||
|
rm -rf jdt-mer-prod
|
||||||
|
|
||||||
|
- name: Notify WeCom (Prod)
|
||||||
|
if: always()
|
||||||
|
env:
|
||||||
|
WEBHOOK_KEY: ${{ secrets.QYWX_WEBHOOK_KEY }}
|
||||||
|
STATUS: ${{ job.status }}
|
||||||
|
REPO: ${{ gitea.repository }}
|
||||||
|
RUN_URL: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}
|
||||||
|
BRANCH: ${{ gitea.ref_name }}
|
||||||
|
COMMIT: ${{ gitea.sha }}
|
||||||
|
ACTOR: ${{ gitea.actor }}
|
||||||
|
run: |
|
||||||
|
apk add --no-cache curl jq
|
||||||
|
EMOJI=$( [ "$STATUS" = "success" ] && echo "✅" || echo "❌" )
|
||||||
|
MSG="$(printf "%s**%s** (Run #%s)\n>**构建结果**: %s\n>**构建详情**: [点击查看](%s)\n>**代码分支**: %s\n>**提交标识**: %s\n>**提交发起**: %s\n" "$EMOJI" "$REPO" "${{ gitea.run_number }}" "$STATUS" "$RUN_URL" "$BRANCH" "$COMMIT" "$ACTOR")"
|
||||||
|
curl -sS -H 'Content-Type: application/json' -d "{\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"$MSG\"}}" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY}"
|
||||||
21
LICENSE
21
LICENSE
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2022 Ronnie Zhang
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
import { resolveToken } from '../utils'
|
|
||||||
|
|
||||||
const token = {
|
|
||||||
admin: 'admin',
|
|
||||||
editor: 'editor',
|
|
||||||
}
|
|
||||||
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
url: '/api/auth/login',
|
|
||||||
method: 'post',
|
|
||||||
response: ({ body }) => {
|
|
||||||
if (['admin', 'editor'].includes(body?.name)) {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
data: {
|
|
||||||
token: token[body.name],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
code: -1,
|
|
||||||
message: '没有此用户',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
url: '/api/auth/refreshToken',
|
|
||||||
method: 'post',
|
|
||||||
response: ({ headers }) => {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
data: {
|
|
||||||
token: resolveToken(headers?.authorization),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import auth from './auth'
|
|
||||||
import user from './user'
|
|
||||||
import post from './post'
|
|
||||||
|
|
||||||
export default [...auth, ...user, ...post]
|
|
||||||
138
mock/api/post.js
138
mock/api/post.js
@@ -1,138 +0,0 @@
|
|||||||
const posts = [
|
|
||||||
{
|
|
||||||
title: '使用纯css优雅配置移动端rem布局',
|
|
||||||
author: '大脸怪',
|
|
||||||
category: 'Css',
|
|
||||||
description: '通常配置rem布局会使用js进行处理,比如750的设计稿会这样...',
|
|
||||||
content: '通常配置rem布局会使用js进行处理,比如750的设计稿会这样',
|
|
||||||
isRecommend: true,
|
|
||||||
isPublish: true,
|
|
||||||
createDate: '2021-11-04T04:03:36.000Z',
|
|
||||||
updateDate: '2021-11-04T04:03:36.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Vue2&Vue3项目风格指南',
|
|
||||||
author: 'Ronnie',
|
|
||||||
category: 'Vue',
|
|
||||||
description: '总结的Vue2和Vue3的项目风格',
|
|
||||||
content: '### 1. 命名风格\n\n> 文件夹如果是由多个单词组成,应该始终是横线连接 ',
|
|
||||||
isRecommend: true,
|
|
||||||
isPublish: true,
|
|
||||||
createDate: '2021-10-25T08:57:47.000Z',
|
|
||||||
updateDate: '2022-02-28T04:02:39.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '如何优雅的给图片添加水印',
|
|
||||||
author: '大脸怪',
|
|
||||||
category: 'JavaScript',
|
|
||||||
description: '优雅的给图片添加水印',
|
|
||||||
content: '我之前写过一篇文章记录了一次上传图片的优化史',
|
|
||||||
isRecommend: true,
|
|
||||||
isPublish: true,
|
|
||||||
createDate: '2021-06-24T18:46:19.000Z',
|
|
||||||
updateDate: '2021-09-23T07:51:22.000Z',
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title: '前端缓存的理解',
|
|
||||||
author: '大脸怪',
|
|
||||||
category: 'Http',
|
|
||||||
description: '谈谈前端缓存的理解',
|
|
||||||
content:
|
|
||||||
'> 背景\n\n公司有个vue-cli3移动端web项目发版更新后发现部分用户手机在钉钉内置浏览器打开出现了缓存',
|
|
||||||
isRecommend: true,
|
|
||||||
isPublish: true,
|
|
||||||
createDate: '2021-06-10T18:51:19.000Z',
|
|
||||||
updateDate: '2021-09-17T09:33:24.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Promise的五个静态方法',
|
|
||||||
author: '大脸怪',
|
|
||||||
category: 'JavaScript',
|
|
||||||
description: '简单介绍下在 Promise 类中,有5 种静态方法及它们的使用场景',
|
|
||||||
content:
|
|
||||||
'## 1. Promise.all\n\n并行执行多个 promise,并等待所有 promise 都准备就绪。再对它们进行处理。',
|
|
||||||
isRecommend: true,
|
|
||||||
isPublish: true,
|
|
||||||
createDate: '2021-02-22T22:37:06.000Z',
|
|
||||||
updateDate: '2021-09-17T09:33:24.000Z',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
url: '/api/posts',
|
|
||||||
method: 'get',
|
|
||||||
response: (data = {}) => {
|
|
||||||
const { title, pageNo, pageSize } = data.query
|
|
||||||
let pageData = []
|
|
||||||
let total = 60
|
|
||||||
const filterData = posts.filter(
|
|
||||||
(item) => item.title.includes(title) || (!title && title !== 0)
|
|
||||||
)
|
|
||||||
if (filterData.length) {
|
|
||||||
if (pageSize) {
|
|
||||||
while (pageData.length < pageSize) {
|
|
||||||
pageData.push(filterData[Math.round(Math.random() * (filterData.length - 1))])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pageData = filterData
|
|
||||||
}
|
|
||||||
pageData = pageData.map((item, index) => ({
|
|
||||||
id: pageSize * (pageNo - 1) + index + 1,
|
|
||||||
...item,
|
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
total = 0
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
message: 'ok',
|
|
||||||
data: {
|
|
||||||
pageData,
|
|
||||||
total,
|
|
||||||
pageNo,
|
|
||||||
pageSize,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
url: '/api/post',
|
|
||||||
method: 'post',
|
|
||||||
response: ({ body }) => {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
message: 'ok',
|
|
||||||
data: body,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
url: '/api/post/:id',
|
|
||||||
method: 'put',
|
|
||||||
response: ({ query, body }) => {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
message: 'ok',
|
|
||||||
data: {
|
|
||||||
id: query.id,
|
|
||||||
body,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
url: '/api/post/:id',
|
|
||||||
method: 'delete',
|
|
||||||
response: ({ query }) => {
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
message: 'ok',
|
|
||||||
data: {
|
|
||||||
id: query.id,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import { resolveToken } from '../utils'
|
|
||||||
|
|
||||||
const users = {
|
|
||||||
admin: {
|
|
||||||
id: 1,
|
|
||||||
name: '大脸怪(admin)',
|
|
||||||
avatar: 'https://assets.qszone.com/images/avatar.jpg',
|
|
||||||
email: 'Ronnie@123.com',
|
|
||||||
role: ['admin'],
|
|
||||||
},
|
|
||||||
editor: {
|
|
||||||
id: 2,
|
|
||||||
name: '大脸怪(editor)',
|
|
||||||
avatar: 'https://assets.qszone.com/images/avatar.jpg',
|
|
||||||
email: 'Ronnie@123.com',
|
|
||||||
role: ['editor'],
|
|
||||||
},
|
|
||||||
guest: {
|
|
||||||
id: 3,
|
|
||||||
name: '访客(guest)',
|
|
||||||
avatar: 'https://assets.qszone.com/images/avatar.jpg',
|
|
||||||
role: [],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
export default [
|
|
||||||
{
|
|
||||||
url: '/api/user',
|
|
||||||
method: 'get',
|
|
||||||
response: ({ headers }) => {
|
|
||||||
const token = resolveToken(headers?.authorization)
|
|
||||||
return {
|
|
||||||
code: 0,
|
|
||||||
data: {
|
|
||||||
...(users[token] || users.guest),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'
|
|
||||||
import api from './api'
|
|
||||||
|
|
||||||
export function setupProdMockServer() {
|
|
||||||
createProdMockServer(api)
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
export function resolveToken(authorization) {
|
|
||||||
/**
|
|
||||||
* * jwt token
|
|
||||||
* * Bearer + token
|
|
||||||
* ! 认证方案: Bearer
|
|
||||||
*/
|
|
||||||
const reqTokenSplit = authorization.split(' ')
|
|
||||||
if (reqTokenSplit.length === 2) {
|
|
||||||
return reqTokenSplit[1]
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
42
package.json
42
package.json
@@ -33,50 +33,50 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@unocss/eslint-config": "^0.55.7",
|
"@unocss/eslint-config": "^0.55.7",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.11.1",
|
||||||
"@wangeditor/editor": "^5.1.23",
|
"@wangeditor/editor": "^5.1.23",
|
||||||
"@wangeditor/editor-for-vue": "5.1.12",
|
"@wangeditor/editor-for-vue": "5.1.12",
|
||||||
"axios": "^1.6.8",
|
"axios": "^1.13.1",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.19",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.6.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"md-editor-v3": "^4.13.0",
|
"md-editor-v3": "^4.21.3",
|
||||||
"mockjs": "^1.1.0",
|
"mockjs": "^1.1.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.3.1",
|
||||||
"vite": "^4.5.3",
|
"vite": "^4.5.14",
|
||||||
"vue": "3.3.4",
|
"vue": "3.3.4",
|
||||||
"vue-echarts": "^6.6.9",
|
"vue-echarts": "^6.7.3",
|
||||||
"vue-router": "^4.3.0",
|
"vue-router": "^4.6.3",
|
||||||
"xlsx": "^0.18.5"
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^17.8.1",
|
"@commitlint/cli": "^17.8.1",
|
||||||
"@commitlint/config-conventional": "^17.8.1",
|
"@commitlint/config-conventional": "^17.8.1",
|
||||||
"@iconify/json": "^2.2.199",
|
"@iconify/json": "^2.2.402",
|
||||||
"@iconify/vue": "^4.1.1",
|
"@iconify/vue": "^4.3.0",
|
||||||
"@unocss/preset-rem-to-px": "^0.55.7",
|
"@unocss/preset-rem-to-px": "^0.55.7",
|
||||||
"@vitejs/plugin-vue": "^4.6.2",
|
"@vitejs/plugin-vue": "^4.6.2",
|
||||||
"@vue/compiler-sfc": "^3.4.21",
|
"@vue/compiler-sfc": "^3.5.22",
|
||||||
"@zclzone/eslint-config": "^0.0.4",
|
"@zclzone/eslint-config": "^0.0.4",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.6.2",
|
||||||
"commitizen": "^4.3.0",
|
"commitizen": "^4.3.1",
|
||||||
"cz-conventional-changelog": "^3.3.0",
|
"cz-conventional-changelog": "^3.3.0",
|
||||||
"cz-customizable": "^7.0.0",
|
"cz-customizable": "^7.5.1",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.6.1",
|
||||||
"esno": "^0.17.0",
|
"esno": "^0.17.0",
|
||||||
"fs-extra": "^11.2.0",
|
"fs-extra": "^11.3.2",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^14.0.1",
|
"lint-staged": "^14.0.1",
|
||||||
"naive-ui": "^2.38.1",
|
"naive-ui": "^2.43.1",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.14.0",
|
||||||
"sass": "^1.75.0",
|
"sass": "^1.93.2",
|
||||||
"unocss": "0.55.3",
|
"unocss": "0.55.3",
|
||||||
"unplugin-auto-import": "^0.16.7",
|
"unplugin-auto-import": "^0.16.7",
|
||||||
"unplugin-icons": "^0.16.6",
|
"unplugin-icons": "^0.16.6",
|
||||||
"unplugin-vue-components": "^0.25.2",
|
"unplugin-vue-components": "^0.25.2",
|
||||||
"vite-plugin-compression": "^0.5.1",
|
"vite-plugin-compression": "^0.5.1",
|
||||||
"vite-plugin-html": "^3.2.2",
|
"vite-plugin-html": "^3.2.2",
|
||||||
"vite-plugin-mkcert": "^1.17.5",
|
"vite-plugin-mkcert": "^1.17.9",
|
||||||
"vite-plugin-mock": "2.9.6",
|
"vite-plugin-mock": "2.9.6",
|
||||||
"vite-plugin-svg-icons": "^2.0.1"
|
"vite-plugin-svg-icons": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
9668
pnpm-lock.yaml
generated
9668
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user