博客 window.open() gongasd

This commit is contained in:
simple321vip
2022-04-11 01:01:11 +08:00
parent eb9ffdf27b
commit fc2aa9d22b
8 changed files with 67 additions and 3 deletions
+8 -1
View File
@@ -11,4 +11,11 @@ const get_blogs = (params: Object) => {
}) })
} }
export { get_blogs } const get_blog = (params: any) => {
return request({
url: '/blog/' + params.blog_id,
method: 'get'
})
}
export { get_blogs, get_blog }
+26
View File
@@ -14,5 +14,31 @@ let app = createApp(App)
app.use(router) app.use(router)
app.use(ElementPlus) app.use(ElementPlus)
app.use(store) app.use(store)
const whiteList = ['/', '/blog']
let url = window.location.href
console.log(url)
if (url != 'http://localhost:3000/' && url.search("blog=") != -1) {
let blog = {
blog_id: 1
}
router.push({
path: '/feedback',
query: blog
})
}
router.beforeEach((to, from, next) => {
console.log(to.path, from.path)
if (whiteList.includes(to.path)) {
next()
} else {
next()
}
})
app.mount('#app') app.mount('#app')
+4
View File
@@ -69,6 +69,10 @@ const routes: Array<RouteRecordRaw> = [
} }
}, },
] ]
},
{
path: "/feedback",
component: () => import('../view/blog/mdview.vue')
} }
] ]
+6 -1
View File
@@ -11,6 +11,8 @@ import MdEditor from 'md-editor-v3';
import 'md-editor-v3/lib/style.css'; import 'md-editor-v3/lib/style.css';
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import { get_blogs } from '../../api/blog' import { get_blogs } from '../../api/blog'
import router from '../../router/index'
type Blog = { type Blog = {
blog_id: number, blog_id: number,
@@ -36,7 +38,10 @@ text.value = "开始吧肿瘤"
const openBlog = () => { const openBlog = () => {
window.open("11111") const { href } = router.resolve({
path: '/blog=1'
});
window.open(href, '_blank');
} }
</script> </script>
+19
View File
@@ -0,0 +1,19 @@
<template>
<md-editor v-model="text" previewOnly />
</template>
<script setup lang="ts">
import MdEditor from 'md-editor-v3';
import { ref } from 'vue';
import { useRoute } from 'vue-router'
import { get_blog } from '../../api/blog'
let text = ref<string>('')
const route = useRoute()
get_blog(route.query).then(response => {
console.log(response.data)
})
</script>
<style>
</style>
+1
View File
@@ -92,6 +92,7 @@ const onLeave = () => {
align-items: center; align-items: center;
width: 90px; width: 90px;
height: 35px; height: 35px;
padding-left: 15px;
} }
.page_title { .page_title {
font-size: 14px; font-size: 14px;
+1
View File
@@ -81,6 +81,7 @@ const onLeave = () => {
align-items: center; align-items: center;
width: 90px; width: 90px;
height: 35px; height: 35px;
padding-left: 15px;
} }
.page_title { .page_title {
font-size: 14px; font-size: 14px;
+2 -1
View File
@@ -36,6 +36,7 @@
<el-button class="plus_button" @click="addPage">+</el-button> <el-button class="plus_button" @click="addPage">+</el-button>
</div> </div>
<div></div>
</div> </div>
</template> </template>
@@ -143,7 +144,7 @@ const addPage = () => {
.nav_tabs { .nav_tabs {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: 70px; width: 55px;
padding: 0px; padding: 0px;
} }