Browse Source

解決vue重新刷新浏览器报404

tags/v1.22.5.1^2
wangjr 3 years ago
parent
commit
78c7c2ce56
6 changed files with 59 additions and 24 deletions
  1. +25
    -0
      routers/home.go
  2. +7
    -0
      routers/routes/routes.go
  3. +5
    -2
      templates/explore/data_analysis.tmpl
  4. +20
    -2
      web_src/js/components/DataAnalysis.vue
  5. +2
    -3
      web_src/js/router/index.js
  6. +0
    -17
      web_src/js/router/main_.js

+ 25
- 0
routers/home.go View File

@@ -603,7 +603,32 @@ func ExploreImages(ctx *context.Context) {
ctx.HTML(200, tplExploreImages)
}

func ExploreDataAnalysisUserTrend(ctx *context.Context) {
ctx.Data["url_params"]="UserTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisUserAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="UserAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisProTrend(ctx *context.Context) {
ctx.Data["url_params"]="ProTrend"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisProAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="ProAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisOverview(ctx *context.Context) {
ctx.Data["url_params"]="Overview"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysisBrainAnalysis(ctx *context.Context) {
ctx.Data["url_params"]="BrainAnalysis"
ctx.HTML(200, tplExploreExploreDataAnalysis)
}
func ExploreDataAnalysis(ctx *context.Context) {
ctx.Data["url_params"]=""
ctx.HTML(200, tplExploreExploreDataAnalysis)
}



+ 7
- 0
routers/routes/routes.go View File

@@ -345,6 +345,13 @@ func RegisterRoutes(m *macaron.Macaron) {
m.Get("/code", routers.ExploreCode)
m.Get("/images", routers.ExploreImages)
m.Get("/data_analysis", routers.ExploreDataAnalysis)
m.Get("/data_analysis/UserTrend", routers.ExploreDataAnalysisUserTrend)
m.Get("/data_analysis/UserAnalysis", routers.ExploreDataAnalysisUserAnalysis)
m.Get("/data_analysis/ProAnalysis", routers.ExploreDataAnalysisProAnalysis)
m.Get("/data_analysis/ProTrend", routers.ExploreDataAnalysisProTrend)
m.Get("/data_analysis/Overview", routers.ExploreDataAnalysisOverview)
m.Get("/data_analysis/BrainAnalysis", routers.ExploreDataAnalysisBrainAnalysis)

}, ignSignIn)
m.Combo("/install", routers.InstallInit).Get(routers.Install).
Post(bindIgnErr(auth.InstallForm{}), routers.InstallPost)


+ 5
- 2
templates/explore/data_analysis.tmpl View File

@@ -1,11 +1,14 @@
{{template "base/head_fluid" .}}
<input id="url_params" type="hidden" value={{.url_params}}/>
<div id="data_analysis" style="height: 100%;">
</div>

{{template "base/footer_fluid" .}}

<!-- <script>
localStorage.setItem("dataAnalysisURL","{{.url_params}}")
</script> -->
<style>
.full.height {
display: flex;


+ 20
- 2
web_src/js/components/DataAnalysis.vue View File

@@ -5,7 +5,7 @@
default-active="this.$route.path"
class="el-menu-vertical-demo"
:router="true" style="height:100%; background-color: #F5F5F6;" >
<el-menu-item index="overview" >
<el-menu-item index="Overview" >
<i class="ri-home-4-line"></i>
<span slot="title">概览</span>
</el-menu-item>
@@ -36,7 +36,25 @@
</div>
</template>

<script>
export default{
data(){
return {
Path_router:'/'
}
},
created(){
//beforeCreate(),created(), beforeMount(), mounted() 都可以
var url_params = document.getElementById("url_params").value;
console.log('url_params:',url_params);
console.log('this.$router.path:',this.$router.path);
if (url_params!='' && url_params!=undefined){
this.$router.push(url_params)
console.log('this.$router.pathbefore:',this.$router.path);
}
},
}
</script>
<style scoped>
/deep/ .is-active{
color: #238BFC ;


+ 2
- 3
web_src/js/router/index.js View File

@@ -27,8 +27,8 @@ export default new Router({
},

{
path:'/overview',
name:'overview',
path:'/Overview',
name:'Overview',
component:Overview,
},
{
@@ -58,7 +58,6 @@ export default new Router({
component:BrainAnalysis,
},


],



+ 0
- 17
web_src/js/router/main_.js View File

@@ -1,17 +0,0 @@
import Vue from 'vue';
import DataAnalysis from './components/DataAnalysis.vue'
import router from './router/index.js'
function initVueDataAnalysis() {
const el = document.getElementById('data_analysis');
if (!el) {
return;
}
new Vue({
el: '#data_analysis',
router,
render: h => h(DataAnalysis)
});
}

initVueDataAnalysis()

Loading…
Cancel
Save