forked from FoundKeyGang/FoundKey
wip
This commit is contained in:
parent
ea2b5a5aac
commit
cbec4229d3
2 changed files with 108 additions and 114 deletions
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<a :href="url" target="_blank" :title="url" v-if="!fetching">
|
<a class="mk-url-preview" :href="url" target="_blank" :title="url" v-if="!fetching">
|
||||||
<div class="thumbnail" v-if="thumbnail" :style="`background-image: url(${thumbnail})`"></div>
|
<div class="thumbnail" v-if="thumbnail" :style="`background-image: url(${thumbnail})`"></div>
|
||||||
<article>
|
<article>
|
||||||
<header>
|
<header>
|
||||||
|
@ -14,8 +14,10 @@
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="typescript">
|
<script lang="ts">
|
||||||
export default {
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
props: ['url'],
|
props: ['url'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -40,16 +42,13 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="stylus" scoped>
|
<style lang="stylus" scoped>
|
||||||
:scope
|
.mk-url-preview
|
||||||
display block
|
display block
|
||||||
font-size 16px
|
font-size 16px
|
||||||
|
|
||||||
> a
|
|
||||||
display block
|
|
||||||
border solid 1px #eee
|
border solid 1px #eee
|
||||||
border-radius 4px
|
border-radius 4px
|
||||||
overflow hidden
|
overflow hidden
|
||||||
|
@ -109,8 +108,6 @@
|
||||||
|
|
||||||
@media (max-width 500px)
|
@media (max-width 500px)
|
||||||
font-size 8px
|
font-size 8px
|
||||||
|
|
||||||
> a
|
|
||||||
border none
|
border none
|
||||||
|
|
||||||
> .thumbnail
|
> .thumbnail
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<a class="reply" v-if="p.reply">%fa:reply%</a>
|
<a class="reply" v-if="p.reply">%fa:reply%</a>
|
||||||
<mk-post-html :ast="p.ast" :i="$root.$data.os.i"/>
|
<mk-post-html :ast="p.ast" :i="$root.$data.os.i"/>
|
||||||
<a class="quote" v-if="p.repost">RP:</a>
|
<a class="quote" v-if="p.repost">RP:</a>
|
||||||
|
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="media" v-if="p.media">
|
<div class="media" v-if="p.media">
|
||||||
<mk-images :images="p.media"/>
|
<mk-images :images="p.media"/>
|
||||||
|
@ -101,6 +102,15 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
url(): string {
|
url(): string {
|
||||||
return `/${this.p.user.username}/${this.p.id}`;
|
return `/${this.p.user.username}/${this.p.id}`;
|
||||||
|
},
|
||||||
|
urls(): string[] {
|
||||||
|
if (this.p.ast) {
|
||||||
|
return this.p.ast
|
||||||
|
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
|
||||||
|
.map(t => t.url);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -113,19 +123,6 @@ export default Vue.extend({
|
||||||
if (this.$root.$data.os.isSignedIn) {
|
if (this.$root.$data.os.isSignedIn) {
|
||||||
this.connection.on('_connected_', this.onStreamConnected);
|
this.connection.on('_connected_', this.onStreamConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.p.text) {
|
|
||||||
const tokens = this.p.ast;
|
|
||||||
|
|
||||||
// URLをプレビュー
|
|
||||||
tokens
|
|
||||||
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
|
|
||||||
.map(t => {
|
|
||||||
riot.mount(this.$refs.text.appendChild(document.createElement('mk-url-preview')), {
|
|
||||||
url: t.url
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.decapture(true);
|
this.decapture(true);
|
||||||
|
|
Loading…
Reference in a new issue