From eaa5cd59526bfc652d78860db1e9c227e1c9c3f0 Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Sat, 24 May 2025 15:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20=E6=89=93=E5=8C=85=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .gitignore | 1 + .gitlab-ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++ .npmrc | 1 + build/buildEnv.ts | 2 +- build/plugins.ts | 5 +++- package.json | 14 +++++++++++- pnpm-lock.yaml | 2 ++ src/App.vue | 7 +++--- src/layout/index.vue | 2 +- 10 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 .npmrc diff --git a/.env.development b/.env.development index 2d6d599..10fcf46 100644 --- a/.env.development +++ b/.env.development @@ -20,7 +20,7 @@ VITE_MOCK_DEV_SERVER=true VITE_STRICT_PORT=false # 是否启用屏幕转vw适配,可以选择 postcss-px-to-viewport-8-plugin || autofit -VITE_POST_CSS_PX_TO_VIEWPORT8_PLUGIN="autofit" +VITE_POST_CSS_PX_TO_VIEWPORT8_PLUGIN="postcss-px-to-viewport-8-plugin" # 是否在打包时使用cdn替换本地库 替换 true 不替换 false VITE_CDN=false diff --git a/.gitignore b/.gitignore index a547bf3..005622e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ lerna-debug.log* node_modules dist +fakeServer dist-ssr *.local diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..55afb95 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,54 @@ +# 定义CI/CD流水线的阶段 +stages: + - build # 第一阶段:构建应用程序 + - build-docker # 第二阶段:构建Docker镜像 + - deploy # 第三阶段:部署应用程序 + +cache: # 缓存内容 + paths: + - node_modules/ + - docker/dist/ + +# 定义全局变量 +variables: + CONTAINER_NAME: 'central-monitor' # Docker容器名称 + DOCKER_TAG: '1.0.0' # Docker镜像标签版本 + +# 构建任务 +build-job: + stage: build # 指定此任务属于build阶段 + script: + # 打印编译开始信息 + - echo "Compiling the code..." + # 使用Maven编译Java项目,跳过测试 + - npm i -g pnpm && pnpm i && pnpm build + # 打印编译完成信息 + - echo "Compile complete." + # 从Docker Hub拉取OpenJDK基础镜像 + - docker pull nginx:1.27.3 + # 打印拉取完成信息 + - echo "docker pull complete." + # 使用Dockerfile构建Docker镜像,并打上标签 + - cd docker && docker build -f Dockerfile -t $CONTAINER_NAME:$DOCKER_TAG . + # 打印构建成功信息 + - echo "Application successfully deployed." + +# 部署任务 +deploy-job: + stage: deploy # 指定此任务属于deploy阶段 + environment: production # 指定部署环境为production + script: + # 打印部署开始信息 + - echo "Deploying application..." + # 停止正在运行的容器(如果存在),|| true确保命令失败不会中断脚本 + - docker stop $CONTAINER_NAME || true + # 删除容器(如果存在) + - docker rm $CONTAINER_NAME || true + # 运行新的Docker容器 + # -d: 后台运行 + # -p: 端口映射(7070和8000) + # --name: 容器名称 + # --restart always: 总是自动重启 + - docker run -d -p 8800:80 --name $CONTAINER_NAME --restart always $CONTAINER_NAME:$DOCKER_TAG + # 打印部署成功信息 + - echo "Application successfully deployed." diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..2c454f1 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +optional-depenencies=true \ No newline at end of file diff --git a/build/buildEnv.ts b/build/buildEnv.ts index 7c3c4ab..4876313 100644 --- a/build/buildEnv.ts +++ b/build/buildEnv.ts @@ -31,7 +31,7 @@ export const buildEnv = (): BuildOptions => { // 规定触发警告的 chunk 大小, 当某个代码分块的大小超过该限制时,Vite 会发出警告 chunkSizeWarningLimit: 2000, rollupOptions: { - external: ['md-editor-v3', 'echarts'], + external: ['echarts', 'fsevents'], input: { // @ts-ignore index: pathResolve('../index.html', import.meta.url), diff --git a/build/plugins.ts b/build/plugins.ts index 0658976..26f6ed8 100644 --- a/build/plugins.ts +++ b/build/plugins.ts @@ -57,7 +57,10 @@ const useMock = (mode: string) => { logger: true, include: 'mock', infixName: false, - enableProd: true, // 线上支持mock + enableDev: true, + // enableProd: true, // 线上支持mock + // build: true, + // http2: true, }) : null; }; diff --git a/package.json b/package.json index aeee351..3662113 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,18 @@ "allowedVersions": { "eslint": "9" } + }, + "packageExtensions": { + "rollup@*": { + "optionalDependencies": { + "fsevents": "*" + } + } } - } + }, + "onlyBuiltDependencies": [ + "@parcel/watcher", + "esbuild", + "vue-demi" + ] } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b09b4aa..0383e15 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,8 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +packageExtensionsChecksum: sha256-P0QlM8/kU0utlq/9p9JMVRZfIyZpKq+o9SyM/Bghnd4= + importers: .: diff --git a/src/App.vue b/src/App.vue index 11b5c9e..123370d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,3 +1,5 @@ + + - diff --git a/src/layout/index.vue b/src/layout/index.vue index 4a49da6..98ae1ea 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -11,7 +11,7 @@ onMounted(() => {