1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-24 07:06:26 +09:00

enhance: ダイアログのお知らせにも画像がある場合見せるように (MisskeyIO/misskey#157)

This commit is contained in:
まっちゃとーにゅ 2023-08-23 00:59:45 +09:00 committed by NoriDev
parent 050a90fe17
commit e649651b45
2 changed files with 46 additions and 18 deletions

View File

@ -13,16 +13,19 @@ SPDX-License-Identifier: AGPL-3.0-only
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i> <i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i> <i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
</span> </span>
<span :class="$style.title">{{ announcement.title }}</span> <Mfm :text="announcement.title"/>
</div> </div>
<div :class="$style.text"><Mfm :text="announcement.text"/></div> <div :class="$style.content">
<MkButton primary full @click="ok">{{ i18n.ts.ok }}</MkButton> <Mfm :text="announcement.text"/>
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
</div>
<MkButton :class="$style.gotIt" primary full :disabled="gotItDisabled" @click="gotIt">{{ i18n.ts.gotIt }}<span v-if="secVisible"> ({{ sec }})</span></MkButton>
</div> </div>
</MkModal> </MkModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, shallowRef } from 'vue'; import { onMounted, ref, shallowRef } from 'vue';
import * as misskey from 'cherrypick-js'; import * as misskey from 'cherrypick-js';
import * as os from '@/os'; import * as os from '@/os';
import MkModal from '@/components/MkModal.vue'; import MkModal from '@/components/MkModal.vue';
@ -37,8 +40,11 @@ const props = withDefaults(defineProps<{
const rootEl = shallowRef<HTMLDivElement>(); const rootEl = shallowRef<HTMLDivElement>();
const modal = shallowRef<InstanceType<typeof MkModal>>(); const modal = shallowRef<InstanceType<typeof MkModal>>();
const gotItDisabled = ref(true);
const secVisible = ref(true);
const sec = ref(props.announcement.closeDuration);
async function ok() { async function gotIt(): Promise<void> {
if (props.announcement.needConfirmationToRead) { if (props.announcement.needConfirmationToRead) {
const confirm = await os.confirm({ const confirm = await os.confirm({
type: 'question', type: 'question',
@ -48,15 +54,19 @@ async function ok() {
if (confirm.canceled) return; if (confirm.canceled) return;
} }
modal.value.close(); await os.api('i/read-announcement', { announcementId: props.announcement.id });
os.api('i/read-announcement', { announcementId: props.announcement.id }); if ($i) {
updateAccount({ updateAccount({
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id), unreadAnnouncements: $i.unreadAnnouncements.filter((a: { id: string; }) => a.id !== props.announcement.id),
}); });
}
modal.value?.close();
} }
function onBgClick() { function onBgClick(): void {
rootEl.value.animate([{ if (sec.value > 0) return;
rootEl.value?.animate([{
offset: 0, offset: 0,
transform: 'scale(1)', transform: 'scale(1)',
}, { }, {
@ -71,6 +81,21 @@ function onBgClick() {
} }
onMounted(() => { onMounted(() => {
if (sec.value > 0 ) {
const waitTimer = setInterval(() => {
if (sec.value === 0) {
clearInterval(waitTimer);
gotItDisabled.value = false;
secVisible.value = false;
} else {
gotItDisabled.value = true;
}
sec.value = sec.value - 1;
}, 1000);
} else {
gotItDisabled.value = false;
secVisible.value = false;
}
}); });
</script> </script>
@ -87,6 +112,7 @@ onMounted(() => {
} }
.header { .header {
font-weight: bold;
font-size: 120%; font-size: 120%;
} }
@ -94,11 +120,12 @@ onMounted(() => {
margin-right: 0.5em; margin-right: 0.5em;
} }
.title { .content {
font-weight: bold;
}
.text {
margin: 1em 0; margin: 1em 0;
> img {
display: block;
max-height: 300px;
max-width: 100%;
}
} }
</style> </style>

View File

@ -25,7 +25,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div :class="$style.content"> <div :class="$style.content">
<Mfm :text="announcement.text"/> <Mfm :text="announcement.text"/>
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/> <img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
<div style="opacity: 0.7; font-size: 85%;"> <div style="margin-top: 8px; opacity: 0.7; font-size: 85%;">
<MkTime :time="announcement.updatedAt ?? announcement.createdAt" mode="detail"/> <MkTime :time="announcement.updatedAt ?? announcement.createdAt" mode="detail"/>
</div> </div>
</div> </div>
@ -125,6 +125,7 @@ definePageMetadata({
.header { .header {
margin-bottom: 16px; margin-bottom: 16px;
font-weight: bold; font-weight: bold;
font-size: 120%;
} }
.content { .content {