From 7d34d4ac83e3c5043d23032cd6d050be1f21745a Mon Sep 17 00:00:00 2001 From: louis <869322496@qq.com> Date: Mon, 4 Mar 2024 13:17:32 +0800 Subject: [PATCH] =?UTF-8?q?build:=20docker=E6=96=87=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 +++++++++++-------- docker-compose.yml | 2 +- src/api/backend/api/systemDictType.ts | 3 ++- src/api/backend/api/typings.d.ts | 6 ++++-- src/layout/index.vue | 2 +- src/store/modules/dict.ts | 7 +++++-- src/store/modules/user.ts | 4 +--- 7 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2096743..fcdfef0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,21 +14,24 @@ RUN npm install -g pnpm # 构建项目 # 安装生成依赖 FROM base AS prod-deps -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile # 基于prod-deps生成的依赖执行构建 FROM base AS builder -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -RUN pnpm run build +## 不适用rimraf,因为rimraf是开发环境依赖 -# 将prod-deps生成的依赖拷贝到base/$PROJECT_DIR中,开始在builder构建阶段build,最后拷贝build生成的dist到base/$PROJECT_DIR中 -FROM base AS result COPY --from=prod-deps $PROJECT_DIR/node_modules $PROJECT_DIR/node_modules -COPY --from=builder $PROJECT_DIR/dist $PROJECT_DIR/dist +# 构建项目 VITE_BASE_URL=/ 为了静态资源assets中文件的路径正确 去掉/api +ENV VITE_BASE_URL=/ +RUN pnpm run build +# # 将prod-deps生成的依赖拷贝到base/$PROJECT_DIR中,开始在builder构建阶段build,最后拷贝build生成的dist到base/$PROJECT_DIR中 +# FROM base AS result + + # 构建nginx,并且在result之后拷贝dist到nginx中,其中包含了自定义nginx.conf, FROM nginx:alpine as production ENV PROJECT_DIR=/huaxin-front -COPY --from=result $PROJECT_DIR/dist/ /usr/share/nginx/html -COPY --from=result $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf +COPY --from=builder $PROJECT_DIR/dist/ /usr/share/nginx/html +COPY --from=builder $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index fa5d10d..1f8774c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: build: context: . dockerfile: Dockerfile - target: result + target: production container_name: huaxin-base-frontend ports: - '80:80' diff --git a/src/api/backend/api/systemDictType.ts b/src/api/backend/api/systemDictType.ts index 36a7652..b641303 100644 --- a/src/api/backend/api/systemDictType.ts +++ b/src/api/backend/api/systemDictType.ts @@ -91,9 +91,10 @@ export async function dictTypeDelete( } /** 一次性获取所有的字典类型(不分页) GET /api/system/dict-type/all*/ -export async function dictTypeGetAll(options?: RequestOptions) { +export async function dictTypeGetAll(params: API.DictTypeListParams, options?: RequestOptions) { return request('/api/system/dict-type/all', { method: 'GET', + params, ...(options || {}), }); } diff --git a/src/api/backend/api/typings.d.ts b/src/api/backend/api/typings.d.ts index 6f33b90..b063b53 100644 --- a/src/api/backend/api/typings.d.ts +++ b/src/api/backend/api/typings.d.ts @@ -264,10 +264,12 @@ declare namespace API { field?: string; order?: 'ASC' | 'DESC'; /** 字典类型名称 */ - name: string; + name?: string; /** 字典类型code */ - code: string; + code?: string; _t?: number; + withItems?: boolean; + storeCodes?: string[]; }; type DictTypeUpdateParams = { diff --git a/src/layout/index.vue b/src/layout/index.vue index 1341604..fb442b5 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -43,7 +43,7 @@ const collapsed = ref(false); // 自定义侧边栏菜单收缩和展开时的宽度 const asiderWidth = computed(() => (collapsed.value ? 80 : 220)); - const getTheme = computed(() => (layoutSetting.value.navTheme === 'light' ? 'light' : 'dark')); + const getTheme = computed(() => (layoutSetting.value.navTheme === 'dark' ? 'dark' : 'light'));