0
0

お知らせをブロードキャストできるように

This commit is contained in:
syuilo 2017-11-16 14:19:14 +09:00
parent 20a6f0a0a7
commit 0cd69cabc9
5 changed files with 84 additions and 6 deletions

View File

@ -396,6 +396,12 @@ desktop:
mk-messaging-home-widget:
title: "Messaging"
mk-broadcast-home-widget:
fetching: "Fetching"
no-broadcasts: "No broadcasts"
have-a-nice-day: "Have a nice day!"
next: "Next"
mk-repost-form:
quote: "Quote..."
cancel: "Cancel"

View File

@ -396,6 +396,12 @@ desktop:
mk-messaging-home-widget:
title: "メッセージ"
mk-broadcast-home-widget:
fetching: "確認中"
no-broadcasts: "お知らせはありません"
have-a-nice-day: "良い一日を!"
next: "次"
mk-repost-form:
quote: "引用する..."
cancel: "キャンセル"

View File

@ -53,6 +53,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
model: os.cpus()[0].model,
cores: os.cpus().length
},
top_image: meta.top_image
top_image: meta.top_image,
broadcasts: meta.broadcasts
});
});

View File

@ -5,5 +5,9 @@
</style>
<script>
this.root.innerHTML = this.opts.content;
this.on('updated', () => {
this.root.innerHTML = this.opts.content;
});
</script>
</mk-raw>

View File

@ -1,4 +1,4 @@
<mk-broadcast-home-widget>
<mk-broadcast-home-widget data-found={ broadcasts.length != 0 } data-melt={ data.design == 1 }>
<div class="icon">
<svg height="32" version="1.1" viewBox="0 0 32 32" width="32">
<path class="tower" d="M16.04,11.24c1.79,0,3.239-1.45,3.239-3.24S17.83,4.76,16.04,4.76c-1.79,0-3.24,1.45-3.24,3.24 C12.78,9.78,14.24,11.24,16.04,11.24z M16.04,13.84c-0.82,0-1.66-0.2-2.4-0.6L7.34,29.98h2.98l1.72-2h8l1.681,2H24.7L18.42,13.24 C17.66,13.64,16.859,13.84,16.04,13.84z M16.02,14.8l2.02,7.2h-4L16.02,14.8z M12.04,25.98l2-2h4l2,2H12.04z"></path>
@ -8,22 +8,35 @@
<path class="wave d" d="M29.18,1.06c-0.479-0.502-1.273-0.522-1.775-0.044c-0.016,0.015-0.029,0.029-0.045,0.044c-0.5,0.52-0.5,1.36,0,1.88 c1.361,1.4,2.041,3.24,2.041,5.08s-0.68,3.66-2.041,5.08c-0.5,0.52-0.5,1.36,0,1.88c0.509,0.508,1.332,0.508,1.841,0 c1.86-1.92,2.8-4.44,2.8-6.96C31.99,5.424,30.98,2.931,29.18,1.06z"></path>
</svg>
</div>
<h1>開発者募集中!</h1>
<p><a href="https://github.com/syuilo/misskey" target="_blank">Misskeyはオープンソースで開発されています。リポジトリはこちら。</a></p>
<p class="fetching" if={ fetching }>%i18n:desktop.tags.mk-broadcast-home-widget.fetching%<mk-ellipsis/></p>
<h1 if={ !fetching }>{
broadcasts.length == 0 ? '%i18n:desktop.tags.mk-broadcast-home-widget.no-broadcasts%' : broadcasts[i].title
}</h1>
<p if={ !fetching }><mk-raw if={ broadcasts.length != 0 } content={ broadcasts[i].text }/><virtual if={ broadcasts.length == 0 }>%i18n:desktop.tags.mk-broadcast-home-widget.have-a-nice-day%</virtual></p>
<a if={ broadcasts.length > 1 } onclick={ next }>%i18n:desktop.tags.mk-broadcast-home-widget.next% &gt;&gt;</a>
<style>
:scope
display block
padding 10px 10px 10px 50px
padding 10px
border solid 1px #4078c0
border-radius 6px
&[data-melt]
border none
&[data-found]
padding-left 50px
> .icon
display block
&:after
content ""
display block
clear both
> .icon
display block
display none
float left
margin-left -40px
@ -72,11 +85,59 @@
font-size 0.7em
color #555
&.fetching
text-align center
a
color #555
text-decoration underline
> a
display block
font-size 0.7em
</style>
<script>
this.data = {
design: 0
};
this.mixin('widget');
this.mixin('os');
this.i = 0;
this.fetching = true;
this.broadcasts = [];
this.on('mount', () => {
this.mios.getMeta().then(meta => {
let broadcasts = [];
if (meta.broadcasts) {
meta.broadcasts.forEach(broadcast => {
if (broadcast[LANG]) {
broadcasts.push(broadcast[LANG]);
}
});
}
this.update({
fetching: false,
broadcasts: broadcasts
});
});
});
this.next = () => {
if (this.i == this.broadcasts.length - 1) {
this.i = 0;
} else {
this.i++;
}
this.update();
};
this.func = () => {
if (++this.data.design == 2) this.data.design = 0;
this.save();
};
</script>
</mk-broadcast-home-widget>