style: 初始化 禁用一些页面 跳转改为让宿主执行

This commit is contained in:
huanghao1412 2023-12-20 11:03:32 +08:00
parent 81e2e4784d
commit b9268d89ec
13 changed files with 87 additions and 77 deletions

6
.env
View File

@ -2,7 +2,9 @@
VITE_DEV_PORT = '8080'
# development path
VITE_DEV_PATH = 'https://demo.mtruning.club'
# VITE_DEV_PATH = 'https://demo.mtruning.club'
VITE_DEV_PATH = 'http://192.168.0.120:3001'
# production path
VITE_PRO_PATH = 'https://demo.mtruning.club'
# VITE_PRO_PATH = 'https://demo.mtruning.club'
VITE_PRO_PATH = 'http://192.168.0.120:3001'

View File

@ -37,61 +37,61 @@ import axiosInstance from './axios'
import { RequestHttpEnum, ContentTypeEnum } from '@/enums/httpEnum'
export const get = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.GET,
params: params,
})
return axiosInstance({
url: url,
method: RequestHttpEnum.GET,
params: params,
})
}
export const post = (url: string, data?: object, headersType?: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.POST,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
return axiosInstance({
url: url,
method: RequestHttpEnum.POST,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
}
export const put = (url: string, data?: object, headersType?: string) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.PUT,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
return axiosInstance({
url: url,
method: RequestHttpEnum.PUT,
data: data,
headers: {
'Content-Type': headersType || ContentTypeEnum.JSON
}
})
}
export const del = (url: string, params?: object) => {
return axiosInstance({
url: url,
method: RequestHttpEnum.DELETE,
params
})
return axiosInstance({
url: url,
method: RequestHttpEnum.DELETE,
params
})
}
// 获取请求函数默认get
export const http = (type?: RequestHttpEnum) => {
switch (type) {
case RequestHttpEnum.GET:
return get
switch (type) {
case RequestHttpEnum.GET:
return get
case RequestHttpEnum.POST:
return post
case RequestHttpEnum.POST:
return post
case RequestHttpEnum.PUT:
return put
case RequestHttpEnum.PUT:
return put
case RequestHttpEnum.DELETE:
return del
case RequestHttpEnum.DELETE:
return del
default:
return get
}
default:
return get
}
}
```
@ -109,11 +109,3 @@ export const http = (type?: RequestHttpEnum) => {
* build: 影响项目构建或依赖修改
* style: 不影响程序逻辑的代码修改
* chore: 不属于以上类型的其他类型(日常事务)
## 交流
QQ 群1030129384
![QQ群](readme/go-view-qq.png)
![渲染海报](readme/logo-poster.png)

View File

@ -10,7 +10,7 @@
<slot name="ri-left"></slot>
</template>
<template #ri-right>
<go-user-info></go-user-info>
<!-- <go-user-info></go-user-info> -->
<slot name="ri-right"></slot>
</template>
</layout-header>

View File

@ -28,7 +28,7 @@ const RootRoute: Array<RouteRecordRaw> = [
]
export const constantRouter: any[] = [LoginRoute, ...RootRoute, ReloadRoute];
export const constantRouter: any[] = [...RootRoute, ReloadRoute];
const router = createRouter({
history: createWebHashHistory(''),

View File

@ -28,9 +28,9 @@ export function createRouterGuards(router: Router) {
}
// @ts-ignore
if (!routerAllowList.includes(to.name) && !loginCheck()) {
next({ name: PageEnum.BASE_LOGIN_NAME })
}
// if (!routerAllowList.includes(to.name) && !loginCheck()) {
// next({ name: PageEnum.BASE_LOGIN_NAME })
// }
next()
})
@ -44,4 +44,4 @@ export function createRouterGuards(router: Router) {
router.onError((error) => {
console.log(error, '路由错误');
});
}
}

View File

@ -59,15 +59,30 @@ export const fetchPathByName = (pageName: string, p?: string) => {
* @param windowOpen
*/
export const routerTurnByPath = (
path: string,
query?: Array<string | number>,
isReplace?: boolean,
windowOpen?: boolean
path: string,
query?: Array<string | number>,
isReplace?: boolean,
windowOpen?: boolean,
isCallByParent?: boolean
) => {
let fullPath = ''
if (query?.length) {
fullPath = `${path}/${query.join('/')}`
}
if (isCallByParent) {
// 获取父页面的 window 对象
var parentWindow = window.parent;
const message = {
// 属于哪个页面
page: 'customLargeScreen',
// 属于什么类型
type: 'changeRouter',
url: fullPath,
openNew: windowOpen ? 1 : 0
}
parentWindow.postMessage(JSON.stringify(message), '*');
return
}
if (windowOpen) {
return openNewWindow(fullPath)
}
@ -204,11 +219,11 @@ export const loginCheck = () => {
/**
* *
* @returns
* @returns
*/
export const previewPath = (id?: string | number) => {
export const previewPath = (id?: string | number) => {
const { origin, pathname } = document.location
const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href')
const previewPath = `${origin}${pathname}${path}/${id || fetchRouteParamsLocation()}`
return previewPath
}
}

View File

@ -152,7 +152,7 @@ const editHandle = () => {
if (!path) return
const id = fetchRouteParamsLocation()
updateToSession(id)
routerTurnByPath(path, [id], undefined, true)
routerTurnByPath(path, [id], undefined, true, true)
}, 2000)
}

View File

@ -117,7 +117,7 @@ const previewHandle = () => {
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }])
}
//
routerTurnByPath(path, [previewId], undefined, true)
routerTurnByPath(path, [previewId], undefined, true, true)
}
//

View File

@ -102,7 +102,7 @@ function importJSON() {
}
//
window.opener.addEventListener(SavePageEnum.CHART, (e: any) => {
window?.opener?.addEventListener(SavePageEnum.CHART, (e: any) => {
window['$message'].success('正在进行更新...')
setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [e.detail])
content.value = JSONStringify(e.detail)

View File

@ -27,16 +27,16 @@
import { ProjectLayoutSider } from './layout/components/ProjectLayoutSider'
import { LayoutHeaderPro } from '@/layout/components/LayoutHeaderPro'
import { LayoutTransitionMain } from '@/layout/components/LayoutTransitionMain/index'
import { goDialog } from '@/utils'
// import { goDialog } from '@/utils'
//
goDialog({
message: '不要在官方后端上发布任何私密数据,任何人都看得到并进行删除!!!!',
isMaskClosable: true,
closeNegativeText: true,
transformOrigin: 'center',
onPositiveCallback: () => {}
})
// //
// goDialog({
// message: '',
// isMaskClosable: true,
// closeNegativeText: true,
// transformOrigin: 'center',
// onPositiveCallback: () => {}
// })
</script>
<style lang="scss" scoped>

View File

@ -23,7 +23,7 @@ export const useModalDataInit = () => {
const editHandle = (cardData: Chartype) => {
if (!cardData) return
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
routerTurnByPath(path, [cardData.id], undefined, true)
routerTurnByPath(path, [cardData.id], undefined, true, true)
}
// 预览处理

View File

@ -26,7 +26,8 @@
<n-text>{{ $t('global.doc') }}</n-text>
</n-button>
<n-tooltip v-if="collapsed" placement="right" trigger="hover">
<!-- 官方地址 -->
<!-- <n-tooltip v-if="collapsed" placement="right" trigger="hover">
<template #trigger>
<n-button secondary @click="handleDoc">
<template #icon>
@ -48,7 +49,7 @@
</n-icon>
</template>
<n-text v-show="!collapsed">{{ $t('global.code_addr') }}</n-text>
</n-button>
</n-button> -->
</n-space>
</div>
</template>

View File

@ -100,7 +100,7 @@ const btnHandle = async (key: string) => {
const { id } = res.data
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
routerTurnByPath(path, [id], undefined, true)
routerTurnByPath(path, [id], undefined, true, true)
closeHandle()
}
} catch (error) {