From cd839e923f035b4d6c0eb41bc6eb27b50c73e9d2 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Thu, 29 Aug 2024 14:25:42 +0800 Subject: [PATCH] update for test --- Dockerfile-test | 44 +++++++++++++++++++++++++++++++++++ index.html | 2 +- src/pages/auth/permission.tsx | 22 +++++++++++------- 3 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 Dockerfile-test diff --git a/Dockerfile-test b/Dockerfile-test new file mode 100644 index 0000000..ef9ed24 --- /dev/null +++ b/Dockerfile-test @@ -0,0 +1,44 @@ +# Dockerfile for a React app build and run + +FROM node:18.19.1-alpine AS builder +MAINTAINER yaclty2@gmail.com +WORKDIR /app + +# envs 配置 +# 应用部署后的URL +ENV APP_SITE_URL "" +# 应用接口前缀 +ENV APP_API_URL "" + +# Copy source code to the builder +COPY package.json yarn.lock* ./ +COPY public ./public +COPY src ./src +COPY index.html ./ +COPY *.ts . +COPY *.json . + +# Install dependencies and build the app +RUN yarn install +RUN yarn build + + +# Step 2. Production image, copy all the files and run nginx +FROM nginx:1.26-alpine3.19 AS runner + +WORKDIR /app + +# envs 配置 +ENV APP_API_URL localhost:50000 + +# nginx配置文件 +#COPY nginx.conf /etc/nginx/conf.d/default.conf.template +# 编译文件 +COPY --from=builder /app/dist ./ +# RUN /bin/sh envsubst /etc/nginx/templates/*.template /etc/nginx/conf.d +#WORKDIR /etc/nginx/conf.d/ +#ENTRYPOINT sed -i "s~~~" /app/index.html && envsubst '$APP_API_URL' < default.conf.template > default.conf && cat default.conf && nginx -g 'daemon off;' +# 暴露80端口 +EXPOSE 80 +# 启动Nginx服务 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/index.html b/index.html index 0346465..1f42c28 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@
-
Payment System resources loading ...
+
Payment System loading ...
diff --git a/src/pages/auth/permission.tsx b/src/pages/auth/permission.tsx index e7c6a6d..cd88234 100644 --- a/src/pages/auth/permission.tsx +++ b/src/pages/auth/permission.tsx @@ -171,21 +171,24 @@ const Permission = () => { return list.filter(it => (it.value == userRole)); }, []) + const buildPermission = (it: UserPermission)=>{ + it.permission_edit = !!it.permission_edit + it.bill_page = !!it.bill_page + it.apply_page = !!it.apply_page + it.complete_button = !!it.complete_button + it.confirm_button = !!it.confirm_button + it.apply_button = !!it.apply_button + it.manual_payment = !!it.manual_payment + return it; + } + // load user permission list const loadUserPermissionList = () => { setState({loading: true}) getUserPermissionList().then(list => { setState({allList:[...list]}) const userRole = user?.permissions?.role ?? 'staff'; - list.forEach(it=>{ - it.permission_edit = !!it.permission_edit - it.bill_page = !!it.bill_page - it.apply_page = !!it.apply_page - it.complete_button = !!it.complete_button - it.confirm_button = !!it.confirm_button - it.apply_button = !!it.apply_button - it.manual_payment = !!it.manual_payment - }) + list.forEach(it=>buildPermission(it)) if(userRole != 'root') { list = list.filter(it => (it.role == userRole)); } @@ -244,6 +247,7 @@ const Permission = () => { await process(value).then((newValue) => { Toast.success(t('base.save_success')) const newList = [...state.list]; + buildPermission(newValue) newList[index] = { ...newValue }