From b4ef5a4b51df9797abdea9e18024e90c430acea9 Mon Sep 17 00:00:00 2001 From: landaiqing Date: Wed, 5 Feb 2025 18:57:58 +0800 Subject: [PATCH] :recycle: refactor some code --- .dockerignore | 1 - Dockerfile | 12 +- auto-import.d.ts | 2 + build.Dockerfile | 17 - components.d.ts | 2 + default.conf | 25 +- nginx.conf | 18 + package.json | 26 +- src/api/storage/index.ts | 52 +++ .../src/CommentInput/CommentInput.vue | 45 +- .../src/CommentList/CommentList.vue | 3 +- .../src/ReplyInput/ReplyInput.vue | 20 +- .../CommentReply/src/ReplyList/ReplyList.vue | 3 +- .../src/ReplyReplyInput/ReplyReply.vue | 21 +- src/components/MyUI/CheckCard/CheckCard.vue | 2 +- src/directives/index.ts | 2 + src/directives/v-focus.ts | 6 + src/store/modules/commentStore.ts | 47 +- src/types/comment.d.ts | 4 +- .../Album/PeopleAlbum/PeopleAlbumList.vue | 406 ++++++++++++++---- src/views/Album/Phoalbum/PhoalbumList.vue | 4 + 21 files changed, 501 insertions(+), 217 deletions(-) delete mode 100644 build.Dockerfile create mode 100644 nginx.conf create mode 100644 src/directives/v-focus.ts diff --git a/.dockerignore b/.dockerignore index d4d7e3f..eb03e3e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,2 @@ node_modules -dist *.log diff --git a/Dockerfile b/Dockerfile index dda3d7f..f7b2726 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ -# 设置基础镜像 + FROM nginx:latest -# 设置作者信息 + LABEL maintainer="landaiqing <>" -# 设置时区 + ENV TimeZone=Asia/Shanghai -# 将dist文件中的内容复制到 /usr/share/nginx/html/ 这个目录下面 + COPY dist/ /usr/share/nginx/html/ -# 用本地的 default.conf 配置来替换nginx镜像里的默认配置 + COPY default.conf /etc/nginx/conf.d/default.conf -# 暴露80端口 + EXPOSE 80 diff --git a/auto-import.d.ts b/auto-import.d.ts index 40bb625..425d0dc 100644 --- a/auto-import.d.ts +++ b/auto-import.d.ts @@ -150,6 +150,7 @@ declare global { const useCloned: typeof import('@vueuse/core')['useCloned'] const useColorMode: typeof import('@vueuse/core')['useColorMode'] const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog'] + const useCountdown: typeof import('@vueuse/core')['useCountdown'] const useCounter: typeof import('@vueuse/core')['useCounter'] const useCssModule: typeof import('vue')['useCssModule'] const useCssVar: typeof import('@vueuse/core')['useCssVar'] @@ -460,6 +461,7 @@ declare module 'vue' { readonly useCloned: UnwrapRef readonly useColorMode: UnwrapRef readonly useConfirmDialog: UnwrapRef + readonly useCountdown: UnwrapRef readonly useCounter: UnwrapRef readonly useCssModule: UnwrapRef readonly useCssVar: UnwrapRef diff --git a/build.Dockerfile b/build.Dockerfile deleted file mode 100644 index a3e7ebd..0000000 --- a/build.Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:22.12.0 as build - -WORKDIR /app - -COPY package*.json ./ - -RUN npm install - -COPY . . - -RUN npm run build - -FROM nginx:alpine - -COPY --from=build /app/dist /usr/share/nginx/html - -EXPOSE 80 diff --git a/components.d.ts b/components.d.ts index 16e712a..eaefd98 100644 --- a/components.d.ts +++ b/components.d.ts @@ -58,6 +58,7 @@ declare module 'vue' { BackgroundAnimation: typeof import('./src/components/BackgroundAnimation/BackgroundAnimation.vue')['default'] BackTop: typeof import('./src/components/MyUI/BackTop/BackTop.vue')['default'] Badge: typeof import('./src/components/MyUI/Badge/Badge.vue')['default'] + BlockOutlined: typeof import('@ant-design/icons-vue')['BlockOutlined'] BoxDog: typeof import('./src/components/BoxDog/BoxDog.vue')['default'] Breadcrumb: typeof import('./src/components/MyUI/Breadcrumb/Breadcrumb.vue')['default'] Button: typeof import('./src/components/MyUI/Button/Button.vue')['default'] @@ -88,6 +89,7 @@ declare module 'vue' { DynamicTitle: typeof import('./src/components/DynamicTitle/DynamicTitle.vue')['default'] Ellipsis: typeof import('./src/components/MyUI/Ellipsis/Ellipsis.vue')['default'] Empty: typeof import('./src/components/MyUI/Empty/Empty.vue')['default'] + EyeInvisibleOutlined: typeof import('@ant-design/icons-vue')['EyeInvisibleOutlined'] EyeOutlined: typeof import('@ant-design/icons-vue')['EyeOutlined'] FileImageOutlined: typeof import('@ant-design/icons-vue')['FileImageOutlined'] Flex: typeof import('./src/components/MyUI/Flex/Flex.vue')['default'] diff --git a/default.conf b/default.conf index b4d968f..c27b530 100644 --- a/default.conf +++ b/default.conf @@ -11,20 +11,35 @@ server { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; access_log /var/log/nginx/host.access.log main; - error_log /var/log/nginx/error.log error; + error_log /var/log/nginx/error.log error; - location / { + location / { root /usr/share/nginx/html; try_files $uri $uri/ /index.html; index index.html index.htm; - } - location ~* \.(js|css)$ { + } + location ~* \.(js|css)$ { gzip_static on; expires max; add_header Cache-Control "public"; root /usr/share/nginx/html; - } + } + location /sys/ { + rewrite ^/sys/(.*)$ /$1 break; + proxy_pass http://127.0.0.1:80; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_read_timeout 3600s; # 设置为1小时 + proxy_send_timeout 3600s; # 设置为1小时 + send_timeout 3600s; # 设置为1小时 + keepalive_timeout 3600s; # 设置为1小时 + } error_page 500 502 503 504 /50x.html; location = /50x.html { diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..198e822 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,18 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 8080; + + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + } +} diff --git a/package.json b/package.json index 1785a06..745dba8 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@ant-design/icons-vue": "^7.0.1", "@intlify/eslint-plugin-vue-i18n": "^3.2.0", "@mediapipe/face_detection": "^0.4.1646425229", + "@mediapipe/face_mesh": "^0.4.1633559619", "@tensorflow-models/coco-ssd": "^2.2.3", "@tensorflow-models/face-detection": "^1.0.3", "@tensorflow-models/face-landmarks-detection": "^1.0.6", @@ -26,17 +27,15 @@ "@tensorflow/tfjs-backend-webgpu": "^4.22.0", "@tensorflow/tfjs-converter": "^4.22.0", "@tensorflow/tfjs-core": "^4.22.0", - "@tensorflow/tfjs-node": "^4.22.0", - "@tensorflow/tfjs-node-gpu": "^4.22.0", "@types/animejs": "^3.1.12", "@types/crypto-js": "^4.2.2", "@types/json-stringify-safe": "^5.0.3", - "@types/node": "^22.10.7", + "@types/node": "^22.13.1", "@types/nprogress": "^0.2.3", "@vladmandic/face-api": "^1.7.14", "@vuepic/vue-datepicker": "^11.0.1", - "@vueuse/core": "^12.4.0", - "@vueuse/integrations": "^12.4.0", + "@vueuse/core": "^12.5.0", + "@vueuse/integrations": "^12.5.0", "alova": "^3.2.8", "animejs": "^3.2.2", "ant-design-vue": "^4.2.6", @@ -45,7 +44,7 @@ "buffer": "^6.0.3", "crypto-js": "^4.2.0", "echarts": "^5.6.0", - "eslint": "9.18.0", + "eslint": "9.19.0", "exifr": "^7.1.3", "go-captcha-vue": "^2.0.5", "gsap": "^3.12.7", @@ -58,36 +57,37 @@ "pinia": "^2.3.1", "pinia-plugin-persistedstate-2": "^2.0.28", "qrcode": "^1", + "rimraf": "^6.0.1", "seedrandom": "^3.0.5", - "swiper": "^11.2.1", + "swiper": "^11.2.2", "unplugin-auto-import": "^19.0.0", "vite-plugin-compression": "^0.5.1", "vite-plugin-html": "^3.2.2", "vite-plugin-node-polyfills": "^0.23.0", "vue": "^3.5.13", "vue-dompurify-html": "^5.2.0", - "vue-i18n": "^11.0.1", + "vue-i18n": "^11.1.0", "vue-router": "^4.5.0", "vue-waterfall-plugin-next": "^2.6.5", "ws": "^8.18.0" }, "devDependencies": { - "@eslint/js": "^9.18.0", + "@eslint/js": "^9.19.0", "@vitejs/plugin-vue": "^5.2.1", "eslint-plugin-vue": "^9.32.0", "globals": "^15.14.0", "sass": "^1.83.4", "typescript": "^5.7.3", - "typescript-eslint": "^8.20.0", + "typescript-eslint": "^8.23.0", "unplugin-vue-components": "^28.0.0", - "vite": "^6.0.9", - "vite-plugin-bundle-obfuscator": "1.4.0", + "vite": "^6.0.11", + "vite-plugin-bundle-obfuscator": "1.4.1", "vite-plugin-chunk-split": "^0.5.0", "vue-tsc": "2.2.0" }, "overrides": { "vite-plugin-chunk-split": { - "vite": "^6.0.9" + "vite": "^6.0.11" } } } diff --git a/src/api/storage/index.ts b/src/api/storage/index.ts index 15ff93c..1c90e54 100644 --- a/src/api/storage/index.ts +++ b/src/api/storage/index.ts @@ -8,3 +8,55 @@ export const uploadFile = (formData) => { } }); }; + +/** + * 获取用户人脸样本列表 + * @param type + */ +export const getFaceSamplesList = (type: number) => { + return service.Post('/api/auth/storage/face/sample/list', { + type: type, + }, { + cacheFor: { + expire: 60 * 60 * 24 * 7, + mode: "restore", + }, + meta: { + ignoreToken: false, + signature: false, + } + }); +}; +/** + * 修改人脸样本名称 + * @param id + * @param face_name + */ +export const modifyFaceSampleName = (id: number, face_name: string) => { + return service.Post('/api/auth/storage/face/sample/modify/name', { + id: id, + face_name: face_name, + }, { + meta: { + ignoreToken: false, + signature: false, + } + }); +}; +/** + * 批量修改人脸样本类型 + * @param ids + * @param face_type + */ +export const modifyFaceTypeBatch = (ids: number[], face_type: number) => { + return service.Post('/api/auth/storage/face/sample/modify/type', { + ids: ids, + face_type: face_type, + }, { + meta: { + ignoreToken: false, + signature: false, + } + }); +}; + diff --git a/src/components/CommentReply/src/CommentInput/CommentInput.vue b/src/components/CommentReply/src/CommentInput/CommentInput.vue index 2fcf55d..cb7dac0 100644 --- a/src/components/CommentReply/src/CommentInput/CommentInput.vue +++ b/src/components/CommentReply/src/CommentInput/CommentInput.vue @@ -40,35 +40,32 @@ - - - {{ t('comment.picture') }} - - + + + {{ t('comment.picture') }} + -