giime 0.6.35 → 0.6.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +50 -50
- package/es/components/src/business/uploadPro/UploadPro.vue.mjs +1 -1
- package/es/components/src/business/uploadPro/UploadPro.vue2.mjs +1 -1
- package/es/components/src/business/uploadPro/UploadPro.vue2.mjs.map +1 -1
- package/es/components/src/composite/previewFile/PreviewFile.vue2.mjs +3 -2
- package/es/components/src/composite/previewFile/PreviewFile.vue2.mjs.map +1 -1
- package/es/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue2.mjs +1 -1
- package/es/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue2.mjs.map +1 -1
- package/es/giime/index.mjs +1 -1
- package/es/giime/version.d.ts +1 -1
- package/es/giime/version.mjs +1 -1
- package/es/giime/version.mjs.map +1 -1
- package/es/hooks/base/useDownload/index.mjs +27 -12
- package/es/hooks/base/useDownload/index.mjs.map +1 -1
- package/es/hooks/base/useUploadFile/index.d.ts +1 -1
- package/es/hooks/base/useUploadFile/index.mjs +4 -4
- package/es/hooks/base/useUploadFile/index.mjs.map +1 -1
- package/es/index.css +50 -50
- package/es/utils/index.mjs +1 -1
- package/es/utils/src/file.d.ts +0 -6
- package/es/utils/src/file.mjs +1 -9
- package/es/utils/src/file.mjs.map +1 -1
- package/es/utils/src/http/interceptors.d.ts +1 -1
- package/es/utils/src/http/interceptors.mjs +4 -1
- package/es/utils/src/http/interceptors.mjs.map +1 -1
- package/lib/components/src/business/uploadPro/UploadPro.vue.js +1 -1
- package/lib/components/src/business/uploadPro/UploadPro.vue2.js +1 -1
- package/lib/components/src/business/uploadPro/UploadPro.vue2.js.map +1 -1
- package/lib/components/src/composite/previewFile/PreviewFile.vue2.js +6 -5
- package/lib/components/src/composite/previewFile/PreviewFile.vue2.js.map +1 -1
- package/lib/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue2.js +1 -1
- package/lib/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue2.js.map +1 -1
- package/lib/giime/index.js +0 -1
- package/lib/giime/index.js.map +1 -1
- package/lib/giime/version.d.ts +1 -1
- package/lib/giime/version.js +1 -1
- package/lib/giime/version.js.map +1 -1
- package/lib/hooks/base/useDownload/index.js +27 -12
- package/lib/hooks/base/useDownload/index.js.map +1 -1
- package/lib/hooks/base/useUploadFile/index.d.ts +1 -1
- package/lib/hooks/base/useUploadFile/index.js +4 -4
- package/lib/hooks/base/useUploadFile/index.js.map +1 -1
- package/lib/index.css +50 -50
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/src/file.d.ts +0 -6
- package/lib/utils/src/file.js +0 -9
- package/lib/utils/src/file.js.map +1 -1
- package/lib/utils/src/http/interceptors.d.ts +1 -1
- package/lib/utils/src/http/interceptors.js +4 -1
- package/lib/utils/src/http/interceptors.js.map +1 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
|
@@ -878,11 +878,29 @@ video {
|
|
|
878
878
|
margin: 0;
|
|
879
879
|
}
|
|
880
880
|
|
|
881
|
-
.gm-
|
|
881
|
+
.gm-number-interval-single[data-v-4e6f4d6f] {
|
|
882
|
+
border-radius: var(--el-input-border-radius, var(--el-border-radius-base));
|
|
883
|
+
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
|
|
884
|
+
background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
|
|
885
|
+
}
|
|
886
|
+
.gm-number-interval-single[data-v-4e6f4d6f] [data-v-4e6f4d6f] .el-input__wrapper {
|
|
887
|
+
box-shadow: none;
|
|
888
|
+
background: none;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
.gm-number-interval-close[data-v-4e6f4d6f] {
|
|
892
|
+
display: none;
|
|
893
|
+
color: var(--el-input-icon-color, var(--el-text-color-placeholder));
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.gm-number-interval-single[data-v-4e6f4d6f]:hover .gm-number-interval-close[data-v-4e6f4d6f] {
|
|
897
|
+
display: flex;
|
|
898
|
+
}
|
|
899
|
+
.gm-upload-pro-preview-dialog[data-v-83f37e2f] [data-v-83f37e2f] .el-dialog__body {
|
|
882
900
|
padding: 0;
|
|
883
901
|
}
|
|
884
902
|
|
|
885
|
-
.gm-upload-pro-file-picture-card[data-v-
|
|
903
|
+
.gm-upload-pro-file-picture-card[data-v-83f37e2f] [data-v-83f37e2f] .el-upload-list__item, .gm-upload-pro-file-picture-card[data-v-83f37e2f] [data-v-83f37e2f] .el-upload--picture-card {
|
|
886
904
|
width: auto;
|
|
887
905
|
height: auto;
|
|
888
906
|
}
|
|
@@ -924,58 +942,69 @@ video {
|
|
|
924
942
|
.gm-upload-pro-file-disabled .el-upload-list__item-status-label {
|
|
925
943
|
display: none;
|
|
926
944
|
}
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
.gm-upload-file-picture-card[data-v-8077ce51] [data-v-8077ce51] .el-upload-list__item, .gm-upload-file-picture-card[data-v-8077ce51] [data-v-8077ce51] .el-upload--picture-card {
|
|
932
|
-
width: auto;
|
|
933
|
-
height: auto;
|
|
945
|
+
[data-v-488ca110] .gmSearchForm .el-form-item {
|
|
946
|
+
margin-right: 0;
|
|
947
|
+
margin-bottom: 4px;
|
|
934
948
|
}
|
|
935
|
-
[data-v-
|
|
949
|
+
[data-v-98c2e804] .gmTableNoBorder .el-table__body .el-table__cell {
|
|
936
950
|
border-right: none;
|
|
937
951
|
}
|
|
938
952
|
|
|
939
|
-
[data-v-
|
|
953
|
+
[data-v-98c2e804] .gmTableNoBorder .el-table__inner-wrapper:before {
|
|
940
954
|
height: 0;
|
|
941
955
|
}
|
|
942
956
|
|
|
943
|
-
[data-v-
|
|
957
|
+
[data-v-98c2e804] .gmTableNoBorder.el-table--border .el-table__inner-wrapper:after {
|
|
944
958
|
height: 0;
|
|
945
959
|
}
|
|
946
960
|
|
|
947
|
-
[data-v-
|
|
961
|
+
[data-v-98c2e804] .gmTableNoBorder.el-table--border:after {
|
|
948
962
|
height: 0;
|
|
949
963
|
}
|
|
950
964
|
|
|
951
|
-
[data-v-
|
|
965
|
+
[data-v-98c2e804] .gmTableNoBorder.el-table--border:before {
|
|
952
966
|
height: 0;
|
|
953
967
|
}
|
|
954
968
|
|
|
955
|
-
[data-v-
|
|
969
|
+
[data-v-98c2e804] .gmTableNoBorder .el-table__border-left-patch {
|
|
956
970
|
height: 0;
|
|
957
971
|
}
|
|
958
|
-
[data-v-
|
|
972
|
+
.gm-flex-center[data-v-c17deec9] {
|
|
973
|
+
align-items: center;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
.gm-flex-justify-between[data-v-c17deec9] {
|
|
977
|
+
justify-content: space-between;
|
|
978
|
+
}
|
|
979
|
+
.gm-upload-preview-dialog[data-v-8077ce51] [data-v-8077ce51] .el-dialog__body {
|
|
980
|
+
padding: 0;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
.gm-upload-file-picture-card[data-v-8077ce51] [data-v-8077ce51] .el-upload-list__item, .gm-upload-file-picture-card[data-v-8077ce51] [data-v-8077ce51] .el-upload--picture-card {
|
|
984
|
+
width: auto;
|
|
985
|
+
height: auto;
|
|
986
|
+
}
|
|
987
|
+
[data-v-2c351ff8] .gmTableNoBorder .el-table__body .el-table__cell {
|
|
959
988
|
border-right: none;
|
|
960
989
|
}
|
|
961
990
|
|
|
962
|
-
[data-v-
|
|
991
|
+
[data-v-2c351ff8] .gmTableNoBorder .el-table__inner-wrapper:before {
|
|
963
992
|
height: 0;
|
|
964
993
|
}
|
|
965
994
|
|
|
966
|
-
[data-v-
|
|
995
|
+
[data-v-2c351ff8] .gmTableNoBorder.el-table--border .el-table__inner-wrapper:after {
|
|
967
996
|
height: 0;
|
|
968
997
|
}
|
|
969
998
|
|
|
970
|
-
[data-v-
|
|
999
|
+
[data-v-2c351ff8] .gmTableNoBorder.el-table--border:after {
|
|
971
1000
|
height: 0;
|
|
972
1001
|
}
|
|
973
1002
|
|
|
974
|
-
[data-v-
|
|
1003
|
+
[data-v-2c351ff8] .gmTableNoBorder.el-table--border:before {
|
|
975
1004
|
height: 0;
|
|
976
1005
|
}
|
|
977
1006
|
|
|
978
|
-
[data-v-
|
|
1007
|
+
[data-v-2c351ff8] .gmTableNoBorder .el-table__border-left-patch {
|
|
979
1008
|
height: 0;
|
|
980
1009
|
}
|
|
981
1010
|
.gm-upload-file {
|
|
@@ -1013,35 +1042,6 @@ video {
|
|
|
1013
1042
|
.gm-upload-file-disabled .el-upload-list__item-status-label {
|
|
1014
1043
|
display: none;
|
|
1015
1044
|
}
|
|
1016
|
-
[data-v-488ca110] .gmSearchForm .el-form-item {
|
|
1017
|
-
margin-right: 0;
|
|
1018
|
-
margin-bottom: 4px;
|
|
1019
|
-
}
|
|
1020
|
-
.gm-number-interval-single[data-v-4e6f4d6f] {
|
|
1021
|
-
border-radius: var(--el-input-border-radius, var(--el-border-radius-base));
|
|
1022
|
-
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
|
|
1023
|
-
background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
|
|
1024
|
-
}
|
|
1025
|
-
.gm-number-interval-single[data-v-4e6f4d6f] [data-v-4e6f4d6f] .el-input__wrapper {
|
|
1026
|
-
box-shadow: none;
|
|
1027
|
-
background: none;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
.gm-number-interval-close[data-v-4e6f4d6f] {
|
|
1031
|
-
display: none;
|
|
1032
|
-
color: var(--el-input-icon-color, var(--el-text-color-placeholder));
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
.gm-number-interval-single[data-v-4e6f4d6f]:hover .gm-number-interval-close[data-v-4e6f4d6f] {
|
|
1036
|
-
display: flex;
|
|
1037
|
-
}
|
|
1038
|
-
.gm-flex-center[data-v-c17deec9] {
|
|
1039
|
-
align-items: center;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
.gm-flex-justify-between[data-v-c17deec9] {
|
|
1043
|
-
justify-content: space-between;
|
|
1044
|
-
}
|
|
1045
1045
|
.circular[data-v-d7b04fae] {
|
|
1046
1046
|
animation: loading-rotate-d7b04fae 2s linear infinite;
|
|
1047
1047
|
}
|
|
@@ -3,7 +3,7 @@ import './UploadPro.vue3.mjs';
|
|
|
3
3
|
import './UploadPro.vue4.mjs';
|
|
4
4
|
import _export_sfc from '../../../../_virtual/_plugin-vue_export-helper.mjs';
|
|
5
5
|
|
|
6
|
-
var UploadPro = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
6
|
+
var UploadPro = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-83f37e2f"]]);
|
|
7
7
|
|
|
8
8
|
export { UploadPro as default };
|
|
9
9
|
//# sourceMappingURL=UploadPro.vue.mjs.map
|
|
@@ -9,7 +9,7 @@ import { uploadFileProps } from './uploadPro.mjs';
|
|
|
9
9
|
import { getGmExports } from '../../../../utils/src/elementPlus/exports.mjs';
|
|
10
10
|
import { useUploadFile } from '../../../../hooks/base/useUploadFile/index.mjs';
|
|
11
11
|
|
|
12
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
12
|
+
const _withScopeId = (n) => (pushScopeId("data-v-83f37e2f"), n = n(), popScopeId(), n);
|
|
13
13
|
const _hoisted_1 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode(
|
|
14
14
|
"div",
|
|
15
15
|
{ class: "el-upload__text gm-text-center !gm-text-xs gm-text-gray-500" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadPro.vue2.mjs","sources":["../../../../../../../packages/components/src/business/uploadPro/UploadPro.vue"],"sourcesContent":["<template>\n <div>\n <div\n v-loading=\"uploadLoading\"\n ref=\"pasteFileRef\"\n :class=\"{ 'gm-upload-pro-file-picture-card': listType === 'picture-card', 'gm-upload-pro-file-disabled': disabled }\"\n class=\"gm-upload-pro-file\"\n >\n <el-checkbox-group v-model=\"checkoutFiles\">\n <el-upload\n ref=\"uploadFileRef\"\n v-bind=\"props\"\n v-model:file-list=\"fileList\"\n :before-remove=\"beforeRemove\"\n action=\"\"\n :http-request=\"httpRequest\"\n :on-success=\"coverFileSuccess\"\n :on-error=\"coverFileError\"\n >\n <slot v-if=\"!disabled\">\n <template v-if=\"listType === 'picture-card'\">\n <div\n class=\"gm-flex gm-flex-col gm-items-center gm-justify-center gm-rounded-md gm-border gm-border-dashed gm-p-1\"\n style=\"flex-direction: column\"\n :style=\"{ width: width + 'px', height: height + 'px' }\"\n >\n <el-icon :size=\"30\" color=\"#999\">\n <UploadFilled />\n </el-icon>\n <div class=\"el-upload__text gm-text-center !gm-text-xs gm-text-gray-500\">\n 将文件拖到此处,复制粘贴,或 <em class=\"gm-text-blue-700\">点击上传</em>\n </div>\n </div>\n </template>\n <template v-else>\n <el-button type=\"primary\" size=\"default\">点击上传</el-button>\n </template>\n </slot>\n <template v-if=\"showFileList && listType === 'picture-card'\" #file=\"{ file }\">\n <el-checkbox v-if=\"checkbox\" :value=\"file\" />\n <slot name=\"file\" :file=\"file\">\n <div class=\"gm-flex gm-items-center gm-justify-center gm-rounded-md\" :style=\"{ width: width + 'px', height: height + 'px' }\">\n <GmFileComponent :file=\"file\" :size=\"width - 40\" :controls=\"false\" :show-icon=\"true\" />\n </div>\n <div class=\"el-upload-list__item-actions\">\n <span class=\"el-upload-list__item-preview\" @click=\"handlePreview(file)\">\n <el-icon><View /></el-icon>\n </span>\n <span v-if=\"showDelete\" class=\"el-upload-list__item-delete\" @click=\"handleRemove(file, fileList)\">\n <el-icon><Delete /></el-icon>\n </span>\n </div>\n </slot>\n </template>\n <template v-else #file=\"slotValue\">\n <slot name=\"file\" v-bind=\"slotValue\" />\n </template>\n <template v-if=\"slots.trigger\" #trigger>\n <slot name=\"trigger\" />\n </template>\n <template v-if=\"slots.tip\" #tip>\n <div class=\"gm-text-sm\">\n <slot name=\"tip\" />\n </div>\n </template>\n </el-upload>\n </el-checkbox-group>\n\n <GmPreviewFile v-model:dialogVisible=\"dialogVisible\" v-model:file-index=\"fileIndex\" :file-list=\"fileList\" />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ElMessageBox } from 'element-plus';\nimport { computed, ref, useSlots } from 'vue';\nimport { fileValidType } from '@giime/utils/src/file';\n// import { pasteFile } from '@giime/utils/src/pasteFile';\nimport { usePasteFile } from '@giime/hooks/base/usePasteFile';\nimport { GmConfirmBox } from '@giime/components/src/plugins/confirmBox';\nimport { Delete, UploadFilled, View } from '@element-plus/icons-vue';\nimport GmFileComponent from '../../composite/fileComponent';\nimport GmPreviewFile from '../../composite/previewFile';\nimport { uploadFileProps } from './uploadPro';\nimport type { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile } from 'element-plus';\nimport { getGmExports } from '@giime/utils/src/elementPlus/exports';\nimport { useUploadFile } from '@giime/hooks/base/useUploadFile';\n\ndefineOptions({\n name: 'GmUploadPro',\n});\nconst slots = useSlots();\n\nconst props = defineProps(uploadFileProps);\nconst emit = defineEmits([\"handleRemove\"]);\n\n/** 上传文件 */\nconst fileList = defineModel<UploadFile[]>('fileList', { required: true });\n/** 多选数据 */\nconst checkoutFiles = defineModel<any[]>('checkoutFiles', { default: () => [] });\n\n/**上传功能 */\nconst { uploadFile } = useUploadFile();\n\nconst loadingUids = ref<Set<number>>(new Set());\nconst uploadLoading = computed(() => props.showLoading && loadingUids.value.size > 0);\n\n/* 上传 */\nconst httpRequest: UploadProps['httpRequest'] = async options => {\n loadingUids.value.add(options.file.uid);\n return uploadFile(options.file, { domainCode: props.domainCode, sceneCode: props.sceneCode, accept: props.accept, acl: props.acl });\n};\n// 上传成功\nconst coverFileSuccess: UploadProps['onSuccess'] = (response: any, uploadFile, uploadFiles) => {\n loadingUids.value.delete(uploadFile.uid);\n props.onSuccess?.(response, uploadFile, uploadFiles);\n};\n// 上传失败\nconst coverFileError: UploadProps['onError'] = (error, uploadFile, uploadFiles) => {\n loadingUids.value.delete(uploadFile.uid);\n props.onError?.(error, uploadFile, uploadFiles);\n};\n\n/* 删除文件前 */\nconst beforeRemove: UploadProps['beforeRemove'] = (file, files) => {\n if (props.disabled) {\n return false;\n }\n return props.beforeRemove?.(file, files) ?? true;\n};\n\n/* 删除文件 */\nconst removeFile = (file: UploadFile, uploadFiles: UploadFiles) => {\n const index = fileList.value.indexOf(file);\n if (index > -1) {\n fileList.value.splice(index, 1);\n emit('handleRemove', { file, index });\n return props.onRemove?.(file, uploadFiles);\n }\n};\n/**点击删除图标 */\nconst handleRemove = async (file: UploadFile, uploadFiles: UploadFiles) => {\n if (props.deleteTip) {\n await GmConfirmBox({ message: '确定删除该文件吗?' }, async () => {});\n }\n\n removeFile(file, uploadFiles);\n};\n\nconst uploadFileRef = ref<UploadInstance>();\nconst exposeEvents = ['abort', 'submit', 'clearFiles', 'handleStart', 'handleRemove'] as const;\nconst { exposeFns } = getGmExports(uploadFileRef, exposeEvents);\n\nconst pasteFileRef = ref<HTMLElement>();\n\n/** 预览 */\nconst dialogVisible = ref(false);\nconst fileIndex = ref(0);\n/**点击预览 */\nconst handlePreview = (file: UploadFile) => {\n fileIndex.value = fileList.value.indexOf(file);\n dialogVisible.value = true;\n};\n\n//** 复制粘贴 */\nconst { onSuccess, onError } = usePasteFile(pasteFileRef, { accept: props.accept, disabled: props.disabled });\nonSuccess((files: File[]) => {\n if (props.disabled) {\n return;\n }\n if (Array.isArray(files) && files.length > 0) {\n files.forEach(file => {\n if (file instanceof File) {\n const rawFile = file as UploadRawFile;\n uploadFileRef.value?.handleStart(rawFile);\n\n // 粘贴成功自动上传\n if (props.autoUpload) {\n uploadFileRef.value?.submit();\n }\n }\n });\n }\n});\n/**粘贴失败 */\nonError((error: Error) => {\n console.error('粘贴错误:', error);\n ElMessageBox.alert(error.message, '提示', {\n type: 'error',\n });\n});\ndefineExpose({\n ...exposeFns,\n uploadFileRef,\n});\n</script>\n\n<style scoped lang=\"scss\">\n.gm-upload-pro-preview-dialog {\n :deep(.el-dialog__body) {\n padding: 0;\n }\n}\n.gm-upload-pro-file-picture-card {\n :deep(.el-upload-list__item),\n :deep(.el-upload--picture-card) {\n width: auto;\n height: auto;\n }\n}\n</style>\n<style lang=\"scss\">\n.gm-upload-pro-file {\n line-height: normal;\n .el-checkbox-group {\n font-size: unset;\n }\n .el-checkbox {\n position: absolute;\n left: 10px;\n top: 0;\n z-index: 9;\n }\n .el-upload-list--picture-card {\n gap: 10px;\n }\n .el-upload-list__item {\n margin: 0;\n }\n .el-upload-list__item-file-name {\n line-height: 1.7;\n }\n .el-upload-dragger {\n padding: 0;\n border: none;\n width: 100%;\n height: 100%;\n display: flex;\n }\n .el-upload--picture-card {\n border: none;\n }\n}\n.gm-upload-pro-file-disabled {\n .el-upload--picture-card {\n display: none;\n }\n .el-upload-list__item-status-label {\n display: none;\n }\n}\n</style>\n"],"names":["_useModel","uploadFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAA,MAAM,IAAO,GAAA,MAAA,CAAA;AAGb,IAAM,MAAA,QAAA,GAAWA,QAA0B,CAAA,OAAA,EAAA,UAA8B,CAAA,CAAA;AAEzE,IAAM,MAAA,aAAA,GAAgBA,kBAAmB,eAAsC,CAAA,CAAA;AAG/E,IAAM,MAAA,EAAE,UAAW,EAAA,GAAI,aAAc,EAAA,CAAA;AAErC,IAAA,MAAM,WAAc,GAAA,GAAA,iBAAqB,IAAA,GAAA,EAAK,CAAA,CAAA;AAC9C,IAAM,MAAA,aAAA,GAAgB,SAAS,MAAM,KAAA,CAAM,eAAe,WAAY,CAAA,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA;AAGpF,IAAM,MAAA,WAAA,GAA0C,OAAM,OAAW,KAAA;AAC/D,MAAA,WAAA,CAAY,KAA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/UploadPro.vue"],"sourcesContent":["<template>\n <div>\n <div\n v-loading=\"uploadLoading\"\n ref=\"pasteFileRef\"\n :class=\"{ 'gm-upload-pro-file-picture-card': listType === 'picture-card', 'gm-upload-pro-file-disabled': disabled }\"\n class=\"gm-upload-pro-file\"\n >\n <el-checkbox-group v-model=\"checkoutFiles\">\n <el-upload\n ref=\"uploadFileRef\"\n v-bind=\"props\"\n v-model:file-list=\"fileList\"\n :before-remove=\"beforeRemove\"\n action=\"\"\n :http-request=\"httpRequest\"\n :on-success=\"coverFileSuccess\"\n :on-error=\"coverFileError\"\n >\n <slot v-if=\"!disabled\">\n <template v-if=\"listType === 'picture-card'\">\n <div\n class=\"gm-flex gm-flex-col gm-items-center gm-justify-center gm-rounded-md gm-border gm-border-dashed gm-p-1\"\n style=\"flex-direction: column\"\n :style=\"{ width: width + 'px', height: height + 'px' }\"\n >\n <el-icon :size=\"30\" color=\"#999\">\n <UploadFilled />\n </el-icon>\n <div class=\"el-upload__text gm-text-center !gm-text-xs gm-text-gray-500\">\n 将文件拖到此处,复制粘贴,或 <em class=\"gm-text-blue-700\">点击上传</em>\n </div>\n </div>\n </template>\n <template v-else>\n <el-button type=\"primary\" size=\"default\">点击上传</el-button>\n </template>\n </slot>\n <template v-if=\"showFileList && listType === 'picture-card'\" #file=\"{ file }\">\n <el-checkbox v-if=\"checkbox\" :value=\"file\" />\n <slot name=\"file\" :file=\"file\">\n <div class=\"gm-flex gm-items-center gm-justify-center gm-rounded-md\" :style=\"{ width: width + 'px', height: height + 'px' }\">\n <GmFileComponent :file=\"file\" :size=\"width - 40\" :controls=\"false\" :show-icon=\"true\" />\n </div>\n <div class=\"el-upload-list__item-actions\">\n <span class=\"el-upload-list__item-preview\" @click=\"handlePreview(file)\">\n <el-icon><View /></el-icon>\n </span>\n <span v-if=\"showDelete\" class=\"el-upload-list__item-delete\" @click=\"handleRemove(file, fileList)\">\n <el-icon><Delete /></el-icon>\n </span>\n </div>\n </slot>\n </template>\n <template v-else #file=\"slotValue\">\n <slot name=\"file\" v-bind=\"slotValue\" />\n </template>\n <template v-if=\"slots.trigger\" #trigger>\n <slot name=\"trigger\" />\n </template>\n <template v-if=\"slots.tip\" #tip>\n <div class=\"gm-text-sm\">\n <slot name=\"tip\" />\n </div>\n </template>\n </el-upload>\n </el-checkbox-group>\n\n <GmPreviewFile v-model:dialogVisible=\"dialogVisible\" v-model:file-index=\"fileIndex\" :file-list=\"fileList\" />\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ElMessageBox } from 'element-plus';\nimport { computed, ref, useSlots } from 'vue';\n// import { fileValidType } from '@giime/utils/src/file';\n// import { pasteFile } from '@giime/utils/src/pasteFile';\nimport { usePasteFile } from '@giime/hooks/base/usePasteFile';\nimport { GmConfirmBox } from '@giime/components/src/plugins/confirmBox';\nimport { Delete, UploadFilled, View } from '@element-plus/icons-vue';\nimport GmFileComponent from '../../composite/fileComponent';\nimport GmPreviewFile from '../../composite/previewFile';\nimport { GmUploadProUserFileResponse, uploadFileProps } from './uploadPro';\nimport type { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile } from 'element-plus';\nimport { getGmExports } from '@giime/utils/src/elementPlus/exports';\nimport { useUploadFile } from '@giime/hooks/base/useUploadFile';\n\ndefineOptions({\n name: 'GmUploadPro',\n});\nconst slots = useSlots();\n\nconst props = defineProps(uploadFileProps);\nconst emit = defineEmits([\"handleRemove\"]);\n\n/** 上传文件 */\nconst fileList = defineModel<UploadFile[]>('fileList', { required: true });\n/** 多选数据 */\nconst checkoutFiles = defineModel<any[]>('checkoutFiles', { default: () => [] });\n\n/**上传功能 */\nconst { uploadFile } = useUploadFile();\n\nconst loadingUids = ref<Set<number>>(new Set());\nconst uploadLoading = computed(() => props.showLoading && loadingUids.value.size > 0);\n\n/* 上传 */\nconst httpRequest: UploadProps['httpRequest'] = async options => {\n loadingUids.value.add(options.file.uid);\n return uploadFile(options.file, { domainCode: props.domainCode, sceneCode: props.sceneCode, accept: props.accept, acl: props.acl });\n};\n// 上传成功\nconst coverFileSuccess: UploadProps['onSuccess'] = (response: GmUploadProUserFileResponse, uploadFile, uploadFiles) => {\n loadingUids.value.delete(uploadFile.uid);\n props.onSuccess?.(response, uploadFile, uploadFiles);\n};\n// 上传失败\nconst coverFileError: UploadProps['onError'] = (error, uploadFile, uploadFiles) => {\n loadingUids.value.delete(uploadFile.uid);\n props.onError?.(error, uploadFile, uploadFiles);\n};\n\n/* 删除文件前 */\nconst beforeRemove: UploadProps['beforeRemove'] = (file, files) => {\n if (props.disabled) {\n return false;\n }\n return props.beforeRemove?.(file, files) ?? true;\n};\n\n/* 删除文件 */\nconst removeFile = (file: UploadFile, uploadFiles: UploadFiles) => {\n const index = fileList.value.indexOf(file);\n if (index > -1) {\n fileList.value.splice(index, 1);\n emit('handleRemove', { file, index });\n return props.onRemove?.(file, uploadFiles);\n }\n};\n/**点击删除图标 */\nconst handleRemove = async (file: UploadFile, uploadFiles: UploadFiles) => {\n if (props.deleteTip) {\n await GmConfirmBox({ message: '确定删除该文件吗?' }, async () => {});\n }\n\n removeFile(file, uploadFiles);\n};\n\nconst uploadFileRef = ref<UploadInstance>();\nconst exposeEvents = ['abort', 'submit', 'clearFiles', 'handleStart', 'handleRemove'] as const;\nconst { exposeFns } = getGmExports(uploadFileRef, exposeEvents);\n\nconst pasteFileRef = ref<HTMLElement>();\n\n/** 预览 */\nconst dialogVisible = ref(false);\nconst fileIndex = ref(0);\n/**点击预览 */\nconst handlePreview = (file: UploadFile) => {\n fileIndex.value = fileList.value.indexOf(file);\n dialogVisible.value = true;\n};\n\n//** 复制粘贴 */\nconst { onSuccess, onError } = usePasteFile(pasteFileRef, { accept: props.accept, disabled: props.disabled });\nonSuccess((files: File[]) => {\n if (props.disabled) {\n return;\n }\n if (Array.isArray(files) && files.length > 0) {\n files.forEach(file => {\n if (file instanceof File) {\n const rawFile = file as UploadRawFile;\n uploadFileRef.value?.handleStart(rawFile);\n\n // 粘贴成功自动上传\n if (props.autoUpload) {\n uploadFileRef.value?.submit();\n }\n }\n });\n }\n});\n/**粘贴失败 */\nonError((error: Error) => {\n console.error('粘贴错误:', error);\n ElMessageBox.alert(error.message, '提示', {\n type: 'error',\n });\n});\ndefineExpose({\n ...exposeFns,\n uploadFileRef,\n});\n</script>\n\n<style scoped lang=\"scss\">\n.gm-upload-pro-preview-dialog {\n :deep(.el-dialog__body) {\n padding: 0;\n }\n}\n.gm-upload-pro-file-picture-card {\n :deep(.el-upload-list__item),\n :deep(.el-upload--picture-card) {\n width: auto;\n height: auto;\n }\n}\n</style>\n<style lang=\"scss\">\n.gm-upload-pro-file {\n line-height: normal;\n .el-checkbox-group {\n font-size: unset;\n }\n .el-checkbox {\n position: absolute;\n left: 10px;\n top: 0;\n z-index: 9;\n }\n .el-upload-list--picture-card {\n gap: 10px;\n }\n .el-upload-list__item {\n margin: 0;\n }\n .el-upload-list__item-file-name {\n line-height: 1.7;\n }\n .el-upload-dragger {\n padding: 0;\n border: none;\n width: 100%;\n height: 100%;\n display: flex;\n }\n .el-upload--picture-card {\n border: none;\n }\n}\n.gm-upload-pro-file-disabled {\n .el-upload--picture-card {\n display: none;\n }\n .el-upload-list__item-status-label {\n display: none;\n }\n}\n</style>\n"],"names":["_useModel","uploadFile"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,IAAA,MAAM,QAAQ,QAAS,EAAA,CAAA;AAEvB,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAA,MAAM,IAAO,GAAA,MAAA,CAAA;AAGb,IAAM,MAAA,QAAA,GAAWA,QAA0B,CAAA,OAAA,EAAA,UAA8B,CAAA,CAAA;AAEzE,IAAM,MAAA,aAAA,GAAgBA,kBAAmB,eAAsC,CAAA,CAAA;AAG/E,IAAM,MAAA,EAAE,UAAW,EAAA,GAAI,aAAc,EAAA,CAAA;AAErC,IAAA,MAAM,WAAc,GAAA,GAAA,iBAAqB,IAAA,GAAA,EAAK,CAAA,CAAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createElementVNode, defineComponent, mergeModels, useModel, computed, resolveComponent, openBlock, createBlock, withCtx, createVNode, createTextVNode, createElementBlock, unref, createCommentVNode, normalizeProps, guardReactiveProps } from 'vue';
|
|
2
2
|
import { ElMessage } from 'element-plus';
|
|
3
|
-
import { downloadFile } from '../../../../utils/src/file.mjs';
|
|
4
3
|
import { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';
|
|
5
4
|
import { GmFileComponent } from '../fileComponent/index.mjs';
|
|
6
5
|
import { previewFileProps } from './previewFile.mjs';
|
|
6
|
+
import { useDownload } from '../../../../hooks/base/useDownload/index.mjs';
|
|
7
7
|
|
|
8
8
|
const _hoisted_1 = { class: "gm-flex gm-items-center gm-justify-between" };
|
|
9
9
|
const _hoisted_2 = /* @__PURE__ */ createElementVNode(
|
|
@@ -34,6 +34,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
34
34
|
const props = __props;
|
|
35
35
|
const dialogVisible = useModel(__props, "dialogVisible");
|
|
36
36
|
const fileIndex = useModel(__props, "fileIndex");
|
|
37
|
+
const downloadMethod = useDownload();
|
|
37
38
|
const files = computed(() => {
|
|
38
39
|
let result = props.fileList;
|
|
39
40
|
if (props.fileList && !props.fileList.length && props.file) {
|
|
@@ -69,7 +70,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
69
70
|
};
|
|
70
71
|
const download = () => {
|
|
71
72
|
const file = files.value[fileIndex.value];
|
|
72
|
-
|
|
73
|
+
downloadMethod.downloadByUrl(file.url || "", { filename: file.name });
|
|
73
74
|
};
|
|
74
75
|
return (_ctx, _cache) => {
|
|
75
76
|
const _component_el_button = resolveComponent("el-button");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewFile.vue2.mjs","sources":["../../../../../../../packages/components/src/composite/previewFile/PreviewFile.vue"],"sourcesContent":["<template>\n <el-dialog v-model=\"dialogVisible\" title=\"预览\" :width=\"width\" top=\"10vh\" append-to-body destroy-on-close>\n <template #header>\n <div class=\"gm-flex gm-items-center gm-justify-between\">\n <span>预览</span>\n <el-button type=\"primary\" size=\"default\" link @click=\"download\">下载</el-button>\n </div>\n </template>\n <div class=\"gm-flex gm-select-none gm-items-center gm-justify-center gm-gap-4\">\n <div v-if=\"files.length > 1\" class=\"gm-cursor-pointer\" @click=\"prev\">\n <el-icon :size=\"40\"><ArrowLeftBold /></el-icon>\n </div>\n <div class=\"gm-flex gm-flex-1 gm-items-center gm-justify-center\" style=\"height: calc(80vh - 72px)\">\n <GmFileComponent v-bind=\"fileProps\" />\n </div>\n <div v-if=\"files.length > 1\" class=\"gm-cursor-pointer\" @click=\"next\">\n <el-icon :size=\"40\"><ArrowRightBold /></el-icon>\n </div>\n </div>\n </el-dialog>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { ElMessage } from 'element-plus';\nimport {
|
|
1
|
+
{"version":3,"file":"PreviewFile.vue2.mjs","sources":["../../../../../../../packages/components/src/composite/previewFile/PreviewFile.vue"],"sourcesContent":["<template>\n <el-dialog v-model=\"dialogVisible\" title=\"预览\" :width=\"width\" top=\"10vh\" append-to-body destroy-on-close>\n <template #header>\n <div class=\"gm-flex gm-items-center gm-justify-between\">\n <span>预览</span>\n <el-button type=\"primary\" size=\"default\" link @click=\"download\">下载</el-button>\n </div>\n </template>\n <div class=\"gm-flex gm-select-none gm-items-center gm-justify-center gm-gap-4\">\n <div v-if=\"files.length > 1\" class=\"gm-cursor-pointer\" @click=\"prev\">\n <el-icon :size=\"40\"><ArrowLeftBold /></el-icon>\n </div>\n <div class=\"gm-flex gm-flex-1 gm-items-center gm-justify-center\" style=\"height: calc(80vh - 72px)\">\n <GmFileComponent v-bind=\"fileProps\" />\n </div>\n <div v-if=\"files.length > 1\" class=\"gm-cursor-pointer\" @click=\"next\">\n <el-icon :size=\"40\"><ArrowRightBold /></el-icon>\n </div>\n </div>\n </el-dialog>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { ElMessage } from 'element-plus';\nimport { ArrowLeftBold, ArrowRightBold } from '@element-plus/icons-vue';\nimport GmFileComponent from '../fileComponent';\nimport { previewFileProps } from './previewFile';\nimport type { UploadFile } from 'element-plus';\nimport { useDownload } from '@giime/hooks/base/useDownload';\n\ndefineOptions({\n name: 'GmPreviewFile',\n});\n\nconst props = defineProps(previewFileProps);\nconst dialogVisible = defineModel<boolean>('dialogVisible', { default: false });\nconst fileIndex = defineModel<number>('fileIndex', { default: 0 });\n\nconst downloadMethod = useDownload();\n\nconst files = computed(() => {\n let result: Partial<UploadFile>[] = props.fileList;\n if (props.fileList && !props.fileList.length && props.file) {\n result = [props.file];\n }\n return result;\n});\n\nconst fileProps = computed(() => {\n const file = files.value[fileIndex.value];\n return {\n file,\n controls: props.controls,\n oncontextmenu: props.oncontextmenu,\n controlslist: props.controlslist,\n field: props.field,\n url: props.url,\n size: props.size,\n };\n});\n\nconst prev = () => {\n if (fileIndex.value > 0) {\n fileIndex.value--;\n return;\n }\n ElMessage.warning('已经是第一张了');\n};\n\nconst next = () => {\n if (fileIndex.value < props.fileList.length - 1) {\n fileIndex.value++;\n return;\n }\n ElMessage.warning('没有更多了!');\n};\n\nconst download = () => {\n const file = files.value[fileIndex.value];\n downloadMethod.downloadByUrl(file.url || '', { filename: file.name });\n};\n</script>\n"],"names":["_useModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAM,MAAA,aAAA,GAAgBA,QAAqB,CAAA,OAAA,EAAA,eAAmC,CAAA,CAAA;AAC9E,IAAM,MAAA,SAAA,GAAYA,QAAmB,CAAA,OAAA,EAAC,WAA2B,CAAA,CAAA;A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AAA;AAEA,IAAA,MAAM,WAAW,MAAM;AACrB,MAAA,MAAM,IAAO,GAAA,KAAA,CAAM,KAAM,CAAA,SAAA,CAAU,KAAK,CAAA,CAAA;AACxC,MAAe,cAAA,CAAA,aAAA,CAAc,KAAK,GAAO,IAAA,EAAA,EAAI,EAAE,QAAU,EAAA,IAAA,CAAK,MAAM,CAAA,CAAA;AAAA,KACtE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/es/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue2.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
53
53
|
modelValue: modelValue.value,
|
|
54
54
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
|
|
55
55
|
options: _ctx.options,
|
|
56
|
-
props: { ..._ctx.cascaderProps
|
|
56
|
+
props: { ..._ctx.cascaderProps },
|
|
57
57
|
clearable: "",
|
|
58
58
|
filterable: "",
|
|
59
59
|
disabled: _ctx.disabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchFormCascader.vue2.mjs","sources":["../../../../../../../../../packages/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue"],"sourcesContent":["<template>\n <gm-form-item ref=\"formItemRef\" :prop=\"prop\">\n <gm-cascader\n ref=\"cascaderRef\"\n v-model=\"modelValue\"\n :options=\"options\"\n :props=\"{ ...cascaderProps
|
|
1
|
+
{"version":3,"file":"SearchFormCascader.vue2.mjs","sources":["../../../../../../../../../packages/components/src/composite/searchForm/searchFormItems/cascader/SearchFormCascader.vue"],"sourcesContent":["<template>\n <gm-form-item ref=\"formItemRef\" :prop=\"prop\">\n <gm-cascader\n ref=\"cascaderRef\"\n v-model=\"modelValue\"\n :options=\"options\"\n :props=\"{ ...cascaderProps }\"\n clearable\n filterable\n :disabled=\"disabled\"\n collapse-tags\n collapse-tags-tooltip\n class=\"gm-w-full\"\n :placeholder=\"label\"\n @change=\"onChange\"\n />\n </gm-form-item>\n</template>\n<script lang=\"ts\" setup>\n// import { inject } from 'vue';\nimport { ref } from 'vue';\nimport { getGmObjExports } from '@giime/utils';\nimport { type FormItemInstance, formItemExposeNames } from '@giime/components/src/base/formItem';\nimport { type CascaderInstance, type CascaderProps, cascaderExposeNames } from '@giime/components/src/base/cascader';\nimport { useWatchModelChange } from '../../composables/useWatchModelChange';\n// import { searchFormHandleQueryKey } from '../../searchForm';\nimport { SearchFormCascaderName, searchFormCascaderEmits, searchFormCascaderProps } from './searchFormCascader';\nimport type { CascaderValue } from 'element-plus';\ndefineOptions({\n name: SearchFormCascaderName,\n});\nconst modelValue = defineModel<CascaderProps['modelValue'] | undefined>();\nconst props = defineProps(searchFormCascaderProps);\nconst emit = defineEmits(searchFormCascaderEmits);\nuseWatchModelChange(modelValue, { prop: props.prop, noDefaultSync: props.noDefaultSync });\n// const handleQuery = inject(searchFormHandleQueryKey);\nconst onChange = (value: CascaderValue) => {\n // handleQuery?.();\n emit('change', value);\n};\nconst cascaderRef = ref<CascaderInstance>();\nconst formItemRef = ref<FormItemInstance>();\nconst { exposeFns: cascaderFns } = getGmObjExports(cascaderRef, cascaderExposeNames);\nconst { exposeFns: formItemFns } = getGmObjExports(formItemRef, formItemExposeNames);\ndefineExpose({\n cascaderExposes: {\n ...cascaderFns,\n },\n formItemExposes: {\n ...formItemFns,\n },\n});\n</script>\n"],"names":["_useModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,IAAM,MAAA,UAAA,GAAaA,QAAoD,CAAA,OAAA,EAAA,YAAC,CAAA,CAAA;AACxE,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAA;AACd,IAAA,MAAM,IAAO,GAAA,MAAA,CAAA;AACb,IAAoB,mBAAA,CAAA,UAAA,EAAY,EAAE,IAAM,EAAA,KAAA,CAAM,MAAM,aAAe,EAAA,KAAA,CAAM,eAAe,CAAA,CAAA;AAExF,IAAM,MAAA,QAAA,GAAW,CAAC,KAAyB,KAAA;AAEzC,MAAA,IAAA,CAAK,UAAU,KAAK,CAAA,CAAA;AAAA,KACtB,CAAA;AACA,IAAA,MAAM,cAAc,GAAsB,EAAA,CAAA;AAC1C,IAAA,MAAM,cAAc,GAAsB,EAAA,CAAA;AAC1C,IAAA,MAAM,EAAE,SAAW,EAAA,WAAA,EAAgB,GAAA,eAAA,CAAgB,aAAa,mBAAmB,CAAA,CAAA;AACnF,IAAA,MAAM,EAAE,SAAW,EAAA,WAAA,EAAgB,GAAA,eAAA,CAAgB,aAAa,mBAAmB,CAAA,CAAA;AACnF,IAAa,QAAA,CAAA;AAAA,MACX,eAAiB,EAAA;AAAA,QACf,GAAG,WAAA;AAAA,OACL;AAAA,MACA,eAAiB,EAAA;AAAA,QACf,GAAG,WAAA;AAAA,OACL;AAAA,KACD,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/es/giime/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ export { giimeDevProxy } from '../utils/src/http/devProxy.mjs';
|
|
|
16
16
|
export { getDomain } from '../utils/src/http/url.mjs';
|
|
17
17
|
export { getModifiedData, hasOwn, keysOf, resetObject } from '../utils/src/objects.mjs';
|
|
18
18
|
export { getDateShortcuts } from '../utils/src/date/dateShortcuts.mjs';
|
|
19
|
-
export { base64ToBlob, base64ToFile, blobToBase64, blobToFile,
|
|
19
|
+
export { base64ToBlob, base64ToFile, blobToBase64, blobToFile, fileMd5, fileToBase64, fileToBlob, fileToUrl, fileValidType, getImageInfo, getVideoInfo, urlToBlob, urlToFile } from '../utils/src/file.mjs';
|
|
20
20
|
export { compareVersions, isVersionGreaterOrEqual, omitOnEvents, remove } from '../utils/src/general.mjs';
|
|
21
21
|
export { b64_hmac_md5, b64_md5, hex_hmac_md5, hex_md5, str_hmac_md5, str_md5, ts_md5_file } from '../utils/src/crypto/md5.mjs';
|
|
22
22
|
export { any_hmac_sha1, any_sha1, b64_hmac_sha1, b64_sha1, hex_hmac_sha1, hex_sha1 } from '../utils/src/crypto/sha1.mjs';
|
package/es/giime/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.6.
|
|
1
|
+
export declare const version = "0.6.36";
|
package/es/giime/version.mjs
CHANGED
package/es/giime/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.6.
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../../packages/giime/version.ts"],"sourcesContent":["export const version = '0.6.36';\n"],"names":[],"mappings":"AAAO,MAAM,OAAU,GAAA;;;;"}
|
|
@@ -18,12 +18,15 @@ const useDownload = () => {
|
|
|
18
18
|
message: h("div", { className: curId }, [`\u5F53\u524D\u4E0B\u8F7D\u8FDB\u5EA6 0%`]),
|
|
19
19
|
duration: 0
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
try {
|
|
22
|
+
await createDownload({
|
|
23
|
+
url,
|
|
24
|
+
filename,
|
|
25
|
+
uuid: curId
|
|
26
|
+
});
|
|
27
|
+
} finally {
|
|
28
|
+
modalInfo.close();
|
|
29
|
+
}
|
|
27
30
|
};
|
|
28
31
|
const downloadByRes = async (res, options) => {
|
|
29
32
|
let contentDispositionName = (res?.headers?.["content-disposition"] || res?.headers?.["Content-Disposition"])?.split("filename=")[1];
|
|
@@ -41,12 +44,15 @@ const useDownload = () => {
|
|
|
41
44
|
});
|
|
42
45
|
const blob = new Blob([resBlob]);
|
|
43
46
|
const fileUrl = window.URL.createObjectURL(blob);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
try {
|
|
48
|
+
await createDownload({
|
|
49
|
+
url: fileUrl,
|
|
50
|
+
filename,
|
|
51
|
+
uuid: curId
|
|
52
|
+
});
|
|
53
|
+
} finally {
|
|
54
|
+
modalInfo.close();
|
|
55
|
+
}
|
|
50
56
|
};
|
|
51
57
|
const downloadToZip = async (fileList, filename) => {
|
|
52
58
|
return new Promise((resolve, reject) => {
|
|
@@ -82,6 +88,9 @@ const useDownload = () => {
|
|
|
82
88
|
reject(error);
|
|
83
89
|
});
|
|
84
90
|
}
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
reject(error);
|
|
93
|
+
modalInfo.close();
|
|
85
94
|
});
|
|
86
95
|
}
|
|
87
96
|
});
|
|
@@ -113,6 +122,12 @@ const useDownload = () => {
|
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
124
|
resolve(blob);
|
|
125
|
+
} else if (eventTarget.status === 404) {
|
|
126
|
+
GmMessage.error("\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u6216\u5DF2\u88AB\u5220\u9664");
|
|
127
|
+
reject(e);
|
|
128
|
+
} else {
|
|
129
|
+
GmMessage.error("\u4E0B\u8F7D\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5\uFF01");
|
|
130
|
+
reject(e);
|
|
116
131
|
}
|
|
117
132
|
};
|
|
118
133
|
xhr.onerror = function(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/hooks/base/useDownload/index.ts"],"sourcesContent":["import { h, ref } from 'vue';\nimport FileSaver from 'file-saver';\n\nimport GmNotification from '@giime/components/src/plugins/notification';\nimport { v4 as uuidv4 } from 'uuid';\nimport JSZip from 'jszip';\nimport { GmMessage } from '@giime/components/src/plugins/message';\nimport type { AxiosResponse } from 'axios';\n\nexport interface DownloadOptions {\n filename?: string;\n}\nexport interface DateownloadZipItem {\n url: string;\n filename?: string;\n}\n\nexport const useDownload = () => {\n const getUrlFilename = (url: string) => {\n const filename = url.split('/').pop()?.split('?')[0] || 'file';\n return filename;\n };\n /**\n * 通过url下载\n * @param url\n * @param options\n */\n const downloadByUrl = async (url: string, options?: DownloadOptions) => {\n const filename = options?.filename || getUrlFilename(url);\n const curId = uuidv4();\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', { className: curId }, [`当前下载进度 0%`]),\n duration: 0,\n });\n await createDownload({\n url,\n filename,\n uuid: curId,\n });\n modalInfo.close();\n };\n /**\n * 通过接口响应结果下载\n * @param res\n * @param options\n */\n const downloadByRes = async (res: AxiosResponse<any, any>, options?: DownloadOptions) => {\n let contentDispositionName = (res?.headers?.['content-disposition'] || res?.headers?.['Content-Disposition'])?.split('filename=')[1];\n try {\n contentDispositionName = decodeURIComponent(contentDispositionName);\n } catch {}\n const filename = options?.filename || contentDispositionName || 'file';\n const resBlob = await res.data;\n const curId = uuidv4();\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', { className: curId }, [`当前下载进度 0%`]),\n duration: 0,\n });\n // 设置type类型\n const blob = new Blob([resBlob]);\n const fileUrl = window.URL.createObjectURL(blob);\n await createDownload({\n url: fileUrl,\n filename,\n uuid: curId,\n });\n modalInfo.close();\n };\n /**\n * 下载多文件 转为zip\n * @param fileList\n * @param filename\n */\n const downloadToZip = async (fileList: DateownloadZipItem[], filename: string) => {\n return new Promise((resolve, reject) => {\n const currentContentClass = `message${Date.now()}`;\n const downloadCount = ref(0);\n const len = fileList.length;\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', [h('div', { className: currentContentClass }, [`总下载文件数:${len},已下载文件数:${downloadCount.value}`])]),\n duration: 0,\n });\n // h('div', { className: currentClass }, [`当前下载进度 ${progress.value}%`]),\n const zipInstance = new JSZip();\n for (let i = 0; i < len; i++) {\n const currentItem = fileList[i];\n // const fileBlob = await\n const downblobOptions = {\n url: currentItem.url,\n filename: currentItem.filename ?? getUrlFilename(currentItem.url),\n isZip: true,\n };\n createDownload(downblobOptions).then(res => {\n zipInstance.file(downblobOptions.filename, res);\n downloadCount.value++;\n editElementContent(currentContentClass, `总下载文件数:${len},已下载文件数:${downloadCount.value}`);\n if (downloadCount.value == len) {\n editElementContent(currentContentClass, `正在合并...`);\n zipInstance\n .generateAsync({ type: 'blob' })\n .then(async res => {\n modalInfo.close();\n\n const fileUrl = window.URL.createObjectURL(res);\n // FileSaver.saveAs(res, filename);\n await downloadByUrl(fileUrl, { filename });\n resolve(true);\n })\n .catch(error => {\n console.error('error', error);\n reject(error);\n });\n }\n });\n }\n });\n };\n const createDownload = (options: { url: string; filename: string; uuid?: string; isZip?: boolean }) => {\n return new Promise<Blob>((resolve, reject) => {\n // 创建一个新的 XMLHttpRequest 对象\n const xhr = new XMLHttpRequest();\n // 初始化一个GET请求\n xhr.open('GET', options.url, true);\n xhr.responseType = 'blob'; // 设置响应类型为blob,以便处理二进制文件\n\n // 监听 progress 事件\n xhr.onprogress = function (event) {\n if (event.lengthComputable) {\n const percentComplete = Math.floor((event.loaded / event.total) * 100);\n if (options.uuid) {\n editElementContent(options.uuid, `当前下载进度 ${percentComplete}%`);\n }\n }\n };\n\n // 监听 load 事件,表示下载完成\n xhr.onload = function (e) {\n const eventTarget = e.target as XMLHttpRequest;\n if ([200, 304].includes(eventTarget.status)) {\n const blob = eventTarget.response;\n // const url = window.URL.createObjectURL(blob);\n if (!options.isZip) {\n FileSaver.saveAs(blob, options.filename);\n GmNotification({\n type: 'success',\n title: '温馨提示',\n message: '下载完成',\n duration: 3000,\n });\n }\n\n resolve(blob);\n }\n };\n\n // 监听 error 事件\n xhr.onerror = function (e) {\n GmMessage.error('下载异常,请重试');\n reject(e);\n };\n\n // 发送请求\n xhr.send();\n });\n };\n return { downloadByUrl, downloadByRes, downloadToZip };\n};\n\n// 动态更新 notify 中的message 信息\nconst editElementContent = (className: string, content: string) => {\n // eslint-disable-next-line unicorn/prefer-query-selector\n const currentEle = document.getElementsByClassName(className)[0];\n if (currentEle) {\n currentEle.innerHTML = content;\n }\n};\n"],"names":["uuidv4","res"],"mappings":";;;;;;;AAiBO,MA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,CAAA,WAAA,CAAY,MAAM,CAAG,EAAA;AAC3C,UAAA,MAAM,OAAO,WAAY,CAAA,QAAA,CAAA;AAEzB,UAAI,IAAA,CAAC,QAAQ,KAAO,EAAA;AAClB,YAAU,SAAA,CAAA,MAAA,CAAO,IAAM,EAAA,OAAA,CAAQ,QAAQ,CAAA,CAAA;AACvC,YAAe,cAAA,CAAA;AAAA,cACb,IAAM,EAAA,SAAA;AAAA,cACN,KAAO,EAAA,0BAAA;AAAA,cACP,OAAS,EAAA,0BAAA;AAAA,cACT,QAAU,EAAA,GAAA;AAAA,aACX,CAAA,CAAA;AAAA,WACH;AAEA,UAAA,OAAA,CAAQ,IAAI,CAAA,CAAA;AAAA,SACd;AAAA,OACF,CAAA;AAGA,MAAI,GAAA,CAAA,OAAA,GAAU,SAAU,CAAG,EAAA;AACzB,QAAA,SAAA,CAAU,MAAM,kDAAU,CAAA,CAAA;AAC1B,QAAA,MAAA,CAAO,CAAC,CAAA,CAAA;AAAA,OACV,CAAA;AAGA,MAAA,GAAA,CAAI,IAAK,EAAA,CAAA;AAAA,KACV,CAAA,CAAA;AAAA,GACH,CAAA;AACA,EAAO,OAAA,EAAE,aAAe,EAAA,aAAA,EAAe,aAAc,EAAA,CAAA;AACvD,EAAA;AAGA,MAAM,kBAAA,GAAqB,CAAC,SAAA,EAAmB,OAAoB,KAAA;AAEjE,EAAA,MAAM,UAAa,GAAA,QAAA,CAAS,sBAAuB,CAAA,SAAS,EAAE,CAAC,CAAA,CAAA;AAC/D,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,UAAA,CAAW,SAAY,GAAA,OAAA,CAAA;AAAA,GACzB;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/hooks/base/useDownload/index.ts"],"sourcesContent":["import { h, ref } from 'vue';\nimport FileSaver from 'file-saver';\n\nimport GmNotification from '@giime/components/src/plugins/notification';\nimport { v4 as uuidv4 } from 'uuid';\nimport JSZip from 'jszip';\nimport { GmMessage } from '@giime/components/src/plugins/message';\nimport type { AxiosResponse } from 'axios';\n\nexport interface DownloadOptions {\n filename?: string;\n}\nexport interface DateownloadZipItem {\n url: string;\n filename?: string;\n}\n\nexport const useDownload = () => {\n const getUrlFilename = (url: string) => {\n const filename = url.split('/').pop()?.split('?')[0] || 'file';\n return filename;\n };\n /**\n * 通过url下载\n * @param url\n * @param options\n */\n const downloadByUrl = async (url: string, options?: DownloadOptions) => {\n const filename = options?.filename || getUrlFilename(url);\n const curId = uuidv4();\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', { className: curId }, [`当前下载进度 0%`]),\n duration: 0,\n });\n try {\n await createDownload({\n url,\n filename,\n uuid: curId,\n });\n } finally {\n modalInfo.close();\n }\n };\n /**\n * 通过接口响应结果下载\n * @param res\n * @param options\n */\n const downloadByRes = async (res: AxiosResponse<any, any>, options?: DownloadOptions) => {\n let contentDispositionName = (res?.headers?.['content-disposition'] || res?.headers?.['Content-Disposition'])?.split('filename=')[1];\n try {\n contentDispositionName = decodeURIComponent(contentDispositionName);\n } catch {}\n const filename = options?.filename || contentDispositionName || 'file';\n const resBlob = await res.data;\n const curId = uuidv4();\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', { className: curId }, [`当前下载进度 0%`]),\n duration: 0,\n });\n // 设置type类型\n const blob = new Blob([resBlob]);\n const fileUrl = window.URL.createObjectURL(blob);\n try {\n await createDownload({\n url: fileUrl,\n filename,\n uuid: curId,\n });\n } finally {\n modalInfo.close();\n }\n };\n /**\n * 下载多文件 转为zip\n * @param fileList\n * @param filename\n */\n const downloadToZip = async (fileList: DateownloadZipItem[], filename: string) => {\n return new Promise((resolve, reject) => {\n const currentContentClass = `message${Date.now()}`;\n const downloadCount = ref(0);\n const len = fileList.length;\n const modalInfo = GmNotification({\n title: '下载中',\n message: h('div', [h('div', { className: currentContentClass }, [`总下载文件数:${len},已下载文件数:${downloadCount.value}`])]),\n duration: 0,\n });\n // h('div', { className: currentClass }, [`当前下载进度 ${progress.value}%`]),\n const zipInstance = new JSZip();\n for (let i = 0; i < len; i++) {\n const currentItem = fileList[i];\n // const fileBlob = await\n const downblobOptions = {\n url: currentItem.url,\n filename: currentItem.filename ?? getUrlFilename(currentItem.url),\n isZip: true,\n };\n createDownload(downblobOptions)\n .then(res => {\n zipInstance.file(downblobOptions.filename, res);\n downloadCount.value++;\n editElementContent(currentContentClass, `总下载文件数:${len},已下载文件数:${downloadCount.value}`);\n if (downloadCount.value == len) {\n editElementContent(currentContentClass, `正在合并...`);\n zipInstance\n .generateAsync({ type: 'blob' })\n .then(async res => {\n modalInfo.close();\n\n const fileUrl = window.URL.createObjectURL(res);\n // FileSaver.saveAs(res, filename);\n await downloadByUrl(fileUrl, { filename });\n resolve(true);\n })\n .catch(error => {\n console.error('error', error);\n reject(error);\n });\n }\n })\n .catch(error => {\n reject(error);\n modalInfo.close();\n });\n }\n });\n };\n const createDownload = (options: { url: string; filename: string; uuid?: string; isZip?: boolean }) => {\n return new Promise<Blob>((resolve, reject) => {\n // 创建一个新的 XMLHttpRequest 对象\n const xhr = new XMLHttpRequest();\n // 初始化一个GET请求\n xhr.open('GET', options.url, true);\n xhr.responseType = 'blob'; // 设置响应类型为blob,以便处理二进制文件\n\n // 监听 progress 事件\n xhr.onprogress = function (event) {\n if (event.lengthComputable) {\n const percentComplete = Math.floor((event.loaded / event.total) * 100);\n if (options.uuid) {\n editElementContent(options.uuid, `当前下载进度 ${percentComplete}%`);\n }\n }\n };\n\n // 监听 load 事件,表示下载完成\n xhr.onload = function (e) {\n const eventTarget = e.target as XMLHttpRequest;\n if ([200, 304].includes(eventTarget.status)) {\n const blob = eventTarget.response;\n // const url = window.URL.createObjectURL(blob);\n if (!options.isZip) {\n FileSaver.saveAs(blob, options.filename);\n GmNotification({\n type: 'success',\n title: '温馨提示',\n message: '下载完成',\n duration: 3000,\n });\n }\n\n resolve(blob);\n } else if (eventTarget.status === 404) {\n GmMessage.error('文件不存在,或已被删除');\n reject(e);\n } else {\n GmMessage.error('下载异常,请重试!');\n reject(e);\n }\n };\n\n // 监听 error 事件\n xhr.onerror = function (e) {\n GmMessage.error('下载异常,请重试');\n reject(e);\n };\n\n // 发送请求\n xhr.send();\n });\n };\n return { downloadByUrl, downloadByRes, downloadToZip };\n};\n\n// 动态更新 notify 中的message 信息\nconst editElementContent = (className: string, content: string) => {\n // eslint-disable-next-line unicorn/prefer-query-selector\n const currentEle = document.getElementsByClassName(className)[0];\n if (currentEle) {\n currentEle.innerHTML = content;\n }\n};\n"],"names":["uuidv4","res"],"mappings":";;;;;;;AAiBO,MAAM,cAAc,MAAM;AAC/B,EAAM,MAAA,cAAA,GAAiB,CAAC,GAAgB,KAAA;AACtC,IAAM,MAAA,QAAA,GAAW,GAAI,CAAA,KAAA,CAAM,GAAG,CAAA,CAAE,GAAI,EAAA,EAAG,KAAM,CAAA,GAAG,CAAE,CAAA,CAAC,CAAK,IAAA,MAAA,CAAA;AACxD,IAAO,OAAA,QAAA,CAAA;AAAA,GACT,CAAA;AAMA,EAAM,MAAA,aAAA,GAAgB,OAAO,GAAA,EAAa,OAA8B,KAAA;AACtE,IAAA,MAAM,QAAW,GAAA,OAAA,EAAS,QAAY,IAAA,cAAA,CAAe,GAAG,CAAA,CAAA;AACxD,IAAA,MAAM,QAAQA,EAAO,EAAA,CAAA;AACrB,IAAA,MAAM,YAAY,cAAe,CAAA;AAAA,MAC/B,KAAO,EAAA,oBAAA;AAAA,MACP,OAAA,EAAS,EAAE,KAAO,EAAA,EAAE,WAAW,KAAM,EAAA,EAAG,CAAC,CAAA,uCAAA,CAAW,CAAC,CAAA;AAAA,MACrD,QAAU,EAAA,CAAA;AAAA,KACX,CAAA,CAAA;AACD,IAAI,IAAA;AACF,MAAA,MAAM,cAAe,CAAA;AAAA,QACnB,GAAA;AAAA,QACA,QAAA;AAAA,QACA,IAAM,EAAA,KAAA;AAAA,OACP,CAAA,CAAA;AAAA,KACD,SAAA;AACA,MAAA,SAAA,CAAU,KAAM,EAAA,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A;AAC3B,UAAA,MAAA,CAAO,CAAC,CAAA,CAAA;AAAA,SACV;AAAA,OACF,CAAA;AAGA,MAAI,GAAA,CAAA,OAAA,GAAU,SAAU,CAAG,EAAA;AACzB,QAAA,SAAA,CAAU,MAAM,kDAAU,CAAA,CAAA;AAC1B,QAAA,MAAA,CAAO,CAAC,CAAA,CAAA;AAAA,OACV,CAAA;AAGA,MAAA,GAAA,CAAI,IAAK,EAAA,CAAA;AAAA,KACV,CAAA,CAAA;AAAA,GACH,CAAA;AACA,EAAO,OAAA,EAAE,aAAe,EAAA,aAAA,EAAe,aAAc,EAAA,CAAA;AACvD,EAAA;AAGA,MAAM,kBAAA,GAAqB,CAAC,SAAA,EAAmB,OAAoB,KAAA;AAEjE,EAAA,MAAM,UAAa,GAAA,QAAA,CAAS,sBAAuB,CAAA,SAAS,EAAE,CAAC,CAAA,CAAA;AAC/D,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,UAAA,CAAW,SAAY,GAAA,OAAA,CAAA;AAAA,GACzB;AACF,CAAA;;;;"}
|
|
@@ -10,7 +10,7 @@ export interface UseUploadFileOptions {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const useUploadFile: () => {
|
|
12
12
|
isLoading: import("vue").Ref<boolean>;
|
|
13
|
-
uploadFile: (file: File, options
|
|
13
|
+
uploadFile: (file: File, options?: UseUploadFileOptions) => Promise<{
|
|
14
14
|
url: string;
|
|
15
15
|
exists: boolean;
|
|
16
16
|
uploadUrl: string;
|
|
@@ -10,14 +10,14 @@ const useUploadFile = () => {
|
|
|
10
10
|
const isLoading = ref(false);
|
|
11
11
|
const domainCode = useGlobalConfig("domainCode");
|
|
12
12
|
const uploadFile = async (file, options) => {
|
|
13
|
-
const uploadDomainCode = options
|
|
13
|
+
const uploadDomainCode = options?.domainCode ?? domainCode.value;
|
|
14
14
|
if (!uploadDomainCode) {
|
|
15
15
|
GmMessage.error("\u9886\u57DF\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A");
|
|
16
16
|
throw new Error("\u9886\u57DF\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A");
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
19
|
isLoading.value = true;
|
|
20
|
-
if (options
|
|
20
|
+
if (options?.accept && options?.accept !== "*") {
|
|
21
21
|
const isValidType = fileValidType(file, options.accept);
|
|
22
22
|
if (!isValidType) {
|
|
23
23
|
GmMessage.error(`\u6587\u4EF6\u7C7B\u578B\u4E0D\u652F\u6301\uFF0C\u8BF7\u4E0A\u4F20 ${options.accept} \u683C\u5F0F\u7684\u6587\u4EF6`);
|
|
@@ -25,11 +25,11 @@ const useUploadFile = () => {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const md5 = await fileMd5(file);
|
|
28
|
-
const acl = options
|
|
28
|
+
const acl = options?.acl || "default";
|
|
29
29
|
const { data } = await postV1ResourcesUrl({
|
|
30
30
|
domainCode: uploadDomainCode,
|
|
31
31
|
// 领域编码
|
|
32
|
-
sceneCode: options
|
|
32
|
+
sceneCode: options?.sceneCode || "internal_oss",
|
|
33
33
|
// 场景编码
|
|
34
34
|
fileName: file.name,
|
|
35
35
|
contentType: file.type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/hooks/base/useUploadFile/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { ref } from 'vue';\nimport { postV1ResourcesUrl } from '@giime/api/resource/controller';\nimport { fileMd5, fileValidType } from '@giime/utils/src/file';\nimport { GmMessage } from '@giime/components/src/plugins/message';\nimport { useGlobalConfig } from '@giime/hooks/base/useGlobalConfig';\n\nexport interface UseUploadFileOptions {\n /**领域编码 */\n domainCode?: string;\n /**场景编码 */\n sceneCode?: string;\n /**接受上传的文件类型 */\n accept?: string;\n /**文件权限,默认继承桶 */\n acl?: string;\n}\n\nexport const useUploadFile = () => {\n const isLoading = ref(false);\n const domainCode = useGlobalConfig('domainCode');\n\n const uploadFile = async (file: File, options
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/hooks/base/useUploadFile/index.ts"],"sourcesContent":["import axios from 'axios';\nimport { ref } from 'vue';\nimport { postV1ResourcesUrl } from '@giime/api/resource/controller';\nimport { fileMd5, fileValidType } from '@giime/utils/src/file';\nimport { GmMessage } from '@giime/components/src/plugins/message';\nimport { useGlobalConfig } from '@giime/hooks/base/useGlobalConfig';\n\nexport interface UseUploadFileOptions {\n /**领域编码 */\n domainCode?: string;\n /**场景编码 */\n sceneCode?: string;\n /**接受上传的文件类型 */\n accept?: string;\n /**文件权限,默认继承桶 */\n acl?: string;\n}\n\nexport const useUploadFile = () => {\n const isLoading = ref(false);\n const domainCode = useGlobalConfig('domainCode');\n\n const uploadFile = async (file: File, options?: UseUploadFileOptions) => {\n // 领域编码\n const uploadDomainCode = options?.domainCode ?? domainCode.value;\n if (!uploadDomainCode) {\n GmMessage.error('领域编码不能为空');\n throw new Error('领域编码不能为空');\n }\n try {\n isLoading.value = true;\n // 验证文件类型\n if (options?.accept && options?.accept !== '*') {\n const isValidType = fileValidType(file, options.accept);\n if (!isValidType) {\n GmMessage.error(`文件类型不支持,请上传 ${options.accept} 格式的文件`);\n throw new Error(`文件类型不支持,请上传 ${options.accept} 格式的文件`);\n }\n }\n const md5 = await fileMd5(file);\n const acl = options?.acl || 'default';\n const { data } = await postV1ResourcesUrl({\n domainCode: uploadDomainCode, // 领域编码\n sceneCode: options?.sceneCode || 'internal_oss', // 场景编码\n fileName: file.name,\n contentType: file.type,\n md5,\n size: file.size,\n acl, // 文件权限\n });\n\n if (data.data.uploadUrl) {\n try {\n await axios.put(data.data.uploadUrl, file, {\n headers: {\n 'Content-Type': file.type,\n 'x-oss-object-acl ': acl,\n },\n });\n } catch (error) {\n GmMessage.error('推送至存储桶失败,请重试');\n throw error;\n }\n }\n\n return data.data;\n } finally {\n isLoading.value = false;\n }\n };\n return {\n isLoading,\n uploadFile,\n };\n};\n"],"names":[],"mappings":";;;;;;;;AAkBO,M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