From 4237a46fd00f74bbceba5cf1e058aee9c6804147 Mon Sep 17 00:00:00 2001 From: xingyuv Date: Wed, 22 Mar 2023 18:02:20 +0800 Subject: [PATCH] feat: iframe --- .env.development | 5 +-- .env.front | 4 ++- .env.production | 1 + .env.test | 3 +- src/api/infra/dbDoc/index.ts | 8 ++--- src/components/IFrame/index.ts | 5 +++ src/components/IFrame/src/IFrame.vue | 25 +++++++++++++++ src/hooks/setting/index.ts | 3 +- src/types/config.d.ts | 1 + src/utils/env.ts | 2 ++ src/views/infra/dbDoc/index.vue | 46 +++++++++++++++++++++++++++- src/views/infra/druid/index.vue | 12 +++++++- src/views/infra/server/index.vue | 12 +++++++- src/views/infra/skywalking/index.vue | 10 +++++- src/views/infra/swagger/index.vue | 12 +++++++- src/views/infra/webSocket/index.vue | 4 +-- vite.config.ts | 2 +- 17 files changed, 137 insertions(+), 18 deletions(-) create mode 100644 src/components/IFrame/index.ts create mode 100644 src/components/IFrame/src/IFrame.vue diff --git a/.env.development b/.env.development index 176c28bb..f8a17486 100644 --- a/.env.development +++ b/.env.development @@ -7,15 +7,16 @@ VITE_PUBLIC_PATH = / # 本地开发代理,可以解决跨域及多地址代理 # 如果接口地址匹配到,则会转发到http://localhost:3000,防止本地出现跨域问题 # 可以有多个,注意多个不能换行,否则代理将会失效 -VITE_PROXY = [["/dev-api","http://localhost:48080"],["/upload","http://localhost:48080/admin-api/infra/file/upload"]] +VITE_PROXY = [["/dev-api","http://localhost:48080"],["/upload","http://192.168.0.22:48080/admin-api/infra/file/upload"]] # VITE_PROXY=[["/api","http://vben.xingyuv.com/test"]] # 是否删除Console.log VITE_DROP_CONSOLE = false # 接口地址 +VITE_GLOB_BASE_URL = "http://localhost:48080" # 如果没有跨域问题,直接在这里配置即可 -VITE_GLOB_API_URL = "http://localhost:48080/admin-api" +VITE_GLOB_API_URL = /admin-api # 文件上传接口 可选 VITE_GLOB_UPLOAD_URL = /upload diff --git a/.env.front b/.env.front index 5a35a843..1d697cb2 100644 --- a/.env.front +++ b/.env.front @@ -14,8 +14,10 @@ VITE_PROXY = [["/dev-api","http://api-dashboard.yudao.iocoder.cn"],["/upload","h VITE_DROP_CONSOLE = false # 接口地址 +# 接口地址 +VITE_GLOB_BASE_URL = "http://api-dashboard.yudao.iocoder.cn" # 如果没有跨域问题,直接在这里配置即可 -VITE_GLOB_API_URL = "http://api-dashboard.yudao.iocoder.cn/admin-api" +VITE_GLOB_API_URL = /admin-api # 文件上传接口 可选 VITE_GLOB_UPLOAD_URL = /upload diff --git a/.env.production b/.env.production index 68729f74..3931f01f 100644 --- a/.env.production +++ b/.env.production @@ -13,6 +13,7 @@ VITE_BUILD_COMPRESS = 'gzip' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false # 接口地址 可以由nginx做转发或者直接写实际地址 +VITE_GLOB_BASE_URL = "http://localhost:48080" VITE_GLOB_API_URL = /admin-api # 文件上传地址 可以由nginx做转发或者直接写实际地址 diff --git a/.env.test b/.env.test index de3ecb98..4ed47d3b 100644 --- a/.env.test +++ b/.env.test @@ -15,7 +15,8 @@ VITE_BUILD_COMPRESS = 'none' VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE = false # 接口地址 可以由nginx做转发或者直接写实际地址 -VITE_GLOB_API_URL = /admin-api +VITE_GLOB_BASE_URL = "http://localhost:48080" +VITE_GLOB_API_URL = /admin-ap # 文件上传地址 可以由nginx做转发或者直接写实际地址 VITE_GLOB_UPLOAD_URL = /upload diff --git a/src/api/infra/dbDoc/index.ts b/src/api/infra/dbDoc/index.ts index 45a78e9b..eb93169f 100644 --- a/src/api/infra/dbDoc/index.ts +++ b/src/api/infra/dbDoc/index.ts @@ -1,16 +1,16 @@ import { defHttp } from '@/utils/http/axios' // 导出Html -export const exportHtmlApi = () => { - return defHttp.get({ url: '/infra/db-doc/export-html' }) +export const exportHtmlApi = async () => { + return defHttp.get({ url: '/infra/db-doc/export-html', responseType: 'blob' }) } // 导出Word export const exportWordApi = () => { - return defHttp.get({ url: '/infra/db-doc/export-word' }) + return defHttp.get({ url: '/infra/db-doc/export-word', responseType: 'blob' }) } // 导出Markdown export const exportMarkdownApi = () => { - return defHttp.get({ url: '/infra/db-doc/export-markdown' }) + return defHttp.get({ url: '/infra/db-doc/export-markdown', responseType: 'blob' }) } diff --git a/src/components/IFrame/index.ts b/src/components/IFrame/index.ts new file mode 100644 index 00000000..7fe1bae7 --- /dev/null +++ b/src/components/IFrame/index.ts @@ -0,0 +1,5 @@ +import { withInstall } from '@/utils' + +import iFrame from './src/IFrame.vue' + +export const IFrame = withInstall(iFrame) diff --git a/src/components/IFrame/src/IFrame.vue b/src/components/IFrame/src/IFrame.vue new file mode 100644 index 00000000..e78ca806 --- /dev/null +++ b/src/components/IFrame/src/IFrame.vue @@ -0,0 +1,25 @@ + + diff --git a/src/hooks/setting/index.ts b/src/hooks/setting/index.ts index cec59ae0..f1d6da22 100644 --- a/src/hooks/setting/index.ts +++ b/src/hooks/setting/index.ts @@ -6,6 +6,7 @@ import { getAppEnvConfig } from '@/utils/env' export const useGlobSetting = (): Readonly => { const { VITE_GLOB_APP_TITLE, + VITE_GLOB_BASE_URL, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, @@ -23,7 +24,7 @@ export const useGlobSetting = (): Readonly => { // Take global configuration const glob: Readonly = { title: VITE_GLOB_APP_TITLE, - apiUrl: VITE_GLOB_API_URL, + apiUrl: VITE_GLOB_BASE_URL + VITE_GLOB_API_URL, shortName: VITE_GLOB_APP_SHORT_NAME, urlPrefix: VITE_GLOB_API_URL_PREFIX, uploadUrl: VITE_GLOB_UPLOAD_URL, diff --git a/src/types/config.d.ts b/src/types/config.d.ts index 58987f9a..62e65c11 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -167,6 +167,7 @@ export interface GlobConfig { export interface GlobEnvConfig { // Site title VITE_GLOB_APP_TITLE: string + VITE_GLOB_BASE_URL: string // Service interface url VITE_GLOB_API_URL: string // Service interface url prefix diff --git a/src/utils/env.ts b/src/utils/env.ts index 1d816e9e..f365b78d 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -24,6 +24,7 @@ export function getAppEnvConfig() { const { VITE_GLOB_APP_TITLE, + VITE_GLOB_BASE_URL, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, @@ -40,6 +41,7 @@ export function getAppEnvConfig() { return { VITE_GLOB_APP_TITLE, + VITE_GLOB_BASE_URL, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_PREFIX, diff --git a/src/views/infra/dbDoc/index.vue b/src/views/infra/dbDoc/index.vue index 3b64cfc4..2dadded1 100644 --- a/src/views/infra/dbDoc/index.vue +++ b/src/views/infra/dbDoc/index.vue @@ -1,3 +1,47 @@