增加群聊置顶、免打扰和应用内提醒

This commit is contained in:
xhgit committed 2026-11-14 16:00:46 +08:00
1 parent ced6e9030d
commit f54077ce46
17 files changed
+228 -42

No files matched your search

+31 -1
View File
@@ -1,11 +1,29 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onBeforeUnmount, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useSession } from '../session'
const session = useSession()
const route = useRoute()
const error = ref('')
const busy = ref(false)
const browser = window.xhchat?.openBrowser
const notice = ref<string>()
let noticeTimer: ReturnType<typeof setTimeout> | undefined
function dismissNotice() {
clearTimeout(noticeTimer)
notice.value = undefined
}
watch(() => session.groupChange, (event) => {
if (!event?.notify || route.params.id === event.groupId) return
dismissNotice()
notice.value = event.groupId
noticeTimer = setTimeout(dismissNotice, 8000)
})
watch(() => route.params.id, (id) => { if (id === notice.value) dismissNotice() })
onBeforeUnmount(dismissNotice)
async function act(action: () => Promise<void>) {
busy.value = true
@@ -48,5 +66,17 @@ async function act(action: () => Promise<void>) {
</div>
</aside>
<RouterView />
<div v-if="notice" class="group-notice" role="status">
<RouterLink :to="'/groups/' + notice" @click="dismissNotice">有新的群消息</RouterLink>
<button type="button" class="plain" aria-label="关闭群消息提醒" @click="dismissNotice">关闭</button>
</div>
</main>
</template>
<style scoped>
.group-notice {
position: fixed; inset-inline-end: 1rem; inset-block-end: 1rem; z-index: 6;
display: flex; align-items: center; gap: .7rem; padding: .6rem .85rem;
background: var(--surface); border: 1px solid var(--line); border-radius: .5rem;
}
</style>