[O] Use tg-blog component
This commit is contained in:
+8
-57
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="Life" v-if="posts.length !== 0">
|
<div id="Life">
|
||||||
<div id="header">
|
<div id="header">
|
||||||
<p>欢迎!</p>
|
<p>欢迎!</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -9,69 +9,20 @@
|
|||||||
这里是我记录生活的地方,没有固定格式内容,更新也会比较频繁。
|
这里是我记录生活的地方,没有固定格式内容,更新也会比较频繁。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<PostView :p="p" v-for="p in posts" :key="p.id"/>
|
<TgBlog postsUrl="https://test-tg-data.hydev.org/liaotalk/posts.json"></TgBlog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {Options, Vue} from 'vue-class-component';
|
import {Options, Vue} from 'vue-class-component';
|
||||||
import {hosts} from "@/scripts/constants";
|
import { TgBlog } from "tg-blog";
|
||||||
import moment from "moment";
|
import 'tg-blog/dist/style.css'
|
||||||
import PostView from "@/components/Post.vue";
|
|
||||||
|
|
||||||
export interface Image {
|
@Options({components: {
|
||||||
href: string
|
TgBlog
|
||||||
url: string
|
}})
|
||||||
style: {
|
|
||||||
left: number
|
|
||||||
top: number
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
'margin-right': number
|
|
||||||
'margin-bottom': number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Post {
|
|
||||||
id: string
|
|
||||||
date: string
|
|
||||||
|
|
||||||
text?: string
|
|
||||||
|
|
||||||
type?: string // If type doesn't exist, it's a regular message
|
|
||||||
views?: string // Service messages have no view count
|
|
||||||
reply?: {
|
|
||||||
url: string
|
|
||||||
text: string
|
|
||||||
thumb?: string
|
|
||||||
}
|
|
||||||
video?: {
|
|
||||||
thumb: string
|
|
||||||
duration: string
|
|
||||||
src: string
|
|
||||||
}
|
|
||||||
images?: Image[]
|
|
||||||
img_group_style?: {
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Options({components: {PostView}})
|
|
||||||
export default class Blog extends Vue
|
export default class Blog extends Vue
|
||||||
{
|
{
|
||||||
posts: Post[] = []
|
|
||||||
|
|
||||||
created(): void
|
|
||||||
{
|
|
||||||
fetch(`${hosts.api}/posts.json`).then(it => it.json()).then(it => {
|
|
||||||
this.posts = it
|
|
||||||
this.posts.forEach(it => it.date = moment(it.date).format('YYYY-MM-DD h:mm'))
|
|
||||||
this.posts.reverse()
|
|
||||||
this.posts = this.posts.filter(it => it.type !== 'service')
|
|
||||||
console.log(it)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -80,7 +31,7 @@ export default class Blog extends Vue
|
|||||||
|
|
||||||
#Life
|
#Life
|
||||||
margin: 20px auto
|
margin: 20px auto
|
||||||
font-size: 0.8em
|
//font-size: 0.92em
|
||||||
width: min(450px, 80vw)
|
width: min(450px, 80vw)
|
||||||
|
|
||||||
#header
|
#header
|
||||||
|
|||||||
+2
-1
@@ -25,7 +25,8 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"allowJs": true
|
"allowJs": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
|
|||||||
+2
-1
@@ -32,6 +32,7 @@ export default defineConfig({
|
|||||||
alias: {
|
alias: {
|
||||||
...tsconfigPathAliases,
|
...tsconfigPathAliases,
|
||||||
vue: "vue/dist/vue.esm-bundler.js"
|
vue: "vue/dist/vue.esm-bundler.js"
|
||||||
}
|
},
|
||||||
|
dedupe: ['vue'],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user