From 9bd0a50f2384b4e348fed49524595ef715450f7c Mon Sep 17 00:00:00 2001 From: LeoKu Date: Sun, 12 Jun 2022 14:38:40 +0800 Subject: [PATCH] Add download multiple support --- index.html | 7 +- package.json | 3 + src/App.vue | 90 ++++++++- src/components/Configurator.vue | 2 +- src/components/Modal/BatchDownloadModal.vue | 183 +++++++++++++++++++ src/components/{ => Modal}/CodeModal.vue | 88 ++++----- src/components/{ => Modal}/DownloadModal.vue | 2 +- src/components/Modal/ModalWrapper.vue | 40 ++++ src/components/VueColorAvatar.vue | 2 +- src/hooks/useAvatarOption.ts | 2 +- src/i18n/locales/en/index.ts | 4 + src/i18n/locales/zh/index.ts | 4 + src/layouts/Header.vue | 1 + src/store/index.ts | 2 +- src/utils/constant.ts | 2 +- src/utils/index.ts | 2 +- yarn.lock | 80 +++++++- 17 files changed, 437 insertions(+), 77 deletions(-) create mode 100644 src/components/Modal/BatchDownloadModal.vue rename src/components/{ => Modal}/CodeModal.vue (73%) rename src/components/{ => Modal}/DownloadModal.vue (97%) create mode 100644 src/components/Modal/ModalWrapper.vue diff --git a/index.html b/index.html index ac1577d..f0b4dfb 100644 --- a/index.html +++ b/index.html @@ -4,10 +4,13 @@ - + diff --git a/package.json b/package.json index e82c9c8..252b8fc 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "canvas-confetti": "^1.4.0", "clipboard": "^2.0.8", "html2canvas": "^1.3.2", + "jszip": "^3.10.0", + "object-hash": "^3.0.0", "perfect-scrollbar": "^1.5.2", "vue": "^3.2.30", "vue-i18n": "^9.2.0-beta.9", @@ -33,6 +35,7 @@ "@babel/preset-typescript": "^7.16.7", "@types/canvas-confetti": "^1.4.2", "@types/jest": "^27.0.2", + "@types/object-hash": "^2.2.1", "@typescript-eslint/eslint-plugin": "^5.11.0", "@typescript-eslint/parser": "^5.11.0", "@vitejs/plugin-vue": "^2.1.0", diff --git a/src/App.vue b/src/App.vue index 4714afa..091e9eb 100644 --- a/src/App.vue +++ b/src/App.vue @@ -20,11 +20,17 @@
- + + +
@@ -57,6 +71,12 @@ + + @@ -64,13 +84,14 @@ diff --git a/src/components/CodeModal.vue b/src/components/Modal/CodeModal.vue similarity index 73% rename from src/components/CodeModal.vue rename to src/components/Modal/CodeModal.vue index ea8e8b1..b02f969 100644 --- a/src/components/CodeModal.vue +++ b/src/components/Modal/CodeModal.vue @@ -1,35 +1,33 @@ + + diff --git a/src/components/VueColorAvatar.vue b/src/components/VueColorAvatar.vue index ef08011..da79382 100644 --- a/src/components/VueColorAvatar.vue +++ b/src/components/VueColorAvatar.vue @@ -24,7 +24,7 @@ export interface VueColorAvatarRef { import { ref, toRefs, watchEffect } from 'vue' import { WrapperShape } from '@/enums' -import { type AvatarOption } from '@/types' +import type { AvatarOption } from '@/types' import { getRandomAvatarOption } from '@/utils' import { AVATAR_LAYER, NONE } from '@/utils/constant' import { widgetData } from '@/utils/dynamic-data' diff --git a/src/hooks/useAvatarOption.ts b/src/hooks/useAvatarOption.ts index ab05fc7..b204899 100644 --- a/src/hooks/useAvatarOption.ts +++ b/src/hooks/useAvatarOption.ts @@ -2,7 +2,7 @@ import { computed } from 'vue' import { useStore } from '@/store' import { SET_AVATAR_OPTION } from '@/store/mutation-type' -import { type AvatarOption } from '@/types' +import type { AvatarOption } from '@/types' export default function useAvatarOption() { const store = useStore() diff --git a/src/i18n/locales/en/index.ts b/src/i18n/locales/en/index.ts index 57d0412..1cb1455 100644 --- a/src/i18n/locales/en/index.ts +++ b/src/i18n/locales/en/index.ts @@ -8,6 +8,7 @@ export default { code: 'code', randomize: 'Randomize', download: 'Download', + downloadMultiple: 'Download multiple', copyCode: 'Copy', copied: 'Copied', downloading: 'Downloading', @@ -39,5 +40,8 @@ export default { text: { codeModalTitle: 'Code', downloadTip: 'LONG PRESS or RIGHT CLICK to save', + downloadMultiple: 'Download', + downloadingMultiple: 'Downloading', + downloadMultipleTip: 'Automatically generate avatar for you', }, } diff --git a/src/i18n/locales/zh/index.ts b/src/i18n/locales/zh/index.ts index 54c691e..1f69f67 100644 --- a/src/i18n/locales/zh/index.ts +++ b/src/i18n/locales/zh/index.ts @@ -8,6 +8,7 @@ export default { code: '配置代码', randomize: '随机生成', download: '下载头像', + downloadMultiple: '批量下载', copyCode: '复制代码', copied: '已复制', downloading: '准备下载', @@ -39,5 +40,8 @@ export default { text: { codeModalTitle: '配置代码', downloadTip: '长按图片或右键点击下载至本地相册', + downloadMultiple: '开始下载', + downloadingMultiple: '正在下载', + downloadMultipleTip: '已为你自动生成头像', }, } diff --git a/src/layouts/Header.vue b/src/layouts/Header.vue index c97caf2..c6118ab 100644 --- a/src/layouts/Header.vue +++ b/src/layouts/Header.vue @@ -11,6 +11,7 @@ rel="nofollow noopener noreferrer" >