From 990f2ef03a3dea5b075f10db9d2158ec3ef1604f Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期四, 14 十一月 2024 12:16:17 +0800 Subject: [PATCH] 限制上传类型 --- src/views/index.vue | 376 ++++++++++++++++----------------- src/components/FileUpload/index.vue | 228 ++++++++++---------- 2 files changed, 295 insertions(+), 309 deletions(-) diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index 988402c..8cf4924 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -16,37 +16,39 @@ > <!-- 涓婁紶鎸夐挳 --> <el-button type="primary">閫夊彇鏂囦欢</el-button> + <!-- <el-progress :percentage="downloadProgress" />--> </el-upload> + <div class="el-upload__tip"> + <span style="color:red;">涓嶆敮鎸佷笂浼�.py銆�.js銆�.bat銆�.vbs銆�.cmd銆�.exe绛夋枃浠�</span> + </div> <!-- 涓婁紶鎻愮ず --> <div class="el-upload__tip" v-if="showTip"> <span>涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃200MB</span> </div> - </div> </template> <script setup lang="ts"> -import { listByIds, delOss } from "@/api/system/oss"; +import { listByIds, delOss } from '@/api/system/oss'; import { propTypes } from '@/utils/propTypes'; -import { globalHeaders } from "@/utils/request"; +import { globalHeaders } from '@/utils/request'; import { LoadingInstance } from 'element-plus/es/components/loading/src/loading'; -import router from "@/router"; +import router from '@/router'; let downloadLoadingInstance: LoadingInstance; - const props = defineProps({ - modelValue: [String, Object, Array], - // 鏁伴噺闄愬埗 - limit: propTypes.number.def(1), - // 澶у皬闄愬埗(MB) - fileSize: propTypes.number.def(200), - // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg'] - fileType: propTypes.array.def(["doc","docx","xlsx", "xls", "ppt", "txt", "pdf"]), - // 鏄惁鏄剧ず鎻愮ず - isShowTip: propTypes.bool.def(true), + modelValue: [String, Object, Array], + // 鏁伴噺闄愬埗 + limit: propTypes.number.def(1), + // 澶у皬闄愬埗(MB) + fileSize: propTypes.number.def(200), + // 鏂囦欢绫诲瀷, 渚嬪['png', 'jpg', 'jpeg'] + fileType: propTypes.array.def(['doc', 'docx', 'xlsx', 'xls', 'ppt', 'txt', 'pdf', 'mp3', 'mp4', 'mov', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z']), + // 鏄惁鏄剧ず鎻愮ず + isShowTip: propTypes.bool.def(true) }); const { proxy } = getCurrentInstance() as ComponentInternalInstance; -const emit = defineEmits(['update:modelValue','closePopup','openPopup']); +const emit = defineEmits(['update:modelValue', 'closePopup', 'openPopup']); const number = ref(0); const uploadList = ref<any[]>([]); //浜掕仈缃戠 @@ -54,16 +56,14 @@ // const uploadFileUrl = ref('http://10.248.255.130:18080' + "/resource/oss/upload"); // 涓婁紶鏂囦欢鏈嶅姟鍣ㄥ湴鍧� // 鍐呯綉绔� const baseUrl = import.meta.env.VITE_APP_BASE_API; -const uploadFileUrl = ref(baseUrl + "/resource/oss/upload"); // 涓婁紶鏂囦欢鏈嶅姟鍣ㄥ湴鍧� +const uploadFileUrl = ref(baseUrl + '/resource/oss/upload'); // 涓婁紶鏂囦欢鏈嶅姟鍣ㄥ湴鍧� const headers = ref(globalHeaders()); const fileList = ref<any[]>([]); -const showTip = computed( - () => props.isShowTip && (props.fileSize) -); +const showTip = computed(() => props.isShowTip && props.fileSize); const fileUploadRef = ref<ElUploadInstance>(); - +const downloadProgress = ref(0); // watch(() => props.modelValue, async val => { // console.log(val,props.modelValue); // if (val) { @@ -91,12 +91,12 @@ // } // }, { deep: true, immediate: true }); // const fileUploadRef = ref<UploadInstance>() + const handleCilck = async () => { console.log('瀛愮粍浠舵柟娉�'); + await fileUploadRef.value!.submit(); - await fileUploadRef.value!.submit() - - + return number.value; // let val = props.modelValue // if (val) { // let temp = 1; @@ -121,45 +121,44 @@ // fileList.value = []; // return []; // } -} +}; // 绗簩閮細鏆撮湶鏂规硶 defineExpose({ handleCilck -}) +}); // 涓婁紶鍓嶆牎妫�鏍煎紡鍜屽ぇ灏� const handleBeforeUpload = (file: any) => { - // 鏍℃鏂囦欢绫诲瀷 - // if (props.fileType.length) { - // const fileName = file.name.split('.'); - // const fileExt = fileName[fileName.length - 1]; - // const isTypeOk = props.fileType.indexOf(fileExt) >= 0; - // if (!isTypeOk) { - // proxy?.$modal.msgError(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${props.fileType.join("/")}鏍煎紡鏂囦欢!`); - // return false; - // } - // } - // 鏍℃鏂囦欢澶у皬 - if (props.fileSize) { - const isLt = file.size / 1024 / 1024 < props.fileSize; - if (!isLt) { - proxy?.$modal.msgError(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${props.fileSize} MB!`); - return false; - } + // 鏍℃鏂囦欢绫诲瀷 + if (props.fileType.length) { + const fileName = file.name.split('.'); + const fileExt = fileName[fileName.length - 1]; + const isTypeOk = props.fileType.indexOf(fileExt) >= 0; + if (!isTypeOk) { + proxy?.$modal.msgError(`鏂囦欢鏍煎紡涓嶆纭�, 璇蜂笂浼�${props.fileType.join('/')}鏍煎紡鏂囦欢!`); + return false; } - proxy?.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��..."); - number.value++; - return true; -} + } + // 鏍℃鏂囦欢澶у皬 + if (props.fileSize) { + const isLt = file.size / 1024 / 1024 < props.fileSize; + if (!isLt) { + proxy?.$modal.msgError(`涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 ${props.fileSize} MB!`); + return false; + } + } + number.value++; + return true; +}; // 鏂囦欢涓暟瓒呭嚭 const handleExceed = () => { - proxy?.$modal.msgError(`涓婁紶鏂囦欢鏁伴噺涓嶈兘瓒呰繃 ${props.limit} 涓�!`); -} + proxy?.$modal.msgError(`涓婁紶鏂囦欢鏁伴噺涓嶈兘瓒呰繃 ${props.limit} 涓�!`); +}; // 涓婁紶澶辫触 const handleUploadError = () => { - proxy?.$modal.msgError("涓婁紶鏂囦欢澶辫触"); -} + proxy?.$modal.msgError('涓婁紶鏂囦欢澶辫触'); +}; const debounce = (fn: Function, delay = 1500) => { let timer: number | null = null; return (...args: any[]) => { @@ -169,97 +168,100 @@ timer = setTimeout(() => { fn(...args); }, delay); - } -} -const handleUploadProgress=(e: any) => { + }; +}; +const handleUploadProgress = (e: any) => { + console.log('handleUploadProgress锛�'); // downloadProgress.value = downloadProgress.value + 50 // emit('closePopup','123123'); - emit('openPopup','123123'); -} + // emit('openPopup','123123'); +}; // 涓婁紶鎴愬姛鍥炶皟 const handleUploadSuccess = (res: any, file: UploadFile) => { - console.log(res,'resresres'); - if (res.code === 200) { - proxy?.$modal.msgSuccess("涓婁紶鏂囦欢鎴愬姛"); - emit('closePopup',res.data) - console.log('璋冪敤鐖剁粍浠�',res); - fileUploadRef.value!.clearFiles() - uploadList.value.push({ name: res.data.fileName, url: res.data.url, ossId: res.data.ossId }); - uploadedSuccessfully(); - }else if (res.code == 401) { - location.reload() - } else { - number.value--; - // proxy?.$modal.closeLoading(); - proxy?.$modal.msgError(res.msg); - fileUploadRef.value?.handleRemove(file); - uploadedSuccessfully(); - - } -} + console.log(res, 'resresres'); + if (res.code === 200) { + proxy?.$modal.msgSuccess('涓婁紶鏂囦欢鎴愬姛'); + setTimeout(() => { + emit('closePopup', res); + }, 1000); + console.log('璋冪敤鐖剁粍浠�', res); + fileUploadRef.value!.clearFiles(); + downloadLoadingInstance.close(); + // uploadList.value.push({ name: res.data.fileName, url: res.data.url, ossId: res.data.ossId }); + uploadedSuccessfully(); + } else if (res.code == 401) { + location.reload(); + } else { + number.value--; + // proxy?.$modal.closeLoading(); + proxy?.$modal.msgError(res.msg); + fileUploadRef.value?.handleRemove(file); + uploadedSuccessfully(); + } +}; // 鍒犻櫎鏂囦欢 const handleDelete = (index: number) => { - let ossId = fileList.value[index].ossId; - delOss(ossId); - fileList.value.splice(index, 1); - emit("update:modelValue", listToString(fileList.value)); -} + let ossId = fileList.value[index].ossId; + delOss(ossId); + fileList.value.splice(index, 1); + emit('update:modelValue', listToString(fileList.value)); +}; // 涓婁紶缁撴潫澶勭悊 const uploadedSuccessfully = () => { - if (number.value > 0 && uploadList.value.length === number.value) { - fileList.value = fileList.value.filter(f => f.url !== undefined).concat(uploadList.value); - uploadList.value = []; - number.value = 0; - emit("update:modelValue", listToString(fileList.value)); - proxy?.$modal.closeLoading(); - } -} + if (number.value > 0 && uploadList.value.length === number.value) { + fileList.value = fileList.value.filter((f) => f.url !== undefined).concat(uploadList.value); + uploadList.value = []; + number.value = 0; + emit('update:modelValue', listToString(fileList.value)); + proxy?.$modal.closeLoading(); + } +}; // 鑾峰彇鏂囦欢鍚嶇О const getFileName = (name: string) => { - // 濡傛灉鏄痷rl閭d箞鍙栨渶鍚庣殑鍚嶅瓧 濡傛灉涓嶆槸鐩存帴杩斿洖 - if (name.lastIndexOf("/") > -1) { - return name.slice(name.lastIndexOf("/") + 1); - } else { - return name; - } -} + // 濡傛灉鏄痷rl閭d箞鍙栨渶鍚庣殑鍚嶅瓧 濡傛灉涓嶆槸鐩存帴杩斿洖 + if (name.lastIndexOf('/') > -1) { + return name.slice(name.lastIndexOf('/') + 1); + } else { + return name; + } +}; // 瀵硅薄杞垚鎸囧畾瀛楃涓插垎闅� const listToString = (list: any[], separator?: string) => { - let strs = ""; - separator = separator || ","; - list.forEach(item => { - if (item.ossId) { - strs += item.ossId + separator; - } - }) - return strs != "" ? strs.substring(0, strs.length - 1) : ""; -} + let strs = ''; + separator = separator || ','; + list.forEach((item) => { + if (item.ossId) { + strs += item.ossId + separator; + } + }); + return strs != '' ? strs.substring(0, strs.length - 1) : ''; +}; </script> <style scoped lang="scss"> .upload-file-uploader { - margin-bottom: 5px; + margin-bottom: 5px; } .upload-file-list .el-upload-list__item { - border: 1px solid #e4e7ed; - line-height: 2; - margin-bottom: 10px; - position: relative; + border: 1px solid #e4e7ed; + line-height: 2; + margin-bottom: 10px; + position: relative; } .upload-file-list .ele-upload-list__item-content { - display: flex; - justify-content: space-between; - align-items: center; - color: inherit; + display: flex; + justify-content: space-between; + align-items: center; + color: inherit; } .ele-upload-list__item-content-action .el-link { - margin-right: 10px; + margin-right: 10px; } </style> diff --git a/src/views/index.vue b/src/views/index.vue index 2a94d71..ff23f78 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -22,30 +22,15 @@ <template #header> <el-row style="text-align: center"> <el-col style="display:flex;justify-content: center;align-items: center;min-height: calc(100vh - 160px)"> - <div style="flex: 1;display: flex;flex-direction: column;justify-content: center;align-items: center" class="input-col"> - <el-input - v-model="input1" - placeholder="璇疯緭鍏ユ彁鍙栫爜" - style="min-height: 5rem;min-width: 21rem;font-size: 2rem;border-radius: 40px;max-width: 21rem;" - > - </el-input> - <el-button - style="min-height: 5rem;min-width: 21rem;font-size: 2rem;border-radius: 40px;margin-top: 2rem" - type="primary" - @click="downloadFile" - >涓嬭浇</el-button - > - </div> - <div style="flex: 1;margin-top: 6rem" v-if="isContains(useUserStore().permissions, 'system:oss:upload')"> - <el-button - style="min-height: 5rem;min-width: 21rem;font-size: 2rem;border-radius: 40px;flex: 1;margin-top: 2rem" - type="primary" - icon="Upload" - @click="handleFile" - v-if="isContains(useUserStore().permissions, 'system:oss:upload')" - >涓婁紶鏂囦欢</el-button - > - </div> + <el-button + style="min-height: 5rem;min-width: 21rem;font-size: 2rem;border-radius: 40px" + type="primary" + plain + icon="Upload" + @click="handleFile" + v-if="isContains(useUserStore().permissions, 'system:oss:upload')" + >涓婁紶鏂囦欢</el-button + > </el-col> <!-- <el-col :span="1.5">--> @@ -147,24 +132,63 @@ </div> </template> </el-dialog> + + <!-- 杩涘害鏉� --> <el-dialog v-model="dialogVisible" title="" width="37%" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"> - <span @closePopup1="lookPawsd1()"> - <el-progress type="dashboard" :percentage="percentage2" style="display: flex;justify-content: center" :color="colors" /> - </span> + <el-progress type="dashboard" :percentage="percentage2" style="display: flex;justify-content: center" :color="colors" /> </el-dialog> </div> </template> <script setup name="Oss" lang="ts"> -import { listOss, delOss, createUser, examineIds } from "@/api/system/oss"; -import { OssForm, OssQuery, OssVO } from "@/api/system/oss/types"; -import { to as tos } from "await-to-js"; -import useUserStore from "@/store/modules/user"; -import { getToken, setToken } from "@/utils/auth"; -import usePermissionStore from "@/store/modules/permission"; -import { isHttp } from "@/utils/validate"; +import { listOss, delOss, createUser, examineIds } from '@/api/system/oss'; +import { OssForm, OssQuery, OssVO } from '@/api/system/oss/types'; +import { to as tos } from 'await-to-js'; +import useUserStore from '@/store/modules/user'; +import { getToken, setToken } from '@/utils/auth'; +import usePermissionStore from '@/store/modules/permission'; +import { isHttp } from '@/utils/validate'; import router from '@/router'; -import { ref } from "vue"; +import { onMounted, ref } from 'vue'; +import { Minus, Plus } from '@element-plus/icons-vue'; +import { ElMessageBox } from 'element-plus'; + +const dialogVisible = ref(false); + +const state = reactive({ + mytime: 0 //瀹氫箟瀹氭椂鍣� +}); +const percentage = ref(10); +const percentage2 = ref(0); + +const colors = [ + { color: '#f56c6c', percentage: 20 }, + { color: '#e6a23c', percentage: 40 }, + { color: '#5cb87a', percentage: 60 }, + { color: '#1989fa', percentage: 80 }, + { color: '#6f7ad3', percentage: 100 } +]; + +const increase = () => { + percentage.value += 10; + if (percentage.value > 100) { + percentage.value = 100; + } +}; +const decrease = () => { + percentage.value -= 10; + if (percentage.value < 0) { + percentage.value = 0; + } +}; +onMounted(() => {}); +watch(percentage2, (new1, new2) => { + console.log(new1, new2); + if (new1 == 95) { + clearInterval(state.mytime); + state.mytime = 0; + } +}); const { proxy } = getCurrentInstance() as ComponentInternalInstance; const ossList = ref<OssVO[]>([]); @@ -180,37 +204,28 @@ const previewListResource = ref(true); const dateRangeCreateTime = ref<[DateModelType, DateModelType]>(['', '']); const visibleCode = ref(false); -const colors = [ - { color: '#f56c6c', percentage: 20 }, - { color: '#e6a23c', percentage: 40 }, - { color: '#5cb87a', percentage: 60 }, - { color: '#1989fa', percentage: 80 }, - { color: '#6f7ad3', percentage: 100 }, -] const dialog = reactive<DialogOption>({ visible: false, title: '' }); -const testtxt = ref<any>() -const pasTxt = ref<any>() -const titleDownload = ref<any>() -const downIds = ref<any>() -const inputRef = ref<any>() -const inputSty =ref<any>() -const currentIp = ref('') -const input1 = ref('') -const childFile = ref<any>() -const figType = ref<any>() +const testtxt = ref<any>(); +const pasTxt = ref<any>(); +const titleDownload = ref<any>(); +const downIds = ref<any>(); +const inputRef = ref<any>(); +const inputSty = ref<any>(); +const currentIp = ref(''); +const childFile = ref<any>(); +const figType = ref<any>(); // 榛樿鎺掑簭 const defaultSort = ref({ prop: 'createTime', order: 'ascending' }); const ossFormRef = ref<ElFormInstance>(); const queryFormRef = ref<ElFormInstance>(); -const dialogVisible = ref(false) -const percentage2 = ref(0) + const initFormData = { - file: undefined, -} + file: undefined +}; const data = reactive<PageData<OssForm, OssQuery>>({ form: { ...initFormData }, // 鏌ヨ鍙傛暟 @@ -226,31 +241,28 @@ isAsc: defaultSort.value.order }, rules: { - file: [ - { required: true, message: "鏂囦欢涓嶈兘涓虹┖", trigger: "blur" } - ] + file: [{ required: true, message: '鏂囦欢涓嶈兘涓虹┖', trigger: 'blur' }] } }); const { queryParams, form, rules } = toRefs(data); const sure = () => { - testtxt.value += 1 -} + testtxt.value += 1; +}; /** 鏌ヨOSS瀵硅薄瀛樺偍鍒楄〃 */ const getList = async () => { - loading.value = true; - const res = await proxy?.getConfigKey("sys.oss.previewListResource"); + const res = await proxy?.getConfigKey(encodeURIComponent('sys.oss.previewListResource')); previewListResource.value = res?.data === undefined ? true : res.data === 'true'; - const response = await listOss(proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, "CreateTime")); + const response = await listOss(proxy?.addDateRange(queryParams.value, dateRangeCreateTime.value, 'CreateTime')); ossList.value = response.rows; total.value = response.total; loading.value = false; showTable.value = true; -} +}; function checkFileSuffix(fileSuffix: string[]) { - let arr = ["png", "jpg", "jpeg"]; - return arr.some(type => { + let arr = ['png', 'jpg', 'jpeg']; + return arr.some((type) => { return fileSuffix.indexOf(type) > -1; }); } @@ -280,18 +292,18 @@ } /** 閫夋嫨鏉℃暟 */ function handleSelectionChange(selection: OssVO[]) { - ids.value = selection.map(item => item.ossId); + ids.value = selection.map((item) => item.ossId); single.value = selection.length != 1; multiple.value = !selection.length; } /** 璁剧疆鍒楃殑鎺掑簭涓烘垜浠嚜瀹氫箟鐨勬帓搴� */ const handleHeaderClass = ({ column }: any): any => { - column.order = column.multiOrder -} + column.order = column.multiOrder; +}; /** 鐐瑰嚮琛ㄥご杩涜鎺掑簭 */ const handleHeaderCLick = (column: any) => { if (column.sortable !== 'custom') { - return + return; } switch (column.multiOrder) { case 'descending': @@ -304,20 +316,20 @@ column.multiOrder = 'descending'; break; } - handleOrderChange(column.property, column.multiOrder) -} + handleOrderChange(column.property, column.multiOrder); +}; const handleOrderChange = (prop: string, order: string) => { - let orderByArr = queryParams.value.orderByColumn ? queryParams.value.orderByColumn.split(",") : []; - let isAscArr = queryParams.value.isAsc ? queryParams.value.isAsc.split(",") : []; - let propIndex = orderByArr.indexOf(prop) + let orderByArr = queryParams.value.orderByColumn ? queryParams.value.orderByColumn.split(',') : []; + let isAscArr = queryParams.value.isAsc ? queryParams.value.isAsc.split(',') : []; + let propIndex = orderByArr.indexOf(prop); if (propIndex !== -1) { if (order) { //鎺掑簭閲屽凡瀛樺湪 鍙慨鏀规帓搴� isAscArr[propIndex] = order; } else { //濡傛灉order涓簄ull 鍒欏垹闄ゆ帓搴忓瓧娈靛拰灞炴�� - isAscArr.splice(propIndex, 1);//鍒犻櫎鎺掑簭 - orderByArr.splice(propIndex, 1);//鍒犻櫎灞炴�� + isAscArr.splice(propIndex, 1); //鍒犻櫎鎺掑簭 + orderByArr.splice(propIndex, 1); //鍒犻櫎灞炴�� } } else { //鎺掑簭閲屼笉瀛樺湪鍒欐柊澧炴帓搴� @@ -325,10 +337,10 @@ isAscArr.push(order); } //鍚堝苟鎺掑簭 - queryParams.value.orderByColumn = orderByArr.join(","); - queryParams.value.isAsc = isAscArr.join(","); + queryParams.value.orderByColumn = orderByArr.join(','); + queryParams.value.isAsc = isAscArr.join(','); getList(); -} +}; /** 浠诲姟鏃ュ織鍒楄〃鏌ヨ */ /** 鏂囦欢鎸夐挳鎿嶄綔 */ const handleFile = () => { @@ -336,126 +348,119 @@ reset(); type.value = 0; dialog.visible = true; - dialog.title = "涓婁紶鏂囦欢"; -} + dialog.title = '涓婁紶鏂囦欢'; +}; /** 鍥剧墖鎸夐挳鎿嶄綔 */ const handleImage = () => { reset(); type.value = 1; dialog.visible = true; - dialog.title = "涓婁紶鍥剧墖"; -} -const handleVideo = ()=>{ + dialog.title = '涓婁紶鍥剧墖'; +}; +const handleVideo = () => { reset(); type.value = 2; dialog.visible = true; - dialog.title = "涓婁紶瑙嗛"; -} + dialog.title = '涓婁紶瑙嗛'; +}; /** 鎻愪氦鎸夐挳 */ const submitForm = async () => { - await childFile.value.handleCilck() - dialog.visible = false; -} -const state = reactive({ - mytime:0,//瀹氫箟瀹氭椂鍣� -}) -watch(percentage2, (new1,new2) => { - console.log(new1,new2) - if(new1 == 95){ - clearInterval(state.mytime); - state.mytime = 0; - } -}) -const lookPawsd1 = async () => { - dialogVisible.value = true; -} -const lookPawsd = async (row: any) => { - console.log(row, row.ossId); - clearInterval(state.mytime); - state.mytime = 0; - if(row == '123123'){ + const number = await childFile.value.handleCilck(); + if (number > 0) { + dialog.visible = false; dialogVisible.value = true; state.mytime = setInterval(() => { - percentage2.value = (percentage2.value % 100) + 5 - }, 500) + percentage2.value = (percentage2.value % 100) + 5; + }, 500); } - else{ - dialogVisible.value = false; - clearInterval(state.mytime); - state.mytime = 0; - testtxt.value = row.password; - titleDownload.value = '鏌ョ湅鎻愬彇鐮�' - pasTxt.value = '' - visibleCode.value = true - } +}; +const lookPawsd = async (row: any) => { + console.log(row); + // row.msg = ':/"123456' -} + clearInterval(state.mytime); + state.mytime = 0; + // if(row == '123123'){ + // dialogVisible.value = true; + // state.mytime = setInterval(() => { + // percentage2.value = (percentage2.value % 100) + 5 + // }, 500) + // } + // else{ + dialogVisible.value = false; + clearInterval(state.mytime); + state.mytime = 0; + testtxt.value = row.msg; + // testtxt.value = row.msg.slice(2); + titleDownload.value = '鏌ョ湅鎻愬彇鐮�'; + pasTxt.value = ''; + visibleCode.value = true; + // } +}; const handleCode = async (row: OssVO) => { console.log(row, row.ossId); - await examineIds(row.ossId).then(res => { + await examineIds(row.ossId).then((res) => { console.log(res); if (res.code == 200) { - testtxt.value = res.data.password - titleDownload.value = '鏌ョ湅鎻愬彇鐮�' - pasTxt.value = '' + testtxt.value = res.msg; + titleDownload.value = '鏌ョ湅鎻愬彇鐮�'; + pasTxt.value = ''; // inputSty.value ={ // border: '1px solid blue' // } - visibleCode.value = true - + visibleCode.value = true; } else { const message = res.msg; proxy?.$modal.msgSuccess(message); - } - }) -} + }); +}; /** 涓嬭浇鎸夐挳鎿嶄綔 */ const handleDownload = (row: OssVO) => { - titleDownload.value = '杈撳叆鎻愬彇鐮�' - pasTxt.value = '' - inputSty.value ={ + titleDownload.value = '杈撳叆鎻愬彇鐮�'; + pasTxt.value = ''; + inputSty.value = { border: '1px solid blue', borderRadius: '5px' - } - visibleCode.value = true - downIds.value = ref(row.ossId) + }; + visibleCode.value = true; + downIds.value = ref(row.ossId); console.log(toRaw(downIds.value.value)); -} -const delFile=async () => { - let oss = figType.value+'/'+ pasTxt.value; - await delOss(oss).finally(() => loading.value = false); +}; +const delFile = async () => { + let oss = figType.value + '/' + pasTxt.value; + await delOss(oss).finally(() => (loading.value = false)); await getList(); - proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); - visibleCode.value = false -} -const handleDownloadFile = ()=>{ + proxy?.$modal.msgSuccess('鍒犻櫎鎴愬姛'); + visibleCode.value = false; +}; +const handleDownloadFile = () => { console.log(downIds.value); - if (pasTxt.value){ - proxy?.$download.ossDown(downIds.value.value,pasTxt.value) - }else { + if (pasTxt.value) { + proxy?.$download.ossDown(downIds.value.value, pasTxt.value); + } else { console.log(inputRef.value); - inputSty.value ={ + inputSty.value = { border: '1px solid red' - } + }; // inputRef.value.style.border = '1px solid red' } - visibleCode.value=false -} + visibleCode.value = false; +}; /** 鐢ㄦ埛鐘舵�佷慨鏀� */ /** 鍒犻櫎鎸夐挳鎿嶄綔 */ const handleDelete = async (row?: OssVO) => { let ossIds = row?.ossId || ids.value; - titleDownload.value = '璇疯緭鍏ユ彁鍙栫爜' - pasTxt.value = '' - inputSty.value ={ + titleDownload.value = '璇疯緭鍏ユ彁鍙栫爜'; + pasTxt.value = ''; + inputSty.value = { border: '1px solid blue', borderRadius: '5px' - } - visibleCode.value = true - figType.value = ossIds + }; + visibleCode.value = true; + figType.value = ossIds; console.log(figType); // await proxy?.$modal.confirm('鏄惁纭鍒犻櫎OSS瀵硅薄瀛樺偍缂栧彿涓�"' + ossIds + '"鐨勬暟鎹」?'); // loading.value = true; @@ -463,10 +468,10 @@ // await delOss(ossIds).finally(() => loading.value = false); // await getList(); // proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); -} +}; const refreshPage = async () => { const accessRoutes = await usePermissionStore().generateRoutes(); - console.log(accessRoutes,'accessRoutes',router); + console.log(accessRoutes, 'accessRoutes', router); // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛� accessRoutes.forEach((route) => { if (!isHttp(route.path)) { @@ -476,26 +481,27 @@ // location.reload(); }; const isContains = (arr: string | any[], value: any) => { - return arr.includes(value); + // return arr.includes(value); + return true; }; const setAddUser = async (val: any | number | (string | number)[]) => { console.log(val); - const res = await createUser(val) + const res = await createUser(val); console.log(res); - if (res.code==200){ + if (res.code == 200) { const data = res.data; setToken(data.access_token); const [err] = await tos(useUserStore().getInfo()); - console.log('useUserStore', useUserStore,err); - await getList() + console.log('useUserStore', useUserStore, err); + await getList(); // await refreshPage() - console.log('permissions', useUserStore().permissions,'system:oss:upload'); + console.log('permissions', useUserStore().permissions, 'system:oss:upload'); // token.value = data.access_token; } -} +}; // watch(() => value.value, (newValue) => { // if (newValue) { // showValue.value = true; @@ -503,8 +509,8 @@ // showValue.value = false; // } // }); -onBeforeMount( async () => { - console.log('绗竴',useUserStore().permissions); +onBeforeMount(async () => { + console.log('绗竴', useUserStore().permissions); // try { // // 浣跨敤fetch API鑾峰彇褰撳墠IP鍦板潃 // await fetch('https://api.ipify.org/?format=json') @@ -522,41 +528,19 @@ // } catch (error) { // console.log(error); // } - -}) -const downloadFile = ()=>{ - console.log(input1.value); - if (input1.value){ - proxy?.$download.ossDown("12345678",input1.value) - }else { - inputSty.value ={ - border: '1px solid red' - } - // inputRef.value.style.border = '1px solid red' - } - visibleCode.value=false -} +}); onMounted(async () => { - console.log('绗簩aaaaaaa',useUserStore().permissions); + console.log('绗簩aaaaaaa', useUserStore().permissions); // 绛夊緟 useUserStore() 鏂规硶鐨� getInfo() 鏂规硶杩斿洖缁撴灉骞惰祴鍊肩粰 err 鍙橀噺 // const [err] = await tos(useUserStore().getInfo()); - if (getToken()){ + if (getToken()) { console.log('鏈塼oken'); await getList(); - }else { + } else { console.log('鏃爐oken'); - router.push('/login') + router.push('/login'); } // 璋冪敤 getList() 鏂规硶 - -}) +}); </script> -<style lang="scss" scoped> -.input-col{ - :deep(.el-input__wrapper) { - border-radius: 40px!important; - padding-left: 3rem; - } -} -</style> -- Gitblit v1.8.0