diff --git a/platform-web-ui/.env b/platform-web-ui/.env index 5974833..706b437 100644 --- a/platform-web-ui/.env +++ b/platform-web-ui/.env @@ -2,3 +2,6 @@ ## 项目标题 VITE_APP_TITLE = "Molly平台管理系统" + +## 租户系统域名链接。如: molly.xaaef.com 或者 .xaaef.com +VITE_TENANT_LINK = "molly.xaaef.com:8555/tenant/" diff --git a/platform-web-ui/.env.development b/platform-web-ui/.env.development index 30cf5db..2caad2b 100644 --- a/platform-web-ui/.env.development +++ b/platform-web-ui/.env.development @@ -1,7 +1,7 @@ # 开发环境自定义的环境变量(命名必须以 VITE_ 开头) ## 后端接口公共路径(如果解决跨域问题采用反向代理就只需写公共路径) -VITE_BASE_API = 'http://localhost:18891' +VITE_BASE_API = 'http://127.0.0.1:18891' ## 路由模式 hash 或 html5 VITE_ROUTER_HISTORY = 'hash' diff --git a/platform-web-ui/package.json b/platform-web-ui/package.json index 2215210..88e89d7 100644 --- a/platform-web-ui/package.json +++ b/platform-web-ui/package.json @@ -38,6 +38,7 @@ "path-browserify": "1.0.1", "path-to-regexp": "6.2.1", "pinia": "2.1.7", + "qrcode-vue3": "^1.6.8", "screenfull": "6.0.2", "sockjs-client": "^1.6.1", "uuid": "^9.0.1", diff --git a/platform-web-ui/pnpm-lock.yaml b/platform-web-ui/pnpm-lock.yaml index afd74b2..0ea3ef8 100644 --- a/platform-web-ui/pnpm-lock.yaml +++ b/platform-web-ui/pnpm-lock.yaml @@ -50,6 +50,9 @@ dependencies: pinia: specifier: 2.1.7 version: 2.1.7(typescript@5.2.2)(vue@3.3.5) + qrcode-vue3: + specifier: ^1.6.8 + version: 1.6.8 screenfull: specifier: 6.0.2 version: 6.0.2 @@ -4179,6 +4182,16 @@ packages: engines: {node: '>=6'} dev: true + /qrcode-generator@1.4.4: + resolution: {integrity: sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw==} + dev: false + + /qrcode-vue3@1.6.8: + resolution: {integrity: sha512-LtMnwKWi58ZqHbXBcsTF/VxDYhI6RrBIrDQw8fbDVlO8p5tJBZa7TaIaVYLY937vKO2WCEBmOKksGlpm5ccEIg==} + dependencies: + qrcode-generator: 1.4.4 + dev: false + /query-string@4.3.4: resolution: {integrity: sha512-O2XLNDBIg1DnTOa+2XrIwSiXEV8h2KImXUnjhhn2+UsvZ+Es2uyd5CCRTNQlDGbzUQOW3aYCBx9rVA6dzsiY7Q==} engines: {node: '>=0.10.0'} diff --git a/platform-web-ui/src/icons/svg/qrcode.svg b/platform-web-ui/src/icons/svg/qrcode.svg new file mode 100644 index 0000000..77d6aa6 --- /dev/null +++ b/platform-web-ui/src/icons/svg/qrcode.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/platform-web-ui/src/utils/index.ts b/platform-web-ui/src/utils/index.ts index 99f31e4..54e1cb9 100644 --- a/platform-web-ui/src/utils/index.ts +++ b/platform-web-ui/src/utils/index.ts @@ -2,6 +2,8 @@ import dayjs from "dayjs" import { removeConfigLayout } from "@/utils/cache/local-storage" import chinaAreaJson from "@/assets/ChinaArea.json" import { ISimpleProject, ISimpleTenant } from "@/types/base" +import { getFileBlob, httpGet } from "./service" +import { AxiosResponse } from "axios" //#region 格式化日期时间 export const DEFAULT_DATE_TIME_PATTERN = "YYYY-MM-DD HH:mm:ss" diff --git a/platform-web-ui/src/utils/service.ts b/platform-web-ui/src/utils/service.ts index c3acc69..24c723d 100644 --- a/platform-web-ui/src/utils/service.ts +++ b/platform-web-ui/src/utils/service.ts @@ -8,6 +8,7 @@ import { useProjectStoreHook } from "@/store/modules/project" import { getEnvBaseURLPrefix } from "." import { ISimpleProject, ISimpleTenant } from "@/types/base" import { defaultTenant } from "@/utils" +import { v4 as uuidv4 } from "uuid" /** 创建请求实例 */ function createService() { @@ -26,7 +27,7 @@ function createService() { const apiData = response.data // 二进制数据则直接返回 const responseType = response.request?.responseType - if (responseType === "blob" || responseType === "arraybuffer") return apiData + if (responseType === "blob" || responseType === "arraybuffer") return response // 这个 code 是和后端约定的业务 code const code = apiData.status // 如果没有 code, 代表这不是项目后端开发的 api @@ -217,4 +218,41 @@ function httpDelete(url: string, params?: T): Promise

{ return httpRequest

({ method: "delete", url, params }) } -export { httpRequest, httpGet, httpPost, httpPut, httpDelete, axiosRequest } +/** 单独抽离的 文件下载 工具函数 */ +async function downloadFile(url: string, fileName?: string): Promise { + const { data, headers } = await axios.get(url, { responseType: "blob" }) + if (!fileName) { + const fn1 = headers["content-disposition"] + if (fn1) { + fileName = fn1.replace(/\w+;filename=(.*)/, "$1") + } else { + fileName = uuidv4().replace(/-/g, "") + } + } + const urlObject = window.URL || window.webkitURL + const downloadUrl = urlObject.createObjectURL(data) + const link = document.createElement("a") + link.href = downloadUrl + link.download = fileName! + document.body.appendChild(link) + link.click() + document.body.removeChild(link) + urlObject.revokeObjectURL(downloadUrl) +} + +/** 单独抽离的 文件下载 工具函数 */ +function getFileBlob(url: string): Promise { + // 单独处理自定义请求/响应回掉 + return new Promise((resolve, reject) => { + axios + .get(url, { responseType: "blob" }) + .then((resp) => { + const { data, headers } = resp + const blob = new Blob([data], { type: headers["content-type"] }) + resolve(blob) + }) + .catch((error) => reject(error)) + }) +} + +export { httpRequest, httpGet, httpPost, httpPut, httpDelete, axiosRequest, downloadFile, getFileBlob } diff --git a/platform-web-ui/src/views/sys/tenant/index.vue b/platform-web-ui/src/views/sys/tenant/index.vue index 16350b4..c2be24d 100644 --- a/platform-web-ui/src/views/sys/tenant/index.vue +++ b/platform-web-ui/src/views/sys/tenant/index.vue @@ -91,7 +91,11 @@