fix: 前端改为单页面应用

This commit is contained in:
fit2cloud-chenyw 2021-11-26 11:38:25 +08:00
parent 1ef27410f6
commit 26c54d41bc
17 changed files with 55 additions and 168 deletions

View File

@ -41,7 +41,6 @@ public class ShiroServiceImpl implements ShiroService {
filterChainDefinitionMap.put("/link/**", ANON);
filterChainDefinitionMap.put("/index.html", ANON);
filterChainDefinitionMap.put("/link.html", ANON);
filterChainDefinitionMap.put("/xggznb/**", ANON);
//获取主题信息

View File

@ -32,15 +32,6 @@ public class IndexController {
return "index.html";
}
@GetMapping("/link")
public String link() {
return "link.html";
}
@GetMapping("/test")
public String test() {
return "test.html";
}
@GetMapping("/deApi")
public String deApi() {
@ -53,12 +44,12 @@ public class IndexController {
}
}
@GetMapping("/xggznb/{index}")
public String xggznb(@PathVariable(value = "index", required = true) Long index) {
@GetMapping("/link/{index}")
public String xggznb(@PathVariable(value = "index", required = true) Long index) {
String url = panelLinkService.getUrlByIndex(index);
HttpServletResponse response = ServletUtils.response();
String param = url.substring(url.indexOf("?") + 1);
Cookie cookie = new Cookie("link", param);
Cookie cookie = new Cookie("link", param.split("=")[1]);
response.addCookie(cookie);
return url;
}

View File

@ -2,7 +2,6 @@ package io.dataease.controller.panel.server;
import io.dataease.base.domain.PanelLink;
import io.dataease.controller.ResultHolder;
import io.dataease.controller.panel.api.LinkApi;
import io.dataease.controller.request.chart.ChartExtRequest;
import io.dataease.controller.request.panel.link.*;
@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.net.URLDecoder;
import java.util.Map;
@ -24,7 +24,6 @@ import java.util.Map;
public class LinkServer implements LinkApi {
@Autowired
private PanelLinkService panelLinkService;
@ -42,12 +41,11 @@ public class LinkServer implements LinkApi {
panelLinkService.changeEnablePwd(request);
}
@Override
public void resetOverTime(@RequestBody OverTimeRequest request) {
panelLinkService.overTime(request);
}
@Override
@ -61,15 +59,16 @@ public class LinkServer implements LinkApi {
}
@Override
public ValidateDto validate(@RequestBody LinkValidateRequest request) throws Exception{
public ValidateDto validate(@RequestBody LinkValidateRequest request) throws Exception {
String link = request.getLink();
link = URLDecoder.decode(link, "UTF-8");
String json = panelLinkService.decryptParam(link);
ValidateDto dto = new ValidateDto();
String resourceId = json;
PanelLink one = panelLinkService.findOne(resourceId);
dto.setResourceId(resourceId);
if (ObjectUtils.isEmpty(one)){
if (ObjectUtils.isEmpty(one)) {
dto.setValid(false);
return dto;
}
@ -91,14 +90,13 @@ public class LinkServer implements LinkApi {
}
@Override
public Object viewDetail(String viewId, ChartExtRequest requestList) throws Exception{
public Object viewDetail(String viewId, ChartExtRequest requestList) throws Exception {
return chartViewService.getData(viewId, requestList);
}
@Override
public String shortUrl(Map<String,String> param) {
public String shortUrl(Map<String, String> param) {
String resourceId = param.get("resourceId");
return panelLinkService.getShortUrl(resourceId);
}

View File

@ -32,7 +32,7 @@ import java.util.List;
public class PanelLinkService {
private static final String BASEURL = "/link.html?link=";
private static final String SHORT_URL_PREFIX = "/xggznb/";
private static final String SHORT_URL_PREFIX = "/link/";
@Resource
private PanelLinkMapper mapper;

View File

@ -4,10 +4,30 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
<title>DataEase</title>
</head>
<body style="height: 100%;">
<div id="link"></div>
</body>
<script>
function getQueryVariable(variable) {
debugger
let query = window.location.search.substring(1)
let vars = []
if (!query) {
query = document.cookie
vars = query.split(';')
}else {
vars = query.split('&')
}
for (var i = 0; i < vars.length; i++) {
const pair = vars[i].split('=')
if (pair[0].trim() === variable) { return pair[1] }
}
return (false)
}
const link = getQueryVariable('link')
const url = "/#/delink?link="+encodeURIComponent(link)
window.location.href = url
</script>
</html>

View File

@ -4,10 +4,10 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
<title>DataEase</title>
</head>
<body style="height: 100%;">
<div id="nolic"></div>
<div>缺少许可</div>
</body>
</html>

View File

@ -1,15 +0,0 @@
<template>
<div id="link" style="height:100%;"><router-view />
</div>
</template>
<script>
export default {
data() {
return {
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,17 +0,0 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: () => import('../views/link/index.vue'),
meta: {
title: '首页'
}
}
]
})

View File

@ -1,26 +0,0 @@
import Vue from 'vue'
import Link from './Link.vue'
import router from './link-router'
import store from '../store'
import '@/styles/index.scss' // global css
import i18n from '../lang' // internationalization
import ElementUI from 'element-ui'
import '@/components/canvas/custom-component' // 注册自定义组件
import widgets from '@/components/widget'
import * as echarts from 'echarts'
import UmyUi from 'umy-ui'
import '@/utils/DateUtil'
Vue.use(UmyUi)
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.use(widgets)
Vue.use(ElementUI, {
i18n: (key, value) => i18n.t(key, value)
})
new Vue({
router,
store,
i18n,
render: h => h(Link)
}).$mount('#link')

View File

@ -1,16 +0,0 @@
<template>
<div id="nolic" style="height:100%;">
<router-view />
</div>
</template>
<script>
export default {
data() {
return {
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,17 +0,0 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: () => import('../views/nolic/index.vue'),
meta: {
title: '首页'
}
}
]
})

View File

@ -1,26 +0,0 @@
import Vue from 'vue'
import Nolic from './Nolic.vue'
import router from './nolic-router'
import store from '../store'
import '@/styles/index.scss' // global css
import i18n from '../lang' // internationalization
import ElementUI from 'element-ui'
import '@/components/canvas/custom-component' // 注册自定义组件
import widgets from '@/components/widget'
import * as echarts from 'echarts'
import UmyUi from 'umy-ui'
Vue.use(UmyUi)
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.use(widgets)
Vue.use(ElementUI, {
i18n: (key, value) => i18n.t(key, value)
})
new Vue({
router,
store,
i18n,
render: h => h(Nolic)
}).$mount('#nolic')

View File

@ -11,7 +11,7 @@ import { filterAsyncRouter } from '@/store/modules/permission'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
const whiteList = ['/login', '/401', '/404'] // no redirect whitelist
const whiteList = ['/login', '/401', '/404', '/delink', '/nolic'] // no redirect whitelist
router.beforeEach(async(to, from, next) => {
// start progress bar
@ -29,7 +29,7 @@ router.beforeEach(async(to, from, next) => {
NProgress.done()
} else {
const hasGetUserInfo = store.getters.name
if (hasGetUserInfo || to.path.indexOf('/preview/') > -1) {
if (hasGetUserInfo || to.path.indexOf('/preview/') > -1 || to.path.indexOf('/delink') > -1 || to.path.indexOf('/nolic') > -1) {
next()
store.dispatch('permission/setCurrentPath', to.path)
} else {

View File

@ -71,6 +71,12 @@ export const constantRoutes = [
}
]
},
{
path: '/delink',
component: () => import('@/views/link'),
hidden: true
},
{
path: '/preview/:reportId',
component: () => import('@/components/canvas/components/Editor/PreviewEject'),
@ -208,7 +214,7 @@ export const constantRoutes = [
]
const createRouter = () => new Router({
// mode: 'history', // require service support
// mode: 'history', // require service support
mode: 'hash',
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes

View File

@ -17,6 +17,7 @@ export default {
components: {
LinkError, LinkPwd, LinkView, LinkExpire
},
data() {
return {
resourceId: null,
@ -32,8 +33,16 @@ export default {
loadInit() {
debugger
this.link = getQueryVariable(this.PARAMKEY)
validate({ link: this.link }).then(res => {
// this.link = getQueryVariable(this.PARAMKEY)
this.link = this.$route.query.link
if (!this.link) {
this.link = getQueryVariable(this.PARAMKEY)
}
if (!this.link) {
this.showError()
return
}
validate({ link: encodeURIComponent(this.link) }).then(res => {
const { resourceId, valid, enablePwd, passPwd, expire } = res.data
this.resourceId = resourceId
//

View File

@ -1,9 +0,0 @@
<template>
<div>缺少许可</div>
</template>
<script>
export default {
}
</script>

View File

@ -36,16 +36,6 @@ module.exports = {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html'
},
link: {
entry: 'src/link/link.js',
template: 'public/link.html',
filename: 'link.html'
},
nolic: {
entry: 'src/nolic/nolic.js',
template: 'public/nolic.html',
filename: 'nolic.html'
}
},
configureWebpack: {