Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a12c27edf7 |
No files matched your search
@@ -12,7 +12,7 @@ on:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
pull-requests: read
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
pull-requests: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
|
||||
@@ -95,7 +95,6 @@ import NavRail from '@/components/ui/NavRail.vue'
|
||||
import OnboardingOverlay from '@/components/ui/onboarding/OnboardingOverlay.vue'
|
||||
import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
|
||||
import SkinSiteSessionFrame from '@/components/ui/SkinSiteSessionFrame.vue'
|
||||
import RemoteAnnouncements from '@/components/ui/RemoteAnnouncements.vue'
|
||||
import StartupAnnouncementModal from '@/components/ui/StartupAnnouncementModal.vue'
|
||||
import SplashScreen from '@/components/ui/SplashScreen.vue'
|
||||
import WindowControls from '@/components/ui/WindowControls.vue'
|
||||
@@ -2228,7 +2227,6 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
||||
<SkinSiteSessionFrame v-if="stateInitialized" />
|
||||
<InstancePlayerModal v-if="stateInitialized" />
|
||||
<StartupAnnouncementModal ref="startupAnnouncementModal" />
|
||||
<RemoteAnnouncements :ready="stateInitialized && !showOnboarding && !stateFailed" />
|
||||
<div id="teleports"></div>
|
||||
<div
|
||||
v-if="stateInitialized && themeStore.customBackgroundPath && !themeStore.transparentBackground"
|
||||
|
||||
@@ -32,33 +32,6 @@ export const ANNOUNCEMENT_CHANGE_TYPES: readonly AnnouncementChangeType[] = [
|
||||
]
|
||||
|
||||
export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
|
||||
{
|
||||
id: 'launcher-1.0.2-beta5',
|
||||
version: '1.0.2-beta5',
|
||||
publishedAt: '2026-10-11',
|
||||
title: {
|
||||
'en-US': 'Starlight Launcher 1.0.2-beta5',
|
||||
'zh-CN': 'Starlight Launcher 1.0.2-beta5',
|
||||
},
|
||||
changes: {
|
||||
added: [
|
||||
{
|
||||
'en-US': 'Added a remote announcements center: a bell in the top bar opens a panel listing launcher announcements fetched from the Starlight skin site.',
|
||||
'zh-CN': '新增远程公告中心:顶栏的铃铛可打开公告面板,展示从 Starlight 皮肤站拉取的启动器公告。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added a custom Minecraft window title option: set a global toggle and default title, and let each instance override it. The game window is renamed on Windows.',
|
||||
'zh-CN': '新增自定义 Minecraft 窗口标题:可设置全局开关与默认标题,并允许各实例单独覆盖;Windows 下会重命名游戏窗口。',
|
||||
},
|
||||
],
|
||||
fixed: [
|
||||
{
|
||||
'en-US': 'Completed the Chinese translations for the armor preview feature.',
|
||||
'zh-CN': '补齐盔甲预览功能的中文翻译。',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'launcher-1.0.2-beta4',
|
||||
version: '1.0.2-beta4',
|
||||
|
||||
@@ -67,23 +67,6 @@
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
<ButtonStyled
|
||||
v-tooltip="formatMessage(messages.announcements)"
|
||||
type="transparent"
|
||||
circular
|
||||
>
|
||||
<button
|
||||
:aria-label="formatMessage(messages.announcements)"
|
||||
class="relative"
|
||||
@click="openAnnouncementCenter"
|
||||
>
|
||||
<NewspaperIcon />
|
||||
<span
|
||||
v-if="announcementUnreadCount"
|
||||
class="absolute right-0 top-0 size-2 rounded-full bg-red ring-2 ring-bg-raised"
|
||||
/>
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
<ButtonStyled
|
||||
v-if="!isDownloadsPage && hasActiveDownloads && !hasVisibleActiveDownloadToasts"
|
||||
color="brand"
|
||||
@@ -207,7 +190,6 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
BellIcon,
|
||||
NewspaperIcon,
|
||||
DownloadIcon,
|
||||
DropdownIcon,
|
||||
OnlineIndicatorIcon,
|
||||
@@ -229,7 +211,7 @@ import {
|
||||
} from '@modrinth/ui'
|
||||
import { convertFileSrc } from '@tauri-apps/api/core'
|
||||
import { Dropdown } from 'floating-vue'
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import AppUpdateButton from '@/components/ui/app-update-button/index.vue'
|
||||
@@ -240,10 +222,6 @@ import { get_many as getInstances } from '@/helpers/instance'
|
||||
import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/process'
|
||||
import type { LoadingBar } from '@/helpers/state'
|
||||
import { progress_bars_list } from '@/helpers/state'
|
||||
import {
|
||||
OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT,
|
||||
REMOTE_ANNOUNCEMENTS_UPDATED_EVENT,
|
||||
} from '@/helpers/remote-announcements'
|
||||
import type { GameInstance } from '@/helpers/types'
|
||||
import { downloadBarTypes, injectDownloadManager } from '@/providers/download-manager'
|
||||
|
||||
@@ -253,25 +231,6 @@ const popupNotificationManager = injectPopupNotificationManager()
|
||||
const downloadManager = injectDownloadManager()
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const announcementUnreadCount = ref(0)
|
||||
|
||||
function openAnnouncementCenter() {
|
||||
window.dispatchEvent(new CustomEvent(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT))
|
||||
}
|
||||
|
||||
function updateAnnouncementCount(event: Event) {
|
||||
const detail = (event as CustomEvent<{ unreadKeys?: string[] }>).detail
|
||||
announcementUnreadCount.value = detail?.unreadKeys?.length ?? 0
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, updateAnnouncementCount)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, updateAnnouncementCount)
|
||||
})
|
||||
|
||||
type NotificationHistoryItem = {
|
||||
key: string
|
||||
createdAt?: number
|
||||
@@ -411,10 +370,6 @@ const messages = defineMessages({
|
||||
id: 'app.action-bar.notifications',
|
||||
defaultMessage: 'Notifications',
|
||||
},
|
||||
announcements: {
|
||||
id: 'app.action-bar.announcements',
|
||||
defaultMessage: 'Announcements',
|
||||
},
|
||||
clearNotifications: {
|
||||
id: 'app.action-bar.notifications.clear',
|
||||
defaultMessage: 'Clear all',
|
||||
|
||||
@@ -1,420 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Button,
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
NewModal,
|
||||
useModalStack,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { renderString } from '@modrinth/utils'
|
||||
import { fetch as tauriFetch } from '@tauri-apps/plugin-http'
|
||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
announcementKey,
|
||||
isAnnouncementActive,
|
||||
mapBroadcastAnnouncements,
|
||||
OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT,
|
||||
parseAnnouncements,
|
||||
REMOTE_ANNOUNCEMENTS_UPDATED_EVENT,
|
||||
type RemoteAnnouncement,
|
||||
safeAnnouncementUrl,
|
||||
} from '@/helpers/remote-announcements'
|
||||
|
||||
import {
|
||||
requestSkinSiteDownloadToken,
|
||||
skinSiteStatus,
|
||||
waitForSkinSiteSession,
|
||||
} from '@/composables/skin-site-session.ts'
|
||||
|
||||
const props = defineProps<{ ready: boolean; previewOnly?: boolean }>()
|
||||
const { formatMessage } = useVIntl()
|
||||
const { hasModal } = useModalStack()
|
||||
const messages = defineMessages({
|
||||
view: { id: 'app.remote-announcements.view', defaultMessage: 'View announcement' },
|
||||
unread: { id: 'app.remote-announcements.unread', defaultMessage: 'Unread' },
|
||||
readAll: {
|
||||
id: 'app.remote-announcements.read-all',
|
||||
defaultMessage: 'Mark all announcements as read',
|
||||
},
|
||||
centerTitle: { id: 'app.remote-announcements.center-title', defaultMessage: 'Announcements' },
|
||||
empty: { id: 'app.remote-announcements.empty', defaultMessage: 'No announcements' },
|
||||
previewTitle: {
|
||||
id: 'app.remote-announcements.preview-title',
|
||||
defaultMessage: 'Announcement style preview',
|
||||
},
|
||||
previewSummary: {
|
||||
id: 'app.remote-announcements.preview-summary',
|
||||
defaultMessage:
|
||||
'This is a local preview. Select View announcement to preview the full Markdown content.',
|
||||
},
|
||||
previewContent: {
|
||||
id: 'app.remote-announcements.preview-content',
|
||||
defaultMessage:
|
||||
'## Announcement preview\n\nThis is **sample content**, not a published announcement.\n\n- Supports headings, lists, and links\n- Close buttons are always available\n\n> Previewing does not change real announcement read status.\n\n| Type | Display |\n| --- | --- |\n| Modal | Full Markdown content |\n| Popup | Summary, then full content |\n\n[Visit the website](https://skin.starlight.cool/)',
|
||||
},
|
||||
previewAction: { id: 'app.remote-announcements.preview-action', defaultMessage: 'Visit website' },
|
||||
})
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const selected = ref<RemoteAnnouncement | null>(null)
|
||||
const active = ref(false)
|
||||
const centerOpen = ref(false)
|
||||
const startupNotice = ref<RemoteAnnouncement | null>(null)
|
||||
const html = computed(() => renderString(selected.value?.content ?? ''))
|
||||
const stateKey = 'starlight-remote-announcements-v2'
|
||||
const read = reactive(new Set<string>())
|
||||
const queuedThisSession = new Set<string>()
|
||||
const startupNotified = new Set<string>()
|
||||
let items: RemoteAnnouncement[] = []
|
||||
let pending: RemoteAnnouncement[] = []
|
||||
let cacheKey = 'starlight-remote-announcements-cache-v1'
|
||||
let cacheLoaded = false
|
||||
let disposed = false
|
||||
let interval: ReturnType<typeof setInterval> | undefined
|
||||
let advanceTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
function persist() {
|
||||
if (props.previewOnly) return
|
||||
try {
|
||||
localStorage.setItem(
|
||||
stateKey,
|
||||
JSON.stringify({
|
||||
read: [...read].slice(-1000),
|
||||
}),
|
||||
)
|
||||
} catch {
|
||||
// localStorage may be unavailable (private mode / quota)
|
||||
}
|
||||
}
|
||||
function emitState() {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(REMOTE_ANNOUNCEMENTS_UPDATED_EVENT, {
|
||||
detail: {
|
||||
items,
|
||||
unreadKeys: items.filter((item) => !read.has(announcementKey(item))).map(announcementKey),
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
function openCenter(item?: RemoteAnnouncement) {
|
||||
if (!props.ready || disposed) return
|
||||
centerOpen.value = true
|
||||
if (item) {
|
||||
startupNotice.value = null
|
||||
selectAnnouncement(item)
|
||||
} else if (!selected.value && items.length) {
|
||||
selectAnnouncement(items[0])
|
||||
}
|
||||
void nextTick(() => modal.value?.show())
|
||||
}
|
||||
function handleOpenCenter() {
|
||||
if (props.previewOnly) return
|
||||
openCenter()
|
||||
}
|
||||
async function show(item: RemoteAnnouncement) {
|
||||
if (
|
||||
disposed ||
|
||||
!props.ready ||
|
||||
!isAnnouncementActive(item) ||
|
||||
(hasModal.value && !active.value && !centerOpen.value)
|
||||
)
|
||||
return
|
||||
centerOpen.value = true
|
||||
active.value = true
|
||||
selectAnnouncement(item)
|
||||
await nextTick()
|
||||
if (!disposed) modal.value?.show()
|
||||
}
|
||||
function selectAnnouncement(item: RemoteAnnouncement) {
|
||||
selected.value = item
|
||||
const key = announcementKey(item)
|
||||
read.add(key)
|
||||
pending = pending.filter((entry) => announcementKey(entry) !== key)
|
||||
persist()
|
||||
emitState()
|
||||
}
|
||||
function markAllRead() {
|
||||
for (const item of items) {
|
||||
read.add(announcementKey(item))
|
||||
}
|
||||
pending = []
|
||||
persist()
|
||||
emitState()
|
||||
}
|
||||
function advance() {
|
||||
if (disposed || !props.ready || hasModal.value || active.value) return
|
||||
const next = pending.shift()
|
||||
if (next) {
|
||||
void show(next)
|
||||
return
|
||||
}
|
||||
for (const item of items) {
|
||||
const key = announcementKey(item)
|
||||
if (
|
||||
item.type === 'notification' &&
|
||||
!startupNotified.has(key) &&
|
||||
!read.has(key) &&
|
||||
isAnnouncementActive(item)
|
||||
) {
|
||||
startupNotice.value = item
|
||||
startupNotified.add(key)
|
||||
setTimeout(() => {
|
||||
if (startupNotice.value === item) {
|
||||
startupNotice.value = null
|
||||
advance()
|
||||
}
|
||||
}, 8000)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
function closed() {
|
||||
active.value = false
|
||||
centerOpen.value = false
|
||||
if (advanceTimer) clearTimeout(advanceTimer)
|
||||
advanceTimer = setTimeout(advance, 350)
|
||||
}
|
||||
function sync(next: RemoteAnnouncement[], fresh: boolean) {
|
||||
items = next.filter((item) => isAnnouncementActive(item))
|
||||
const keys = new Set(items.map(announcementKey))
|
||||
pending = pending.filter((item) => keys.has(announcementKey(item)))
|
||||
if (selected.value && !keys.has(announcementKey(selected.value))) selected.value = null
|
||||
emitState()
|
||||
if (fresh) {
|
||||
for (const item of items) {
|
||||
const key = announcementKey(item)
|
||||
if (
|
||||
item.type === 'modal' &&
|
||||
!queuedThisSession.has(key) &&
|
||||
(!read.has(key) || item.priority === 'critical')
|
||||
) {
|
||||
queuedThisSession.add(key)
|
||||
pending.push(item)
|
||||
}
|
||||
}
|
||||
advance()
|
||||
}
|
||||
}
|
||||
function loadCache() {
|
||||
if (cacheLoaded || !cacheKey) return
|
||||
cacheLoaded = true
|
||||
try {
|
||||
const cached = JSON.parse(localStorage.getItem(cacheKey) ?? 'null')
|
||||
if (cached && typeof cached.savedAt === 'number' && Date.now() - cached.savedAt < 86400000) {
|
||||
const parsed = parseAnnouncements(cached.items)
|
||||
if (parsed) sync(parsed, false)
|
||||
}
|
||||
} catch {
|
||||
// Ignore malformed or expired cache payloads
|
||||
}
|
||||
}
|
||||
function saveCache(next: RemoteAnnouncement[]) {
|
||||
if (!cacheKey) return
|
||||
try {
|
||||
localStorage.setItem(cacheKey, JSON.stringify({ savedAt: Date.now(), items: next }))
|
||||
} catch {
|
||||
// localStorage may be unavailable (private mode / quota)
|
||||
}
|
||||
}
|
||||
async function refresh() {
|
||||
if (disposed) return
|
||||
loadCache()
|
||||
if (skinSiteStatus.value !== 'signed-in') return
|
||||
try {
|
||||
await waitForSkinSiteSession()
|
||||
const token = await requestSkinSiteDownloadToken()
|
||||
const response = await tauriFetch('https://skin.starlight.cool/starlight/skin/broadcast/all', {
|
||||
method: 'GET',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (!response.ok) return
|
||||
const data = await response.json()
|
||||
const parsed = mapBroadcastAnnouncements((data as { payload?: unknown } | null)?.payload)
|
||||
if (parsed && !disposed) {
|
||||
sync(parsed, true)
|
||||
saveCache(parsed)
|
||||
}
|
||||
} catch {
|
||||
// Remote fetch failed; previously cached items remain displayed
|
||||
}
|
||||
}
|
||||
async function openLink(value: unknown) {
|
||||
const url = safeAnnouncementUrl(value)
|
||||
if (!url) return
|
||||
try {
|
||||
await openUrl(url)
|
||||
} catch {
|
||||
// Opener may reject unknown schemes
|
||||
}
|
||||
}
|
||||
function contentClick(event: MouseEvent) {
|
||||
const link = event.target instanceof Element ? event.target.closest('a') : null
|
||||
if (!link) return
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
void openLink(link.getAttribute('href'))
|
||||
}
|
||||
function preview(type: RemoteAnnouncement['type'], withAction = false) {
|
||||
if (!props.previewOnly || !props.ready || hasModal.value || disposed) return
|
||||
const now = new Date().toISOString()
|
||||
const item: RemoteAnnouncement = {
|
||||
id: 'local-preview-' + type,
|
||||
title: formatMessage(messages.previewTitle),
|
||||
summary: formatMessage(messages.previewSummary),
|
||||
content: formatMessage(messages.previewContent),
|
||||
type,
|
||||
priority: 'normal',
|
||||
starts_at: now,
|
||||
ends_at: null,
|
||||
published_at: now,
|
||||
action_label: withAction ? formatMessage(messages.previewAction) : null,
|
||||
action_url: withAction ? 'https://skin.starlight.cool/' : null,
|
||||
}
|
||||
read.clear()
|
||||
queuedThisSession.clear()
|
||||
sync([item], true)
|
||||
}
|
||||
defineExpose({ preview })
|
||||
onMounted(() => {
|
||||
if (props.previewOnly) return
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem(stateKey) ?? 'null')
|
||||
if (saved && Array.isArray(saved.read))
|
||||
for (const key of saved.read) if (typeof key === 'string') read.add(key)
|
||||
} catch {
|
||||
// Ignore malformed local read-state
|
||||
}
|
||||
window.addEventListener(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT, handleOpenCenter)
|
||||
const start = () => {
|
||||
if (disposed) return
|
||||
void refresh()
|
||||
interval = setInterval(() => {
|
||||
sync(items, false)
|
||||
advance()
|
||||
}, 15000)
|
||||
}
|
||||
// Defer the startup request until after first paint.
|
||||
if (typeof requestIdleCallback === 'function') {
|
||||
requestIdleCallback(start, { timeout: 2000 })
|
||||
} else {
|
||||
setTimeout(start, 500)
|
||||
}
|
||||
})
|
||||
watch([() => props.ready, hasModal], () => {
|
||||
if (advanceTimer) clearTimeout(advanceTimer)
|
||||
advanceTimer = setTimeout(advance, 350)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
disposed = true
|
||||
if (interval) clearInterval(interval)
|
||||
if (advanceTimer) clearTimeout(advanceTimer)
|
||||
window.removeEventListener(OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT, handleOpenCenter)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="startupNotice"
|
||||
class="fixed right-4 top-16 z-50 w-[22rem] max-w-[calc(100vw-2rem)] rounded-xl border border-surface-5 bg-surface-3 p-3 shadow-lg"
|
||||
>
|
||||
<button class="w-full text-left" @click="startupNotice && openCenter(startupNotice)">
|
||||
<div class="mb-1 text-xs font-semibold uppercase text-brand">
|
||||
{{ formatMessage(messages.unread) }}
|
||||
</div>
|
||||
<div class="font-semibold text-[var(--color-text-primary)]">{{ startupNotice.title }}</div>
|
||||
<div
|
||||
v-if="startupNotice.summary"
|
||||
class="mt-1 line-clamp-2 text-sm text-[var(--color-text-tertiary)]"
|
||||
>
|
||||
{{ startupNotice.summary }}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<NewModal
|
||||
ref="modal"
|
||||
:header="formatMessage(messages.centerTitle)"
|
||||
:on-hide="closed"
|
||||
max-width="80vw"
|
||||
width="80vw"
|
||||
max-content-height="calc(80vh - 8rem)"
|
||||
scrollable
|
||||
>
|
||||
<div class="flex h-[calc(80vh-8rem)] min-h-0 gap-3">
|
||||
<aside class="flex min-h-0 w-[32%] min-w-[14rem] flex-col border-r border-surface-5 pr-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<span class="font-semibold text-[var(--color-text-primary)]">{{
|
||||
formatMessage(messages.centerTitle)
|
||||
}}</span>
|
||||
<Button
|
||||
v-if="items.some((item) => !read.has(announcementKey(item)))"
|
||||
@click="markAllRead"
|
||||
>{{ formatMessage(messages.readAll) }}</Button
|
||||
>
|
||||
</div>
|
||||
<div
|
||||
v-if="!items.length"
|
||||
class="py-8 text-center text-sm text-[var(--color-text-tertiary)]"
|
||||
>
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</div>
|
||||
<div v-else class="flex min-h-0 flex-col gap-1 overflow-auto">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="announcementKey(item)"
|
||||
class="flex items-start gap-2 rounded-lg p-2 text-left hover:bg-surface-4"
|
||||
:class="{
|
||||
'bg-surface-4': selected && announcementKey(selected) === announcementKey(item),
|
||||
}"
|
||||
@click="selectAnnouncement(item)"
|
||||
>
|
||||
<span
|
||||
class="mt-1.5 size-2 shrink-0 rounded-full"
|
||||
:class="read.has(announcementKey(item)) ? 'opacity-0' : 'bg-red'"
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate font-medium text-[var(--color-text-primary)]">{{
|
||||
item.title
|
||||
}}</span>
|
||||
<span class="block line-clamp-2 text-xs text-[var(--color-text-tertiary)]">{{
|
||||
item.summary || item.content
|
||||
}}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
<section v-if="selected" class="min-h-0 min-w-0 flex-1 overflow-auto px-1">
|
||||
<h2 class="mb-4 text-xl font-semibold text-[var(--color-text-primary)]">
|
||||
{{ selected.title }}
|
||||
</h2>
|
||||
<div
|
||||
class="markdown-body break-words"
|
||||
@click="contentClick"
|
||||
@auxclick="contentClick"
|
||||
v-html="html"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end">
|
||||
<Button
|
||||
v-if="selected.action_url && selected.action_label"
|
||||
type="colored"
|
||||
color="brand"
|
||||
@click="openLink(selected.action_url)"
|
||||
>{{ selected.action_label }}</Button
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
<div
|
||||
v-else
|
||||
class="flex flex-1 items-center justify-center text-sm text-[var(--color-text-tertiary)]"
|
||||
>
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</div>
|
||||
</div>
|
||||
<template #actions>
|
||||
<div class="flex flex-wrap justify-end gap-2">
|
||||
<Button @click="modal?.hide()">{{ formatMessage(commonMessages.closeButton) }} </Button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
</template>
|
||||
@@ -36,29 +36,24 @@ const fullscreenSetting: Ref<boolean> = ref(
|
||||
instance.value.force_fullscreen ?? globalSettings.force_fullscreen,
|
||||
)
|
||||
const maximizeWindowSetting = ref(instance.value.maximize_window ?? globalSettings.maximize_window)
|
||||
const windowTitle = ref(instance.value.window_title ?? '')
|
||||
|
||||
const editInstanceObject = computed(() => {
|
||||
const title = windowTitle.value.trim() ? windowTitle.value.trim() : null
|
||||
if (!overrideWindowSettings.value) {
|
||||
return {
|
||||
force_fullscreen: null,
|
||||
maximize_window: null,
|
||||
game_resolution: null,
|
||||
// The title is independent of the window-size override checkbox.
|
||||
window_title: title,
|
||||
}
|
||||
}
|
||||
return {
|
||||
force_fullscreen: fullscreenSetting.value,
|
||||
maximize_window: maximizeWindowSetting.value,
|
||||
game_resolution: fullscreenSetting.value ? null : resolution.value,
|
||||
window_title: title,
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
[overrideWindowSettings, resolution, fullscreenSetting, maximizeWindowSetting, windowTitle],
|
||||
[overrideWindowSettings, resolution, fullscreenSetting, maximizeWindowSetting],
|
||||
async () => {
|
||||
await edit(instance.value.id, editInstanceObject.value)
|
||||
},
|
||||
@@ -114,18 +109,6 @@ const messages = defineMessages({
|
||||
id: 'instance.settings.tabs.window.height.enter',
|
||||
defaultMessage: 'Enter height...',
|
||||
},
|
||||
windowTitle: {
|
||||
id: 'instance.settings.tabs.window.window-title',
|
||||
defaultMessage: 'Window title',
|
||||
},
|
||||
windowTitleDescription: {
|
||||
id: 'instance.settings.tabs.window.window-title.description',
|
||||
defaultMessage: 'Customize the Minecraft window title. Leave empty to keep the default.',
|
||||
},
|
||||
enterWindowTitle: {
|
||||
id: 'instance.settings.tabs.window.window-title.enter',
|
||||
defaultMessage: 'Enter window title...',
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -217,25 +200,5 @@ const messages = defineMessages({
|
||||
:placeholder="formatMessage(messages.enterHeight)"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="globalSettings.custom_window_title_enabled"
|
||||
class="flex items-center gap-4 justify-between"
|
||||
>
|
||||
<div class="flex flex-col gap-1">
|
||||
<h2 class="m-0 inline-flex items-center gap-2 text-lg font-semibold text-contrast">
|
||||
{{ formatMessage(messages.windowTitle) }}
|
||||
</h2>
|
||||
<p class="m-0">
|
||||
{{ formatMessage(messages.windowTitleDescription) }}
|
||||
</p>
|
||||
</div>
|
||||
<StyledInput
|
||||
id="window-title"
|
||||
v-model="windowTitle"
|
||||
autocomplete="off"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.enterWindowTitle)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -38,26 +38,6 @@ const messages = defineMessages({
|
||||
id: 'app.settings.defaults.maximize-window.unsupported',
|
||||
defaultMessage: 'Not supported on this operating system.',
|
||||
},
|
||||
windowTitleEnabled: {
|
||||
id: 'app.settings.defaults.window-title.enabled',
|
||||
defaultMessage: 'Custom Minecraft window title',
|
||||
},
|
||||
windowTitleEnabledDescription: {
|
||||
id: 'app.settings.defaults.window-title.enabled-description',
|
||||
defaultMessage: 'Allow instances to customize the Minecraft window title.',
|
||||
},
|
||||
defaultWindowTitle: {
|
||||
id: 'app.settings.defaults.window-title.default',
|
||||
defaultMessage: 'Default window title',
|
||||
},
|
||||
defaultWindowTitleDescription: {
|
||||
id: 'app.settings.defaults.window-title.default-description',
|
||||
defaultMessage: 'Used when an instance leaves its window title empty.',
|
||||
},
|
||||
defaultWindowTitlePlaceholder: {
|
||||
id: 'app.settings.defaults.window-title.default-placeholder',
|
||||
defaultMessage: 'Enter default window title...',
|
||||
},
|
||||
width: { id: 'app.settings.defaults.width', defaultMessage: 'Width' },
|
||||
widthDescription: {
|
||||
id: 'app.settings.defaults.width-description',
|
||||
@@ -232,36 +212,6 @@ watch(
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>
|
||||
<span id="settings-target-defaults-window-title" tabindex="-1">
|
||||
{{ formatMessage(messages.windowTitleEnabled) }}
|
||||
</span>
|
||||
</template>
|
||||
<template #description>{{
|
||||
formatMessage(messages.windowTitleEnabledDescription)
|
||||
}}</template>
|
||||
<template #control>
|
||||
<Toggle id="custom-window-title-enabled" v-model="settings.custom_window_title_enabled" />
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow stacked>
|
||||
<template #label>{{ formatMessage(messages.defaultWindowTitle) }}</template>
|
||||
<template #description>{{
|
||||
formatMessage(messages.defaultWindowTitleDescription)
|
||||
}}</template>
|
||||
<template #control>
|
||||
<StyledInput
|
||||
id="default-window-title"
|
||||
v-model="settings.default_window_title"
|
||||
:disabled="!settings.custom_window_title_enabled"
|
||||
autocomplete="off"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.defaultWindowTitlePlaceholder)"
|
||||
wrapper-class="w-full"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection>
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { mapBroadcastAnnouncements } from './remote-announcements.ts'
|
||||
|
||||
test('maps a broadcast entry into a remote announcement', () => {
|
||||
const result = mapBroadcastAnnouncements([
|
||||
{
|
||||
id: 1,
|
||||
title: '维护通知',
|
||||
subtitle: '今晚停机',
|
||||
content: '服务器将于今晚维护。',
|
||||
updateAt: 1791640873710,
|
||||
star: true,
|
||||
importantLevel: 9,
|
||||
source: 'SKIN',
|
||||
},
|
||||
])
|
||||
assert.equal(result?.length, 1)
|
||||
const item = result?.[0]
|
||||
assert.equal(item?.id, '1')
|
||||
assert.equal(item?.title, '维护通知')
|
||||
assert.equal(item?.summary, '今晚停机')
|
||||
assert.equal(item?.priority, 'critical')
|
||||
assert.equal(item?.pinned, true)
|
||||
assert.equal(item?.type, 'modal')
|
||||
assert.equal(item?.published_at, new Date(1791640873710).toISOString())
|
||||
assert.equal(item?.ends_at, null)
|
||||
})
|
||||
|
||||
test('empty or blank subtitle becomes null summary', () => {
|
||||
const result = mapBroadcastAnnouncements([
|
||||
{ id: 2, title: '公告', subtitle: ' ', content: '内容', updateAt: 1000 },
|
||||
])
|
||||
assert.equal(result?.[0]?.summary, null)
|
||||
})
|
||||
|
||||
test('skips entries missing required fields', () => {
|
||||
const result = mapBroadcastAnnouncements([
|
||||
{ id: 3, title: '有效', content: '内容', updateAt: 1000 },
|
||||
{ id: 4, title: '', content: '内容', updateAt: 1000 },
|
||||
{ title: '无 id', content: '内容', updateAt: 1000 },
|
||||
{ id: 5, title: '无时间', content: '内容' },
|
||||
null,
|
||||
'不是对象',
|
||||
])
|
||||
assert.equal(result?.length, 1)
|
||||
assert.equal(result?.[0]?.id, '3')
|
||||
})
|
||||
|
||||
test('clamps importantLevel and maps priority boundaries', () => {
|
||||
const result = mapBroadcastAnnouncements([
|
||||
{ id: 6, title: 'a', content: 'x', updateAt: 1000, importantLevel: 0 },
|
||||
{ id: 7, title: 'b', content: 'x', updateAt: 1000, importantLevel: 3 },
|
||||
{ id: 8, title: 'c', content: 'x', updateAt: 1000, importantLevel: 6 },
|
||||
{ id: 9, title: 'd', content: 'x', updateAt: 1000, importantLevel: 999 },
|
||||
])
|
||||
const byId = new Map(result?.map((item) => [item.id, item.priority]))
|
||||
assert.equal(byId.get('6'), 'low')
|
||||
assert.equal(byId.get('7'), 'normal')
|
||||
assert.equal(byId.get('8'), 'high')
|
||||
assert.equal(byId.get('9'), 'critical')
|
||||
})
|
||||
|
||||
test('returns null for non-array payloads', () => {
|
||||
assert.equal(mapBroadcastAnnouncements(null), null)
|
||||
assert.equal(mapBroadcastAnnouncements({ payload: [] }), null)
|
||||
assert.equal(mapBroadcastAnnouncements('nope'), null)
|
||||
})
|
||||
|
||||
test('pinned announcements sort first', () => {
|
||||
const result = mapBroadcastAnnouncements([
|
||||
{ id: 10, title: '普通', content: 'x', updateAt: 2000, importantLevel: 9 },
|
||||
{ id: 11, title: '置顶', content: 'x', updateAt: 1000, star: true },
|
||||
])
|
||||
assert.equal(result?.[0]?.id, '11')
|
||||
assert.equal(result?.[1]?.id, '10')
|
||||
})
|
||||
@@ -5,7 +5,6 @@ export type RemoteAnnouncement = {
|
||||
content: string
|
||||
type: 'modal' | 'notification'
|
||||
priority: 'low' | 'normal' | 'high' | 'critical'
|
||||
pinned?: boolean
|
||||
starts_at: string
|
||||
ends_at: string | null
|
||||
published_at: string
|
||||
@@ -33,28 +32,18 @@ export function parseAnnouncements(value: unknown): RemoteAnnouncement[] | null
|
||||
if (!entry || typeof entry !== 'object') continue
|
||||
const item = entry as Record<string, unknown>
|
||||
if (
|
||||
typeof item.id !== 'string' ||
|
||||
item.id.length > 100 ||
|
||||
ids.has(item.id) ||
|
||||
typeof item.title !== 'string' ||
|
||||
!item.title.trim() ||
|
||||
item.title.length > 120 ||
|
||||
typeof item.content !== 'string' ||
|
||||
item.content.length > 20000 ||
|
||||
typeof item.id !== 'string' || item.id.length > 100 || ids.has(item.id) ||
|
||||
typeof item.title !== 'string' || !item.title.trim() || item.title.length > 120 ||
|
||||
typeof item.content !== 'string' || item.content.length > 20000 ||
|
||||
(item.summary != null && (typeof item.summary !== 'string' || item.summary.length > 300)) ||
|
||||
!['modal', 'notification'].includes(String(item.type)) ||
|
||||
!['low', 'normal', 'high', 'critical'].includes(String(item.priority)) ||
|
||||
typeof item.starts_at !== 'string' ||
|
||||
!Number.isFinite(Date.parse(item.starts_at)) ||
|
||||
typeof item.published_at !== 'string' ||
|
||||
!Number.isFinite(Date.parse(item.published_at)) ||
|
||||
(item.ends_at != null &&
|
||||
(typeof item.ends_at !== 'string' || !Number.isFinite(Date.parse(item.ends_at)))) ||
|
||||
(item.action_label != null &&
|
||||
(typeof item.action_label !== 'string' || item.action_label.length > 80)) ||
|
||||
typeof item.starts_at !== 'string' || !Number.isFinite(Date.parse(item.starts_at)) ||
|
||||
typeof item.published_at !== 'string' || !Number.isFinite(Date.parse(item.published_at)) ||
|
||||
(item.ends_at != null && (typeof item.ends_at !== 'string' || !Number.isFinite(Date.parse(item.ends_at)))) ||
|
||||
(item.action_label != null && (typeof item.action_label !== 'string' || item.action_label.length > 80)) ||
|
||||
(item.action_url != null && !safeAnnouncementUrl(item.action_url))
|
||||
)
|
||||
continue
|
||||
) continue
|
||||
ids.add(item.id)
|
||||
items.push({
|
||||
...item,
|
||||
@@ -65,12 +54,7 @@ export function parseAnnouncements(value: unknown): RemoteAnnouncement[] | null
|
||||
} as RemoteAnnouncement)
|
||||
}
|
||||
const rank = { low: 0, normal: 1, high: 2, critical: 3 }
|
||||
return items.sort(
|
||||
(first, second) =>
|
||||
Number(second.pinned ?? false) - Number(first.pinned ?? false) ||
|
||||
rank[second.priority] - rank[first.priority] ||
|
||||
Date.parse(second.published_at) - Date.parse(first.published_at),
|
||||
)
|
||||
return items.sort((first, second) => rank[second.priority] - rank[first.priority] || Date.parse(second.published_at) - Date.parse(first.published_at))
|
||||
}
|
||||
|
||||
export function isAnnouncementActive(item: RemoteAnnouncement, now = Date.now()) {
|
||||
@@ -80,76 +64,3 @@ export function isAnnouncementActive(item: RemoteAnnouncement, now = Date.now())
|
||||
export function announcementKey(item: RemoteAnnouncement) {
|
||||
return item.id + ':' + item.published_at
|
||||
}
|
||||
|
||||
export const REMOTE_ANNOUNCEMENTS_UPDATED_EVENT = 'starlight:remote-announcements-updated'
|
||||
export const OPEN_REMOTE_ANNOUNCEMENT_CENTER_EVENT = 'starlight:open-remote-announcement-center'
|
||||
type BroadcastAnnouncementEntry = {
|
||||
title?: unknown
|
||||
subtitle?: unknown
|
||||
content?: unknown
|
||||
updateAt?: unknown
|
||||
star?: unknown
|
||||
importantLevel?: unknown
|
||||
id?: unknown
|
||||
}
|
||||
|
||||
function broadcastPriority(level: number): RemoteAnnouncement['priority'] {
|
||||
if (level >= 9) return 'critical'
|
||||
if (level >= 6) return 'high'
|
||||
if (level >= 3) return 'normal'
|
||||
return 'low'
|
||||
}
|
||||
|
||||
export function mapBroadcastAnnouncements(payload: unknown): RemoteAnnouncement[] | null {
|
||||
if (!Array.isArray(payload) || payload.length > 200) return null
|
||||
const items: RemoteAnnouncement[] = []
|
||||
const seen = new Set<string>()
|
||||
for (const entry of payload) {
|
||||
if (!entry || typeof entry !== 'object') continue
|
||||
const item = entry as BroadcastAnnouncementEntry
|
||||
if (
|
||||
typeof item.id !== 'number' ||
|
||||
!Number.isFinite(item.id) ||
|
||||
typeof item.title !== 'string' ||
|
||||
!item.title.trim() ||
|
||||
item.title.length > 120 ||
|
||||
typeof item.content !== 'string' ||
|
||||
item.content.length > 20000 ||
|
||||
typeof item.updateAt !== 'number' ||
|
||||
!Number.isFinite(item.updateAt) ||
|
||||
(item.subtitle != null && typeof item.subtitle !== 'string')
|
||||
)
|
||||
continue
|
||||
const id = String(item.id)
|
||||
if (seen.has(id)) continue
|
||||
seen.add(id)
|
||||
const level =
|
||||
typeof item.importantLevel === 'number' && Number.isFinite(item.importantLevel)
|
||||
? Math.max(0, Math.min(10, Math.floor(item.importantLevel)))
|
||||
: 0
|
||||
const starred = item.star === true
|
||||
const published = new Date(item.updateAt).toISOString()
|
||||
const summary = typeof item.subtitle === 'string' && item.subtitle.trim() ? item.subtitle : null
|
||||
items.push({
|
||||
id,
|
||||
title: item.title,
|
||||
summary,
|
||||
content: item.content,
|
||||
type: starred || level >= 8 ? 'modal' : 'notification',
|
||||
priority: broadcastPriority(level),
|
||||
pinned: starred,
|
||||
starts_at: published,
|
||||
ends_at: null,
|
||||
published_at: published,
|
||||
action_url: null,
|
||||
action_label: null,
|
||||
})
|
||||
}
|
||||
const rank = { low: 0, normal: 1, high: 2, critical: 3 }
|
||||
return items.sort(
|
||||
(first, second) =>
|
||||
Number(second.pinned ?? false) - Number(first.pinned ?? false) ||
|
||||
rank[second.priority] - rank[first.priority] ||
|
||||
Date.parse(second.published_at) - Date.parse(first.published_at),
|
||||
)
|
||||
}
|
||||
-3
@@ -55,7 +55,6 @@ export type GameInstance = {
|
||||
force_fullscreen?: boolean
|
||||
maximize_window?: boolean
|
||||
game_resolution?: [number, number]
|
||||
window_title?: string | null
|
||||
launch_preparation_timeout?: number | null
|
||||
hooks: Hooks
|
||||
}
|
||||
@@ -240,8 +239,6 @@ type AppSettings = {
|
||||
force_fullscreen: boolean
|
||||
maximize_window: boolean
|
||||
game_resolution: [number, number]
|
||||
custom_window_title_enabled: boolean
|
||||
default_window_title: string
|
||||
hide_on_process_start: boolean
|
||||
enter_lightweight_mode_on_game_launch: boolean
|
||||
auto_set_java_high_performance_mode: boolean
|
||||
|
||||
@@ -11431,59 +11431,5 @@
|
||||
},
|
||||
"app.anniversary.banner": {
|
||||
"message": "Happy {ordinal} Anniversary, Starlight!"
|
||||
},
|
||||
"instance.settings.tabs.window.window-title": {
|
||||
"message": "Window title"
|
||||
},
|
||||
"instance.settings.tabs.window.window-title.description": {
|
||||
"message": "Customize the Minecraft window title. Leave empty to keep the default."
|
||||
},
|
||||
"instance.settings.tabs.window.window-title.enter": {
|
||||
"message": "Enter window title..."
|
||||
},
|
||||
"app.settings.defaults.window-title.enabled": {
|
||||
"message": "Custom Minecraft window title"
|
||||
},
|
||||
"app.settings.defaults.window-title.enabled-description": {
|
||||
"message": "Allow instances to customize the Minecraft window title."
|
||||
},
|
||||
"app.settings.defaults.window-title.default": {
|
||||
"message": "Default window title"
|
||||
},
|
||||
"app.settings.defaults.window-title.default-description": {
|
||||
"message": "Used when an instance does not provide its own title."
|
||||
},
|
||||
"app.settings.defaults.window-title.default-placeholder": {
|
||||
"message": "Enter the default window title..."
|
||||
},
|
||||
"app.action-bar.announcements": {
|
||||
"message": "Announcements"
|
||||
},
|
||||
"app.remote-announcements.center-title": {
|
||||
"message": "Announcements"
|
||||
},
|
||||
"app.remote-announcements.empty": {
|
||||
"message": "No announcements"
|
||||
},
|
||||
"app.remote-announcements.view": {
|
||||
"message": "View announcement"
|
||||
},
|
||||
"app.remote-announcements.unread": {
|
||||
"message": "Unread"
|
||||
},
|
||||
"app.remote-announcements.read-all": {
|
||||
"message": "Mark all announcements as read"
|
||||
},
|
||||
"app.remote-announcements.preview-title": {
|
||||
"message": "Announcement style preview"
|
||||
},
|
||||
"app.remote-announcements.preview-summary": {
|
||||
"message": "This is a local preview notification. Select View announcement to see the full Markdown content."
|
||||
},
|
||||
"app.remote-announcements.preview-content": {
|
||||
"message": "## Announcement preview\n\nThis is **sample content**, not a published announcement.\n\n- Supports headings, lists, and links\n- Close buttons are always available\n\n> Previewing does not change real announcement read status.\n\n| Type | Display |\n| --- | --- |\n| Modal | Full Markdown content |\n| Popup | Summary, then full content |\n\n[Visit the website](https://skin.starlight.cool/)"
|
||||
},
|
||||
"app.remote-announcements.preview-action": {
|
||||
"message": "Visit website"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11351,16 +11351,5 @@
|
||||
"app.settings.synced-options.game-settings.value-off": { "message": "关闭" },
|
||||
"app.settings.synced-options.game-settings.value-on": { "message": "开启" },
|
||||
"app.settings.synced-options.game-settings.value-unset": { "message": "选择一个值" },
|
||||
"app.anniversary.banner": { "message": "Starlight {ordinal} 周年快乐!" },
|
||||
"instance.settings.tabs.window.window-title": { "message": "窗口标题" },
|
||||
"instance.settings.tabs.window.window-title.description": { "message": "自定义 Minecraft 窗口标题。留空则使用默认标题。" },
|
||||
"instance.settings.tabs.window.window-title.enter": { "message": "输入窗口标题..." },
|
||||
"app.settings.defaults.window-title.enabled": { "message": "自定义 Minecraft 窗口标题" },
|
||||
"app.settings.defaults.window-title.enabled-description": { "message": "允许实例自定义 Minecraft 窗口标题。" },
|
||||
"app.settings.defaults.window-title.default": { "message": "默认窗口标题" },
|
||||
"app.settings.defaults.window-title.default-description": { "message": "当实例未提供自己的标题时使用。" },
|
||||
"app.settings.defaults.window-title.default-placeholder": { "message": "输入默认窗口标题..." },
|
||||
"app.action-bar.announcements": { "message": "公告" },
|
||||
"app.remote-announcements.center-title": { "message": "公告" },
|
||||
"app.remote-announcements.empty": { "message": "暂无公告" }
|
||||
}
|
||||
"app.anniversary.banner": { "message": "Starlight {ordinal} 周年快乐!" }
|
||||
}
|
||||
@@ -333,12 +333,6 @@ pub struct EditInstance {
|
||||
)]
|
||||
pub launch_preparation_timeout: Option<Option<u64>>,
|
||||
pub hooks: Option<Hooks>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "serde_with::rust::double_option"
|
||||
)]
|
||||
pub window_title: Option<Option<String>>,
|
||||
|
||||
#[serde(
|
||||
default,
|
||||
@@ -537,8 +531,7 @@ fn edit_to_core(edit_instance: EditInstance) -> Result<CoreEditInstance> {
|
||||
|| edit_instance.maximize_window.is_some()
|
||||
|| edit_instance.game_resolution.is_some()
|
||||
|| edit_instance.launch_preparation_timeout.is_some()
|
||||
|| edit_instance.hooks.is_some()
|
||||
|| edit_instance.window_title.is_some();
|
||||
|| edit_instance.hooks.is_some();
|
||||
if has_launch_change {
|
||||
Some(InstanceLaunchOverridesPatch {
|
||||
player: None,
|
||||
@@ -553,7 +546,6 @@ fn edit_to_core(edit_instance: EditInstance) -> Result<CoreEditInstance> {
|
||||
launch_preparation_timeout: edit_instance
|
||||
.launch_preparation_timeout,
|
||||
hooks: edit_instance.hooks,
|
||||
window_title: edit_instance.window_title,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -253,14 +253,6 @@ impl LightweightMode {
|
||||
if payload.maximize_window {
|
||||
maximize_minecraft_window(payload.pid).await;
|
||||
}
|
||||
if let Some(title) = payload
|
||||
.window_title
|
||||
.as_ref()
|
||||
.map(|value| value.trim())
|
||||
.filter(|value| !value.is_empty())
|
||||
{
|
||||
rename_minecraft_window(payload.pid, title).await;
|
||||
}
|
||||
let settings = match theseus::settings::get().await {
|
||||
Ok(settings) => settings,
|
||||
Err(error) => {
|
||||
@@ -340,8 +332,6 @@ struct ProcessEventPayload {
|
||||
pid: u32,
|
||||
#[serde(default)]
|
||||
maximize_window: bool,
|
||||
#[serde(default)]
|
||||
window_title: Option<String>,
|
||||
event: String,
|
||||
crashed: Option<bool>,
|
||||
#[serde(default)]
|
||||
@@ -349,7 +339,7 @@ struct ProcessEventPayload {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicU32, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
static MAXIMIZE_PROCESS_ID: AtomicU32 = AtomicU32::new(0);
|
||||
@@ -410,74 +400,6 @@ async fn maximize_minecraft_window(pid: u32) {
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
async fn maximize_minecraft_window(_pid: u32) {}
|
||||
#[cfg(target_os = "windows")]
|
||||
static RENAME_WINDOW_HANDLE: AtomicIsize = AtomicIsize::new(0);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
unsafe extern "system" fn rename_if_owned_by_process(
|
||||
hwnd: windows::Win32::Foundation::HWND,
|
||||
_: windows::Win32::Foundation::LPARAM,
|
||||
) -> windows::core::BOOL {
|
||||
use windows::Win32::UI::WindowsAndMessaging::{
|
||||
GetWindowThreadProcessId, IsWindowVisible,
|
||||
};
|
||||
use windows::core::BOOL;
|
||||
|
||||
let mut window_pid = 0;
|
||||
unsafe { GetWindowThreadProcessId(hwnd, Some(&mut window_pid)) };
|
||||
if window_pid == MAXIMIZE_PROCESS_ID.load(Ordering::Relaxed)
|
||||
&& unsafe { IsWindowVisible(hwnd).as_bool() }
|
||||
{
|
||||
RENAME_WINDOW_HANDLE.store(hwnd.0 as isize, Ordering::Relaxed);
|
||||
return BOOL(0);
|
||||
}
|
||||
BOOL(1)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
async fn rename_minecraft_window(pid: u32, title: &str) {
|
||||
if pid == 0 || title.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
// PCL keeps re-applying the title: FML/Quilt and some mods reset it
|
||||
// while the game boots, so a one-shot rename is not enough.
|
||||
let deadline =
|
||||
tokio::time::Instant::now() + std::time::Duration::from_secs(45);
|
||||
let mut applied = false;
|
||||
loop {
|
||||
let found = {
|
||||
let _guard = MAXIMIZE_WINDOW_ENUMERATION.lock();
|
||||
MAXIMIZE_PROCESS_ID.store(pid, Ordering::Relaxed);
|
||||
RENAME_WINDOW_HANDLE.store(0, Ordering::Relaxed);
|
||||
unsafe {
|
||||
use windows::Win32::Foundation::LPARAM;
|
||||
use windows::Win32::UI::WindowsAndMessaging::EnumWindows;
|
||||
let _ =
|
||||
EnumWindows(Some(rename_if_owned_by_process), LPARAM(0));
|
||||
}
|
||||
RENAME_WINDOW_HANDLE.load(Ordering::Relaxed)
|
||||
};
|
||||
if found != 0 {
|
||||
let hwnd = windows::Win32::Foundation::HWND(found as *mut _);
|
||||
let wide: Vec<u16> = title.encode_utf16().chain(Some(0)).collect();
|
||||
unsafe {
|
||||
use windows::Win32::UI::WindowsAndMessaging::SetWindowTextW;
|
||||
let _ =
|
||||
SetWindowTextW(hwnd, windows::core::PCWSTR(wide.as_ptr()));
|
||||
}
|
||||
applied = true;
|
||||
}
|
||||
if tokio::time::Instant::now() >= deadline {
|
||||
return;
|
||||
}
|
||||
let _ = applied;
|
||||
tokio::time::sleep(std::time::Duration::from_millis(400)).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
async fn rename_minecraft_window(_pid: u32, _title: &str) {}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn lightweight_mode_frontend_ready(
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE settings ADD COLUMN custom_window_title_enabled INTEGER NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE settings ADD COLUMN default_window_title TEXT NOT NULL DEFAULT 'Minecraft';
|
||||
@@ -250,17 +250,6 @@ async fn run_credentials(
|
||||
.launch_overrides
|
||||
.maximize_window
|
||||
.unwrap_or(settings.maximize_window);
|
||||
let window_title = settings
|
||||
.custom_window_title_enabled
|
||||
.then(|| {
|
||||
context
|
||||
.launch_overrides
|
||||
.window_title
|
||||
.clone()
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.unwrap_or_else(|| settings.default_window_title.clone())
|
||||
})
|
||||
.filter(|value| !value.trim().is_empty());
|
||||
let env_args = context
|
||||
.launch_overrides
|
||||
.custom_env_vars
|
||||
@@ -330,7 +319,6 @@ async fn run_credentials(
|
||||
&memory,
|
||||
&resolution,
|
||||
maximize_window,
|
||||
window_title,
|
||||
credentials,
|
||||
post_exit_hook,
|
||||
&context,
|
||||
|
||||
@@ -157,7 +157,6 @@ pub(crate) async fn import_axolotl(
|
||||
),
|
||||
maximize_window: Some(config.launch_overrides.maximize_window),
|
||||
game_resolution: Some(config.launch_overrides.game_resolution),
|
||||
window_title: None,
|
||||
launch_preparation_timeout: Some(
|
||||
config.launch_overrides.launch_preparation_timeout,
|
||||
),
|
||||
|
||||
@@ -400,7 +400,6 @@ pub async fn emit_process(
|
||||
uuid: Uuid,
|
||||
pid: u32,
|
||||
maximize_window: bool,
|
||||
window_title: Option<String>,
|
||||
event: ProcessPayloadType,
|
||||
message: &str,
|
||||
crashed: Option<bool>,
|
||||
@@ -417,7 +416,6 @@ pub async fn emit_process(
|
||||
uuid,
|
||||
pid,
|
||||
maximize_window,
|
||||
window_title,
|
||||
event,
|
||||
message: message.to_string(),
|
||||
crashed,
|
||||
|
||||
@@ -336,8 +336,6 @@ pub struct ProcessPayload {
|
||||
pub uuid: Uuid,
|
||||
pub pid: u32,
|
||||
pub maximize_window: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub window_title: Option<String>,
|
||||
pub event: ProcessPayloadType,
|
||||
pub message: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
||||
@@ -1520,7 +1520,6 @@ pub async fn launch_minecraft(
|
||||
memory: &MemorySettings,
|
||||
resolution: &WindowSize,
|
||||
maximize_window: bool,
|
||||
window_title: Option<String>,
|
||||
credentials: &Credentials,
|
||||
post_exit_hook: Option<String>,
|
||||
context: &InstanceLaunchContext,
|
||||
@@ -2392,7 +2391,6 @@ pub async fn launch_minecraft(
|
||||
command,
|
||||
post_exit_hook,
|
||||
maximize_window,
|
||||
window_title,
|
||||
instance_path.clone(),
|
||||
logs_folder,
|
||||
version_info.logging.is_some(),
|
||||
|
||||
@@ -103,12 +103,6 @@ pub struct InstanceLaunchOverridesPatch {
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "serde_with::rust::double_option"
|
||||
)]
|
||||
pub window_title: Option<Option<String>>,
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "serde_with::rust::double_option"
|
||||
)]
|
||||
pub launch_preparation_timeout: Option<Option<u64>>,
|
||||
pub hooks: Option<Hooks>,
|
||||
}
|
||||
@@ -377,10 +371,6 @@ fn apply_launch_overrides_patch(
|
||||
if let Some(game_resolution) = patch.game_resolution {
|
||||
overrides.game_resolution = game_resolution;
|
||||
}
|
||||
if let Some(window_title) = patch.window_title {
|
||||
overrides.window_title =
|
||||
window_title.filter(|value| !value.trim().is_empty());
|
||||
}
|
||||
if let Some(mode) = patch.instance_mode {
|
||||
overrides.instance_mode = Some(mode);
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ pub struct InstanceLaunchOverrides {
|
||||
pub maximize_window: Option<bool>,
|
||||
pub game_resolution: Option<WindowSize>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub window_title: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub launch_preparation_timeout: Option<u64>,
|
||||
pub hooks: Hooks,
|
||||
}
|
||||
@@ -57,7 +55,6 @@ impl InstanceLaunchOverrides {
|
||||
force_fullscreen: None,
|
||||
maximize_window: None,
|
||||
game_resolution: None,
|
||||
window_title: None,
|
||||
launch_preparation_timeout: None,
|
||||
hooks: Hooks {
|
||||
pre_launch: None,
|
||||
@@ -89,8 +86,6 @@ pub(crate) struct InstanceLaunchOverridesData {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub game_resolution: Option<WindowSize>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub window_title: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub launch_preparation_timeout: Option<u64>,
|
||||
#[serde(default)]
|
||||
pub hooks: Hooks,
|
||||
@@ -112,7 +107,6 @@ impl InstanceLaunchOverridesData {
|
||||
force_fullscreen: self.force_fullscreen,
|
||||
maximize_window: self.maximize_window,
|
||||
game_resolution: self.game_resolution,
|
||||
window_title: self.window_title,
|
||||
launch_preparation_timeout: self.launch_preparation_timeout,
|
||||
hooks: self.hooks,
|
||||
}
|
||||
@@ -131,7 +125,6 @@ impl From<&InstanceLaunchOverrides> for InstanceLaunchOverridesData {
|
||||
force_fullscreen: overrides.force_fullscreen,
|
||||
maximize_window: overrides.maximize_window,
|
||||
game_resolution: overrides.game_resolution,
|
||||
window_title: overrides.window_title.clone(),
|
||||
launch_preparation_timeout: overrides.launch_preparation_timeout,
|
||||
hooks: overrides.hooks.clone(),
|
||||
}
|
||||
|
||||
@@ -621,7 +621,6 @@ where
|
||||
force_fullscreen: input.force_fullscreen,
|
||||
maximize_window: None,
|
||||
game_resolution: input.game_resolution,
|
||||
window_title: None,
|
||||
launch_preparation_timeout: None,
|
||||
hooks: input.hooks,
|
||||
};
|
||||
|
||||
@@ -312,7 +312,6 @@ impl ProcessManager {
|
||||
mut mc_command: Command,
|
||||
post_exit_command: Option<String>,
|
||||
maximize_window: bool,
|
||||
window_title: Option<String>,
|
||||
game_dir: PathBuf,
|
||||
logs_folder: PathBuf,
|
||||
xml_logging: bool,
|
||||
@@ -337,7 +336,6 @@ impl ProcessManager {
|
||||
uuid: Uuid::new_v4(),
|
||||
pid: mc_proc.id().unwrap_or_default(),
|
||||
maximize_window,
|
||||
window_title: window_title.clone(),
|
||||
start_time: Utc::now(),
|
||||
instance_id: instance_id.to_string(),
|
||||
instance_path: instance_path.to_string(),
|
||||
@@ -511,7 +509,6 @@ impl ProcessManager {
|
||||
metadata.uuid,
|
||||
metadata.pid,
|
||||
metadata.maximize_window,
|
||||
metadata.window_title.clone(),
|
||||
ProcessPayloadType::Launched,
|
||||
"Launched Minecraft",
|
||||
None,
|
||||
@@ -589,7 +586,6 @@ pub struct ProcessMetadata {
|
||||
pub uuid: Uuid,
|
||||
pub pid: u32,
|
||||
pub maximize_window: bool,
|
||||
pub window_title: Option<String>,
|
||||
pub instance_id: String,
|
||||
pub instance_path: String,
|
||||
pub instance_name: String,
|
||||
@@ -1315,7 +1311,6 @@ impl Process {
|
||||
uuid,
|
||||
pid,
|
||||
false,
|
||||
None,
|
||||
ProcessPayloadType::Finished,
|
||||
"Exited process",
|
||||
Some(!mc_exit_status.success() && !manually_killed),
|
||||
@@ -1456,7 +1451,6 @@ mod post_upgrade_tests {
|
||||
uuid,
|
||||
pid: child.id().unwrap(),
|
||||
maximize_window: false,
|
||||
window_title: None,
|
||||
instance_id: "first".into(),
|
||||
instance_path: "first".into(),
|
||||
instance_name: "First".into(),
|
||||
|
||||
@@ -176,10 +176,6 @@ pub struct Settings {
|
||||
pub force_fullscreen: bool,
|
||||
pub maximize_window: bool,
|
||||
#[serde(default)]
|
||||
pub custom_window_title_enabled: bool,
|
||||
#[serde(default = "default_window_title")]
|
||||
pub default_window_title: String,
|
||||
#[serde(default)]
|
||||
pub force_unicode_font: bool,
|
||||
pub game_resolution: WindowSize,
|
||||
pub hide_on_process_start: bool,
|
||||
@@ -202,10 +198,6 @@ pub struct Settings {
|
||||
pub version: usize,
|
||||
}
|
||||
|
||||
fn default_window_title() -> String {
|
||||
"Minecraft".to_string()
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
@@ -336,16 +328,6 @@ impl Settings {
|
||||
)
|
||||
.fetch_one(exec)
|
||||
.await?;
|
||||
let custom_window_title_enabled: bool = sqlx::query_scalar(
|
||||
"SELECT custom_window_title_enabled FROM settings WHERE id = 0",
|
||||
)
|
||||
.fetch_one(exec)
|
||||
.await?;
|
||||
let default_window_title: String = sqlx::query_scalar(
|
||||
"SELECT default_window_title FROM settings WHERE id = 0",
|
||||
)
|
||||
.fetch_one(exec)
|
||||
.await?;
|
||||
let settings = Self {
|
||||
max_concurrent_downloads: res.max_concurrent_downloads as usize,
|
||||
max_concurrent_writes: res.max_concurrent_writes as usize,
|
||||
@@ -433,8 +415,6 @@ impl Settings {
|
||||
},
|
||||
force_fullscreen: res.mc_force_fullscreen == 1,
|
||||
maximize_window: res.mc_maximize_window == 1,
|
||||
custom_window_title_enabled,
|
||||
default_window_title,
|
||||
force_unicode_font: sqlx::query_scalar(
|
||||
"SELECT mc_force_unicode_font FROM settings WHERE id = 0",
|
||||
)
|
||||
@@ -683,18 +663,6 @@ impl Settings {
|
||||
.bind(self.ignore_ssl_errors)
|
||||
.execute(exec)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"UPDATE settings SET custom_window_title_enabled = ? WHERE id = 0",
|
||||
)
|
||||
.bind(self.custom_window_title_enabled)
|
||||
.execute(exec)
|
||||
.await?;
|
||||
sqlx::query(
|
||||
"UPDATE settings SET default_window_title = ? WHERE id = 0",
|
||||
)
|
||||
.bind(self.default_window_title.trim())
|
||||
.execute(exec)
|
||||
.await?;
|
||||
sqlx::query("UPDATE settings SET mc_memory_optimize = ? WHERE id = 0")
|
||||
.bind(self.memory.optimize_before_launch)
|
||||
.execute(exec)
|
||||
|
||||
@@ -8,7 +8,6 @@ export * from './format-number'
|
||||
export * from './how-ago'
|
||||
export * from './i18n'
|
||||
export * from './i18n-debug'
|
||||
export * from './modal-stack'
|
||||
export * from './page-leave-safety'
|
||||
export * from './scroll-indicator'
|
||||
export type { ArmorPreviewConfig } from './skin-rendering/armor-preview-types'
|
||||
|
||||
Reference in new issue
Block a user