镜像自地址
https://github.com/wikimedia/mediawiki-extensions-SearchVue
已同步 2024-05-25 08:42:55 +08:00
0fa8e18b85
Change-Id: Iabb7aae258d6a5eb1be3a7fe0a9f90f4735ec880
60 行
1.1 KiB
Vue
60 行
1.1 KiB
Vue
<template>
|
|
<div class="quickViewSnippet">
|
|
<!-- eslint-disable vue/no-v-html -->
|
|
<p v-html="text"></p>
|
|
<a :href="url" @click.prevent="onClick">{{ gotoFullPageText }}</a>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
/**
|
|
* @file QuickViewSnippet.vue
|
|
*
|
|
* Placeholder
|
|
*/
|
|
|
|
// @vue/component
|
|
module.exports = exports = {
|
|
name: 'QuickViewSnippet',
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
text: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
computed: {
|
|
url() {
|
|
const title = new mw.Title( this.title );
|
|
return title.getUrl();
|
|
},
|
|
gotoFullPageText() {
|
|
const namespace = new mw.Title( this.title ).getNamespaceId();
|
|
return this.$i18n( 'searchvue-snippet-gotofullpage-ns' + namespace ).exists() ?
|
|
this.$i18n( 'searchvue-snippet-gotofullpage-ns' + namespace ).text() :
|
|
this.$i18n( 'searchvue-snippet-gotofullpage' ).text();
|
|
}
|
|
},
|
|
methods: {
|
|
onClick() {
|
|
this.$emit(
|
|
'log-event',
|
|
{
|
|
action: 'click-snippet',
|
|
goTo: this.url
|
|
} );
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.quickViewSnippet {
|
|
width: 365px;
|
|
margin: 0 auto 20px;
|
|
}
|
|
</style>
|