| | |
| | | <div class="mb-[10px]" v-show="showSearch"> |
| | | <el-card shadow="hover"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> |
| | | <!-- <el-form-item label="文件名" prop="fileName">--> |
| | | <!-- <el-input v-model="queryParams.fileName" placeholder="请输入文件名" clearable style="width: 200px" @keyup.enter="handleQuery" />--> |
| | | <!-- </el-form-item>--> |
| | | |
| | | <el-form-item label="原名" prop="originalName"> |
| | | <el-input v-model="queryParams.originalName" placeholder="请输入原名" clearable style="width: 200px" @keyup.enter="handleQuery" /> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="文件后缀" prop="fileSuffix">--> |
| | | <!-- <el-input v-model="queryParams.fileSuffix" placeholder="请输入文件后缀" clearable style="width: 200px" @keyup.enter="handleQuery" />--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item label="创建时间">--> |
| | | <!-- <el-date-picker--> |
| | | <!-- v-model="dateRangeCreateTime"--> |
| | | <!-- value-format="YYYY-MM-DD HH:mm:ss"--> |
| | | <!-- type="daterange"--> |
| | | <!-- range-separator="-"--> |
| | | <!-- start-placeholder="开始日期"--> |
| | | <!-- end-placeholder="结束日期"--> |
| | | <!-- :default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"--> |
| | | <!-- ></el-date-picker>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- <el-form-item label="服务商" prop="service">--> |
| | | <!-- <el-input v-model="queryParams.service" placeholder="请输入服务商" clearable style="width: 200px" @keyup.enter="handleQuery" />--> |
| | | <!-- </el-form-item>--> |
| | | |
| | | <el-form-item> |
| | | <el-button type="primary" icon="search" @click="handleQuery">搜索</el-button> |
| | | <el-button icon="Refresh" @click="resetQuery">重置</el-button> |
| | |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Upload" @click="handleFile" v-if="isContains(useUserStore().permissions, 'system:oss:upload')">上传文件</el-button> |
| | | </el-col> |
| | | <!-- <el-col :span="1.5">--> |
| | | <!-- <el-button type="primary" plain icon="Upload" @click="handleImage" v-if="isContains(useUserStore().permissions, 'system:oss:upload')">上传图片</el-button>--> |
| | | <!-- </el-col>--> |
| | | <!-- <el-col :span="1.5">--> |
| | | <!-- <el-button type="primary" plain icon="Upload" @click="handleVideo" v-if="isContains(useUserStore().permissions, 'system:oss:upload')">上传视频</el-button>--> |
| | | <!-- </el-col>--> |
| | | |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-if="isContains(useUserStore().permissions, 'system:oss:remove')"> |
| | | 删除 |
| | | </el-button> |
| | | </el-col> |
| | | <!-- <el-col :span="1.5">--> |
| | | <!-- <el-button--> |
| | | <!-- :type="previewListResource ? 'danger' : 'warning'"--> |
| | | <!-- plain--> |
| | | <!-- @click="handlePreviewListResource(!previewListResource)"--> |
| | | <!-- v-hasPermi="['system:oss:edit']"--> |
| | | <!-- >预览开关 :--> |
| | | <!-- {{--> |
| | | <!-- previewListResource ? "禁用" : "启用" }}</el-button--> |
| | | <!-- >--> |
| | | <!-- </el-col>--> |
| | | <el-col :span="1.5"> |
| | | <el-button type="info" plain icon="Operation" @click="handleOssConfig" v-hasPermi="['system:oss:lists']">配置管理</el-button> |
| | | </el-col> |
| | | <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> |
| | | </el-row> |
| | | </template> |
| | | |
| | | <el-table |
| | | v-loading="loading" |
| | | :data="ossList" |
| | |
| | | v-if="showTable" |
| | | > |
| | | <el-table-column type="selection" width="55" align="center" /> |
| | | <!-- <el-table-column label="对象存储主键" align="center" prop="ossId" v-if="true" />--> |
| | | <!-- <el-table-column label="文件名" align="center" prop="fileName" />--> |
| | | <el-table-column label="原名" align="center" prop="originalName" /> |
| | | <!-- <el-table-column label="文件后缀" align="center" prop="fileSuffix" />--> |
| | | <!-- <el-table-column label="文件展示" align="center" prop="url">--> |
| | | <!-- <template #default="scope">--> |
| | | <!-- <ImagePreview--> |
| | | <!-- v-if="previewListResource && checkFileSuffix(scope.row.fileSuffix)"--> |
| | | <!-- :width="100"--> |
| | | <!-- :height="100"--> |
| | | <!-- :src="scope.row.url"--> |
| | | <!-- :preview-src-list="[scope.row.url]"--> |
| | | <!-- />--> |
| | | <!-- <span v-text="scope.row.url" v-if="!checkFileSuffix(scope.row.fileSuffix) || !previewListResource" />--> |
| | | <!-- </template>--> |
| | | <!-- </el-table-column>--> |
| | | <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="180" sortable="custom">--> |
| | | <!-- <template #default="scope">--> |
| | | <!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>--> |
| | | <!-- </template>--> |
| | | <!-- </el-table-column>--> |
| | | <el-table-column label="上传人" align="center" prop="createByName" /> |
| | | <!-- <el-table-column label="服务商" align="center" prop="service" sortable="custom" />--> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template #default="scope"> |
| | | <el-tooltip content="查看提取码" placement="top"> |
| | |
| | | |
| | | <script setup name="Oss" lang="ts"> |
| | | import { listOss, delOss, createUser, examineIds } from "@/api/system/oss"; |
| | | import ImagePreview from "@/components/ImagePreview/index.vue"; |
| | | import { OssForm, OssQuery, OssVO } from "@/api/system/oss/types"; |
| | | import { getInfo } from "@/api/login"; |
| | | import { to as tos } from "await-to-js"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | import { setToken } from "@/utils/auth"; |
| | | import { getToken, setToken } from "@/utils/auth"; |
| | | import usePermissionStore from "@/store/modules/permission"; |
| | | import { isHttp } from "@/utils/validate"; |
| | | import { any } from "vue-types"; |
| | | |
| | | const router = useRouter(); |
| | | import router from '@/router'; |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | |
| | | const ossList = ref<OssVO[]>([]); |
| | |
| | | getList(); |
| | | } |
| | | /** 任务日志列表查询 */ |
| | | const handleOssConfig = () => { |
| | | router.push('/system/oss-config/index') |
| | | } |
| | | /** 文件按钮操作 */ |
| | | const handleFile = () => { |
| | | reset(); |
| | |
| | | const submitForm = async () => { |
| | | await childFile.value.handleCilck() |
| | | dialog.visible = false; |
| | | // setTimeout(() =>{ getList();},1000) |
| | | |
| | | } |
| | | const handleCode = async (row: OssVO) => { |
| | | console.log(row, row.ossId); |
| | |
| | | |
| | | } |
| | | /** 用户状态修改 */ |
| | | const handlePreviewListResource = async (preview: boolean) => { |
| | | let text = preview ? "启用" : "停用"; |
| | | try { |
| | | await proxy?.$modal.confirm('确认要"' + text + '""预览列表图片"配置吗?'); |
| | | await proxy?.updateConfigByKey("sys.oss.previewListResource", preview); |
| | | await getList() |
| | | proxy?.$modal.msgSuccess(text + "成功"); |
| | | } catch { return } |
| | | } |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (row?: OssVO) => { |
| | | const ossIds = row?.ossId || ids.value; |
| | |
| | | proxy?.$modal.msgSuccess("删除成功"); |
| | | } |
| | | const refreshPage = async () => { |
| | | // const [err] = await tos(useUserStore().getInfo()); |
| | | // console.log(err); |
| | | const accessRoutes = await usePermissionStore().generateRoutes(); |
| | | console.log(accessRoutes,'accessRoutes',router); |
| | | // 根据roles权限生成可访问的路由表 |
| | | accessRoutes.forEach((route) => { |
| | | if (!isHttp(route.path)) { |
| | |
| | | const isContains = (arr: string | any[], value: any) => { |
| | | return arr.includes(value); |
| | | }; |
| | | |
| | | const setAddUser = async (val: any | number | (string | number)[]) => { |
| | | console.log(val); |
| | | const res = await createUser(val) |
| | |
| | | if (res.code==200){ |
| | | const data = res.data; |
| | | setToken(data.access_token); |
| | | await refreshPage() |
| | | const [err] = await tos(useUserStore().getInfo()); |
| | | console.log('useUserStore', useUserStore,err); |
| | | await getList() |
| | | await nextTick(async () => { |
| | | const [err] = await tos(useUserStore().getInfo()); |
| | | console.log('useUserStore', useUserStore,err); |
| | | |
| | | // await refreshPage() |
| | | |
| | | console.log('permissions', useUserStore().permissions,'system:oss:upload'); |
| | | |
| | | }) |
| | | |
| | | // token.value = data.access_token; |
| | | } |
| | | } |
| | |
| | | // }); |
| | | onBeforeMount( async () => { |
| | | console.log('第一',useUserStore().permissions); |
| | | try { |
| | | // 使用fetch API获取当前IP地址 |
| | | await fetch('https://api.ipify.org/?format=json') |
| | | .then(response => response.json()) |
| | | .then(async data => { |
| | | currentIp.value = data.ip; |
| | | let obj = { |
| | | username: data.ip |
| | | } |
| | | await setAddUser(obj) |
| | | }) |
| | | .catch(error => { |
| | | console.error('获取IP地址失败:', error); |
| | | }); |
| | | } catch (error) { |
| | | console.log(error); |
| | | } |
| | | // try { |
| | | // // 使用fetch API获取当前IP地址 |
| | | // await fetch('https://api.ipify.org/?format=json') |
| | | // .then(response => response.json()) |
| | | // .then(async data => { |
| | | // currentIp.value = data.ip; |
| | | // let obj = { |
| | | // username: data.ip |
| | | // } |
| | | // await setAddUser(obj) |
| | | // }) |
| | | // .catch(error => { |
| | | // console.error('获取IP地址失败:', error); |
| | | // }); |
| | | // } catch (error) { |
| | | // console.log(error); |
| | | // } |
| | | |
| | | }) |
| | | onMounted(async () => { |
| | | console.log('第二',useUserStore().permissions); |
| | | console.log('第二aaaaaaa',useUserStore().permissions); |
| | | // 等待 useUserStore() 方法的 getInfo() 方法返回结果并赋值给 err 变量 |
| | | // const [err] = await tos(useUserStore().getInfo()); |
| | | |
| | | if (getToken()){ |
| | | await getList(); |
| | | }else { |
| | | router.push('/login') |
| | | } |
| | | // 调用 getList() 方法 |
| | | // await getList(); |
| | | |
| | | }) |
| | | |
| | | </script> |