Compare commits
71
Commits
fix/ui
...
v1.0.2-beta9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
598fb5c679 | ||
|
|
aaf394f790 | ||
|
|
3c8ac04269 | ||
|
|
71b8d111fb | ||
|
|
febbd84ae7 | ||
|
|
667c1a0900 | ||
|
|
ac38c98203 | ||
|
|
ef1435bd31 | ||
|
|
87de306245 | ||
|
|
fbcbb803ac | ||
|
|
7b3a5212e6 | ||
|
|
8d73689356 | ||
|
|
4a3b4268b9 | ||
|
|
64f2f85607 | ||
|
|
ede28e0062 | ||
|
|
b0178c046f | ||
|
|
57ff974d79 | ||
|
|
ac9373ddae | ||
|
|
47c4a3973d | ||
|
|
a85e88339f | ||
|
|
d4eb492772 | ||
|
|
e1aa1b47ec | ||
|
|
023447fe85 | ||
|
|
1baf1a041e | ||
|
|
6a0d9b719c | ||
|
|
ba43b9d5bc | ||
|
|
1c671943b7 | ||
|
|
eef7d02f45 | ||
|
|
947a739672 | ||
|
|
799d542227 | ||
|
|
77258eee9d | ||
|
|
a4615c7b73 | ||
|
|
146b88afce | ||
|
|
9bdc965cd5 | ||
|
|
d6d4fcf8a0 | ||
|
|
8cc4782497 | ||
|
|
77b381b8d0 | ||
|
|
4124f26095 | ||
|
|
041d288b25 | ||
|
|
86306b8ddd | ||
|
|
8599a014ad | ||
|
|
bf175160b0 | ||
|
|
d17a66e44f | ||
|
|
3198eac35a | ||
|
|
d83a65a052 | ||
|
|
00f0f111d8 | ||
|
|
0edf96fc2c | ||
|
|
871b0ee001 | ||
|
|
adebde714d | ||
|
|
0195cbf5ac | ||
|
|
13a56f4200 | ||
|
|
d3a510eee6 | ||
|
|
8b94e7dbbe | ||
|
|
ccb96a8cf1 | ||
|
|
0f35a5f707 | ||
|
|
6fb73490d3 | ||
|
|
2dcf26c9d9 | ||
|
|
9ccacba3fd | ||
|
|
54499dd9da | ||
|
|
fce6c60759 | ||
|
|
dcbad9447d | ||
|
|
4abf643852 | ||
|
|
a8d8e1674b | ||
|
|
60f3fd8816 | ||
|
|
c71c220446 | ||
|
|
a95153d0b1 | ||
|
|
853147b04d | ||
|
|
8d61826c5f | ||
|
|
2e92887eb2 | ||
|
|
47bdb1e79c | ||
|
|
98396c6bcd |
No files matched your search
@@ -374,6 +374,44 @@ jobs:
|
||||
)
|
||||
gh release upload "${GITHUB_REF_NAME}" "release-check/${bundle_name}" --clobber
|
||||
|
||||
- name: Publish to skin site
|
||||
continue-on-error: true
|
||||
env:
|
||||
SKIN_SITE_TOKEN: ${{ secrets.SKIN_SITE_CI_UPLOAD_TOKEN }}
|
||||
SKIN_SITE_URL: ${{ vars.SKIN_SITE_URL || 'https://skin.starlight.cool' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${SKIN_SITE_TOKEN:-}" ]; then
|
||||
echo "::warning::SKIN_SITE_CI_UPLOAD_TOKEN not configured, skipping skin site publish"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
version="${GITHUB_REF_NAME#v}"
|
||||
bundle="release-check/Starlight_Launcher_${version}_skin-site-update.zip"
|
||||
if [ ! -f "${bundle}" ]; then
|
||||
echo "::warning::Bundle ${bundle} not found, skipping skin site publish"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
upload_response=$(curl -fsS -X POST \
|
||||
-H "Authorization: Bearer ${SKIN_SITE_TOKEN}" \
|
||||
-F "archive=@${bundle};type=application/zip" \
|
||||
"${SKIN_SITE_URL}/starlight/launcher/admin/upload?forceUpdate=false")
|
||||
|
||||
release_id=$(printf '%s' "${upload_response}" | jq -r '.payload.id // empty')
|
||||
if [ -z "${release_id}" ]; then
|
||||
echo "::warning::Skin site upload did not return a release id: ${upload_response}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Uploaded release id: ${release_id}"
|
||||
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: Bearer ${SKIN_SITE_TOKEN}" \
|
||||
"${SKIN_SITE_URL}/starlight/launcher/admin/${release_id}/activate"
|
||||
|
||||
echo "Skin site release ${version} published"
|
||||
|
||||
- name: Notify Update Server to publish release assets
|
||||
if: ${{ env.UPDATE_SERVER_URL != '' && env.UPDATE_SERVER_WEBHOOK_SECRET != '' }}
|
||||
env:
|
||||
|
||||
Generated
+2
-2
@@ -6841,7 +6841,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "theseus"
|
||||
version = "1.0.2-beta4"
|
||||
version = "1.0.2-beta7"
|
||||
dependencies = [
|
||||
"ariadne",
|
||||
"async-minecraft-ping",
|
||||
@@ -6945,7 +6945,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "theseus_gui"
|
||||
version = "1.0.2-beta4"
|
||||
version = "1.0.2-beta7"
|
||||
dependencies = [
|
||||
"ashpd",
|
||||
"async_zip",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@modrinth/app-frontend",
|
||||
"private": true,
|
||||
"version": "1.0.2-beta4",
|
||||
"version": "1.0.2-beta9",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -50,7 +50,8 @@
|
||||
"vue": "^3.5.13",
|
||||
"vue-i18n": "^10.0.0",
|
||||
"vue-router": "^4.6.0",
|
||||
"vuedraggable": "^4.1.0"
|
||||
"vuedraggable": "^4.1.0",
|
||||
"xxhash-wasm": "1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.1.1",
|
||||
|
||||
@@ -94,13 +94,14 @@ import NavButton from '@/components/ui/NavButton.vue'
|
||||
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 StartupAnnouncementModal from '@/components/ui/StartupAnnouncementModal.vue'
|
||||
import WindowControls from '@/components/ui/WindowControls.vue'
|
||||
import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
||||
import { initSkinSiteSession } from '@/composables/skin-site-session'
|
||||
import { useDropImport } from '@/composables/useDropImport'
|
||||
import { setupKeyboardShortcuts } from '@/composables/useKeyboardShortcuts'
|
||||
import { minecraftLaunchErrorKey } from '@/composables/useMinecraftLaunchError'
|
||||
import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
||||
import { AxolotlBrandConfig, config, getOfficialLabrinthBaseUrl } from '@/config'
|
||||
@@ -132,6 +133,7 @@ import {
|
||||
} from '@/helpers/settings.ts'
|
||||
import { getSidebarExpanded, setSidebarExpanded } from '@/helpers/sidebar-state.ts'
|
||||
import { get_opening_command, initialize_state } from '@/helpers/state'
|
||||
import { installUiScale, setUiScale } from '@/helpers/ui-scale'
|
||||
import {
|
||||
areUpdatesEnabled,
|
||||
backupAppDbForUpdate,
|
||||
@@ -145,7 +147,6 @@ import {
|
||||
isNetworkMetered,
|
||||
setRestartAfterPendingUpdate,
|
||||
} from '@/helpers/utils.js'
|
||||
import { installUiScale, setUiScale } from '@/helpers/ui-scale'
|
||||
import { start_join_server, start_join_singleplayer_world } from '@/helpers/worlds.ts'
|
||||
import i18n, { resolveInitialLocale } from '@/i18n.config'
|
||||
import {
|
||||
@@ -184,6 +185,8 @@ const onSchematicWorkshopPage = computed(() => route.path === '/lab/schematic-pr
|
||||
const isSchematicFile = (path: string) => /\.(litematic|schematic|schem)$/i.test(path)
|
||||
const APP_LEFT_NAV_WIDTH = '4rem'
|
||||
|
||||
setupKeyboardShortcuts()
|
||||
|
||||
const discoverContentPath = computed(() => {
|
||||
const projectType = route.params.projectType
|
||||
if (
|
||||
@@ -1156,6 +1159,7 @@ async function setupApp() {
|
||||
stateInitialized.value = true
|
||||
showOnboarding.value = !onboarded
|
||||
void reconcileMojangAuthSourceAtStartup().catch(handleError)
|
||||
void initSkinSiteSession().catch(handleError)
|
||||
|
||||
isMaximized.value = await getCurrentWindow().isMaximized()
|
||||
|
||||
@@ -2225,7 +2229,6 @@ provideAppUpdateDownloadProgress(appUpdateDownload)
|
||||
<template>
|
||||
<AnniversaryCelebration />
|
||||
<SplashScreen v-if="!stateFailed" ref="splashScreen" data-tauri-drag-region />
|
||||
<SkinSiteSessionFrame v-if="stateInitialized" />
|
||||
<InstancePlayerModal v-if="stateInitialized" />
|
||||
<StartupAnnouncementModal ref="startupAnnouncementModal" />
|
||||
<RemoteAnnouncements :ready="stateInitialized && !showOnboarding && !stateFailed" />
|
||||
|
||||
@@ -32,6 +32,170 @@ export const ANNOUNCEMENT_CHANGE_TYPES: readonly AnnouncementChangeType[] = [
|
||||
]
|
||||
|
||||
export const launcherAnnouncements: readonly LauncherAnnouncement[] = [
|
||||
{
|
||||
id: 'launcher-1.0.2-beta9',
|
||||
version: '1.0.2-beta9',
|
||||
publishedAt: '2026-10-19',
|
||||
title: {
|
||||
'en-US': 'Starlight Launcher 1.0.2-beta9',
|
||||
'zh-CN': 'Starlight Launcher 1.0.2-beta9',
|
||||
},
|
||||
changes: {
|
||||
added: [
|
||||
{
|
||||
'en-US': 'Finished the skin site admin console: system overview, announcements, user and player management, review paper editor, mod upload with batch operations, chat room management with real-time voice, servers, audit log, resource downloads, donations and launcher releases.',
|
||||
'zh-CN': '补全皮肤站管理台:系统概览、公告、用户与玩家管理、审核试卷编辑器、Mod 上传与批量操作、聊天室房间管理与实时语音、服务器、审计日志、资源下载、捐赠与启动器版本管理。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added Wiki management to the admin console, including a MediaWiki migration center that imports pages from an existing wiki and lets you review, publish or roll back the result.',
|
||||
'zh-CN': '管理台新增维基管理,包含 MediaWiki 迁移中心:可从现有 Wiki 导入页面,并对结果进行审核、发布或回滚。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added a read-only Wiki reader in the launcher: render pages, follow links between entries, and keep a back stack while browsing.',
|
||||
'zh-CN': '启动器新增维基阅读页:渲染词条正文、跟随词条链接跳转,并在浏览时保留返回栈。',
|
||||
},
|
||||
],
|
||||
changed: [
|
||||
{
|
||||
'en-US': 'Releases are now published to the skin site automatically when a tag is pushed, so the download page stays in sync without a manual upload.',
|
||||
'zh-CN': '推送 tag 发版时会自动把版本同步到皮肤站,下载页无需再手动上传即可保持同步。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Server management pages are only shown to web administrators.',
|
||||
'zh-CN': '服务器管理页仅对网页管理员展示。',
|
||||
},
|
||||
],
|
||||
fixed: [
|
||||
{
|
||||
'en-US': 'Fixed the Chinese and English text on the skin site home navigation cards.',
|
||||
'zh-CN': '修复皮肤站主页导航卡片的中英文案。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Renamed the public download and map endpoints to resolve a duplicate export.',
|
||||
'zh-CN': '重命名公开下载与地图接口,解决导出冲突。',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'launcher-1.0.2-beta8',
|
||||
version: '1.0.2-beta8',
|
||||
publishedAt: '2026-10-18',
|
||||
title: {
|
||||
'en-US': 'Starlight Launcher 1.0.2-beta8',
|
||||
'zh-CN': 'Starlight Launcher 1.0.2-beta8',
|
||||
},
|
||||
changes: {
|
||||
added: [
|
||||
{
|
||||
'en-US': 'The skin site is now fully native inside the launcher: sign-in, registration, password reset, account settings, players, downloads, world map and player review all run through the launcher UI instead of an embedded web page.',
|
||||
'zh-CN': '皮肤站全面改为启动器原生界面:登录、注册、找回密码、账号设置、角色管理、资源下载、服务器地图与玩家审核均不再依赖内嵌网页。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added a bug tracker: browse and filter issues, read details and comments, post replies, create new issues and follow notifications.',
|
||||
'zh-CN': '新增问题追踪:可浏览与筛选问题、查看详情与评论、发表回复、提交新问题并接收通知。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added an admin console with a permission gate: system overview, announcements, users, players, player review and launcher releases.',
|
||||
'zh-CN': '新增管理控制台(带权限校验):系统概览、公告管理、用户管理、玩家管理、玩家审核与启动器版本管理。',
|
||||
},
|
||||
],
|
||||
changed: [
|
||||
{
|
||||
'en-US': 'Hosted modpack downloads now go through the dedicated download server, keeping large downloads off the main API host.',
|
||||
'zh-CN': '整合包下载改为走独立的下载服务器,避免大文件下载挤占主 API 服务。',
|
||||
},
|
||||
],
|
||||
fixed: [
|
||||
{
|
||||
'en-US': 'LogShare now collects logs with a lightweight reader, fixing crash log uploads that previously failed.',
|
||||
'zh-CN': 'LogShare 改用轻量日志收集,修复崩溃日志上传失败的问题。',
|
||||
},
|
||||
{
|
||||
'en-US': 'The onboarding tour now scrolls each step into view when the step changes.',
|
||||
'zh-CN': '引导教程在切换步骤时自动滚动到目标元素。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Fixed a type mismatch while collecting crash context credentials.',
|
||||
'zh-CN': '修复崩溃上下文凭据收集中的类型不匹配问题。',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'launcher-1.0.2-beta7',
|
||||
version: '1.0.2-beta7',
|
||||
publishedAt: '2026-10-17',
|
||||
title: {
|
||||
'en-US': 'Starlight Launcher 1.0.2-beta7',
|
||||
'zh-CN': 'Starlight Launcher 1.0.2-beta7',
|
||||
},
|
||||
changes: {
|
||||
fixed: [
|
||||
{
|
||||
'en-US': 'Fixed real-time log backlog that could stall the console under heavy output.',
|
||||
'zh-CN': '修复实时日志积压导致控制台卡顿的问题。',
|
||||
},
|
||||
{
|
||||
'en-US': 'The update channel now defaults to the build type: installing a Beta build starts on the Beta channel instead of Release.',
|
||||
'zh-CN': '更新通道默认值改为跟随安装包版本:安装 Beta 版后默认使用 Beta 通道,不再回落为 Release。',
|
||||
},
|
||||
{
|
||||
'en-US': 'On Linux, the default game directory for StarLight instances no longer points at the system install path (e.g. /usr/bin); it falls back to the home directory.',
|
||||
'zh-CN': 'Linux 上 StarLight 实例的默认游戏目录不再指向系统安装路径(如 /usr/bin),改为回退到用户主目录。',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'launcher-1.0.2-beta6',
|
||||
version: '1.0.2-beta6',
|
||||
publishedAt: '2026-10-11',
|
||||
title: {
|
||||
'en-US': 'Starlight Launcher 1.0.2-beta6',
|
||||
'zh-CN': 'Starlight Launcher 1.0.2-beta6',
|
||||
},
|
||||
changes: {
|
||||
added: [
|
||||
{
|
||||
'en-US': 'Added keyboard shortcut settings: enable and rebind navigation and quick-scrolling shortcuts.',
|
||||
'zh-CN': '新增键盘快捷键设置:可启用并自定义导航与快速滚动快捷键。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added crash log sharing and AI analysis: share crash diagnostics to LogShare for a structured summary and optional AI analysis, with a rebuilt crash window that browses log files and streams the analysis.',
|
||||
'zh-CN': '新增崩溃日志分享与 AI 分析:可将崩溃诊断分享到 LogShare 获取结构化摘要与 AI 分析;崩溃窗口重做为双栏布局,可浏览日志文件并流式查看分析结果。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Crash logs now also collect JVM crash reports (hs_err_pid*.log) and launcher logs.',
|
||||
'zh-CN': '崩溃日志现在也会收集 JVM 崩溃报告(hs_err_pid*.log)与启动器日志。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Added a launcher log export entry.',
|
||||
'zh-CN': '新增启动器日志导出入口。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Instance groups can now be reordered by dragging.',
|
||||
'zh-CN': '实例分组支持拖拽重排。',
|
||||
},
|
||||
],
|
||||
changed: [
|
||||
{
|
||||
'en-US': 'Synced the latest supported AI chat model list from LobeHub.',
|
||||
'zh-CN': '同步 LobeHub 最新的 AI 聊天模型列表。',
|
||||
},
|
||||
],
|
||||
fixed: [
|
||||
{
|
||||
'en-US': 'Fixed remote announcements not refreshing.',
|
||||
'zh-CN': '修复远端公告不刷新的问题。',
|
||||
},
|
||||
{
|
||||
'en-US': 'Completed the Chinese translations for the armor preview feature.',
|
||||
'zh-CN': '补齐盔甲预览功能的中文翻译。',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'launcher-1.0.2-beta5',
|
||||
version: '1.0.2-beta5',
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { ButtonStyled, NewModal, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import MinecraftLoginModal from '@/components/ui/MinecraftLoginModal.vue'
|
||||
import SkinSiteLoginModal from '@/components/ui/skin-site/SkinSiteLoginModal.vue'
|
||||
import {
|
||||
openSkinSiteLogin,
|
||||
requestSkinSitePlayers,
|
||||
skinSitePlayers,
|
||||
skinSiteStatus,
|
||||
@@ -28,7 +27,7 @@ const { formatMessage } = useVIntl()
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const microsoftLogin = ref<InstanceType<typeof MinecraftLoginModal>>()
|
||||
const router = useRouter()
|
||||
const skinSiteLoginModal = ref<InstanceType<typeof SkinSiteLoginModal>>()
|
||||
const accounts = ref<PlayerChoice[]>([])
|
||||
const active = ref(false)
|
||||
const loading = ref(false)
|
||||
@@ -137,9 +136,8 @@ function signInSkinSite() {
|
||||
rejectSelection?.(new PlayerSelectionNavigatedAwayError())
|
||||
resolveSelection = undefined
|
||||
rejectSelection = undefined
|
||||
openSkinSiteLogin()
|
||||
skinSiteLoginModal.value?.show()
|
||||
modal.value?.hide()
|
||||
void router.push('/starlight-skin')
|
||||
}
|
||||
|
||||
const unregister = registerInstancePlayerPicker((id, saved) => {
|
||||
@@ -246,5 +244,6 @@ onUnmounted(() => {
|
||||
<p v-if="saving" class="m-0" role="status">{{ formatMessage(messages.saving) }}</p>
|
||||
</div>
|
||||
</NewModal>
|
||||
<SkinSiteLoginModal ref="skinSiteLoginModal" @signed-in="refresh" />
|
||||
<MinecraftLoginModal ref="microsoftLogin" @complete="refresh" />
|
||||
</template>
|
||||
@@ -244,6 +244,7 @@
|
||||
</div>
|
||||
</Accordion>
|
||||
<MinecraftLoginModal ref="minecraftLoginModal" @complete="onMicrosoftLogin" />
|
||||
<SkinSiteLoginModal ref="skinSiteLoginModal" @signed-in="onSkinSiteSignedIn" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -269,12 +270,12 @@ import { useQueryClient } from '@tanstack/vue-query'
|
||||
import { listen } from '@tauri-apps/api/event'
|
||||
import type { Ref } from 'vue'
|
||||
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
import axolotlLogo from '@/assets/netherstar.png'
|
||||
import MinecraftLoginModal from '@/components/ui/MinecraftLoginModal.vue'
|
||||
import SkinSiteLoginModal from '@/components/ui/skin-site/SkinSiteLoginModal.vue'
|
||||
import {
|
||||
openSkinSiteLogin,
|
||||
requestSkinSitePlayers,
|
||||
selectedSkinSitePlayerId,
|
||||
selectSkinSitePlayer,
|
||||
@@ -298,21 +299,20 @@ import { getPlayerHeadUrl } from '@/helpers/rendering/batch-skin-renderer.ts'
|
||||
import type { Skin } from '@/helpers/skins'
|
||||
import { get_available_skins } from '@/helpers/skins'
|
||||
import { handleSevereError } from '@/store/error.js'
|
||||
import { useTheming } from '@/store/state'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
const { browserOffline, offline, refreshBrowserOffline } = useNetworkStatus()
|
||||
const queryClient = useQueryClient()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const themeStore = useTheming()
|
||||
const skinSiteLoginModal = ref<InstanceType<typeof SkinSiteLoginModal>>()
|
||||
|
||||
async function goToSkinSiteLogin() {
|
||||
openSkinSiteLogin()
|
||||
// The login action must reveal the iframe even if Minimal Home was selected.
|
||||
themeStore.homeLayout = 'standard'
|
||||
await router.push('/').catch(handleError)
|
||||
skinSiteLoginModal.value?.show()
|
||||
}
|
||||
|
||||
function onSkinSiteSignedIn() {
|
||||
void requestSkinSitePlayers().catch(() => {})
|
||||
}
|
||||
const refreshingNetwork = ref(false)
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,23 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
|
||||
import { skinSiteFrameUrl } from '@/composables/skin-site-session'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const messages = defineMessages({
|
||||
frameTitle: {
|
||||
id: 'app.starlight-skin.frame-title',
|
||||
defaultMessage: 'StarLight Skin Site',
|
||||
},
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<iframe
|
||||
:src="skinSiteFrameUrl"
|
||||
allow="clipboard-write; clipboard-read"
|
||||
:title="formatMessage(messages.frameTitle)"
|
||||
class="block h-full min-h-0 w-full border-0"
|
||||
/>
|
||||
</template>
|
||||
@@ -1,65 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
receiveSkinSiteMessage,
|
||||
resetSkinSiteSession,
|
||||
setSkinSiteFrame,
|
||||
SKIN_SITE_ORIGIN,
|
||||
skinSiteStatus,
|
||||
skinSiteUser,
|
||||
} from '@/composables/skin-site-session'
|
||||
import { clearHostedSession } from '@/helpers/hosted-packs'
|
||||
|
||||
const frame = ref<HTMLIFrameElement>()
|
||||
let lastMessage = 0
|
||||
let expiryTimer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
watch(
|
||||
[skinSiteStatus, () => skinSiteUser.value?.uuid],
|
||||
() => {
|
||||
void clearHostedSession().catch(() => {})
|
||||
},
|
||||
{ flush: 'sync' },
|
||||
)
|
||||
|
||||
function connect() {
|
||||
resetSkinSiteSession()
|
||||
lastMessage = 0
|
||||
const contentWindow = frame.value?.contentWindow ?? null
|
||||
setSkinSiteFrame(contentWindow)
|
||||
contentWindow?.postMessage({ type: 'starlight-skin-session-connect' }, SKIN_SITE_ORIGIN)
|
||||
}
|
||||
|
||||
function receive(event: MessageEvent) {
|
||||
if (receiveSkinSiteMessage(event, frame.value?.contentWindow ?? null)) lastMessage = Date.now()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('message', receive)
|
||||
connect()
|
||||
expiryTimer = setInterval(() => {
|
||||
if (lastMessage && Date.now() - lastMessage > 90_000) resetSkinSiteSession()
|
||||
}, 10_000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('message', receive)
|
||||
clearInterval(expiryTimer)
|
||||
setSkinSiteFrame(null)
|
||||
resetSkinSiteSession()
|
||||
void clearHostedSession().catch(() => {})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<iframe
|
||||
ref="frame"
|
||||
:src="`${SKIN_SITE_ORIGIN}/`"
|
||||
title="StarLight Skin Site session"
|
||||
aria-hidden="true"
|
||||
tabindex="-1"
|
||||
class="pointer-events-none fixed -left-[10000px] top-0 h-px w-px opacity-0"
|
||||
@load="connect"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,62 @@
|
||||
export interface CrashLogFile {
|
||||
age: number
|
||||
filename: string
|
||||
log_type: 'InfoLog' | 'CrashReport' | 'JvmCrash' | 'LauncherLog'
|
||||
output?: string | null
|
||||
}
|
||||
|
||||
const RUN_ASSOCIATION_WINDOW_SECONDS = 3 * 60
|
||||
|
||||
export function shouldUseLogShareAutoAnalysis(settings: {
|
||||
ai_source: 'logshare' | 'custom'
|
||||
auto_upload: boolean
|
||||
no_storage?: boolean
|
||||
}): boolean {
|
||||
return settings.ai_source === 'logshare' && settings.auto_upload
|
||||
}
|
||||
|
||||
function isRelevantLog(file: CrashLogFile): boolean {
|
||||
const lower = file.filename.toLowerCase()
|
||||
if (file.log_type === 'CrashReport') return lower.endsWith('.txt')
|
||||
if (file.log_type === 'JvmCrash') return lower.startsWith('hs_err') && lower.endsWith('.log')
|
||||
return ['latest.log', 'debug.log', 'launcher_log.txt', 'latest_stdout.log'].includes(lower)
|
||||
}
|
||||
|
||||
export function selectCrashLogFiles(files: CrashLogFile[]): CrashLogFile[] {
|
||||
const sorted = files.filter(isRelevantLog).sort((left, right) => right.age - left.age)
|
||||
const anchor = sorted[0]?.age
|
||||
if (anchor === undefined) return []
|
||||
|
||||
const singletonTypes = new Set<CrashLogFile['log_type']>()
|
||||
return sorted.filter((file) => {
|
||||
if (anchor - file.age > RUN_ASSOCIATION_WINDOW_SECONDS) return false
|
||||
if (file.log_type !== 'CrashReport' && file.log_type !== 'JvmCrash') return true
|
||||
if (singletonTypes.has(file.log_type)) return false
|
||||
singletonTypes.add(file.log_type)
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
export function crashLogKey(file: CrashLogFile): string {
|
||||
return `${file.log_type}:${file.filename}`
|
||||
}
|
||||
|
||||
export function crashLogLabel(file: CrashLogFile): string {
|
||||
return file.log_type === 'CrashReport' ? `crash-reports/${file.filename}` : file.filename
|
||||
}
|
||||
|
||||
export function preferredCrashLogKey(files: CrashLogFile[]): string {
|
||||
const preferred =
|
||||
files.find((file) => file.log_type === 'CrashReport') ??
|
||||
files.find((file) => file.log_type === 'JvmCrash') ??
|
||||
files.find((file) => file.filename.toLowerCase() === 'latest.log') ??
|
||||
files[0]
|
||||
return preferred ? crashLogKey(preferred) : ''
|
||||
}
|
||||
|
||||
export function combineCrashLogs(files: CrashLogFile[]): string {
|
||||
return files
|
||||
.filter((file) => file.output)
|
||||
.map((file) => `===== ${crashLogLabel(file)} =====\n${file.output}`)
|
||||
.join('\n\n')
|
||||
}
|
||||
@@ -197,6 +197,27 @@ export function useOnboardingTour(
|
||||
requestAnimationFrame(updateRect)
|
||||
}
|
||||
|
||||
// Bring the current step target into view when the tour jumps to a step
|
||||
// whose target lives inside a scrollable container (e.g. the settings
|
||||
// sidebar). Without this the bubble can point at an off-screen element.
|
||||
function ensureTargetVisible() {
|
||||
const target = targetElement.value
|
||||
if (!target) return
|
||||
const rect = target.getBoundingClientRect()
|
||||
const outOfView =
|
||||
rect.top < 0 ||
|
||||
rect.left < 0 ||
|
||||
rect.bottom > window.innerHeight ||
|
||||
rect.right > window.innerWidth
|
||||
if (!outOfView) return
|
||||
target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' })
|
||||
requestAnimationFrame(() => {
|
||||
if (targetElement.value === target) {
|
||||
targetRect.value = target.getBoundingClientRect()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goTo(destination: StepDestination) {
|
||||
if (destination === 'complete') {
|
||||
events.complete()
|
||||
@@ -343,6 +364,7 @@ export function useOnboardingTour(
|
||||
await nextTick()
|
||||
updateBubbleSize()
|
||||
updateTarget()
|
||||
ensureTargetVisible()
|
||||
})
|
||||
|
||||
watch(mode, () => {
|
||||
|
||||
@@ -6,6 +6,8 @@ import { ref, watch } from 'vue'
|
||||
import { get, set } from '@/helpers/settings.ts'
|
||||
|
||||
import CrashAnalysisAISettings from './CrashAnalysisAISettings.vue'
|
||||
import LogShareSettings from './LogShareSettings.vue'
|
||||
import SharedLogsSettings from './SharedLogsSettings.vue'
|
||||
import SettingsRow from './SettingsRow.vue'
|
||||
import SettingsSection from './SettingsSection.vue'
|
||||
|
||||
@@ -391,5 +393,7 @@ watch(
|
||||
</SettingsSection>
|
||||
|
||||
<CrashAnalysisAISettings />
|
||||
<LogShareSettings />
|
||||
<SharedLogsSettings />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,231 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
defineMessages,
|
||||
type KeyBinding,
|
||||
KeybindingChips,
|
||||
KeybindingModal,
|
||||
Toggle,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { getNavShortcutEnabled, setNavShortcutEnabled } from '@/helpers/nav-shortcut-state'
|
||||
import { getQuickScrollEnabled, setQuickScrollEnabled } from '@/helpers/scroll-top-state'
|
||||
import { NAV_ACTIONS, SCROLL_ACTIONS, type ShortcutAction } from '@/helpers/shortcut-actions'
|
||||
import {
|
||||
buildConflicts,
|
||||
clearStoredBinding,
|
||||
resolveAllBindings,
|
||||
storeBinding,
|
||||
} from '@/helpers/shortcut-bindings'
|
||||
import { useTheming } from '@/store/theme'
|
||||
|
||||
import SettingsRow from './SettingsRow.vue'
|
||||
import SettingsSection from './SettingsSection.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const themeStore = useTheming()
|
||||
|
||||
themeStore.quickScrollEnabled = getQuickScrollEnabled()
|
||||
themeStore.shortcutBindings = resolveAllBindings()
|
||||
for (const action of NAV_ACTIONS) {
|
||||
themeStore[action.enabledField] = getNavShortcutEnabled(action.id)
|
||||
}
|
||||
|
||||
const messages = defineMessages({
|
||||
scrollTitle: {
|
||||
id: 'app.shortcut-settings.scroll-title',
|
||||
defaultMessage: 'Quick scrolling',
|
||||
},
|
||||
scrollDescription: {
|
||||
id: 'app.shortcut-settings.scroll-description',
|
||||
defaultMessage: 'Move through long pages with the keyboard.',
|
||||
},
|
||||
enable: { id: 'app.shortcut-settings.enable', defaultMessage: 'Enable quick scrolling' },
|
||||
navTitle: {
|
||||
id: 'app.shortcut-settings.nav-title',
|
||||
defaultMessage: 'Navigation shortcuts',
|
||||
},
|
||||
navDescription: {
|
||||
id: 'app.shortcut-settings.nav-description',
|
||||
defaultMessage: 'Jump to a menu item with its shortcut. Each shortcut is off until enabled.',
|
||||
},
|
||||
changeShortcut: {
|
||||
id: 'app.shortcut-settings.change-shortcut',
|
||||
defaultMessage: 'Change the shortcut for {action}',
|
||||
},
|
||||
})
|
||||
|
||||
function actionLabel(action: ShortcutAction) {
|
||||
return formatMessage(action.label)
|
||||
}
|
||||
|
||||
function actionDescription(action: ShortcutAction) {
|
||||
return formatMessage(action.description)
|
||||
}
|
||||
|
||||
function bindingFor(action: ShortcutAction): KeyBinding {
|
||||
return themeStore.shortcutBindings[action.id] ?? action.defaultBinding
|
||||
}
|
||||
|
||||
function sameBinding(left: KeyBinding, right: KeyBinding) {
|
||||
return (
|
||||
left.device === right.device &&
|
||||
left.code === right.code &&
|
||||
left.mod === right.mod &&
|
||||
left.shift === right.shift &&
|
||||
left.alt === right.alt
|
||||
)
|
||||
}
|
||||
|
||||
const editing = ref<ShortcutAction | null>(null)
|
||||
const keybindingModal = ref<InstanceType<typeof KeybindingModal>>()
|
||||
|
||||
const editingLabel = computed(() => (editing.value ? actionLabel(editing.value) : undefined))
|
||||
const editingBinding = computed(() => (editing.value ? bindingFor(editing.value) : null))
|
||||
const editingDefault = computed(() => editing.value?.defaultBinding ?? null)
|
||||
const editingConflicts = computed(() =>
|
||||
editing.value
|
||||
? buildConflicts(editing.value.id, (id) => {
|
||||
const action = [...SCROLL_ACTIONS, ...NAV_ACTIONS].find((candidate) => candidate.id === id)
|
||||
return action ? actionLabel(action) : id
|
||||
})
|
||||
: [],
|
||||
)
|
||||
|
||||
function openShortcut(action: ShortcutAction) {
|
||||
editing.value = action
|
||||
keybindingModal.value?.show()
|
||||
}
|
||||
|
||||
function saveShortcut(binding: KeyBinding) {
|
||||
const action = editing.value
|
||||
if (!action) return
|
||||
|
||||
// A combination matching the default is stored as "not changed", so a later
|
||||
// change to the default still reaches this shortcut.
|
||||
if (sameBinding(binding, action.defaultBinding)) clearStoredBinding(action.id)
|
||||
else storeBinding(action.id, binding)
|
||||
|
||||
themeStore.shortcutBindings = { ...themeStore.shortcutBindings, [action.id]: binding }
|
||||
}
|
||||
|
||||
function toggleQuickScroll(value: unknown) {
|
||||
themeStore.quickScrollEnabled = !!value
|
||||
setQuickScrollEnabled(themeStore.quickScrollEnabled)
|
||||
}
|
||||
|
||||
function toggleNavShortcut(action: ShortcutAction, value: unknown) {
|
||||
themeStore[action.enabledField] = !!value
|
||||
setNavShortcutEnabled(action.id, !!value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-6">
|
||||
<SettingsSection>
|
||||
<template #header>
|
||||
<h2 class="m-0 text-lg font-semibold text-[var(--color-text-primary)]">
|
||||
{{ formatMessage(messages.scrollTitle) }}
|
||||
</h2>
|
||||
<p class="m-0 mt-1 text-sm leading-relaxed text-[var(--color-text-tertiary)]">
|
||||
{{ formatMessage(messages.scrollDescription) }}
|
||||
</p>
|
||||
</template>
|
||||
<SettingsRow>
|
||||
<template #label>
|
||||
<span id="settings-target-shortcuts-enable" tabindex="-1">
|
||||
{{ formatMessage(messages.enable) }}
|
||||
</span>
|
||||
</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="quick-scroll-enabled"
|
||||
:model-value="themeStore.quickScrollEnabled"
|
||||
@update:model-value="toggleQuickScroll"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow v-for="action in SCROLL_ACTIONS" :key="action.id">
|
||||
<template #label>
|
||||
<span :id="`settings-target-${action.id}`" tabindex="-1">{{ actionLabel(action) }}</span>
|
||||
</template>
|
||||
<template #description>{{ actionDescription(action) }}</template>
|
||||
<template #control>
|
||||
<button
|
||||
type="button"
|
||||
class="keybinding-trigger"
|
||||
:aria-label="formatMessage(messages.changeShortcut, { action: actionLabel(action) })"
|
||||
@click="openShortcut(action)"
|
||||
>
|
||||
<KeybindingChips :binding="bindingFor(action)" />
|
||||
</button>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<SettingsSection>
|
||||
<template #header>
|
||||
<h2
|
||||
id="settings-target-shortcuts-nav"
|
||||
tabindex="-1"
|
||||
class="m-0 text-lg font-semibold text-[var(--color-text-primary)]"
|
||||
>
|
||||
{{ formatMessage(messages.navTitle) }}
|
||||
</h2>
|
||||
<p class="m-0 mt-1 text-sm leading-relaxed text-[var(--color-text-tertiary)]">
|
||||
{{ formatMessage(messages.navDescription) }}
|
||||
</p>
|
||||
</template>
|
||||
<SettingsRow v-for="action in NAV_ACTIONS" :key="action.id">
|
||||
<template #label>{{ actionLabel(action) }}</template>
|
||||
<template #description>{{ actionDescription(action) }}</template>
|
||||
<template #control>
|
||||
<div class="flex flex-wrap items-center justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
class="keybinding-trigger"
|
||||
:aria-label="formatMessage(messages.changeShortcut, { action: actionLabel(action) })"
|
||||
@click="openShortcut(action)"
|
||||
>
|
||||
<KeybindingChips :binding="bindingFor(action)" />
|
||||
</button>
|
||||
<Toggle
|
||||
:id="`nav-shortcut-${action.id}`"
|
||||
:model-value="themeStore[action.enabledField]"
|
||||
@update:model-value="(value) => toggleNavShortcut(action, value)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
|
||||
<KeybindingModal
|
||||
ref="keybindingModal"
|
||||
:action-label="editingLabel"
|
||||
:binding="editingBinding"
|
||||
:default-binding="editingDefault"
|
||||
:conflicts="editingConflicts"
|
||||
@save="saveShortcut"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.keybinding-trigger {
|
||||
cursor: pointer;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
padding: 0.25rem 0.375rem;
|
||||
transition:
|
||||
background-color 0.15s ease,
|
||||
border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.keybinding-trigger:hover,
|
||||
.keybinding-trigger:focus-visible {
|
||||
border-color: var(--surface-4);
|
||||
background: var(--surface-3);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,354 @@
|
||||
<script setup lang="ts">
|
||||
import { Combobox, defineMessages, injectNotificationManager, Toggle, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import { type AIState, getAIState, sharedAIState } from '@/helpers/ai'
|
||||
import {
|
||||
get_crash_analysis_ai_settings,
|
||||
get_log_share_settings,
|
||||
update_crash_analysis_ai_settings,
|
||||
update_log_share_settings,
|
||||
} from '@/helpers/logs'
|
||||
|
||||
import SettingsRow from './SettingsRow.vue'
|
||||
import SettingsSection from './SettingsSection.vue'
|
||||
|
||||
type CrashAISettings = {
|
||||
enabled: boolean
|
||||
provider_id: string
|
||||
model_id: string
|
||||
ai_source: 'logshare' | 'custom'
|
||||
}
|
||||
|
||||
type LogShareSettings = {
|
||||
share_provider: 'logshare' | 'mclogs'
|
||||
ai_source: string
|
||||
auto_upload: boolean
|
||||
multi_file: boolean
|
||||
no_storage: boolean
|
||||
show_progress: boolean
|
||||
}
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
const settings = ref<LogShareSettings>({
|
||||
share_provider: 'logshare',
|
||||
ai_source: 'logshare',
|
||||
auto_upload: true,
|
||||
multi_file: true,
|
||||
no_storage: false,
|
||||
show_progress: true,
|
||||
})
|
||||
const aiSettings = ref<CrashAISettings>({
|
||||
enabled: false,
|
||||
provider_id: '',
|
||||
model_id: '',
|
||||
ai_source: 'logshare',
|
||||
})
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.log-share.settings.title', defaultMessage: 'Log sharing & AI analysis' },
|
||||
description: {
|
||||
id: 'app.log-share.settings.description',
|
||||
defaultMessage:
|
||||
'Share crash diagnostics with LogShare for a structured summary and optional AI analysis. LogShare is preferred; mclo.gs is used as a fallback.',
|
||||
},
|
||||
shareProvider: {
|
||||
id: 'app.log-share.settings.share-provider',
|
||||
defaultMessage: 'Log sharing service',
|
||||
},
|
||||
shareProviderDescription: {
|
||||
id: 'app.log-share.settings.share-provider-description',
|
||||
defaultMessage: 'Where the diagnostic link is uploaded when you share it.',
|
||||
},
|
||||
aiSource: { id: 'app.log-share.settings.ai-source', defaultMessage: 'AI analysis source' },
|
||||
aiSourceLogShare: {
|
||||
id: 'app.log-share.settings.ai-source-logshare',
|
||||
defaultMessage: 'LogShare AI',
|
||||
},
|
||||
aiSourceCustom: {
|
||||
id: 'app.log-share.settings.ai-source-custom',
|
||||
defaultMessage: 'Custom AI provider',
|
||||
},
|
||||
aiSourceDescription: {
|
||||
id: 'app.log-share.settings.ai-source-description',
|
||||
defaultMessage:
|
||||
'Both sources send a sanitized and shortened crash context. AI output may be inaccurate.',
|
||||
},
|
||||
enabled: {
|
||||
id: 'app.crash-analysis.ai.settings.enabled',
|
||||
defaultMessage: 'Enable AI explanations',
|
||||
},
|
||||
enabledDescription: {
|
||||
id: 'app.crash-analysis.ai.settings.enabled-description',
|
||||
defaultMessage: 'Local rule-based crash analysis remains available without AI.',
|
||||
},
|
||||
provider: { id: 'app.crash-analysis.ai.settings.provider', defaultMessage: 'AI provider' },
|
||||
model: { id: 'app.crash-analysis.ai.settings.model', defaultMessage: 'Text model' },
|
||||
noProviders: {
|
||||
id: 'app.crash-analysis.ai.settings.no-providers',
|
||||
defaultMessage: 'Enable a provider and a text model above before using AI crash explanations.',
|
||||
},
|
||||
autoUpload: {
|
||||
id: 'app.log-share.settings.auto-upload',
|
||||
defaultMessage: 'Upload to get a structured summary automatically',
|
||||
},
|
||||
autoUploadDescription: {
|
||||
id: 'app.log-share.settings.auto-upload-description',
|
||||
defaultMessage: 'Only effective in LogShare AI mode.',
|
||||
},
|
||||
multiFile: { id: 'app.log-share.settings.multi-file', defaultMessage: 'Multi-file upload' },
|
||||
multiFileDescription: {
|
||||
id: 'app.log-share.settings.multi-file-description',
|
||||
defaultMessage: 'Upload latest.log, crash reports, hs_err and launcher logs together.',
|
||||
},
|
||||
noStorage: {
|
||||
id: 'app.log-share.settings.no-storage',
|
||||
defaultMessage: 'Analyze without storing logs',
|
||||
},
|
||||
noStorageDescription: {
|
||||
id: 'app.log-share.settings.no-storage-description',
|
||||
defaultMessage:
|
||||
'Submit content directly for analysis and skip the stored upload. Disables the automatic summary.',
|
||||
},
|
||||
showProgress: {
|
||||
id: 'app.log-share.settings.show-progress',
|
||||
defaultMessage: 'Show AI analysis progress',
|
||||
},
|
||||
showProgressDescription: {
|
||||
id: 'app.log-share.settings.show-progress-description',
|
||||
defaultMessage: 'Display thinking, tool and limit status while LogShare AI is working.',
|
||||
},
|
||||
})
|
||||
|
||||
const emptyState: AIState = { settings: { enabled: false }, catalog_source: '', providers: [] }
|
||||
const aiState = computed(() => sharedAIState.value ?? emptyState)
|
||||
const providers = computed(() =>
|
||||
aiState.value.providers.filter(
|
||||
(provider) => provider.enabled && provider.models.some((model) => model.enabled),
|
||||
),
|
||||
)
|
||||
const providerOptions = computed(() =>
|
||||
providers.value.map((provider) => ({
|
||||
value: provider.provider_id,
|
||||
label: provider.custom_name || provider.provider_id,
|
||||
})),
|
||||
)
|
||||
const modelOptions = computed(
|
||||
() =>
|
||||
providers.value
|
||||
.find((provider) => provider.provider_id === aiSettings.value.provider_id)
|
||||
?.models.filter((model) => model.enabled)
|
||||
.map((model) => ({ value: model.id, label: model.name || model.id })) ?? [],
|
||||
)
|
||||
|
||||
const isCustom = computed(() => aiSettings.value.ai_source === 'custom')
|
||||
const noStorageEnabled = computed(() => aiSettings.value.ai_source === 'logshare')
|
||||
|
||||
const shareProviderOptions = [
|
||||
{ value: 'logshare', label: 'LogShare' },
|
||||
{ value: 'mclogs', label: 'mclo.gs' },
|
||||
]
|
||||
const aiSourceOptions = [
|
||||
{ value: 'logshare', label: formatMessage(messages.aiSourceLogShare) },
|
||||
{ value: 'custom', label: formatMessage(messages.aiSourceCustom) },
|
||||
]
|
||||
|
||||
async function saveShare(next: LogShareSettings): Promise<void> {
|
||||
saving.value = true
|
||||
try {
|
||||
await update_log_share_settings(next)
|
||||
settings.value = next
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveAI(next: CrashAISettings): Promise<void> {
|
||||
saving.value = true
|
||||
try {
|
||||
await update_crash_analysis_ai_settings(next)
|
||||
aiSettings.value = next
|
||||
settings.value = { ...settings.value, ai_source: next.ai_source }
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function updateShare(patch: Partial<LogShareSettings>): void {
|
||||
void saveShare({ ...settings.value, ...patch })
|
||||
}
|
||||
|
||||
function selectShareProvider(value: unknown): void {
|
||||
const provider = value === 'mclogs' ? 'mclogs' : 'logshare'
|
||||
updateShare({ share_provider: provider, ai_source: aiSettings.value.ai_source })
|
||||
}
|
||||
|
||||
function selectAiSource(value: unknown): void {
|
||||
const source = value === 'custom' ? 'custom' : 'logshare'
|
||||
void saveAI({ ...aiSettings.value, ai_source: source })
|
||||
}
|
||||
|
||||
function updateEnabled(enabled: boolean): void {
|
||||
void saveAI({ ...aiSettings.value, enabled })
|
||||
}
|
||||
|
||||
function updateProvider(providerId: string): void {
|
||||
const provider = providers.value.find((item) => item.provider_id === providerId)
|
||||
const modelId = provider?.models.find((model) => model.enabled)?.id ?? ''
|
||||
void saveAI({ ...aiSettings.value, provider_id: providerId, model_id: modelId })
|
||||
}
|
||||
|
||||
function updateModel(modelId: string): void {
|
||||
void saveAI({ ...aiSettings.value, model_id: modelId })
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const [nextShare, nextAI] = await Promise.all([
|
||||
get_log_share_settings(),
|
||||
get_crash_analysis_ai_settings(),
|
||||
getAIState(),
|
||||
])
|
||||
settings.value = { ...nextShare, ai_source: nextAI.ai_source }
|
||||
aiSettings.value = nextAI
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SettingsSection
|
||||
v-if="!loading"
|
||||
id="settings-target-log-share"
|
||||
:title="formatMessage(messages.title)"
|
||||
:description="formatMessage(messages.description)"
|
||||
>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.shareProvider) }}</template>
|
||||
<template #description>{{ formatMessage(messages.shareProviderDescription) }}</template>
|
||||
<template #control>
|
||||
<Combobox
|
||||
id="log-share-provider"
|
||||
:model-value="settings.share_provider"
|
||||
:options="shareProviderOptions"
|
||||
:disabled="saving"
|
||||
@update:model-value="selectShareProvider($event)"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.aiSource) }}</template>
|
||||
<template #description>{{ formatMessage(messages.aiSourceDescription) }}</template>
|
||||
<template #control>
|
||||
<Combobox
|
||||
id="log-share-ai-source"
|
||||
:model-value="aiSettings.ai_source"
|
||||
:options="aiSourceOptions"
|
||||
:disabled="saving"
|
||||
@update:model-value="selectAiSource($event)"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<template v-if="isCustom">
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.enabled) }}</template>
|
||||
<template #description>{{ formatMessage(messages.enabledDescription) }}</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="crash-analysis-ai-enabled"
|
||||
:model-value="aiSettings.enabled"
|
||||
:disabled="saving || !aiState.settings.enabled || !providers.length"
|
||||
@update:model-value="updateEnabled(!!$event)"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<template v-if="providers.length">
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.provider) }}</template>
|
||||
<template #control>
|
||||
<Combobox
|
||||
id="crash-analysis-ai-provider"
|
||||
:model-value="aiSettings.provider_id"
|
||||
:options="providerOptions"
|
||||
:disabled="saving"
|
||||
@update:model-value="updateProvider(String($event))"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.model) }}</template>
|
||||
<template #control>
|
||||
<Combobox
|
||||
id="crash-analysis-ai-model"
|
||||
:model-value="aiSettings.model_id"
|
||||
:options="modelOptions"
|
||||
:disabled="saving || !aiSettings.provider_id"
|
||||
@update:model-value="updateModel(String($event))"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</template>
|
||||
<p v-else class="m-0 p-4 text-sm text-[var(--color-text-tertiary)]">
|
||||
{{ formatMessage(messages.noProviders) }}
|
||||
</p>
|
||||
</template>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.autoUpload) }}</template>
|
||||
<template #description>{{ formatMessage(messages.autoUploadDescription) }}</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="log-share-auto-upload"
|
||||
:model-value="settings.auto_upload"
|
||||
:disabled="saving || !noStorageEnabled || settings.no_storage"
|
||||
@update:model-value="updateShare({ auto_upload: !!$event })"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.multiFile) }}</template>
|
||||
<template #description>{{ formatMessage(messages.multiFileDescription) }}</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="log-share-multi-file"
|
||||
:model-value="settings.multi_file"
|
||||
:disabled="saving"
|
||||
@update:model-value="updateShare({ multi_file: !!$event })"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.noStorage) }}</template>
|
||||
<template #description>{{ formatMessage(messages.noStorageDescription) }}</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="log-share-no-storage"
|
||||
:model-value="settings.no_storage"
|
||||
:disabled="saving || !noStorageEnabled"
|
||||
@update:model-value="updateShare({ no_storage: !!$event })"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
<SettingsRow>
|
||||
<template #label>{{ formatMessage(messages.showProgress) }}</template>
|
||||
<template #description>{{ formatMessage(messages.showProgressDescription) }}</template>
|
||||
<template #control>
|
||||
<Toggle
|
||||
id="log-share-show-progress"
|
||||
:model-value="settings.show_progress"
|
||||
:disabled="saving"
|
||||
@update:model-value="updateShare({ show_progress: !!$event })"
|
||||
/>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
</template>
|
||||
@@ -0,0 +1,129 @@
|
||||
<script setup lang="ts">
|
||||
import { Button, defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { delete_shared_log, list_shared_logs } from '@/helpers/logs'
|
||||
|
||||
import SettingsRow from './SettingsRow.vue'
|
||||
import SettingsSection from './SettingsSection.vue'
|
||||
|
||||
type SharedLog = {
|
||||
id: string
|
||||
url: string
|
||||
raw: string
|
||||
token: string
|
||||
provider: string
|
||||
instance_id: string | null
|
||||
instance_name: string | null
|
||||
truncated: boolean
|
||||
created_at: number
|
||||
}
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { addNotification, handleError } = injectNotificationManager()
|
||||
const logs = ref<SharedLog[]>([])
|
||||
const loading = ref(true)
|
||||
const deletingId = ref<string | null>(null)
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.log-share.shared-logs.title', defaultMessage: 'Shared logs' },
|
||||
description: {
|
||||
id: 'app.log-share.shared-logs.description',
|
||||
defaultMessage:
|
||||
'Every diagnostic you have shared is listed here. Delete an entry to remove it from your history and request its removal from the sharing service.',
|
||||
},
|
||||
empty: { id: 'app.log-share.shared-logs.empty', defaultMessage: 'No shared logs yet.' },
|
||||
delete: { id: 'app.log-share.shared-logs.delete', defaultMessage: 'Delete' },
|
||||
deleting: { id: 'app.log-share.shared-logs.deleting', defaultMessage: 'Deleting…' },
|
||||
deleted: {
|
||||
id: 'app.log-share.shared-logs.deleted',
|
||||
defaultMessage: 'Shared log removed.',
|
||||
},
|
||||
deleteFailed: {
|
||||
id: 'app.log-share.shared-logs.delete-failed',
|
||||
defaultMessage: 'Failed to delete the shared log.',
|
||||
},
|
||||
truncated: { id: 'app.log-share.shared-logs.truncated', defaultMessage: 'Truncated' },
|
||||
})
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
try {
|
||||
logs.value = await list_shared_logs()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(log: SharedLog): Promise<void> {
|
||||
if (deletingId.value) return
|
||||
deletingId.value = log.id
|
||||
try {
|
||||
await delete_shared_log(log.id, log.token)
|
||||
logs.value = logs.value.filter((item) => item.id !== log.id)
|
||||
addNotification({ title: formatMessage(messages.deleted), type: 'success' })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
addNotification({ title: formatMessage(messages.deleteFailed), type: 'error' })
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(timestamp: number): string {
|
||||
return new Date(timestamp * 1000).toLocaleString()
|
||||
}
|
||||
|
||||
onMounted(refresh)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<SettingsSection
|
||||
id="settings-target-shared-logs"
|
||||
:title="formatMessage(messages.title)"
|
||||
:description="formatMessage(messages.description)"
|
||||
>
|
||||
<SettingsRow stacked>
|
||||
<template #control>
|
||||
<div class="flex w-full min-w-0 flex-col gap-2">
|
||||
<p v-if="loading" class="m-0 p-2 text-sm text-[var(--color-text-tertiary)]">…</p>
|
||||
<p v-else-if="!logs.length" class="m-0 p-2 text-sm text-[var(--color-text-tertiary)]">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<ul v-else class="m-0 flex max-h-72 list-none flex-col gap-1 overflow-y-auto p-2">
|
||||
<li
|
||||
v-for="log in logs"
|
||||
:key="log.id"
|
||||
class="flex items-center gap-3 rounded-lg bg-surface-2 px-3 py-2"
|
||||
>
|
||||
<a
|
||||
:href="log.url || `https://logshare.cn/${log.id}`"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="min-w-0 flex-1 truncate text-[var(--color-text-default)] underline"
|
||||
>
|
||||
{{ log.url || log.id }}
|
||||
</a>
|
||||
<span class="shrink-0 text-xs text-[var(--color-text-tertiary)]">
|
||||
{{ log.provider }}
|
||||
<template v-if="log.truncated">
|
||||
· {{ formatMessage(messages.truncated) }}
|
||||
</template>
|
||||
<template v-if="log.instance_name"> · {{ log.instance_name }} </template>
|
||||
· {{ formatDate(log.created_at) }}
|
||||
</span>
|
||||
<Button type="outlined" :disabled="deletingId === log.id" @click="remove(log)"
|
||||
>{{
|
||||
deletingId === log.id
|
||||
? formatMessage(messages.deleting)
|
||||
: formatMessage(messages.delete)
|
||||
}}
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</SettingsRow>
|
||||
</SettingsSection>
|
||||
</template>
|
||||
@@ -3,6 +3,7 @@ import type { MessageDescriptor } from '@modrinth/ui'
|
||||
export type SettingsCategoryId =
|
||||
| 'interface'
|
||||
| 'home-navigation'
|
||||
| 'shortcut-settings'
|
||||
| 'language-translation'
|
||||
| 'ai'
|
||||
| 'java-performance'
|
||||
@@ -45,6 +46,15 @@ export const settingsCategoryDefinitions: SettingsCategoryDefinition[] = [
|
||||
group: 'launcher',
|
||||
onboardingId: 'settings-tab-home-navigation',
|
||||
},
|
||||
{
|
||||
id: 'shortcut-settings',
|
||||
name: {
|
||||
id: 'app.settings.tabs.shortcut-settings',
|
||||
defaultMessage: 'Keyboard shortcuts',
|
||||
},
|
||||
group: 'launcher',
|
||||
onboardingId: 'settings-tab-shortcut-settings',
|
||||
},
|
||||
{
|
||||
id: 'language-translation',
|
||||
name: {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
GameIcon,
|
||||
GaugeIcon,
|
||||
InfoIcon,
|
||||
KeyboardIcon,
|
||||
LanguagesIcon,
|
||||
LayoutTemplateIcon,
|
||||
PaintbrushIcon,
|
||||
@@ -49,6 +50,10 @@ const categoryContent: Record<SettingsCategoryId, Pick<SettingsCategory, 'icon'
|
||||
icon: LayoutTemplateIcon,
|
||||
content: defineAsyncComponent(() => import('./HomeNavigationSettings.vue')),
|
||||
},
|
||||
'shortcut-settings': {
|
||||
icon: KeyboardIcon,
|
||||
content: defineAsyncComponent(() => import('./KeybindSettings.vue')),
|
||||
},
|
||||
'language-translation': {
|
||||
icon: LanguagesIcon,
|
||||
content: defineAsyncComponent(() => import('./LanguageTranslationSettings.vue')),
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
<script setup lang="ts">
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
|
||||
import { type SkinSiteChatUserInfo, skinSiteChatUserSearch } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
roomId?: number
|
||||
label?: string
|
||||
placeholder?: string
|
||||
excludeUuids?: string[]
|
||||
allowedUuids?: string[]
|
||||
allowedHint?: string
|
||||
}>(),
|
||||
{
|
||||
roomId: undefined,
|
||||
label: undefined,
|
||||
placeholder: undefined,
|
||||
excludeUuids: () => [],
|
||||
allowedUuids: undefined,
|
||||
allowedHint: undefined,
|
||||
},
|
||||
)
|
||||
|
||||
const model = defineModel<SkinSiteChatUserInfo | null>({ required: true })
|
||||
|
||||
const messages = defineMessages({
|
||||
label: { id: 'app.skin-site.chat.user-picker.label', defaultMessage: 'Pick a user' },
|
||||
placeholder: {
|
||||
id: 'app.skin-site.chat.user-picker.placeholder',
|
||||
defaultMessage: 'Search username, email or account ID',
|
||||
},
|
||||
byUser: { id: 'app.skin-site.chat.user-picker.by-user', defaultMessage: 'By user' },
|
||||
byPlayer: { id: 'app.skin-site.chat.user-picker.by-player', defaultMessage: 'By player' },
|
||||
hint: {
|
||||
id: 'app.skin-site.chat.user-picker.hint',
|
||||
defaultMessage: 'Fuzzy search on username and email, or search by account ID.',
|
||||
},
|
||||
playerHint: {
|
||||
id: 'app.skin-site.chat.user-picker.player-hint',
|
||||
defaultMessage: 'Enter a player name to find the bound user.',
|
||||
},
|
||||
empty: {
|
||||
id: 'app.skin-site.chat.user-picker.empty',
|
||||
defaultMessage: 'No matching user.',
|
||||
},
|
||||
banned: {
|
||||
id: 'app.skin-site.chat.user-picker.banned',
|
||||
defaultMessage: 'This account is banned.',
|
||||
},
|
||||
guest: {
|
||||
id: 'app.skin-site.chat.user-picker.guest',
|
||||
defaultMessage: 'Guests cannot become a manager or settlement owner.',
|
||||
},
|
||||
alreadyIn: {
|
||||
id: 'app.skin-site.chat.user-picker.already-in',
|
||||
defaultMessage: 'This user is already in the room.',
|
||||
},
|
||||
notAllowed: {
|
||||
id: 'app.skin-site.chat.user-picker.not-allowed',
|
||||
defaultMessage: 'This user is outside the allowed range.',
|
||||
},
|
||||
select: { id: 'app.skin-site.chat.user-picker.select', defaultMessage: 'Select' },
|
||||
selected: {
|
||||
id: 'app.skin-site.chat.user-picker.selected',
|
||||
defaultMessage: 'Selected',
|
||||
},
|
||||
idLabel: { id: 'app.skin-site.chat.user-picker.id', defaultMessage: 'ID' },
|
||||
})
|
||||
|
||||
const keyword = ref('')
|
||||
const searchMode = ref<'user' | 'player'>('user')
|
||||
const results = ref<SkinSiteChatUserInfo[]>([])
|
||||
const preview = ref<SkinSiteChatUserInfo | null>(null)
|
||||
const loading = ref(false)
|
||||
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
let requestId = 0
|
||||
|
||||
const currentLabel = computed(() => props.label ?? formatMessage(messages.label))
|
||||
const currentPlaceholder = computed(
|
||||
() => props.placeholder ?? formatMessage(messages.placeholder),
|
||||
)
|
||||
|
||||
watch([keyword, searchMode], () => {
|
||||
clearTimeout(timer)
|
||||
const query = keyword.value.trim()
|
||||
if (!query) {
|
||||
results.value = []
|
||||
preview.value = null
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
timer = setTimeout(() => void search(query), 300)
|
||||
})
|
||||
|
||||
watch(model, (value) => {
|
||||
if (value) return
|
||||
keyword.value = ''
|
||||
preview.value = null
|
||||
results.value = []
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.roomId,
|
||||
() => {
|
||||
model.value = null
|
||||
},
|
||||
)
|
||||
|
||||
onBeforeUnmount(() => clearTimeout(timer))
|
||||
|
||||
async function search(query: string) {
|
||||
const current = ++requestId
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await skinSiteChatUserSearch(query, props.roomId, searchMode.value)
|
||||
if (current !== requestId) return
|
||||
if (!res.success) throw new Error(res.errorMessage)
|
||||
results.value = res.payload ?? []
|
||||
preview.value = results.value.length === 1 ? results.value[0] : null
|
||||
} catch (error) {
|
||||
if (current === requestId) {
|
||||
results.value = []
|
||||
handleError(error)
|
||||
}
|
||||
} finally {
|
||||
if (current === requestId) loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function unavailableReason(user: SkinSiteChatUserInfo): string | null {
|
||||
if (user.banned) return formatMessage(messages.banned)
|
||||
if (user.permissions.includes('GUEST')) return formatMessage(messages.guest)
|
||||
if (props.excludeUuids.includes(user.uuid)) return formatMessage(messages.alreadyIn)
|
||||
if (props.allowedUuids && !props.allowedUuids.includes(user.uuid)) {
|
||||
return props.allowedHint ?? formatMessage(messages.notAllowed)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function selectPreview() {
|
||||
if (preview.value && !unavailableReason(preview.value)) {
|
||||
model.value = preview.value
|
||||
}
|
||||
}
|
||||
|
||||
function formatTime(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return '—'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<span class="text-xs font-semibold text-secondary">{{ currentLabel }}</span>
|
||||
<div class="flex gap-2">
|
||||
<select
|
||||
v-model="searchMode"
|
||||
class="shrink-0 rounded-lg border border-solid border-surface-5 bg-bg-raised px-2 py-1.5 text-xs text-contrast outline-none focus:border-brand"
|
||||
>
|
||||
<option value="user">{{ formatMessage(messages.byUser) }}</option>
|
||||
<option value="player">{{ formatMessage(messages.byPlayer) }}</option>
|
||||
</select>
|
||||
<input
|
||||
v-model.trim="keyword"
|
||||
type="text"
|
||||
maxlength="100"
|
||||
:placeholder="searchMode === 'player' ? formatMessage(messages.playerHint) : currentPlaceholder"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg-raised px-3 py-1.5 text-xs text-contrast outline-none focus:border-brand"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<span class="text-[11px] text-secondary">
|
||||
{{ searchMode === 'player' ? formatMessage(messages.playerHint) : formatMessage(messages.hint) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="keyword && !loading"
|
||||
class="flex max-h-56 flex-col gap-1.5 overflow-y-auto rounded-lg border border-solid border-surface-5 bg-bg-raised p-2"
|
||||
>
|
||||
<button
|
||||
v-for="user in results"
|
||||
:key="user.uuid"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between gap-3 rounded-lg border border-solid p-2 text-left transition-colors"
|
||||
:class="
|
||||
preview?.uuid === user.uuid
|
||||
? 'border-brand bg-brand/10'
|
||||
: 'border-transparent bg-bg hover:border-surface-5'
|
||||
"
|
||||
@click="preview = user"
|
||||
>
|
||||
<span class="flex min-w-0 items-center gap-2">
|
||||
<span class="grid size-8 shrink-0 place-items-center rounded-lg bg-brand/15 text-xs font-bold text-brand">
|
||||
{{ user.username.slice(0, 1).toUpperCase() }}
|
||||
</span>
|
||||
<span class="min-w-0">
|
||||
<strong class="block truncate text-xs text-contrast">{{ user.username }}</strong>
|
||||
<span class="block truncate text-[10px] text-secondary">
|
||||
{{ formatMessage(messages.idLabel) }} {{ user.id }} · {{ user.email }}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="unavailableReason(user)"
|
||||
class="shrink-0 rounded-full bg-red/20 px-2 py-0.5 text-[10px] font-semibold text-red"
|
||||
>
|
||||
{{ unavailableReason(user) }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="model?.uuid === user.uuid"
|
||||
class="shrink-0 rounded-full bg-brand px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.selected) }}
|
||||
</span>
|
||||
</button>
|
||||
<p v-if="!results.length" class="m-0 py-4 text-center text-xs text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section
|
||||
v-if="preview"
|
||||
class="flex flex-col gap-3 rounded-lg border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="m-0 text-sm font-bold text-contrast">{{ preview.username }}</h3>
|
||||
<p class="m-0 text-[11px] text-secondary">
|
||||
{{ formatMessage(messages.idLabel) }} {{ preview.id }}
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="preview.banned ? 'bg-red text-contrast' : 'bg-green text-contrast'"
|
||||
>
|
||||
{{ preview.banned ? 'Banned' : 'OK' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="grid gap-2 text-[11px] sm:grid-cols-2">
|
||||
<div class="min-w-0">
|
||||
<span class="block text-secondary">UUID</span>
|
||||
<span class="block break-all font-mono text-contrast">{{ preview.uuid }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="block text-secondary">Email</span>
|
||||
<span class="block break-all text-contrast">{{ preview.email }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="block text-secondary">QQ</span>
|
||||
<span class="block text-contrast">{{ preview.qq ?? '—' }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span class="block text-secondary">Registered</span>
|
||||
<span class="block text-contrast">{{ formatTime(preview.registerTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1.5">
|
||||
<span
|
||||
v-for="perm in preview.permissions"
|
||||
:key="perm"
|
||||
class="rounded bg-bg px-2 py-0.5 font-mono text-[10px] text-secondary"
|
||||
>
|
||||
{{ perm }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="unavailableReason(preview)" class="m-0 text-[11px] text-red">
|
||||
{{ unavailableReason(preview) }}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded-lg bg-brand px-3 py-2 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="Boolean(unavailableReason(preview))"
|
||||
@click="selectPreview"
|
||||
>
|
||||
{{ model?.uuid === preview.uuid ? formatMessage(messages.selected) : formatMessage(messages.select) }}
|
||||
</button>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import { loadCachedRoomAvatar } from './room-avatar-cache'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
roomId: number
|
||||
avatarAttachmentId?: number | null
|
||||
name: string
|
||||
size?: 'sm' | 'md' | 'lg' | 'xl'
|
||||
}>(),
|
||||
{ avatarAttachmentId: null, size: 'md' },
|
||||
)
|
||||
|
||||
const avatarUrl = ref<string | null>(null)
|
||||
const loading = ref(false)
|
||||
|
||||
const sizeClass = computed(
|
||||
() =>
|
||||
({
|
||||
sm: 'size-9 rounded-lg text-lg',
|
||||
md: 'size-10 rounded-lg text-xl',
|
||||
lg: 'size-12 rounded-lg text-2xl',
|
||||
xl: 'size-20 rounded-xl text-3xl',
|
||||
})[props.size],
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [props.roomId, props.avatarAttachmentId] as const,
|
||||
async ([roomId, attachmentId]) => {
|
||||
avatarUrl.value = null
|
||||
if (!attachmentId) {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
const url = await loadCachedRoomAvatar(roomId, attachmentId)
|
||||
if (props.roomId === roomId && props.avatarAttachmentId === attachmentId) {
|
||||
avatarUrl.value = url
|
||||
}
|
||||
loading.value = false
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="grid shrink-0 place-items-center overflow-hidden border border-solid border-surface-5 bg-brand/10 font-bold text-brand"
|
||||
:class="sizeClass"
|
||||
>
|
||||
<img
|
||||
v-if="avatarUrl"
|
||||
:src="avatarUrl"
|
||||
:alt="name"
|
||||
class="h-full w-full object-cover"
|
||||
decoding="async"
|
||||
/>
|
||||
<span v-else-if="loading" class="text-[10px] text-secondary">…</span>
|
||||
<span v-else class="select-none">#</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,161 @@
|
||||
<script setup lang="ts">
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onBeforeUnmount, ref, watch } from 'vue'
|
||||
|
||||
import { skinSiteChatAttachmentUpload } from '@/helpers/skin-site-api'
|
||||
|
||||
import RoomAvatar from './RoomAvatar.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
roomId?: number
|
||||
avatarAttachmentId?: number | null
|
||||
name: string
|
||||
token?: string | null
|
||||
remove?: boolean
|
||||
}>(),
|
||||
{ roomId: 0, avatarAttachmentId: null, token: null, remove: false },
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:token', value: string | null): void
|
||||
(e: 'update:remove', value: boolean): void
|
||||
(e: 'update:uploading', value: boolean): void
|
||||
}>()
|
||||
|
||||
const messages = defineMessages({
|
||||
label: { id: 'app.skin-site.chat.avatar.label', defaultMessage: 'Room avatar' },
|
||||
upload: { id: 'app.skin-site.chat.avatar.upload', defaultMessage: 'Upload avatar' },
|
||||
replace: { id: 'app.skin-site.chat.avatar.replace', defaultMessage: 'Replace avatar' },
|
||||
remove: { id: 'app.skin-site.chat.avatar.remove', defaultMessage: 'Remove avatar' },
|
||||
hint: {
|
||||
id: 'app.skin-site.chat.avatar.hint',
|
||||
defaultMessage: 'PNG, JPEG or WebP, up to 8192 px per side and 5 MB.',
|
||||
},
|
||||
badFormat: {
|
||||
id: 'app.skin-site.chat.avatar.bad-format',
|
||||
defaultMessage: 'Only PNG, JPEG and WebP are supported.',
|
||||
},
|
||||
tooLarge: {
|
||||
id: 'app.skin-site.chat.avatar.too-large',
|
||||
defaultMessage: 'Avatar must not exceed 5 MB.',
|
||||
},
|
||||
notImage: {
|
||||
id: 'app.skin-site.chat.avatar.not-image',
|
||||
defaultMessage: 'Avatar must be an image.',
|
||||
},
|
||||
})
|
||||
|
||||
const MAX_BYTES = 5 * 1024 * 1024
|
||||
const ALLOWED = ['png', 'jpg', 'jpeg', 'webp']
|
||||
|
||||
const uploading = ref(false)
|
||||
const previewUrl = ref<string | null>(null)
|
||||
|
||||
watch(
|
||||
() => props.token,
|
||||
(token) => {
|
||||
if (!token) revokePreview()
|
||||
},
|
||||
)
|
||||
|
||||
function revokePreview() {
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value)
|
||||
previewUrl.value = null
|
||||
}
|
||||
|
||||
async function selectAvatar(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const ext = file.name.split('.').pop()?.toLowerCase()
|
||||
if (!ext || !ALLOWED.includes(ext)) {
|
||||
addNotification({ type: 'error', title: formatMessage(messages.badFormat) })
|
||||
return
|
||||
}
|
||||
if (file.size > MAX_BYTES) {
|
||||
addNotification({ type: 'error', title: formatMessage(messages.tooLarge) })
|
||||
return
|
||||
}
|
||||
|
||||
uploading.value = true
|
||||
emit('update:uploading', true)
|
||||
try {
|
||||
const res = await skinSiteChatAttachmentUpload(file)
|
||||
if (!res.success) throw new Error(res.errorMessage)
|
||||
if (res.payload.attachment.kind !== 'IMAGE') {
|
||||
addNotification({ type: 'error', title: formatMessage(messages.notImage) })
|
||||
return
|
||||
}
|
||||
revokePreview()
|
||||
previewUrl.value = URL.createObjectURL(file)
|
||||
emit('update:token', res.payload.token)
|
||||
emit('update:remove', false)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
uploading.value = false
|
||||
emit('update:uploading', false)
|
||||
}
|
||||
}
|
||||
|
||||
function removeAvatar() {
|
||||
revokePreview()
|
||||
emit('update:token', null)
|
||||
emit('update:remove', true)
|
||||
}
|
||||
|
||||
onBeforeUnmount(revokePreview)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-xs font-semibold text-secondary">
|
||||
{{ formatMessage(messages.label) }}
|
||||
</span>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<div
|
||||
v-if="previewUrl"
|
||||
class="size-20 overflow-hidden rounded-xl border border-solid border-surface-5 bg-bg-raised"
|
||||
>
|
||||
<img :src="previewUrl" alt="" class="h-full w-full object-cover" />
|
||||
</div>
|
||||
<RoomAvatar
|
||||
v-else
|
||||
:room-id="roomId"
|
||||
:avatar-attachment-id="remove ? null : avatarAttachmentId"
|
||||
:name="name || 'Room'"
|
||||
size="xl"
|
||||
/>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label
|
||||
class="cursor-pointer rounded-lg bg-button-bg px-3 py-1.5 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
:class="uploading ? 'pointer-events-none opacity-50' : ''"
|
||||
>
|
||||
{{ uploading ? '…' : (avatarAttachmentId || previewUrl ? formatMessage(messages.replace) : formatMessage(messages.upload)) }}
|
||||
<input
|
||||
type="file"
|
||||
class="hidden"
|
||||
accept=".png,.jpg,.jpeg,.webp"
|
||||
@change="selectAvatar"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="previewUrl || (avatarAttachmentId && !remove)"
|
||||
type="button"
|
||||
class="rounded-lg bg-red/20 px-3 py-1.5 text-xs font-semibold text-red hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="uploading"
|
||||
@click="removeAvatar"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="m-0 text-[11px] text-secondary">{{ formatMessage(messages.hint) }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,171 @@
|
||||
<script setup lang="ts">
|
||||
import { SparklesIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { Avatar, ButtonStyled, defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
requestSkinSiteLuck,
|
||||
skinSitePlayers,
|
||||
skinSitePlayersStatus,
|
||||
skinSiteStatus,
|
||||
skinSiteUser,
|
||||
} from '@/composables/skin-site-session'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const messages = defineMessages({
|
||||
signedOutTitle: { id: 'app.skin-site.home.signed-out-title', defaultMessage: 'Not signed in' },
|
||||
signedOutBody: {
|
||||
id: 'app.skin-site.home.signed-out-body',
|
||||
defaultMessage: 'Sign in to the StarLight skin site to manage players and download packs.',
|
||||
},
|
||||
players: { id: 'app.skin-site.home.players', defaultMessage: 'Your players' },
|
||||
noPlayers: {
|
||||
id: 'app.skin-site.home.no-players',
|
||||
defaultMessage: 'No players yet. Add one on the skin site.',
|
||||
},
|
||||
luck: { id: 'app.skin-site.home.luck', defaultMessage: "Today's luck" },
|
||||
luckUnavailable: { id: 'app.skin-site.home.luck-unavailable', defaultMessage: 'Unavailable' },
|
||||
loading: { id: 'app.skin-site.home.loading', defaultMessage: 'Loading…' },
|
||||
error: { id: 'app.skin-site.home.error', defaultMessage: 'Could not load players.' },
|
||||
signIn: { id: 'app.skin-site.home.sign-in', defaultMessage: 'Sign in' },
|
||||
settings: { id: 'app.skin-site.home.settings', defaultMessage: 'Account' },
|
||||
admin: { id: 'app.skin-site.home.admin', defaultMessage: 'Admin' },
|
||||
myPlayers: { id: 'app.skin-site.home.my-players', defaultMessage: 'My players' },
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'sign-in' | 'open-settings' | 'open-players' | 'open-admin'): void
|
||||
}>()
|
||||
|
||||
const luck = ref<number | null>(null)
|
||||
const luckLoading = ref(false)
|
||||
|
||||
const signedIn = computed(() => skinSiteStatus.value === 'signed-in' && !!skinSiteUser.value)
|
||||
|
||||
const isAdmin = computed(() => {
|
||||
const permissions = skinSiteUser.value?.permissions ?? []
|
||||
return permissions.includes('WEB_ADMIN') || permissions.includes('SERVER_ADMIN')
|
||||
})
|
||||
const players = computed(() => skinSitePlayers.value)
|
||||
const playersLoading = computed(
|
||||
() => skinSitePlayersStatus.value === 'checking' || skinSitePlayersStatus.value === 'idle',
|
||||
)
|
||||
const playersError = computed(() => skinSitePlayersStatus.value === 'error')
|
||||
|
||||
async function loadLuck() {
|
||||
if (!signedIn.value) {
|
||||
luck.value = null
|
||||
return
|
||||
}
|
||||
luckLoading.value = true
|
||||
try {
|
||||
luck.value = await requestSkinSiteLuck()
|
||||
} catch {
|
||||
luck.value = null
|
||||
} finally {
|
||||
luckLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadLuck)
|
||||
watch(signedIn, loadLuck)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col gap-4 rounded-2xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<div v-if="!signedIn" class="flex flex-col items-start gap-2">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">
|
||||
{{ formatMessage(messages.signedOutTitle) }}
|
||||
</h3>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.signedOutBody) }}</p>
|
||||
<ButtonStyled color="brand">
|
||||
<button type="button" @click="emit('sign-in')">
|
||||
{{ formatMessage(messages.signIn) }}
|
||||
</button>
|
||||
</ButtonStyled>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="flex size-10 shrink-0 items-center justify-center rounded-full bg-brand-highlight text-lg font-bold text-contrast"
|
||||
>
|
||||
{{ skinSiteUser!.username.slice(0, 1).toUpperCase() }}
|
||||
</div>
|
||||
<div class="flex min-w-0 flex-col">
|
||||
<span class="truncate font-semibold text-contrast">{{ skinSiteUser!.username }}</span>
|
||||
<span class="truncate text-xs text-secondary">{{ skinSiteUser!.uuid }}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('open-settings')"
|
||||
>
|
||||
{{ formatMessage(messages.settings) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="isAdmin"
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('open-admin')"
|
||||
>
|
||||
{{ formatMessage(messages.admin) }}
|
||||
</button>
|
||||
<div
|
||||
class="ml-auto flex shrink-0 items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-sm"
|
||||
:title="formatMessage(messages.luck)"
|
||||
>
|
||||
<SpinnerIcon v-if="luckLoading" class="size-4 animate-spin" />
|
||||
<template v-else-if="luck !== null">
|
||||
<SparklesIcon class="size-4 text-brand" />
|
||||
<span class="font-semibold text-contrast">{{ luck }}</span>
|
||||
</template>
|
||||
<span v-else class="text-xs text-secondary">{{
|
||||
formatMessage(messages.luckUnavailable)
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.players)
|
||||
}}</span>
|
||||
|
||||
<div v-if="playersLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="playersError" class="m-0 text-sm text-red">
|
||||
{{ formatMessage(messages.error) }}
|
||||
</p>
|
||||
<p v-else-if="!players.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.noPlayers) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-wrap gap-3">
|
||||
<div
|
||||
v-for="player in players"
|
||||
:key="player.uuid"
|
||||
class="flex items-center gap-2 rounded-xl bg-button-bg px-2 py-1.5"
|
||||
>
|
||||
<Avatar
|
||||
:src="player.headDataUrl"
|
||||
:alt="player.name"
|
||||
size="2rem"
|
||||
pixelated
|
||||
class="!rounded-md"
|
||||
/>
|
||||
<div class="flex flex-col">
|
||||
<span class="text-sm font-medium text-contrast">{{ player.name }}</span>
|
||||
<span v-if="player.isMojang" class="text-[10px] uppercase text-secondary"
|
||||
>Mojang</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,194 @@
|
||||
<script setup lang="ts">
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { skinSiteUser } from '@/composables/skin-site-session'
|
||||
|
||||
import AdminAccessAuditPage from './admin/AdminAccessAuditPage.vue'
|
||||
import AdminBroadcastPage from './admin/AdminBroadcastPage.vue'
|
||||
import AdminChatPage from './admin/AdminChatPage.vue'
|
||||
import AdminDonationsPage from './admin/AdminDonationsPage.vue'
|
||||
import AdminDownloadsPage from './admin/AdminDownloadsPage.vue'
|
||||
import AdminLauncherPage from './admin/AdminLauncherPage.vue'
|
||||
import AdminModsPage from './admin/AdminModsPage.vue'
|
||||
import AdminPlayersPage from './admin/AdminPlayersPage.vue'
|
||||
import AdminReviewPage from './admin/AdminReviewPage.vue'
|
||||
import AdminServersPage from './admin/AdminServersPage.vue'
|
||||
import AdminSummaryPage from './admin/AdminSummaryPage.vue'
|
||||
import AdminUsersPage from './admin/AdminUsersPage.vue'
|
||||
import AdminWikiPage from './admin/AdminWikiPage.vue'
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.title', defaultMessage: 'Admin console' },
|
||||
back: { id: 'app.skin-site.admin.back', defaultMessage: 'Back to home' },
|
||||
noAccess: { id: 'app.skin-site.admin.no-access', defaultMessage: 'You do not have access.' },
|
||||
noAccessHint: {
|
||||
id: 'app.skin-site.admin.no-access-hint',
|
||||
defaultMessage: 'Sign in with an administrator account to use this console.',
|
||||
},
|
||||
groupSecurity: { id: 'app.skin-site.admin.group.security', defaultMessage: 'Security' },
|
||||
groupUsers: { id: 'app.skin-site.admin.group.users', defaultMessage: 'Users' },
|
||||
groupCommunity: { id: 'app.skin-site.admin.group.community', defaultMessage: 'Community' },
|
||||
groupResources: { id: 'app.skin-site.admin.group.resources', defaultMessage: 'Resources' },
|
||||
itemServers: { id: 'app.skin-site.admin.item.servers', defaultMessage: 'Servers' },
|
||||
itemSummary: { id: 'app.skin-site.admin.item.summary', defaultMessage: 'Summary' },
|
||||
itemAccessAudit: { id: 'app.skin-site.admin.item.access-audit', defaultMessage: 'Access audit' },
|
||||
itemUsers: { id: 'app.skin-site.admin.item.users', defaultMessage: 'Users' },
|
||||
itemPlayers: { id: 'app.skin-site.admin.item.players', defaultMessage: 'Players' },
|
||||
itemReview: { id: 'app.skin-site.admin.item.review', defaultMessage: 'Player review' },
|
||||
itemBroadcast: { id: 'app.skin-site.admin.item.broadcast', defaultMessage: 'Broadcast' },
|
||||
itemChat: { id: 'app.skin-site.admin.item.chat', defaultMessage: 'Chat rooms' },
|
||||
itemWiki: { id: 'app.skin-site.admin.item.wiki', defaultMessage: 'Wiki' },
|
||||
itemDonations: { id: 'app.skin-site.admin.item.donations', defaultMessage: 'Donations' },
|
||||
itemMods: { id: 'app.skin-site.admin.item.mods', defaultMessage: 'Mods' },
|
||||
itemLauncher: { id: 'app.skin-site.admin.item.launcher', defaultMessage: 'Launcher' },
|
||||
itemDownloads: { id: 'app.skin-site.admin.item.downloads', defaultMessage: 'Downloads' },
|
||||
})
|
||||
|
||||
type AdminKey =
|
||||
| 'servers'
|
||||
| 'summary'
|
||||
| 'access-audit'
|
||||
| 'users'
|
||||
| 'players'
|
||||
| 'review'
|
||||
| 'broadcast'
|
||||
| 'chat'
|
||||
| 'wiki'
|
||||
| 'donations'
|
||||
| 'mods'
|
||||
| 'launcher'
|
||||
| 'downloads'
|
||||
|
||||
interface NavItem {
|
||||
key: AdminKey
|
||||
label: string
|
||||
}
|
||||
interface NavGroup {
|
||||
id: string
|
||||
label: string
|
||||
items: NavItem[]
|
||||
}
|
||||
|
||||
const navGroups = computed<NavGroup[]>(() => [
|
||||
{
|
||||
id: 'security',
|
||||
label: formatMessage(messages.groupSecurity),
|
||||
items: [
|
||||
...(hasWebAdmin.value
|
||||
? [{ key: 'servers' as AdminKey, label: formatMessage(messages.itemServers) }]
|
||||
: []),
|
||||
{ key: 'summary', label: formatMessage(messages.itemSummary) },
|
||||
{ key: 'access-audit', label: formatMessage(messages.itemAccessAudit) },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'users',
|
||||
label: formatMessage(messages.groupUsers),
|
||||
items: [
|
||||
{ key: 'users', label: formatMessage(messages.itemUsers) },
|
||||
{ key: 'players', label: formatMessage(messages.itemPlayers) },
|
||||
{ key: 'review', label: formatMessage(messages.itemReview) },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'community',
|
||||
label: formatMessage(messages.groupCommunity),
|
||||
items: [
|
||||
{ key: 'broadcast', label: formatMessage(messages.itemBroadcast) },
|
||||
{ key: 'chat', label: formatMessage(messages.itemChat) },
|
||||
{ key: 'wiki', label: formatMessage(messages.itemWiki) },
|
||||
...(hasWebAdmin.value
|
||||
? [{ key: 'donations' as AdminKey, label: formatMessage(messages.itemDonations) }]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'resources',
|
||||
label: formatMessage(messages.groupResources),
|
||||
items: [
|
||||
{ key: 'mods', label: formatMessage(messages.itemMods) },
|
||||
{ key: 'launcher', label: formatMessage(messages.itemLauncher) },
|
||||
{ key: 'downloads', label: formatMessage(messages.itemDownloads) },
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
const hasAdminAccess = computed(() => {
|
||||
const permissions = skinSiteUser.value?.permissions ?? []
|
||||
return permissions.includes('WEB_ADMIN') || permissions.includes('SERVER_ADMIN')
|
||||
})
|
||||
|
||||
const hasWebAdmin = computed(() => {
|
||||
const permissions = skinSiteUser.value?.permissions ?? []
|
||||
return permissions.includes('WEB_ADMIN')
|
||||
})
|
||||
|
||||
const current = ref<AdminKey>('summary')
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="!hasAdminAccess"
|
||||
class="flex flex-col gap-1 rounded-xl border border-solid border-surface-5 bg-bg-raised p-6"
|
||||
>
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.noAccess) }}</h2>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.noAccessHint) }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex min-h-0 flex-1 gap-4">
|
||||
<nav class="flex w-48 shrink-0 flex-col gap-3 overflow-y-auto">
|
||||
<div v-for="group in navGroups" :key="group.id" class="flex flex-col gap-1">
|
||||
<span class="px-2 text-[10px] font-bold tracking-wide text-secondary uppercase">
|
||||
{{ group.label }}
|
||||
</span>
|
||||
<button
|
||||
v-for="item in group.items"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
class="rounded-lg px-2 py-1.5 text-left text-xs font-semibold transition-colors"
|
||||
:class="
|
||||
current === item.key
|
||||
? 'bg-brand text-contrast'
|
||||
: 'text-secondary hover:bg-button-bg hover:text-contrast'
|
||||
"
|
||||
@click="current = item.key"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<section
|
||||
class="min-w-0 flex-1 overflow-y-auto rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<AdminSummaryPage v-if="current === 'summary'" />
|
||||
<AdminServersPage v-else-if="current === 'servers' && hasWebAdmin" />
|
||||
<AdminAccessAuditPage v-else-if="current === 'access-audit'" />
|
||||
<AdminBroadcastPage v-else-if="current === 'broadcast'" />
|
||||
<AdminChatPage v-else-if="current === 'chat'" />
|
||||
<AdminUsersPage v-else-if="current === 'users'" />
|
||||
<AdminPlayersPage v-else-if="current === 'players'" />
|
||||
<AdminReviewPage v-else-if="current === 'review'" />
|
||||
<AdminLauncherPage v-else-if="current === 'launcher'" />
|
||||
<AdminModsPage v-else-if="current === 'mods'" />
|
||||
<AdminWikiPage v-else-if="current === 'wiki'" />
|
||||
<AdminDownloadsPage v-else-if="current === 'downloads'" />
|
||||
<AdminDonationsPage v-else-if="current === 'donations' && hasWebAdmin" />
|
||||
<p v-else class="m-0 text-sm text-secondary">{{ current }}</p>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,90 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import { type SkinSiteAnnouncement, skinSiteAnnouncements } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.home.announcements.title', defaultMessage: 'Announcements' },
|
||||
empty: {
|
||||
id: 'app.skin-site.home.announcements.empty',
|
||||
defaultMessage: 'No announcements right now.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.home.announcements.loading', defaultMessage: 'Loading…' },
|
||||
failed: {
|
||||
id: 'app.skin-site.home.announcements.failed',
|
||||
defaultMessage: 'Could not load announcements.',
|
||||
},
|
||||
})
|
||||
|
||||
const announcements = ref<SkinSiteAnnouncement[]>([])
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
function formatDate(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleDateString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const result = await skinSiteAnnouncements()
|
||||
if (result.success) {
|
||||
announcements.value = [...(result.payload ?? [])]
|
||||
.sort((a, b) => {
|
||||
if (a.star !== b.star) return a.star ? -1 : 1
|
||||
return b.updateAt - a.updateAt
|
||||
})
|
||||
.slice(0, 5)
|
||||
} else {
|
||||
failed.value = true
|
||||
}
|
||||
} catch {
|
||||
failed.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-2">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">
|
||||
{{ formatMessage(messages.title) }}
|
||||
</h3>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!announcements.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in announcements"
|
||||
:key="item.id"
|
||||
class="flex flex-col gap-1 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex items-start gap-2">
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
{{ item.title }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">{{ formatDate(item.updateAt) }}</span>
|
||||
</div>
|
||||
<span v-if="item.subtitle" class="truncate text-xs text-secondary">{{
|
||||
item.subtitle
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,187 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
StyledInput,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { type SkinSiteBugIssueType, skinSiteCreateBugIssue } from '@/helpers/skin-site-api'
|
||||
|
||||
const emit = defineEmits<{ (e: 'created', id: number): void }>()
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.bug-create.title', defaultMessage: 'New issue' },
|
||||
type: { id: 'app.skin-site.bug-create.type', defaultMessage: 'Type' },
|
||||
titleField: { id: 'app.skin-site.bug-create.title-field', defaultMessage: 'Title' },
|
||||
titlePlaceholder: {
|
||||
id: 'app.skin-site.bug-create.title-placeholder',
|
||||
defaultMessage: 'A short summary of the problem',
|
||||
},
|
||||
description: { id: 'app.skin-site.bug-create.description', defaultMessage: 'Description' },
|
||||
descriptionPlaceholder: {
|
||||
id: 'app.skin-site.bug-create.description-placeholder',
|
||||
defaultMessage: 'What happened, and how can it be reproduced?',
|
||||
},
|
||||
privateLabel: { id: 'app.skin-site.bug-create.private', defaultMessage: 'Private issue' },
|
||||
privateHint: {
|
||||
id: 'app.skin-site.bug-create.private-hint',
|
||||
defaultMessage: 'Only you and the maintainers can see it.',
|
||||
},
|
||||
images: { id: 'app.skin-site.bug-create.images', defaultMessage: 'Images' },
|
||||
imagesHint: {
|
||||
id: 'app.skin-site.bug-create.images-hint',
|
||||
defaultMessage: 'Optional, up to 5 images.',
|
||||
},
|
||||
submit: { id: 'app.skin-site.bug-create.submit', defaultMessage: 'Create issue' },
|
||||
submitting: { id: 'app.skin-site.bug-create.submitting', defaultMessage: 'Creating…' },
|
||||
created: { id: 'app.skin-site.bug-create.created', defaultMessage: 'Issue created.' },
|
||||
cancel: { id: 'app.skin-site.bug-create.cancel', defaultMessage: 'Cancel' },
|
||||
typeBug: { id: 'app.skin-site.bugs.type.bug', defaultMessage: 'Bug' },
|
||||
typeFeature: { id: 'app.skin-site.bugs.type.feature', defaultMessage: 'Feature' },
|
||||
typeImprovement: { id: 'app.skin-site.bugs.type.improvement', defaultMessage: 'Improvement' },
|
||||
})
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const type = ref<SkinSiteBugIssueType>('BUG')
|
||||
const title = ref('')
|
||||
const description = ref('')
|
||||
const isPrivate = ref(false)
|
||||
const images = ref<File[]>([])
|
||||
const working = ref(false)
|
||||
|
||||
const TYPE_OPTIONS: SkinSiteBugIssueType[] = ['BUG', 'FEATURE', 'IMPROVEMENT']
|
||||
|
||||
function typeLabel(t: SkinSiteBugIssueType): string {
|
||||
if (t === 'FEATURE') return formatMessage(messages.typeFeature)
|
||||
if (t === 'IMPROVEMENT') return formatMessage(messages.typeImprovement)
|
||||
return formatMessage(messages.typeBug)
|
||||
}
|
||||
|
||||
const canSubmit = computed(
|
||||
() => title.value.trim().length > 0 && description.value.trim().length > 0 && !working.value,
|
||||
)
|
||||
|
||||
function reset() {
|
||||
type.value = 'BUG'
|
||||
title.value = ''
|
||||
description.value = ''
|
||||
isPrivate.value = false
|
||||
images.value = []
|
||||
working.value = false
|
||||
}
|
||||
|
||||
function show() {
|
||||
reset()
|
||||
modal.value?.show()
|
||||
}
|
||||
|
||||
function onFiles(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
images.value = Array.from(input.files ?? []).slice(0, 5)
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!canSubmit.value) return
|
||||
working.value = true
|
||||
try {
|
||||
const result = await skinSiteCreateBugIssue(
|
||||
{
|
||||
type: type.value,
|
||||
title: title.value.trim(),
|
||||
description: description.value.trim(),
|
||||
private: isPrivate.value,
|
||||
},
|
||||
images.value,
|
||||
)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.created) })
|
||||
modal.value?.hide()
|
||||
emit('created', result.payload.id)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
working.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
modal.value?.hide()
|
||||
reset()
|
||||
}
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)" @hide="reset">
|
||||
<div class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.type) }}</span>
|
||||
<select
|
||||
v-model="type"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg-raised px-3 py-2 text-sm text-contrast"
|
||||
>
|
||||
<option v-for="t in TYPE_OPTIONS" :key="t" :value="t">{{ typeLabel(t) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.titleField) }}</span>
|
||||
<StyledInput
|
||||
v-model="title"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.titlePlaceholder)"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.description) }}</span>
|
||||
<textarea
|
||||
v-model="description"
|
||||
rows="5"
|
||||
class="w-full resize-y rounded-lg border border-solid border-surface-5 bg-bg-raised px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
:placeholder="formatMessage(messages.descriptionPlaceholder)"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex items-start gap-2">
|
||||
<input v-model="isPrivate" type="checkbox" class="mt-1" />
|
||||
<span class="flex flex-col">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.privateLabel) }}
|
||||
</span>
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.privateHint) }}</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.images) }}</span>
|
||||
<input type="file" accept="image/*" multiple @change="onFiles" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.imagesHint) }}</span>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="cancel"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
@click="submit"
|
||||
>
|
||||
{{ working ? formatMessage(messages.submitting) : formatMessage(messages.submit) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</NewModal>
|
||||
</template>
|
||||
@@ -0,0 +1,425 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteBugComment,
|
||||
skinSiteBugComments,
|
||||
type SkinSiteBugIssue,
|
||||
skinSiteBugIssue,
|
||||
type SkinSiteBugIssueType,
|
||||
type SkinSiteBugPriority,
|
||||
type SkinSiteBugResolution,
|
||||
type SkinSiteBugStatus,
|
||||
skinSiteCreateBugComment,
|
||||
skinSiteDeleteBugComment,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const props = defineProps<{ issueId: number }>()
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
back: { id: 'app.skin-site.bug-detail.back', defaultMessage: 'Back to list' },
|
||||
loading: { id: 'app.skin-site.bug-detail.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.bug-detail.failed', defaultMessage: 'Could not load this issue.' },
|
||||
issueNo: { id: 'app.skin-site.bug-detail.issue-no', defaultMessage: 'Issue #{id}' },
|
||||
by: { id: 'app.skin-site.bug-detail.by', defaultMessage: 'by {name}' },
|
||||
assignee: { id: 'app.skin-site.bug-detail.assignee', defaultMessage: 'Assignee: {name}' },
|
||||
unassigned: { id: 'app.skin-site.bug-detail.unassigned', defaultMessage: 'Unassigned' },
|
||||
descriptionEmpty: {
|
||||
id: 'app.skin-site.bug-detail.description-empty',
|
||||
defaultMessage: 'No description provided.',
|
||||
},
|
||||
resolution: { id: 'app.skin-site.bug-detail.resolution', defaultMessage: 'Resolution: {name}' },
|
||||
commentsTitle: { id: 'app.skin-site.bug-detail.comments-title', defaultMessage: 'Comments' },
|
||||
commentsEmpty: {
|
||||
id: 'app.skin-site.bug-detail.comments-empty',
|
||||
defaultMessage: 'No comments yet. Be the first to reply.',
|
||||
},
|
||||
commentsLoading: {
|
||||
id: 'app.skin-site.bug-detail.comments-loading',
|
||||
defaultMessage: 'Loading comments…',
|
||||
},
|
||||
commentPlaceholder: {
|
||||
id: 'app.skin-site.bug-detail.comment-placeholder',
|
||||
defaultMessage: 'Write a comment…',
|
||||
},
|
||||
commentSubmit: { id: 'app.skin-site.bug-detail.comment-submit', defaultMessage: 'Comment' },
|
||||
commentSending: { id: 'app.skin-site.bug-detail.comment-sending', defaultMessage: 'Sending…' },
|
||||
commentEmptyError: {
|
||||
id: 'app.skin-site.bug-detail.comment-empty-error',
|
||||
defaultMessage: 'Comment cannot be empty.',
|
||||
},
|
||||
commentPosted: {
|
||||
id: 'app.skin-site.bug-detail.comment-posted',
|
||||
defaultMessage: 'Comment posted.',
|
||||
},
|
||||
commentDeleted: {
|
||||
id: 'app.skin-site.bug-detail.comment-deleted',
|
||||
defaultMessage: 'Comment deleted.',
|
||||
},
|
||||
delete: { id: 'app.skin-site.bug-detail.delete', defaultMessage: 'Delete' },
|
||||
deleting: { id: 'app.skin-site.bug-detail.deleting', defaultMessage: 'Deleting…' },
|
||||
system: { id: 'app.skin-site.bug-detail.system', defaultMessage: 'System' },
|
||||
typeBug: { id: 'app.skin-site.bugs.type.bug', defaultMessage: 'Bug' },
|
||||
typeFeature: { id: 'app.skin-site.bugs.type.feature', defaultMessage: 'Feature' },
|
||||
typeImprovement: { id: 'app.skin-site.bugs.type.improvement', defaultMessage: 'Improvement' },
|
||||
statusPending: { id: 'app.skin-site.bugs.status.pending', defaultMessage: 'Pending' },
|
||||
statusConfirmed: { id: 'app.skin-site.bugs.status.confirmed', defaultMessage: 'Confirmed' },
|
||||
statusNeedsInfo: { id: 'app.skin-site.bugs.status.needs-info', defaultMessage: 'Needs info' },
|
||||
statusInProgress: { id: 'app.skin-site.bugs.status.in-progress', defaultMessage: 'In progress' },
|
||||
statusVerifying: { id: 'app.skin-site.bugs.status.verifying', defaultMessage: 'Verifying' },
|
||||
statusClosed: { id: 'app.skin-site.bugs.status.closed', defaultMessage: 'Closed' },
|
||||
priorityCritical: { id: 'app.skin-site.bugs.priority.critical', defaultMessage: 'Critical' },
|
||||
priorityHigh: { id: 'app.skin-site.bugs.priority.high', defaultMessage: 'High' },
|
||||
priorityNormal: { id: 'app.skin-site.bugs.priority.normal', defaultMessage: 'Normal' },
|
||||
priorityLow: { id: 'app.skin-site.bugs.priority.low', defaultMessage: 'Low' },
|
||||
resFixed: { id: 'app.skin-site.bugs.resolution.fixed', defaultMessage: 'Fixed' },
|
||||
resWontFix: { id: 'app.skin-site.bugs.resolution.wont-fix', defaultMessage: 'Won’t fix' },
|
||||
resByDesign: { id: 'app.skin-site.bugs.resolution.by-design', defaultMessage: 'By design' },
|
||||
resDuplicate: { id: 'app.skin-site.bugs.resolution.duplicate', defaultMessage: 'Duplicate' },
|
||||
resCannotReproduce: {
|
||||
id: 'app.skin-site.bugs.resolution.cannot-reproduce',
|
||||
defaultMessage: 'Cannot reproduce',
|
||||
},
|
||||
resInvalid: { id: 'app.skin-site.bugs.resolution.invalid', defaultMessage: 'Invalid' },
|
||||
})
|
||||
|
||||
const issue = ref<SkinSiteBugIssue | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
const comments = ref<SkinSiteBugComment[]>([])
|
||||
const commentsLoading = ref(true)
|
||||
const commentsHasMore = ref(false)
|
||||
const commentsLoadingMore = ref(false)
|
||||
const commentDraft = ref('')
|
||||
const commentSending = ref(false)
|
||||
const deletingId = ref<number | null>(null)
|
||||
|
||||
function typeLabel(type: SkinSiteBugIssueType): string {
|
||||
switch (type) {
|
||||
case 'FEATURE':
|
||||
return formatMessage(messages.typeFeature)
|
||||
case 'IMPROVEMENT':
|
||||
return formatMessage(messages.typeImprovement)
|
||||
default:
|
||||
return formatMessage(messages.typeBug)
|
||||
}
|
||||
}
|
||||
|
||||
function statusLabel(status: SkinSiteBugStatus): string {
|
||||
switch (status) {
|
||||
case 'CONFIRMED':
|
||||
return formatMessage(messages.statusConfirmed)
|
||||
case 'NEEDS_INFO':
|
||||
return formatMessage(messages.statusNeedsInfo)
|
||||
case 'IN_PROGRESS':
|
||||
return formatMessage(messages.statusInProgress)
|
||||
case 'VERIFYING':
|
||||
return formatMessage(messages.statusVerifying)
|
||||
case 'CLOSED':
|
||||
return formatMessage(messages.statusClosed)
|
||||
default:
|
||||
return formatMessage(messages.statusPending)
|
||||
}
|
||||
}
|
||||
|
||||
function priorityLabel(priority: SkinSiteBugPriority): string {
|
||||
switch (priority) {
|
||||
case 'CRITICAL':
|
||||
return formatMessage(messages.priorityCritical)
|
||||
case 'HIGH':
|
||||
return formatMessage(messages.priorityHigh)
|
||||
case 'LOW':
|
||||
return formatMessage(messages.priorityLow)
|
||||
default:
|
||||
return formatMessage(messages.priorityNormal)
|
||||
}
|
||||
}
|
||||
|
||||
function resolutionLabel(resolution: SkinSiteBugResolution): string {
|
||||
switch (resolution) {
|
||||
case 'WONT_FIX':
|
||||
return formatMessage(messages.resWontFix)
|
||||
case 'BY_DESIGN':
|
||||
return formatMessage(messages.resByDesign)
|
||||
case 'DUPLICATE':
|
||||
return formatMessage(messages.resDuplicate)
|
||||
case 'CANNOT_REPRODUCE':
|
||||
return formatMessage(messages.resCannotReproduce)
|
||||
case 'INVALID':
|
||||
return formatMessage(messages.resInvalid)
|
||||
default:
|
||||
return formatMessage(messages.resFixed)
|
||||
}
|
||||
}
|
||||
|
||||
function formatDateTime(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
const canSubmit = computed(() => !commentSending.value && commentDraft.value.trim().length > 0)
|
||||
|
||||
async function loadIssue() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteBugIssue(props.issueId)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
issue.value = result.payload
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadComments(reset = true) {
|
||||
if (reset) {
|
||||
commentsLoading.value = true
|
||||
comments.value = []
|
||||
} else {
|
||||
commentsLoadingMore.value = true
|
||||
}
|
||||
try {
|
||||
const result = await skinSiteBugComments(props.issueId, reset ? 0 : comments.value.length, 50)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
const page = result.payload
|
||||
comments.value = reset ? page.items : [...comments.value, ...page.items]
|
||||
commentsHasMore.value = page.hasMore
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
commentsLoading.value = false
|
||||
commentsLoadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitComment() {
|
||||
const content = commentDraft.value.trim()
|
||||
if (!content || commentSending.value) return
|
||||
commentSending.value = true
|
||||
try {
|
||||
const result = await skinSiteCreateBugComment(props.issueId, content)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
comments.value = [...comments.value, result.payload]
|
||||
commentDraft.value = ''
|
||||
addNotification({ type: 'success', title: formatMessage(messages.commentPosted) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
commentSending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteComment(comment: SkinSiteBugComment) {
|
||||
if (deletingId.value !== null) return
|
||||
deletingId.value = comment.id
|
||||
try {
|
||||
const result = await skinSiteDeleteBugComment(comment.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
comments.value = comments.value.filter((c) => c.id !== comment.id)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.commentDeleted) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadIssue()
|
||||
void loadComments(true)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
|
||||
<template v-else-if="issue">
|
||||
<header
|
||||
class="flex flex-col gap-2 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ typeLabel(issue.type) }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="{
|
||||
'bg-green text-contrast':
|
||||
issue.status === 'CONFIRMED' || issue.status === 'VERIFYING',
|
||||
'bg-yellow text-contrast':
|
||||
issue.status === 'NEEDS_INFO' || issue.status === 'IN_PROGRESS',
|
||||
'bg-button-bg text-secondary': issue.status === 'PENDING',
|
||||
'bg-surface-5 text-secondary': issue.status === 'CLOSED',
|
||||
}"
|
||||
>
|
||||
{{ statusLabel(issue.status) }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="{
|
||||
'bg-red text-contrast': issue.priority === 'CRITICAL',
|
||||
'bg-orange text-contrast': issue.priority === 'HIGH',
|
||||
'bg-button-bg text-secondary':
|
||||
issue.priority === 'NORMAL' || issue.priority === 'LOW',
|
||||
}"
|
||||
>
|
||||
{{ priorityLabel(issue.priority) }}
|
||||
</span>
|
||||
<span v-if="issue.private" class="shrink-0 text-[10px] font-semibold text-secondary">
|
||||
🔒
|
||||
</span>
|
||||
<span class="min-w-0 flex-1 truncate text-xs text-secondary">
|
||||
{{ formatMessage(messages.issueNo, { id: issue.id }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ issue.title }}</h1>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 text-xs text-secondary">
|
||||
<span>{{ formatMessage(messages.by, { name: issue.authorName }) }}</span>
|
||||
<span>{{ formatDateTime(issue.createdAt) }}</span>
|
||||
<span v-if="issue.assigneeName">
|
||||
{{ formatMessage(messages.assignee, { name: issue.assigneeName }) }}
|
||||
</span>
|
||||
<span v-else>{{ formatMessage(messages.unassigned) }}</span>
|
||||
</div>
|
||||
<span v-if="issue.resolution" class="text-xs font-semibold text-secondary">
|
||||
{{ formatMessage(messages.resolution, { name: resolutionLabel(issue.resolution) }) }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<div class="rounded-xl border border-solid border-surface-5 bg-bg-raised p-4">
|
||||
<p
|
||||
v-if="issue.description"
|
||||
class="m-0 whitespace-pre-wrap break-words text-sm text-contrast"
|
||||
>
|
||||
{{ issue.description }}
|
||||
</p>
|
||||
<p v-else class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.descriptionEmpty) }}
|
||||
</p>
|
||||
<div v-if="issue.images.length" class="mt-3 flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="image in issue.images"
|
||||
:key="image.hash"
|
||||
class="rounded-lg bg-surface-5 px-2 py-1 text-[10px] font-mono text-secondary"
|
||||
>
|
||||
{{ image.hash }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="flex flex-col gap-3">
|
||||
<h2 class="m-0 text-base font-bold text-contrast">
|
||||
{{ formatMessage(messages.commentsTitle) }}
|
||||
</h2>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div v-if="commentsLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.commentsLoading) }}
|
||||
</div>
|
||||
<p
|
||||
v-else-if="!comments.length"
|
||||
class="m-0 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4 text-sm text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.commentsEmpty) }}
|
||||
</p>
|
||||
<div
|
||||
v-for="comment in comments"
|
||||
v-else
|
||||
:key="comment.id"
|
||||
class="flex flex-col gap-1.5 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2 text-xs text-secondary">
|
||||
<span class="font-semibold text-contrast">{{ comment.authorName }}</span>
|
||||
<span
|
||||
v-if="comment.system"
|
||||
class="rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold"
|
||||
>
|
||||
{{ formatMessage(messages.system) }}
|
||||
</span>
|
||||
<span>{{ formatDateTime(comment.createdAt) }}</span>
|
||||
<span v-if="comment.editedAt">(edited)</span>
|
||||
<button
|
||||
v-if="comment.canDelete"
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingId !== null"
|
||||
@click="deleteComment(comment)"
|
||||
>
|
||||
{{
|
||||
deletingId === comment.id
|
||||
? formatMessage(messages.deleting)
|
||||
: formatMessage(messages.delete)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
<p class="m-0 whitespace-pre-wrap break-words text-sm text-contrast">
|
||||
{{ comment.content }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="commentsHasMore"
|
||||
type="button"
|
||||
class="w-fit self-center rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="commentsLoadingMore"
|
||||
@click="loadComments(false)"
|
||||
>
|
||||
{{ formatMessage(messages.commentsTitle) }}
|
||||
</button>
|
||||
|
||||
<form class="flex flex-col gap-2" @submit.prevent="submitComment">
|
||||
<textarea
|
||||
v-model="commentDraft"
|
||||
rows="3"
|
||||
class="w-full resize-y rounded-xl border border-solid border-surface-5 bg-bg-raised p-3 text-sm text-contrast outline-none focus:border-brand"
|
||||
:placeholder="formatMessage(messages.commentPlaceholder)"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
class="w-fit self-end rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
>
|
||||
{{
|
||||
commentSending
|
||||
? formatMessage(messages.commentSending)
|
||||
: formatMessage(messages.commentSubmit)
|
||||
}}
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,306 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteBugIssue,
|
||||
skinSiteBugIssues,
|
||||
type SkinSiteBugIssueType,
|
||||
type SkinSiteBugPriority,
|
||||
type SkinSiteBugStatus,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.bugs.title', defaultMessage: 'Bugs & suggestions' },
|
||||
back: { id: 'app.skin-site.bugs.back', defaultMessage: 'Back to home' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.bugs.subtitle',
|
||||
defaultMessage: 'Report issues and follow their progress.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.bugs.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.bugs.failed', defaultMessage: 'Could not load issues.' },
|
||||
empty: { id: 'app.skin-site.bugs.empty', defaultMessage: 'No issues match these filters.' },
|
||||
all: { id: 'app.skin-site.bugs.all', defaultMessage: 'All' },
|
||||
more: { id: 'app.skin-site.bugs.more', defaultMessage: 'Load more' },
|
||||
openOnly: { id: 'app.skin-site.bugs.open-only', defaultMessage: 'Open only' },
|
||||
create: { id: 'app.skin-site.bugs.create', defaultMessage: 'New issue' },
|
||||
notifications: {
|
||||
id: 'app.skin-site.bugs.notifications',
|
||||
defaultMessage: 'Notifications',
|
||||
},
|
||||
comments: { id: 'app.skin-site.bugs.comments', defaultMessage: '{count} comments' },
|
||||
typeBug: { id: 'app.skin-site.bugs.type.bug', defaultMessage: 'Bug' },
|
||||
typeFeature: { id: 'app.skin-site.bugs.type.feature', defaultMessage: 'Feature' },
|
||||
typeImprovement: { id: 'app.skin-site.bugs.type.improvement', defaultMessage: 'Improvement' },
|
||||
statusPending: { id: 'app.skin-site.bugs.status.pending', defaultMessage: 'Pending' },
|
||||
statusConfirmed: { id: 'app.skin-site.bugs.status.confirmed', defaultMessage: 'Confirmed' },
|
||||
statusNeedsInfo: { id: 'app.skin-site.bugs.status.needs-info', defaultMessage: 'Needs info' },
|
||||
statusInProgress: { id: 'app.skin-site.bugs.status.in-progress', defaultMessage: 'In progress' },
|
||||
statusVerifying: { id: 'app.skin-site.bugs.status.verifying', defaultMessage: 'Verifying' },
|
||||
statusClosed: { id: 'app.skin-site.bugs.status.closed', defaultMessage: 'Closed' },
|
||||
priorityCritical: { id: 'app.skin-site.bugs.priority.critical', defaultMessage: 'Critical' },
|
||||
priorityHigh: { id: 'app.skin-site.bugs.priority.high', defaultMessage: 'High' },
|
||||
priorityNormal: { id: 'app.skin-site.bugs.priority.normal', defaultMessage: 'Normal' },
|
||||
priorityLow: { id: 'app.skin-site.bugs.priority.low', defaultMessage: 'Low' },
|
||||
})
|
||||
const emit = defineEmits<{
|
||||
(e: 'back' | 'create' | 'notifications'): void
|
||||
(e: 'open', id: number): void
|
||||
}>()
|
||||
|
||||
const items = ref<SkinSiteBugIssue[]>([])
|
||||
const hasMore = ref(false)
|
||||
const loading = ref(true)
|
||||
const loadingMore = ref(false)
|
||||
const failed = ref(false)
|
||||
|
||||
const typeFilter = ref<SkinSiteBugIssueType | ''>('')
|
||||
const statusFilter = ref<SkinSiteBugStatus | ''>('')
|
||||
const priorityFilter = ref<SkinSiteBugPriority | ''>('')
|
||||
const openOnly = ref(true)
|
||||
|
||||
const TYPE_OPTIONS: SkinSiteBugIssueType[] = ['BUG', 'FEATURE', 'IMPROVEMENT']
|
||||
const STATUS_OPTIONS: SkinSiteBugStatus[] = [
|
||||
'PENDING',
|
||||
'CONFIRMED',
|
||||
'NEEDS_INFO',
|
||||
'IN_PROGRESS',
|
||||
'VERIFYING',
|
||||
'CLOSED',
|
||||
]
|
||||
const PRIORITY_OPTIONS: SkinSiteBugPriority[] = ['CRITICAL', 'HIGH', 'NORMAL', 'LOW']
|
||||
|
||||
function typeLabel(type: SkinSiteBugIssueType): string {
|
||||
switch (type) {
|
||||
case 'FEATURE':
|
||||
return formatMessage(messages.typeFeature)
|
||||
case 'IMPROVEMENT':
|
||||
return formatMessage(messages.typeImprovement)
|
||||
default:
|
||||
return formatMessage(messages.typeBug)
|
||||
}
|
||||
}
|
||||
|
||||
function statusLabel(status: SkinSiteBugStatus): string {
|
||||
switch (status) {
|
||||
case 'CONFIRMED':
|
||||
return formatMessage(messages.statusConfirmed)
|
||||
case 'NEEDS_INFO':
|
||||
return formatMessage(messages.statusNeedsInfo)
|
||||
case 'IN_PROGRESS':
|
||||
return formatMessage(messages.statusInProgress)
|
||||
case 'VERIFYING':
|
||||
return formatMessage(messages.statusVerifying)
|
||||
case 'CLOSED':
|
||||
return formatMessage(messages.statusClosed)
|
||||
default:
|
||||
return formatMessage(messages.statusPending)
|
||||
}
|
||||
}
|
||||
|
||||
function priorityLabel(priority: SkinSiteBugPriority): string {
|
||||
switch (priority) {
|
||||
case 'CRITICAL':
|
||||
return formatMessage(messages.priorityCritical)
|
||||
case 'HIGH':
|
||||
return formatMessage(messages.priorityHigh)
|
||||
case 'LOW':
|
||||
return formatMessage(messages.priorityLow)
|
||||
default:
|
||||
return formatMessage(messages.priorityNormal)
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleDateString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function load(reset = true) {
|
||||
if (reset) {
|
||||
loading.value = true
|
||||
items.value = []
|
||||
} else {
|
||||
loadingMore.value = true
|
||||
}
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteBugIssues({
|
||||
offset: reset ? 0 : items.value.length,
|
||||
limit: 20,
|
||||
type: typeFilter.value || undefined,
|
||||
status: statusFilter.value || undefined,
|
||||
priority: priorityFilter.value || undefined,
|
||||
openOnly: openOnly.value,
|
||||
})
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
const page = result.payload
|
||||
items.value = reset ? page.items : [...items.value, ...page.items]
|
||||
hasMore.value = page.hasMore
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function clearFilters() {
|
||||
typeFilter.value = ''
|
||||
statusFilter.value = ''
|
||||
priorityFilter.value = ''
|
||||
void load(true)
|
||||
}
|
||||
|
||||
onMounted(() => load(true))
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<header class="flex flex-wrap items-start gap-3">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
</div>
|
||||
<div class="ml-auto flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110"
|
||||
@click="emit('notifications')"
|
||||
>
|
||||
{{ formatMessage(messages.notifications) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('create')"
|
||||
>
|
||||
{{ formatMessage(messages.create) }}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select
|
||||
v-model="typeFilter"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
@change="load(true)"
|
||||
>
|
||||
<option value="">{{ formatMessage(messages.all) }}</option>
|
||||
<option v-for="t in TYPE_OPTIONS" :key="t" :value="t">{{ typeLabel(t) }}</option>
|
||||
</select>
|
||||
<select
|
||||
v-model="statusFilter"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
@change="load(true)"
|
||||
>
|
||||
<option value="">{{ formatMessage(messages.all) }}</option>
|
||||
<option v-for="s in STATUS_OPTIONS" :key="s" :value="s">{{ statusLabel(s) }}</option>
|
||||
</select>
|
||||
<select
|
||||
v-model="priorityFilter"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
@change="load(true)"
|
||||
>
|
||||
<option value="">{{ formatMessage(messages.all) }}</option>
|
||||
<option v-for="p in PRIORITY_OPTIONS" :key="p" :value="p">{{ priorityLabel(p) }}</option>
|
||||
</select>
|
||||
<label class="flex items-center gap-1.5 text-xs text-secondary">
|
||||
<input v-model="openOnly" type="checkbox" @change="load(true)" />
|
||||
{{ formatMessage(messages.openOnly) }}
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110"
|
||||
@click="clearFilters"
|
||||
>
|
||||
{{ formatMessage(messages.all) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!items.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="issue in items"
|
||||
:key="issue.id"
|
||||
class="flex cursor-pointer flex-col gap-1.5 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3 hover:border-brand"
|
||||
@click="emit('open', issue.id)"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ typeLabel(issue.type) }}
|
||||
</span>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
#{{ issue.id }} {{ issue.title }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="{
|
||||
'bg-green text-contrast':
|
||||
issue.status === 'CONFIRMED' || issue.status === 'VERIFYING',
|
||||
'bg-yellow text-contrast':
|
||||
issue.status === 'NEEDS_INFO' || issue.status === 'IN_PROGRESS',
|
||||
'bg-button-bg text-secondary': issue.status === 'PENDING',
|
||||
'bg-surface-5 text-secondary': issue.status === 'CLOSED',
|
||||
}"
|
||||
>
|
||||
{{ statusLabel(issue.status) }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="{
|
||||
'bg-red text-contrast': issue.priority === 'CRITICAL',
|
||||
'bg-orange text-contrast': issue.priority === 'HIGH',
|
||||
'bg-button-bg text-secondary':
|
||||
issue.priority === 'NORMAL' || issue.priority === 'LOW',
|
||||
}"
|
||||
>
|
||||
{{ priorityLabel(issue.priority) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-xs text-secondary">
|
||||
<span>{{ issue.authorName }}</span>
|
||||
<span>{{ formatDate(issue.createdAt) }}</span>
|
||||
<span>{{ formatMessage(messages.comments, { count: issue.commentCount }) }}</span>
|
||||
<span v-if="issue.assigneeName">→ {{ issue.assigneeName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="hasMore"
|
||||
type="button"
|
||||
class="w-fit self-center rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="loadingMore"
|
||||
@click="load(false)"
|
||||
>
|
||||
{{ formatMessage(messages.more) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,140 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteBugNotification,
|
||||
skinSiteBugNotifications,
|
||||
skinSiteMarkBugNotificationRead,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void; (e: 'open', id: number): void }>()
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.bug-notifications.title', defaultMessage: 'Notifications' },
|
||||
back: { id: 'app.skin-site.bug-notifications.back', defaultMessage: 'Back to home' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.bug-notifications.subtitle',
|
||||
defaultMessage: 'Activity on issues you reported or follow.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.bug-notifications.loading', defaultMessage: 'Loading…' },
|
||||
failed: {
|
||||
id: 'app.skin-site.bug-notifications.failed',
|
||||
defaultMessage: 'Could not load notifications.',
|
||||
},
|
||||
empty: { id: 'app.skin-site.bug-notifications.empty', defaultMessage: 'No new notifications.' },
|
||||
item: {
|
||||
id: 'app.skin-site.bug-notifications.item',
|
||||
defaultMessage: '{name} updated issue #{id}',
|
||||
},
|
||||
markAll: {
|
||||
id: 'app.skin-site.bug-notifications.mark-all',
|
||||
defaultMessage: 'Mark all as read',
|
||||
},
|
||||
markedAll: {
|
||||
id: 'app.skin-site.bug-notifications.marked-all',
|
||||
defaultMessage: 'All notifications marked as read.',
|
||||
},
|
||||
})
|
||||
|
||||
const items = ref<SkinSiteBugNotification[]>([])
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const marking = ref(false)
|
||||
|
||||
function formatDateTime(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteBugNotifications()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
items.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function markAllRead() {
|
||||
if (marking.value || !items.value.length) return
|
||||
marking.value = true
|
||||
try {
|
||||
await skinSiteMarkBugNotificationRead()
|
||||
items.value = []
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
marking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load())
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<header class="flex flex-wrap items-center gap-3">
|
||||
<div class="flex flex-col gap-1">
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="items.length"
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="marking"
|
||||
@click="markAllRead"
|
||||
>
|
||||
{{ formatMessage(messages.markAll) }}
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!items.length"
|
||||
class="m-0 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4 text-sm text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="flex cursor-pointer flex-wrap items-center gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3 hover:border-brand"
|
||||
@click="emit('open', item.issueId)"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate text-sm text-contrast">
|
||||
{{ formatMessage(messages.item, { name: item.actorName, id: item.issueId }) }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">{{ formatDateTime(item.createdAt) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { requestCaptcha, verifyCaptcha } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.captcha.title', defaultMessage: 'Let us check you are human' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.captcha.subtitle',
|
||||
defaultMessage: 'Drag the slider to rotate the image upright.',
|
||||
},
|
||||
submit: { id: 'app.skin-site.captcha.submit', defaultMessage: 'Submit' },
|
||||
loading: { id: 'app.skin-site.captcha.loading', defaultMessage: 'Loading captcha…' },
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'verified', clientId: string): void; (e: 'cancel'): void }>()
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const image = ref('')
|
||||
const challengeClientId = ref('')
|
||||
const degree = ref(0)
|
||||
|
||||
/** The image is rotated by the server; the slider counter-rotates the preview. */
|
||||
const previewRotation = computed(() => `${degree.value}deg`)
|
||||
|
||||
function resetState() {
|
||||
degree.value = 0
|
||||
image.value = ''
|
||||
challengeClientId.value = ''
|
||||
}
|
||||
|
||||
async function loadCaptcha() {
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await requestCaptcha()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
image.value = result.payload.image ?? ''
|
||||
challengeClientId.value = result.payload.clientId
|
||||
degree.value = 0
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
modal.value?.hide()
|
||||
emit('cancel')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function show() {
|
||||
resetState()
|
||||
modal.value?.show()
|
||||
await loadCaptcha()
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value || !challengeClientId.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const result = await verifyCaptcha({
|
||||
clientId: challengeClientId.value,
|
||||
degree: degree.value,
|
||||
})
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
await loadCaptcha()
|
||||
return
|
||||
}
|
||||
modal.value?.hide()
|
||||
emit('verified', result.payload)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
modal.value?.hide()
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)" @hide="resetState">
|
||||
<div class="flex flex-col items-center gap-6">
|
||||
<p class="m-0 text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
|
||||
<div
|
||||
class="size-44 overflow-hidden rounded-full border-4 border-solid border-bg-raised bg-button-bg"
|
||||
>
|
||||
<img
|
||||
v-if="image"
|
||||
:src="image"
|
||||
alt=""
|
||||
class="size-full object-cover transition-transform duration-75"
|
||||
:style="{ transform: `rotate(${previewRotation})` }"
|
||||
draggable="false"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="w-full max-w-sm">
|
||||
<input
|
||||
v-model.number="degree"
|
||||
type="range"
|
||||
min="0"
|
||||
max="360"
|
||||
step="1"
|
||||
class="w-full accent-brand"
|
||||
:disabled="loading || submitting"
|
||||
/>
|
||||
<div class="mt-1 flex justify-between text-xs text-secondary">
|
||||
<span>0°</span>
|
||||
<span>90°</span>
|
||||
<span>180°</span>
|
||||
<span>270°</span>
|
||||
<span>360°</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-secondary hover:bg-button-bg"
|
||||
@click="cancel"
|
||||
>
|
||||
{{ formatMessage(commonMessages.cancelButton) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 font-semibold text-contrast"
|
||||
:disabled="loading || submitting || !image"
|
||||
@click="submit"
|
||||
>
|
||||
{{ formatMessage(loading ? messages.loading : messages.submit) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
</template>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import { HeartIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSitePublicDonationSummary,
|
||||
skinSitePublicDonationSummary,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.home.donation.title', defaultMessage: 'Donation thanks' },
|
||||
total: { id: 'app.skin-site.home.donation.total', defaultMessage: 'Total raised' },
|
||||
donors: { id: 'app.skin-site.home.donation.donors', defaultMessage: '{count} donors' },
|
||||
unavailable: {
|
||||
id: 'app.skin-site.home.donation.unavailable',
|
||||
defaultMessage: 'Donation summary unavailable.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.home.donation.loading', defaultMessage: 'Loading…' },
|
||||
})
|
||||
|
||||
const summary = ref<SkinSitePublicDonationSummary | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const result = await skinSitePublicDonationSummary()
|
||||
if (result.success) summary.value = result.payload
|
||||
else failed.value = true
|
||||
} catch {
|
||||
failed.value = true
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex items-center gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised px-4 py-3"
|
||||
>
|
||||
<HeartIcon class="size-5 shrink-0 text-brand" />
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<span class="text-sm font-semibold text-contrast">{{ formatMessage(messages.title) }}</span>
|
||||
<span v-if="loading" class="flex items-center gap-1 text-xs text-secondary">
|
||||
<SpinnerIcon class="size-3 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</span>
|
||||
<span v-else-if="failed" class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.unavailable) }}
|
||||
</span>
|
||||
<span v-else-if="summary" class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.total) }}: {{ summary.totalAmount }} ·
|
||||
{{ formatMessage(messages.donors, { count: summary.donorCount }) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,198 @@
|
||||
<script setup lang="ts">
|
||||
import { DownloadIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSitePublicDownloadCategories,
|
||||
type SkinSitePublicDownloadCategory,
|
||||
type SkinSitePublicDownloadItem,
|
||||
skinSitePublicDownloadList,
|
||||
type SkinSitePublicDownloadStatus,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.downloads.title', defaultMessage: 'Downloads' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.downloads.subtitle',
|
||||
defaultMessage: 'Files shared by the server. Pick a category to narrow the list.',
|
||||
},
|
||||
back: { id: 'app.skin-site.downloads.back', defaultMessage: 'Back to home' },
|
||||
all: { id: 'app.skin-site.downloads.all', defaultMessage: 'All' },
|
||||
empty: { id: 'app.skin-site.downloads.empty', defaultMessage: 'Nothing to download yet.' },
|
||||
loading: { id: 'app.skin-site.downloads.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.downloads.failed', defaultMessage: 'Could not load downloads.' },
|
||||
goDownload: { id: 'app.skin-site.downloads.go', defaultMessage: 'Download' },
|
||||
uploader: { id: 'app.skin-site.downloads.uploader', defaultMessage: 'by {name}' },
|
||||
statusOk: { id: 'app.skin-site.downloads.status.ok', defaultMessage: 'OK' },
|
||||
statusNew: { id: 'app.skin-site.downloads.status.new', defaultMessage: 'New' },
|
||||
statusLegacy: { id: 'app.skin-site.downloads.status.legacy', defaultMessage: 'Legacy' },
|
||||
statusOutdated: { id: 'app.skin-site.downloads.status.outdated', defaultMessage: 'Outdated' },
|
||||
statusRemoval: { id: 'app.skin-site.downloads.status.removal', defaultMessage: 'Removal' },
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const items = ref<SkinSitePublicDownloadItem[]>([])
|
||||
const categories = ref<SkinSitePublicDownloadCategory[]>([])
|
||||
const selectedCategory = ref<string | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
const filtered = computed(() =>
|
||||
selectedCategory.value
|
||||
? items.value.filter((item) => item.category.includes(selectedCategory.value!))
|
||||
: items.value,
|
||||
)
|
||||
|
||||
function statusLabel(status: SkinSitePublicDownloadStatus): string {
|
||||
switch (status) {
|
||||
case 'NEW':
|
||||
return formatMessage(messages.statusNew)
|
||||
case 'LEGACY':
|
||||
return formatMessage(messages.statusLegacy)
|
||||
case 'OUTDATED':
|
||||
return formatMessage(messages.statusOutdated)
|
||||
case 'REMOVAL':
|
||||
return formatMessage(messages.statusRemoval)
|
||||
default:
|
||||
return formatMessage(messages.statusOk)
|
||||
}
|
||||
}
|
||||
|
||||
async function openUrl(url: string) {
|
||||
const { openUrl: open } = await import('@tauri-apps/plugin-opener')
|
||||
await open(url)
|
||||
}
|
||||
|
||||
function download(item: SkinSitePublicDownloadItem) {
|
||||
const route = item.routes?.[0]
|
||||
void openUrl(route?.url ?? item.url)
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const [listResult, categoryResult] = await Promise.all([
|
||||
skinSitePublicDownloadList(),
|
||||
skinSitePublicDownloadCategories(),
|
||||
])
|
||||
if (!listResult.success) throw new Error(listResult.errorMessage)
|
||||
items.value = listResult.payload ?? []
|
||||
if (categoryResult.success) categories.value = categoryResult.payload ?? []
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<header class="flex flex-col gap-1">
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
</header>
|
||||
|
||||
<div v-if="categories.length" class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold transition-colors"
|
||||
:class="
|
||||
selectedCategory === null
|
||||
? 'bg-brand text-contrast'
|
||||
: 'bg-button-bg text-secondary hover:brightness-110'
|
||||
"
|
||||
@click="selectedCategory = null"
|
||||
>
|
||||
{{ formatMessage(messages.all) }}
|
||||
</button>
|
||||
<button
|
||||
v-for="category in categories"
|
||||
:key="category.id"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold transition-colors"
|
||||
:class="
|
||||
selectedCategory === category.name
|
||||
? 'bg-brand text-contrast'
|
||||
: 'bg-button-bg text-secondary hover:brightness-110'
|
||||
"
|
||||
@click="selectedCategory = category.name"
|
||||
>
|
||||
{{ category.name }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!filtered.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in filtered"
|
||||
:key="item.id"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="min-w-0 truncate text-sm font-semibold text-contrast">
|
||||
{{ item.filename }}
|
||||
</span>
|
||||
<span
|
||||
v-for="status in item.status"
|
||||
:key="status"
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="{
|
||||
'bg-green text-contrast': status === 'NEW',
|
||||
'bg-yellow text-contrast': status === 'LEGACY',
|
||||
'bg-red text-contrast': status === 'OUTDATED' || status === 'REMOVAL',
|
||||
'bg-button-bg text-secondary':
|
||||
status !== 'NEW' &&
|
||||
status !== 'LEGACY' &&
|
||||
status !== 'OUTDATED' &&
|
||||
status !== 'REMOVAL',
|
||||
}"
|
||||
>
|
||||
{{ statusLabel(status) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="item.description" class="truncate text-xs text-secondary">
|
||||
{{ item.description }}
|
||||
</span>
|
||||
<span v-if="item.uploader" class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.uploader, { name: item.uploader }) }}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex shrink-0 items-center gap-1 rounded-full bg-brand px-3 py-1.5 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="download(item)"
|
||||
>
|
||||
<DownloadIcon class="size-3.5" />
|
||||
{{ formatMessage(messages.goDownload) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,154 @@
|
||||
<script setup lang="ts">
|
||||
import { CopyIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { ref } from 'vue'
|
||||
|
||||
import SkinSiteAccountCard from './SkinSiteAccountCard.vue'
|
||||
import SkinSiteAdminView from './SkinSiteAdminView.vue'
|
||||
import SkinSiteAnnouncements from './SkinSiteAnnouncements.vue'
|
||||
import SkinSiteBugCreateModal from './SkinSiteBugCreateModal.vue'
|
||||
import SkinSiteBugDetailView from './SkinSiteBugDetailView.vue'
|
||||
import SkinSiteBugListView from './SkinSiteBugListView.vue'
|
||||
import SkinSiteBugNotificationsView from './SkinSiteBugNotificationsView.vue'
|
||||
import SkinSiteDonationCard from './SkinSiteDonationCard.vue'
|
||||
import SkinSiteDownloadsView from './SkinSiteDownloadsView.vue'
|
||||
import SkinSiteLoginModal from './SkinSiteLoginModal.vue'
|
||||
import SkinSiteMapView from './SkinSiteMapView.vue'
|
||||
import SkinSiteNavCards from './SkinSiteNavCards.vue'
|
||||
import SkinSiteProfileModal from './SkinSiteProfileModal.vue'
|
||||
import SkinSiteProfileView from './SkinSiteProfileView.vue'
|
||||
import SkinSiteReviewView from './SkinSiteReviewView.vue'
|
||||
import WikiView from './WikiView.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.home.title', defaultMessage: 'StarLight Skin Site' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.home.subtitle',
|
||||
defaultMessage: 'The wardrobe for StarLight Server players.',
|
||||
},
|
||||
address: { id: 'app.skin-site.home.address', defaultMessage: 'Skin site address' },
|
||||
copied: { id: 'app.skin-site.home.copied', defaultMessage: 'Address copied.' },
|
||||
})
|
||||
|
||||
const YGGDRASIL_URL = 'https://skin.starlight.cool/yggdrasil'
|
||||
const loginModal = ref<InstanceType<typeof SkinSiteLoginModal>>()
|
||||
const profileModal = ref<InstanceType<typeof SkinSiteProfileModal>>()
|
||||
const view = ref<
|
||||
| 'home'
|
||||
| 'players'
|
||||
| 'downloads'
|
||||
| 'map'
|
||||
| 'review'
|
||||
| 'bugs'
|
||||
| 'bug-detail'
|
||||
| 'bug-notifications'
|
||||
| 'admin'
|
||||
| 'wiki'
|
||||
>('home')
|
||||
const selectedBugId = ref<number | null>(null)
|
||||
|
||||
function openBug(id: number) {
|
||||
selectedBugId.value = id
|
||||
view.value = 'bug-detail'
|
||||
}
|
||||
|
||||
function backToBugList() {
|
||||
selectedBugId.value = null
|
||||
view.value = 'bugs'
|
||||
}
|
||||
|
||||
const bugCreateModal = ref<InstanceType<typeof SkinSiteBugCreateModal>>()
|
||||
|
||||
function openBugNotifications() {
|
||||
view.value = 'bug-notifications'
|
||||
}
|
||||
|
||||
function onBugCreated(id: number) {
|
||||
openBug(id)
|
||||
}
|
||||
|
||||
async function copyAddress() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(YGGDRASIL_URL)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.copied) })
|
||||
} catch {
|
||||
// Clipboard may be unavailable; the address stays selectable.
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 w-full flex-col overflow-y-auto">
|
||||
<div class="mx-auto flex w-full max-w-5xl flex-col gap-6 p-6">
|
||||
<SkinSiteProfileView v-if="view === 'players'" @back="view = 'home'" />
|
||||
<SkinSiteDownloadsView v-else-if="view === 'downloads'" @back="view = 'home'" />
|
||||
<SkinSiteMapView v-else-if="view === 'map'" @back="view = 'home'" />
|
||||
<SkinSiteReviewView v-else-if="view === 'review'" @back="view = 'home'" />
|
||||
<SkinSiteBugListView
|
||||
v-else-if="view === 'bugs'"
|
||||
@back="view = 'home'"
|
||||
@open="openBug"
|
||||
@create="bugCreateModal?.show()"
|
||||
@notifications="openBugNotifications"
|
||||
/>
|
||||
<SkinSiteBugNotificationsView
|
||||
v-else-if="view === 'bug-notifications'"
|
||||
@back="view = 'bugs'"
|
||||
@open="openBug"
|
||||
/>
|
||||
<SkinSiteAdminView v-else-if="view === 'admin'" @back="view = 'home'" />
|
||||
<WikiView v-else-if="view === 'wiki'" />
|
||||
|
||||
<SkinSiteBugDetailView
|
||||
v-else-if="view === 'bug-detail' && selectedBugId !== null"
|
||||
:issue-id="selectedBugId"
|
||||
@back="backToBugList"
|
||||
/>
|
||||
|
||||
<template v-else>
|
||||
<header class="flex flex-col items-center gap-1 text-center">
|
||||
<h1 class="m-0 text-2xl font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
</header>
|
||||
|
||||
<SkinSiteAccountCard
|
||||
@sign-in="loginModal?.show()"
|
||||
@open-settings="profileModal?.show()"
|
||||
@open-players="view = 'players'"
|
||||
@open-admin="view = 'admin'"
|
||||
/>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<SkinSiteNavCards @navigate="(v) => (view = v)" />
|
||||
<SkinSiteAnnouncements />
|
||||
</div>
|
||||
|
||||
<SkinSiteDonationCard />
|
||||
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-2 rounded-xl border border-solid border-surface-5 bg-bg-raised px-4 py-3"
|
||||
>
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.address)
|
||||
}}</span>
|
||||
<code class="min-w-0 flex-1 truncate text-xs text-secondary">{{ YGGDRASIL_URL }}</code>
|
||||
<button
|
||||
type="button"
|
||||
class="flex shrink-0 items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="copyAddress"
|
||||
>
|
||||
<CopyIcon class="size-3.5" />
|
||||
{{ formatMessage({ id: 'app.skin-site.home.copy', defaultMessage: 'Copy' }) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<SkinSiteLoginModal ref="loginModal" />
|
||||
<SkinSiteProfileModal ref="profileModal" />
|
||||
<SkinSiteBugCreateModal ref="bugCreateModal" @created="onBugCreated" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,185 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
StyledInput,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { reloadSkinSiteSession, signInSkinSite } from '@/composables/skin-site-session'
|
||||
|
||||
import SkinSiteCaptchaModal from './SkinSiteCaptchaModal.vue'
|
||||
import SkinSitePasswordResetModal from './SkinSitePasswordResetModal.vue'
|
||||
import SkinSiteRegisterModal from './SkinSiteRegisterModal.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.login.title', defaultMessage: 'Sign in to StarLight' },
|
||||
username: { id: 'app.skin-site.login.username', defaultMessage: 'Username or email' },
|
||||
password: { id: 'app.skin-site.login.password', defaultMessage: 'Password' },
|
||||
signIn: { id: 'app.skin-site.login.sign-in', defaultMessage: 'Sign in' },
|
||||
signingIn: { id: 'app.skin-site.login.signing-in', defaultMessage: 'Signing in…' },
|
||||
register: { id: 'app.skin-site.login.register', defaultMessage: 'Create account' },
|
||||
forgotPassword: { id: 'app.skin-site.login.forgot', defaultMessage: 'Forgot password?' },
|
||||
usernameHint: {
|
||||
id: 'app.skin-site.login.username-hint',
|
||||
defaultMessage: '3–16 characters, or a registered email address.',
|
||||
},
|
||||
passwordHint: {
|
||||
id: 'app.skin-site.login.password-hint',
|
||||
defaultMessage: '6–50 characters with upper case, lower case and a digit.',
|
||||
},
|
||||
success: { id: 'app.skin-site.login.success', defaultMessage: 'Signed in to StarLight.' },
|
||||
})
|
||||
|
||||
const PASSWORD_RE = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,50}$/
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const captchaModal = ref<InstanceType<typeof SkinSiteCaptchaModal>>()
|
||||
const registerModal = ref<InstanceType<typeof SkinSiteRegisterModal>>()
|
||||
const passwordResetModal = ref<InstanceType<typeof SkinSitePasswordResetModal>>()
|
||||
|
||||
function openRegister() {
|
||||
modal.value?.hide()
|
||||
registerModal.value?.show()
|
||||
}
|
||||
|
||||
function openPasswordReset() {
|
||||
modal.value?.hide()
|
||||
passwordResetModal.value?.show()
|
||||
}
|
||||
const username = ref('')
|
||||
const password = ref('')
|
||||
const working = ref(false)
|
||||
|
||||
const emit = defineEmits<{ (e: 'signed-in' | 'cancel'): void }>()
|
||||
|
||||
const usernameValid = computed(() => {
|
||||
const value = username.value.trim()
|
||||
if (!value) return false
|
||||
if (value.includes('@')) return value.length < 64
|
||||
return value.length >= 3 && value.length <= 16
|
||||
})
|
||||
|
||||
const passwordValid = computed(() => PASSWORD_RE.test(password.value))
|
||||
const canSubmit = computed(() => usernameValid.value && passwordValid.value && !working.value)
|
||||
|
||||
function reset() {
|
||||
username.value = ''
|
||||
password.value = ''
|
||||
working.value = false
|
||||
}
|
||||
|
||||
function show() {
|
||||
reset()
|
||||
modal.value?.show()
|
||||
}
|
||||
|
||||
async function beginSignIn() {
|
||||
if (!canSubmit.value) return
|
||||
captchaModal.value?.show()
|
||||
}
|
||||
|
||||
async function onCaptchaVerified(clientId: string) {
|
||||
working.value = true
|
||||
try {
|
||||
const result = await signInSkinSite({
|
||||
username: username.value.trim(),
|
||||
password: password.value,
|
||||
clientId,
|
||||
})
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
await reloadSkinSiteSession()
|
||||
addNotification({ type: 'success', title: formatMessage(messages.success) })
|
||||
modal.value?.hide()
|
||||
reset()
|
||||
emit('signed-in')
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
working.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
modal.value?.hide()
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
function onRegisterSignedIn() {
|
||||
emit('signed-in')
|
||||
}
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)" @hide="reset">
|
||||
<div class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.username) }}</span>
|
||||
<StyledInput v-model="username" type="text" autocomplete="username" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.usernameHint) }}</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.password) }}</span>
|
||||
<StyledInput v-model="password" type="password" autocomplete="current-password" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.passwordHint) }}</span>
|
||||
</label>
|
||||
<div class="flex justify-between text-sm">
|
||||
<button type="button" class="text-brand hover:underline" @click="openRegister">
|
||||
{{ formatMessage(messages.register) }}
|
||||
</button>
|
||||
<button type="button" class="text-brand hover:underline" @click="openPasswordReset">
|
||||
{{ formatMessage(messages.forgotPassword) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-secondary hover:bg-button-bg"
|
||||
@click="cancel"
|
||||
>
|
||||
{{ formatMessage(commonMessages.cancelButton) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
@click="beginSignIn"
|
||||
>
|
||||
{{ formatMessage(working ? messages.signingIn : messages.signIn) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
|
||||
<SkinSiteRegisterModal
|
||||
ref="registerModal"
|
||||
@signed-in="onRegisterSignedIn"
|
||||
@cancel="modal?.show()"
|
||||
/>
|
||||
<SkinSitePasswordResetModal
|
||||
ref="passwordResetModal"
|
||||
@done="modal?.show()"
|
||||
@cancel="modal?.show()"
|
||||
/>
|
||||
|
||||
<SkinSiteCaptchaModal
|
||||
ref="captchaModal"
|
||||
@verified="onCaptchaVerified"
|
||||
@cancel="working = false"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,142 @@
|
||||
<script setup lang="ts">
|
||||
import { ExternalIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import { type SkinSitePublicMapServer, skinSitePublicMapServers } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.map.title', defaultMessage: 'Server map' },
|
||||
back: { id: 'app.skin-site.map.back', defaultMessage: 'Back to home' },
|
||||
internal: { id: 'app.skin-site.map.internal', defaultMessage: 'Internal' },
|
||||
external: { id: 'app.skin-site.map.external', defaultMessage: 'External' },
|
||||
server: { id: 'app.skin-site.map.server', defaultMessage: 'Server' },
|
||||
map: { id: 'app.skin-site.map.map', defaultMessage: 'Map' },
|
||||
openExternal: { id: 'app.skin-site.map.open', defaultMessage: 'Open in browser' },
|
||||
loading: { id: 'app.skin-site.map.loading', defaultMessage: 'Loading maps…' },
|
||||
empty: { id: 'app.skin-site.map.empty', defaultMessage: 'No maps available.' },
|
||||
failed: { id: 'app.skin-site.map.failed', defaultMessage: 'Could not load maps.' },
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const servers = ref<SkinSitePublicMapServer[]>([])
|
||||
const internal = ref(false)
|
||||
const serverIndex = ref(0)
|
||||
const mapIndex = ref(0)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
const filteredServers = computed(() => servers.value.filter((s) => s.internal === internal.value))
|
||||
const selectedServer = computed(() => filteredServers.value[serverIndex.value])
|
||||
const selectedMap = computed(() => selectedServer.value?.maps[mapIndex.value])
|
||||
|
||||
watch(internal, () => {
|
||||
serverIndex.value = 0
|
||||
mapIndex.value = 0
|
||||
})
|
||||
watch(serverIndex, () => {
|
||||
mapIndex.value = 0
|
||||
})
|
||||
|
||||
async function openExternal() {
|
||||
if (!selectedMap.value) return
|
||||
const { openUrl } = await import('@tauri-apps/plugin-opener')
|
||||
await openUrl(selectedMap.value.url)
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSitePublicMapServers()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
servers.value = result.payload ?? []
|
||||
if (!servers.value.some((s) => !s.internal)) internal.value = true
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex h-full min-h-0 flex-col gap-3">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
<h1 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
|
||||
<select
|
||||
v-model="internal"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
>
|
||||
<option :value="false">{{ formatMessage(messages.external) }}</option>
|
||||
<option :value="true">{{ formatMessage(messages.internal) }}</option>
|
||||
</select>
|
||||
|
||||
<select
|
||||
v-if="filteredServers.length"
|
||||
v-model.number="serverIndex"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
>
|
||||
<option v-for="(server, index) in filteredServers" :key="index" :value="index">
|
||||
{{ server.name }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<select
|
||||
v-if="selectedServer?.maps.length"
|
||||
v-model.number="mapIndex"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
>
|
||||
<option v-for="(map, index) in selectedServer.maps" :key="index" :value="index">
|
||||
{{ map.name }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<button
|
||||
v-if="selectedMap"
|
||||
type="button"
|
||||
class="ml-auto flex items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openExternal"
|
||||
>
|
||||
<ExternalIcon class="size-3.5" />
|
||||
{{ formatMessage(messages.openExternal) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="loading"
|
||||
class="flex flex-1 items-center justify-center gap-2 text-sm text-secondary"
|
||||
>
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 flex-1 text-center text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!selectedMap" class="m-0 flex-1 text-center text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<iframe
|
||||
v-else
|
||||
:key="selectedMap.url"
|
||||
:src="selectedMap.url"
|
||||
:title="`${selectedServer?.name} · ${selectedMap.name}`"
|
||||
class="min-h-0 w-full flex-1 rounded-lg border border-solid border-surface-5"
|
||||
allow="fullscreen"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,145 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
BookIcon,
|
||||
BugIcon,
|
||||
DownloadIcon,
|
||||
MapIcon,
|
||||
ShieldCheckIcon,
|
||||
UserIcon,
|
||||
} from '@modrinth/assets'
|
||||
import { defineMessages, useVIntl } from '@modrinth/ui'
|
||||
import type { Component } from 'vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'navigate', view: 'downloads' | 'review' | 'bugs' | 'map' | 'wiki'): void
|
||||
}>()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.home.nav.title', defaultMessage: 'Skin site' },
|
||||
download: { id: 'app.skin-site.home.nav.download', defaultMessage: 'Downloads' },
|
||||
downloadDesc: {
|
||||
id: 'app.skin-site.home.nav.download-desc',
|
||||
defaultMessage: 'Browse files shared by the server.',
|
||||
},
|
||||
review: { id: 'app.skin-site.home.nav.review', defaultMessage: 'Player review' },
|
||||
reviewDesc: {
|
||||
id: 'app.skin-site.home.nav.review-desc',
|
||||
defaultMessage: 'Submit and review player applications.',
|
||||
},
|
||||
wiki: { id: 'app.skin-site.home.nav.wiki', defaultMessage: 'Server wiki' },
|
||||
wikiDesc: {
|
||||
id: 'app.skin-site.home.nav.wiki-desc',
|
||||
defaultMessage: 'Guides and documentation for the server.',
|
||||
},
|
||||
bugs: { id: 'app.skin-site.home.nav.bugs', defaultMessage: 'Bug tracker' },
|
||||
bugsDesc: {
|
||||
id: 'app.skin-site.home.nav.bugs-desc',
|
||||
defaultMessage: 'Report issues and follow their progress.',
|
||||
},
|
||||
map: { id: 'app.skin-site.home.nav.map', defaultMessage: 'Server map' },
|
||||
mapDesc: {
|
||||
id: 'app.skin-site.home.nav.map-desc',
|
||||
defaultMessage: 'Explore the live world map.',
|
||||
},
|
||||
profile: { id: 'app.skin-site.home.nav.profile', defaultMessage: 'Profile' },
|
||||
profileDesc: {
|
||||
id: 'app.skin-site.home.nav.profile-desc',
|
||||
defaultMessage: 'Manage your account and textures.',
|
||||
},
|
||||
})
|
||||
|
||||
interface NavItem {
|
||||
id: string
|
||||
title: string
|
||||
description: string
|
||||
icon: Component
|
||||
href: string
|
||||
}
|
||||
|
||||
const SKIN_SITE = 'https://skin.starlight.cool'
|
||||
|
||||
const items: NavItem[] = [
|
||||
{
|
||||
id: 'download',
|
||||
title: formatMessage(messages.download),
|
||||
description: formatMessage(messages.downloadDesc),
|
||||
icon: DownloadIcon,
|
||||
href: `${SKIN_SITE}/download`,
|
||||
},
|
||||
{
|
||||
id: 'review',
|
||||
title: formatMessage(messages.review),
|
||||
description: formatMessage(messages.reviewDesc),
|
||||
icon: ShieldCheckIcon,
|
||||
href: `${SKIN_SITE}/review`,
|
||||
},
|
||||
{
|
||||
id: 'wiki',
|
||||
title: formatMessage(messages.wiki),
|
||||
description: formatMessage(messages.wikiDesc),
|
||||
icon: BookIcon,
|
||||
href: `${SKIN_SITE}/wiki`,
|
||||
},
|
||||
{
|
||||
id: 'bugs',
|
||||
title: formatMessage(messages.bugs),
|
||||
description: formatMessage(messages.bugsDesc),
|
||||
icon: BugIcon,
|
||||
href: `${SKIN_SITE}/bugs`,
|
||||
},
|
||||
{
|
||||
id: 'map',
|
||||
title: formatMessage(messages.map),
|
||||
description: formatMessage(messages.mapDesc),
|
||||
icon: MapIcon,
|
||||
href: `${SKIN_SITE}/map`,
|
||||
},
|
||||
{
|
||||
id: 'profile',
|
||||
title: formatMessage(messages.profile),
|
||||
description: formatMessage(messages.profileDesc),
|
||||
icon: UserIcon,
|
||||
href: `${SKIN_SITE}/profile`,
|
||||
},
|
||||
]
|
||||
|
||||
function open(item: NavItem) {
|
||||
if (
|
||||
item.id === 'download' ||
|
||||
item.id === 'review' ||
|
||||
item.id === 'bugs' ||
|
||||
item.id === 'map' ||
|
||||
item.id === 'wiki'
|
||||
) {
|
||||
emit(
|
||||
'navigate',
|
||||
item.id === 'download'
|
||||
? 'downloads'
|
||||
: (item.id as 'review' | 'bugs' | 'map' | 'wiki'),
|
||||
)
|
||||
return
|
||||
}
|
||||
void import('@tauri-apps/plugin-opener').then(({ openUrl }) => openUrl(item.href))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-3">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">{{ formatMessage(messages.title) }}</h3>
|
||||
<div class="grid grid-cols-2 gap-3 sm:grid-cols-3">
|
||||
<button
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="flex flex-col items-start gap-1 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3 text-left transition-colors hover:bg-button-bg"
|
||||
@click="open(item)"
|
||||
>
|
||||
<component :is="item.icon" class="size-5 text-brand" />
|
||||
<span class="text-sm font-semibold text-contrast">{{ item.title }}</span>
|
||||
<span class="text-xs text-secondary">{{ item.description }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,238 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
StyledInput,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, onUnmounted, ref } from 'vue'
|
||||
|
||||
import { skinSitePasswordReset, skinSitePasswordResetEmailVerify } from '@/helpers/skin-site-api'
|
||||
|
||||
import SkinSiteCaptchaModal from './SkinSiteCaptchaModal.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.reset.title', defaultMessage: 'Reset password' },
|
||||
email: { id: 'app.skin-site.reset.email', defaultMessage: 'Email' },
|
||||
emailHint: {
|
||||
id: 'app.skin-site.reset.email-hint',
|
||||
defaultMessage: 'Use the address you registered with.',
|
||||
},
|
||||
code: { id: 'app.skin-site.reset.code', defaultMessage: 'Verification code' },
|
||||
sendCode: { id: 'app.skin-site.reset.send-code', defaultMessage: 'Send code' },
|
||||
sending: { id: 'app.skin-site.reset.sending', defaultMessage: 'Sending…' },
|
||||
resendIn: { id: 'app.skin-site.reset.resend-in', defaultMessage: 'Sent ({seconds}s)' },
|
||||
newPassword: { id: 'app.skin-site.reset.new-password', defaultMessage: 'New password' },
|
||||
repeatPassword: { id: 'app.skin-site.reset.repeat-password', defaultMessage: 'Repeat password' },
|
||||
passwordHint: {
|
||||
id: 'app.skin-site.reset.password-hint',
|
||||
defaultMessage: '6–50 characters with upper case, lower case and a digit.',
|
||||
},
|
||||
mismatch: { id: 'app.skin-site.reset.mismatch', defaultMessage: 'Passwords do not match.' },
|
||||
submit: { id: 'app.skin-site.reset.submit', defaultMessage: 'Reset password' },
|
||||
success: {
|
||||
id: 'app.skin-site.reset.success',
|
||||
defaultMessage: 'Password updated. You can sign in now.',
|
||||
},
|
||||
})
|
||||
|
||||
const PASSWORD_RE = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,50}$/
|
||||
const COUNTDOWN_SECONDS = 60
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const captchaModal = ref<InstanceType<typeof SkinSiteCaptchaModal>>()
|
||||
const email = ref('')
|
||||
const code = ref('')
|
||||
const newPassword = ref('')
|
||||
const repeatPassword = ref('')
|
||||
const sending = ref(false)
|
||||
const working = ref(false)
|
||||
const countdown = ref(0)
|
||||
let timer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
const emit = defineEmits<{ (e: 'done' | 'cancel'): void }>()
|
||||
|
||||
function stopTimer() {
|
||||
if (timer) clearInterval(timer)
|
||||
timer = undefined
|
||||
}
|
||||
|
||||
function startCountdown() {
|
||||
countdown.value = COUNTDOWN_SECONDS
|
||||
stopTimer()
|
||||
timer = setInterval(() => {
|
||||
countdown.value -= 1
|
||||
if (countdown.value <= 0) stopTimer()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const canSendCode = computed(
|
||||
() => email.value.trim().length > 0 && !sending.value && countdown.value <= 0,
|
||||
)
|
||||
|
||||
const passwordValid = computed(() => PASSWORD_RE.test(newPassword.value))
|
||||
const passwordsMatch = computed(() => newPassword.value === repeatPassword.value)
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
email.value.trim().length > 0 &&
|
||||
code.value.trim().length === 6 &&
|
||||
passwordValid.value &&
|
||||
passwordsMatch.value &&
|
||||
!working.value,
|
||||
)
|
||||
|
||||
function reset() {
|
||||
stopTimer()
|
||||
email.value = ''
|
||||
code.value = ''
|
||||
newPassword.value = ''
|
||||
repeatPassword.value = ''
|
||||
sending.value = false
|
||||
working.value = false
|
||||
countdown.value = 0
|
||||
}
|
||||
|
||||
function show() {
|
||||
reset()
|
||||
modal.value?.show()
|
||||
}
|
||||
|
||||
async function sendCode() {
|
||||
if (!canSendCode.value) return
|
||||
sending.value = true
|
||||
try {
|
||||
const result = await skinSitePasswordResetEmailVerify(email.value.trim())
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
addNotification({ type: 'success', title: result.payload })
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function beginReset() {
|
||||
if (!canSubmit.value) return
|
||||
if (!passwordsMatch.value) {
|
||||
handleError(new Error(formatMessage(messages.mismatch)))
|
||||
return
|
||||
}
|
||||
captchaModal.value?.show()
|
||||
}
|
||||
|
||||
async function onCaptchaVerified(clientId: string) {
|
||||
working.value = true
|
||||
try {
|
||||
const result = await skinSitePasswordReset({
|
||||
clientId,
|
||||
email: email.value.trim(),
|
||||
emailVerifyCode: code.value.trim(),
|
||||
newPassword: newPassword.value,
|
||||
})
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
addNotification({ type: 'success', title: formatMessage(messages.success) })
|
||||
modal.value?.hide()
|
||||
emit('done')
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
working.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
modal.value?.hide()
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
onUnmounted(stopTimer)
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)" @hide="reset">
|
||||
<div class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.email) }}</span>
|
||||
<StyledInput v-model="email" type="email" autocomplete="email" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.emailHint) }}</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.code) }}</span>
|
||||
<div class="flex gap-2">
|
||||
<StyledInput v-model="code" type="text" class="flex-1" maxlength="6" />
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-4 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSendCode"
|
||||
@click="sendCode"
|
||||
>
|
||||
{{
|
||||
sending
|
||||
? formatMessage(messages.sending)
|
||||
: countdown > 0
|
||||
? formatMessage(messages.resendIn, { seconds: countdown })
|
||||
: formatMessage(messages.sendCode)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.newPassword) }}</span>
|
||||
<StyledInput v-model="newPassword" type="password" autocomplete="new-password" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.passwordHint) }}</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{
|
||||
formatMessage(messages.repeatPassword)
|
||||
}}</span>
|
||||
<StyledInput v-model="repeatPassword" type="password" autocomplete="new-password" />
|
||||
<span v-if="repeatPassword && !passwordsMatch" class="text-xs text-red">
|
||||
{{ formatMessage(messages.mismatch) }}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-secondary hover:bg-button-bg"
|
||||
@click="cancel"
|
||||
>
|
||||
{{ formatMessage(commonMessages.cancelButton) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
@click="beginReset"
|
||||
>
|
||||
{{ formatMessage(messages.submit) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
|
||||
<SkinSiteCaptchaModal
|
||||
ref="captchaModal"
|
||||
@verified="onCaptchaVerified"
|
||||
@cancel="working = false"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,402 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
StyledInput,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, onUnmounted, ref } from 'vue'
|
||||
|
||||
import { reloadSkinSiteSession, skinSiteUser } from '@/composables/skin-site-session'
|
||||
import {
|
||||
skinSiteChangePassword,
|
||||
skinSiteChangeUsername,
|
||||
skinSiteChangeYggdrasilPassword,
|
||||
skinSiteUploadAvatar,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.profile.title', defaultMessage: 'Account settings' },
|
||||
basic: { id: 'app.skin-site.profile.basic', defaultMessage: 'Profile' },
|
||||
username: { id: 'app.skin-site.profile.username', defaultMessage: 'Username' },
|
||||
usernameHint: {
|
||||
id: 'app.skin-site.profile.username-hint',
|
||||
defaultMessage: '3–16 characters.',
|
||||
},
|
||||
save: { id: 'app.skin-site.profile.save', defaultMessage: 'Save' },
|
||||
avatar: { id: 'app.skin-site.profile.avatar', defaultMessage: 'Avatar' },
|
||||
chooseAvatar: { id: 'app.skin-site.profile.choose-avatar', defaultMessage: 'Choose image' },
|
||||
avatarHint: {
|
||||
id: 'app.skin-site.profile.avatar-hint',
|
||||
defaultMessage: 'Square images work best; the centre is cropped to 256×256.',
|
||||
},
|
||||
security: { id: 'app.skin-site.profile.security', defaultMessage: 'Security' },
|
||||
sitePasswordHint: {
|
||||
id: 'app.skin-site.profile.site-password-hint',
|
||||
defaultMessage: 'This is the password used to sign in to the skin site.',
|
||||
},
|
||||
oldPassword: { id: 'app.skin-site.profile.old-password', defaultMessage: 'Current password' },
|
||||
newPassword: { id: 'app.skin-site.profile.new-password', defaultMessage: 'New password' },
|
||||
repeatPassword: {
|
||||
id: 'app.skin-site.profile.repeat-password',
|
||||
defaultMessage: 'Repeat new password',
|
||||
},
|
||||
mismatch: { id: 'app.skin-site.profile.mismatch', defaultMessage: 'Passwords do not match.' },
|
||||
passwordHint: {
|
||||
id: 'app.skin-site.profile.password-hint',
|
||||
defaultMessage: '6–50 characters with upper case, lower case and a digit.',
|
||||
},
|
||||
submitPassword: {
|
||||
id: 'app.skin-site.profile.submit-password',
|
||||
defaultMessage: 'Update password',
|
||||
},
|
||||
minecraftPassword: {
|
||||
id: 'app.skin-site.profile.minecraft-password',
|
||||
defaultMessage: 'Minecraft password',
|
||||
},
|
||||
minecraftPasswordHint: {
|
||||
id: 'app.skin-site.profile.minecraft-password-hint',
|
||||
defaultMessage: 'Used by the launcher; defaults to the website password.',
|
||||
},
|
||||
resetDefault: {
|
||||
id: 'app.skin-site.profile.reset-default',
|
||||
defaultMessage: 'Reset to website password',
|
||||
},
|
||||
saved: { id: 'app.skin-site.profile.saved', defaultMessage: 'Saved.' },
|
||||
avatarUploaded: {
|
||||
id: 'app.skin-site.profile.avatar-uploaded',
|
||||
defaultMessage: 'Avatar updated.',
|
||||
},
|
||||
passwordChanged: {
|
||||
id: 'app.skin-site.profile.password-changed',
|
||||
defaultMessage: 'Password updated.',
|
||||
},
|
||||
minecraftPasswordChanged: {
|
||||
id: 'app.skin-site.profile.minecraft-password-changed',
|
||||
defaultMessage: 'Minecraft password updated.',
|
||||
},
|
||||
})
|
||||
|
||||
const PASSWORD_RE = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)\S{6,50}$/
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const username = ref('')
|
||||
const savingUsername = ref(false)
|
||||
const avatarPreview = ref('')
|
||||
const uploadingAvatar = ref(false)
|
||||
|
||||
const oldPassword = ref('')
|
||||
const newPassword = ref('')
|
||||
const repeatPassword = ref('')
|
||||
const savingPassword = ref(false)
|
||||
|
||||
const newMinecraftPassword = ref('')
|
||||
const repeatMinecraftPassword = ref('')
|
||||
const savingMinecraftPassword = ref(false)
|
||||
|
||||
const usernameValid = computed(() => {
|
||||
const value = username.value.trim()
|
||||
return value.length >= 3 && value.length <= 16
|
||||
})
|
||||
const usernameChanged = computed(
|
||||
() => !!skinSiteUser.value && username.value.trim() !== skinSiteUser.value.username,
|
||||
)
|
||||
|
||||
const passwordValid = computed(() => PASSWORD_RE.test(newPassword.value))
|
||||
const passwordsMatch = computed(() => newPassword.value === repeatPassword.value)
|
||||
const canSavePassword = computed(
|
||||
() => !!oldPassword.value && passwordValid.value && passwordsMatch.value && !savingPassword.value,
|
||||
)
|
||||
|
||||
const minecraftPasswordValid = computed(() => PASSWORD_RE.test(newMinecraftPassword.value))
|
||||
const minecraftPasswordsMatch = computed(
|
||||
() => newMinecraftPassword.value === repeatMinecraftPassword.value,
|
||||
)
|
||||
const canSaveMinecraftPassword = computed(
|
||||
() =>
|
||||
minecraftPasswordValid.value && minecraftPasswordsMatch.value && !savingMinecraftPassword.value,
|
||||
)
|
||||
|
||||
function show() {
|
||||
username.value = skinSiteUser.value?.username ?? ''
|
||||
avatarPreview.value = ''
|
||||
oldPassword.value = ''
|
||||
newPassword.value = ''
|
||||
repeatPassword.value = ''
|
||||
newMinecraftPassword.value = ''
|
||||
repeatMinecraftPassword.value = ''
|
||||
modal.value?.show()
|
||||
}
|
||||
async function saveUsername() {
|
||||
if (!usernameChanged.value || !usernameValid.value) return
|
||||
savingUsername.value = true
|
||||
try {
|
||||
const result = await skinSiteChangeUsername(username.value.trim())
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
await reloadSkinSiteSession()
|
||||
addNotification({ type: 'success', title: formatMessage(messages.saved) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingUsername.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** Centre-crop the picked image to a square and scale it to 256×256. */
|
||||
async function cropToSquare(file: File): Promise<Blob> {
|
||||
const bitmap = await createImageBitmap(file)
|
||||
const side = Math.min(bitmap.width, bitmap.height)
|
||||
const sx = (bitmap.width - side) / 2
|
||||
const sy = (bitmap.height - side) / 2
|
||||
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = 256
|
||||
canvas.height = 256
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (!ctx) throw new Error('无法创建画布')
|
||||
ctx.imageSmoothingQuality = 'high'
|
||||
ctx.drawImage(bitmap, sx, sy, side, side, 0, 0, 256, 256)
|
||||
bitmap.close?.()
|
||||
|
||||
return await new Promise<Blob>((resolve, reject) => {
|
||||
canvas.toBlob((blob) => (blob ? resolve(blob) : reject(new Error('无法处理图片'))), 'image/png')
|
||||
})
|
||||
}
|
||||
|
||||
async function onAvatarPicked(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
uploadingAvatar.value = true
|
||||
try {
|
||||
const blob = await cropToSquare(file)
|
||||
avatarPreview.value = URL.createObjectURL(blob)
|
||||
const result = await skinSiteUploadAvatar(blob)
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
await reloadSkinSiteSession()
|
||||
addNotification({ type: 'success', title: formatMessage(messages.avatarUploaded) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
uploadingAvatar.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function savePassword() {
|
||||
if (!canSavePassword.value) return
|
||||
savingPassword.value = true
|
||||
try {
|
||||
const result = await skinSiteChangePassword(oldPassword.value, newPassword.value)
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
oldPassword.value = ''
|
||||
newPassword.value = ''
|
||||
repeatPassword.value = ''
|
||||
addNotification({ type: 'success', title: formatMessage(messages.passwordChanged) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingPassword.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveMinecraftPassword(resetToDefault: boolean) {
|
||||
if (!resetToDefault && !canSaveMinecraftPassword.value) return
|
||||
savingMinecraftPassword.value = true
|
||||
try {
|
||||
const result = await skinSiteChangeYggdrasilPassword(
|
||||
resetToDefault ? null : newMinecraftPassword.value,
|
||||
)
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
newMinecraftPassword.value = ''
|
||||
repeatMinecraftPassword.value = ''
|
||||
addNotification({ type: 'success', title: formatMessage(messages.minecraftPasswordChanged) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingMinecraftPassword.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
modal.value?.hide()
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
if (avatarPreview.value) URL.revokeObjectURL(avatarPreview.value)
|
||||
})
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)">
|
||||
<div class="flex flex-col gap-6">
|
||||
<section class="flex flex-col gap-3">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">
|
||||
{{ formatMessage(messages.basic) }}
|
||||
</h3>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.username)
|
||||
}}</span>
|
||||
<div class="flex gap-2">
|
||||
<StyledInput v-model="username" type="text" class="flex-1" maxlength="16" />
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-brand px-4 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!usernameChanged || !usernameValid || savingUsername"
|
||||
@click="saveUsername"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.usernameHint) }}</span>
|
||||
</label>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.avatar)
|
||||
}}</span>
|
||||
<div class="flex items-center gap-3">
|
||||
<img
|
||||
v-if="avatarPreview"
|
||||
:src="avatarPreview"
|
||||
alt=""
|
||||
class="size-12 rounded-lg object-cover"
|
||||
/>
|
||||
<label
|
||||
class="cursor-pointer rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
>
|
||||
{{ formatMessage(messages.chooseAvatar) }}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
class="hidden"
|
||||
:disabled="uploadingAvatar"
|
||||
@change="onAvatarPicked"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.avatarHint) }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="flex flex-col gap-3">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">
|
||||
{{ formatMessage(messages.security) }}
|
||||
</h3>
|
||||
<span class="text-sm text-secondary">{{ formatMessage(messages.sitePasswordHint) }}</span>
|
||||
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
||||
<StyledInput
|
||||
v-model="oldPassword"
|
||||
type="password"
|
||||
:placeholder="formatMessage(messages.oldPassword)"
|
||||
autocomplete="current-password"
|
||||
/>
|
||||
<StyledInput
|
||||
v-model="newPassword"
|
||||
type="password"
|
||||
:placeholder="formatMessage(messages.newPassword)"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
<StyledInput
|
||||
v-model="repeatPassword"
|
||||
type="password"
|
||||
:placeholder="formatMessage(messages.repeatPassword)"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</div>
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.passwordHint) }}</span>
|
||||
<span v-if="repeatPassword && !passwordsMatch" class="text-xs text-red">
|
||||
{{ formatMessage(messages.mismatch) }}
|
||||
</span>
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSavePassword"
|
||||
@click="savePassword"
|
||||
>
|
||||
{{ formatMessage(messages.submitPassword) }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="flex flex-col gap-3">
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.minecraftPassword)
|
||||
}}</span>
|
||||
<span class="text-xs text-secondary">{{
|
||||
formatMessage(messages.minecraftPasswordHint)
|
||||
}}</span>
|
||||
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<StyledInput
|
||||
v-model="newMinecraftPassword"
|
||||
type="password"
|
||||
:placeholder="formatMessage(messages.newPassword)"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
<StyledInput
|
||||
v-model="repeatMinecraftPassword"
|
||||
type="password"
|
||||
:placeholder="formatMessage(messages.repeatPassword)"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="repeatMinecraftPassword && !minecraftPasswordsMatch" class="text-xs text-red">
|
||||
{{ formatMessage(messages.mismatch) }}
|
||||
</span>
|
||||
<div class="flex flex-wrap justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast"
|
||||
:disabled="savingMinecraftPassword"
|
||||
@click="saveMinecraftPassword(true)"
|
||||
>
|
||||
{{ formatMessage(messages.resetDefault) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSaveMinecraftPassword"
|
||||
@click="saveMinecraftPassword(false)"
|
||||
>
|
||||
{{ formatMessage(messages.submitPassword) }}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-secondary hover:bg-button-bg"
|
||||
@click="close"
|
||||
>
|
||||
{{ formatMessage(commonMessages.closeButton) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
</template>
|
||||
@@ -0,0 +1,283 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon, TrashIcon, UploadIcon } from '@modrinth/assets'
|
||||
import { Avatar, defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import SkinPreviewRenderer from '@modrinth/ui/src/components/skin/SkinPreviewRenderer.vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
requestSkinSitePlayers,
|
||||
skinSitePlayers,
|
||||
skinSitePlayersStatus,
|
||||
skinSiteStatus,
|
||||
skinSiteUser,
|
||||
} from '@/composables/skin-site-session'
|
||||
import {
|
||||
skinSiteDeleteTexture,
|
||||
type SkinSitePlayerSkin,
|
||||
skinSitePlayerSkin,
|
||||
skinSiteUploadTexture,
|
||||
type SkinTextureType,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.profile-view.title', defaultMessage: 'Your players' },
|
||||
signedOut: {
|
||||
id: 'app.skin-site.profile-view.signed-out',
|
||||
defaultMessage: 'Sign in to manage your players.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.profile-view.loading', defaultMessage: 'Loading players…' },
|
||||
noPlayers: {
|
||||
id: 'app.skin-site.profile-view.no-players',
|
||||
defaultMessage: 'No players yet.',
|
||||
},
|
||||
selectHint: {
|
||||
id: 'app.skin-site.profile-view.select-hint',
|
||||
defaultMessage: 'Select a player to preview and edit its textures.',
|
||||
},
|
||||
skin: { id: 'app.skin-site.profile-view.skin', defaultMessage: 'Skin' },
|
||||
cape: { id: 'app.skin-site.profile-view.cape', defaultMessage: 'Cape' },
|
||||
elytra: { id: 'app.skin-site.profile-view.elytra', defaultMessage: 'Elytra' },
|
||||
upload: { id: 'app.skin-site.profile-view.upload', defaultMessage: 'Upload' },
|
||||
remove: { id: 'app.skin-site.profile-view.remove', defaultMessage: 'Remove' },
|
||||
readonly: {
|
||||
id: 'app.skin-site.profile-view.readonly',
|
||||
defaultMessage: 'Mojang accounts are managed by Mojang; textures cannot be edited here.',
|
||||
},
|
||||
uploaded: { id: 'app.skin-site.profile-view.uploaded', defaultMessage: 'Texture updated.' },
|
||||
removed: { id: 'app.skin-site.profile-view.removed', defaultMessage: 'Texture removed.' },
|
||||
back: { id: 'app.skin-site.profile-view.back', defaultMessage: 'Back to home' },
|
||||
})
|
||||
const selectedId = ref<string | null>(null)
|
||||
const texture = ref<SkinSitePlayerSkin>({})
|
||||
const loadingTexture = ref(false)
|
||||
const uploading = ref<SkinTextureType | null>(null)
|
||||
|
||||
const signedIn = computed(() => skinSiteStatus.value === 'signed-in' && !!skinSiteUser.value)
|
||||
const players = computed(() => skinSitePlayers.value)
|
||||
const playersLoading = computed(
|
||||
() => skinSitePlayersStatus.value === 'checking' || skinSitePlayersStatus.value === 'idle',
|
||||
)
|
||||
const selectedPlayer = computed(
|
||||
() => players.value.find((p) => p.uuid === selectedId.value) ?? null,
|
||||
)
|
||||
const editable = computed(() => !!selectedPlayer.value && !selectedPlayer.value.isMojang)
|
||||
|
||||
const skinVariant = computed<'CLASSIC' | 'SLIM'>(() =>
|
||||
texture.value.model === 'slim' ? 'SLIM' : 'CLASSIC',
|
||||
)
|
||||
|
||||
function selectPlayer(id: string) {
|
||||
selectedId.value = id
|
||||
}
|
||||
|
||||
async function loadTexture(uuid: string) {
|
||||
loadingTexture.value = true
|
||||
texture.value = {}
|
||||
try {
|
||||
const result = await skinSitePlayerSkin(uuid)
|
||||
if (result.success && result.payload) texture.value = result.payload
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
loadingTexture.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(selectedId, (id) => {
|
||||
if (id) void loadTexture(id)
|
||||
else texture.value = {}
|
||||
})
|
||||
|
||||
async function onUpload(type: SkinTextureType, event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file || !selectedId.value) return
|
||||
uploading.value = type
|
||||
try {
|
||||
const metadata: Record<string, string> = {}
|
||||
if (type === 'SKIN') metadata.model = texture.value.model ?? 'default'
|
||||
const result = await skinSiteUploadTexture(selectedId.value, file, type, metadata)
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
addNotification({ type: 'success', title: formatMessage(messages.uploaded) })
|
||||
await loadTexture(selectedId.value)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
uploading.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function removeTexture(type: SkinTextureType) {
|
||||
if (!selectedId.value) return
|
||||
uploading.value = type
|
||||
try {
|
||||
const result = await skinSiteDeleteTexture(selectedId.value, type)
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
addNotification({ type: 'success', title: formatMessage(messages.removed) })
|
||||
await loadTexture(selectedId.value)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
uploading.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (signedIn.value) void requestSkinSitePlayers().catch(() => {})
|
||||
})
|
||||
|
||||
watch(signedIn, (value) => {
|
||||
if (value) void requestSkinSitePlayers().catch(() => {})
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<div v-if="!signedIn" class="rounded-2xl border border-solid border-surface-5 bg-bg-raised p-4">
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.signedOut) }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="grid grid-cols-1 gap-4 lg:grid-cols-[18rem_minmax(0,1fr)]">
|
||||
<!-- Player list -->
|
||||
<div
|
||||
class="flex flex-col gap-2 rounded-2xl border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">
|
||||
{{ formatMessage(messages.title) }}
|
||||
</h3>
|
||||
|
||||
<div v-if="playersLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="!players.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.noPlayers) }}
|
||||
</p>
|
||||
<button
|
||||
v-for="player in players"
|
||||
:key="player.uuid"
|
||||
type="button"
|
||||
class="flex items-center gap-2 rounded-xl px-2 py-1.5 text-left transition-colors"
|
||||
:class="
|
||||
player.uuid === selectedId
|
||||
? 'bg-brand-highlight text-contrast'
|
||||
: 'bg-button-bg hover:brightness-110'
|
||||
"
|
||||
@click="selectPlayer(player.uuid)"
|
||||
>
|
||||
<Avatar
|
||||
:src="player.headDataUrl"
|
||||
:alt="player.name"
|
||||
size="1.75rem"
|
||||
pixelated
|
||||
class="!rounded-md"
|
||||
/>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-medium">{{ player.name }}</span>
|
||||
<span v-if="player.isMojang" class="shrink-0 text-[10px] uppercase text-secondary"
|
||||
>Mojang</span
|
||||
>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Preview + texture actions -->
|
||||
<div
|
||||
class="flex flex-col gap-4 rounded-2xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<p v-if="!selectedPlayer" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.selectHint) }}
|
||||
</p>
|
||||
|
||||
<template v-else>
|
||||
<div class="flex items-center gap-2">
|
||||
<h3 class="m-0 text-base font-semibold text-contrast">{{ selectedPlayer.name }}</h3>
|
||||
<span v-if="selectedPlayer.isMojang" class="text-xs text-secondary">Mojang</span>
|
||||
</div>
|
||||
|
||||
<div class="relative h-80 w-full overflow-hidden rounded-xl bg-button-bg">
|
||||
<div v-if="loadingTexture" class="absolute inset-0 flex items-center justify-center">
|
||||
<SpinnerIcon class="size-6 animate-spin text-secondary" />
|
||||
</div>
|
||||
<SkinPreviewRenderer
|
||||
v-else
|
||||
:texture-src="texture.skin ?? ''"
|
||||
:cape-src="texture.cape"
|
||||
:variant="skinVariant"
|
||||
:nametag="selectedPlayer.name"
|
||||
:initial-rotation="Math.PI / 8"
|
||||
class="size-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p v-if="!editable" class="m-0 text-xs text-secondary">
|
||||
{{ formatMessage(messages.readonly) }}
|
||||
</p>
|
||||
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="entry in [
|
||||
{ type: 'SKIN' as SkinTextureType, label: messages.skin, value: texture.skin },
|
||||
{ type: 'CAPE' as SkinTextureType, label: messages.cape, value: texture.cape },
|
||||
{
|
||||
type: 'ELYTRA' as SkinTextureType,
|
||||
label: messages.elytra,
|
||||
value: texture.elytra,
|
||||
},
|
||||
]"
|
||||
:key="entry.type"
|
||||
class="flex items-center gap-2 rounded-xl bg-button-bg px-3 py-2"
|
||||
>
|
||||
<span class="min-w-0 flex-1 text-sm font-medium text-contrast">
|
||||
{{ formatMessage(entry.label) }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">
|
||||
{{ entry.value ? '✓' : '—' }}
|
||||
</span>
|
||||
<label
|
||||
class="flex shrink-0 cursor-pointer items-center gap-1 rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast"
|
||||
>
|
||||
<UploadIcon class="size-3" />
|
||||
{{ formatMessage(messages.upload) }}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/png"
|
||||
class="hidden"
|
||||
:disabled="uploading !== null"
|
||||
@change="(e) => onUpload(entry.type, e)"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="entry.value"
|
||||
type="button"
|
||||
class="flex shrink-0 items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-red"
|
||||
:disabled="uploading !== null"
|
||||
@click="removeTexture(entry.type)"
|
||||
>
|
||||
<TrashIcon class="size-3" />
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,299 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
commonMessages,
|
||||
defineMessages,
|
||||
injectNotificationManager,
|
||||
NewModal,
|
||||
StyledInput,
|
||||
useVIntl,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, onUnmounted, ref } from 'vue'
|
||||
|
||||
import { reloadSkinSiteSession, signInSkinSite } from '@/composables/skin-site-session'
|
||||
import {
|
||||
skinSiteRegister,
|
||||
skinSiteRegisterCondition,
|
||||
skinSiteRegisterEmailVerify,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
import SkinSiteCaptchaModal from './SkinSiteCaptchaModal.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.register.title', defaultMessage: 'Create a StarLight account' },
|
||||
email: { id: 'app.skin-site.register.email', defaultMessage: 'Email' },
|
||||
code: { id: 'app.skin-site.register.code', defaultMessage: 'Verification code' },
|
||||
sendCode: { id: 'app.skin-site.register.send-code', defaultMessage: 'Send code' },
|
||||
sending: { id: 'app.skin-site.register.sending', defaultMessage: 'Sending…' },
|
||||
resendIn: { id: 'app.skin-site.register.resend-in', defaultMessage: 'Sent ({seconds}s)' },
|
||||
password: { id: 'app.skin-site.register.password', defaultMessage: 'Password' },
|
||||
repeatPassword: {
|
||||
id: 'app.skin-site.register.repeat-password',
|
||||
defaultMessage: 'Repeat password',
|
||||
},
|
||||
passwordHint: {
|
||||
id: 'app.skin-site.register.password-hint',
|
||||
defaultMessage: '6–50 characters with upper case, lower case and a digit.',
|
||||
},
|
||||
mismatch: { id: 'app.skin-site.register.mismatch', defaultMessage: 'Passwords do not match.' },
|
||||
qq: { id: 'app.skin-site.register.qq', defaultMessage: 'QQ (optional)' },
|
||||
inviteCode: { id: 'app.skin-site.register.invite-code', defaultMessage: 'Invite code' },
|
||||
inviteRequired: {
|
||||
id: 'app.skin-site.register.invite-required',
|
||||
defaultMessage: 'This server requires an invite code.',
|
||||
},
|
||||
submit: { id: 'app.skin-site.register.submit', defaultMessage: 'Create account' },
|
||||
success: {
|
||||
id: 'app.skin-site.register.success',
|
||||
defaultMessage: 'Account created and signed in.',
|
||||
},
|
||||
closed: {
|
||||
id: 'app.skin-site.register.closed',
|
||||
defaultMessage: 'Registration is currently closed on this server.',
|
||||
},
|
||||
})
|
||||
|
||||
const PASSWORD_RE = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,50}$/
|
||||
const COUNTDOWN_SECONDS = 60
|
||||
|
||||
const modal = ref<InstanceType<typeof NewModal>>()
|
||||
const captchaModal = ref<InstanceType<typeof SkinSiteCaptchaModal>>()
|
||||
const email = ref('')
|
||||
const code = ref('')
|
||||
const password = ref('')
|
||||
const repeatPassword = ref('')
|
||||
const qq = ref('')
|
||||
const inviteCode = ref('')
|
||||
const inviteRequired = ref(false)
|
||||
const registerAllowed = ref(true)
|
||||
const sending = ref(false)
|
||||
const working = ref(false)
|
||||
const countdown = ref(0)
|
||||
const loadingCondition = ref(false)
|
||||
let timer: ReturnType<typeof setInterval> | undefined
|
||||
|
||||
const emit = defineEmits<{ (e: 'signed-in' | 'cancel'): void }>()
|
||||
|
||||
function stopTimer() {
|
||||
if (timer) clearInterval(timer)
|
||||
timer = undefined
|
||||
}
|
||||
|
||||
function startCountdown() {
|
||||
countdown.value = COUNTDOWN_SECONDS
|
||||
stopTimer()
|
||||
timer = setInterval(() => {
|
||||
countdown.value -= 1
|
||||
if (countdown.value <= 0) stopTimer()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
const canSendCode = computed(
|
||||
() => email.value.trim().length > 0 && !sending.value && countdown.value <= 0,
|
||||
)
|
||||
|
||||
const passwordValid = computed(() => PASSWORD_RE.test(password.value))
|
||||
const passwordsMatch = computed(() => password.value === repeatPassword.value)
|
||||
const qqValid = computed(() => qq.value.trim() === '' || /^\d{5,}$/.test(qq.value.trim()))
|
||||
const inviteValid = computed(() => !inviteRequired.value || inviteCode.value.trim().length > 0)
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
registerAllowed.value &&
|
||||
email.value.trim().length > 0 &&
|
||||
code.value.trim().length === 6 &&
|
||||
passwordValid.value &&
|
||||
passwordsMatch.value &&
|
||||
qqValid.value &&
|
||||
inviteValid.value &&
|
||||
!working.value,
|
||||
)
|
||||
|
||||
function reset() {
|
||||
stopTimer()
|
||||
email.value = ''
|
||||
code.value = ''
|
||||
password.value = ''
|
||||
repeatPassword.value = ''
|
||||
qq.value = ''
|
||||
inviteCode.value = ''
|
||||
sending.value = false
|
||||
working.value = false
|
||||
countdown.value = 0
|
||||
}
|
||||
|
||||
async function loadCondition() {
|
||||
loadingCondition.value = true
|
||||
try {
|
||||
const result = await skinSiteRegisterCondition()
|
||||
if (result.success) {
|
||||
registerAllowed.value = result.payload.registerAllowed
|
||||
inviteRequired.value = result.payload.inviteCodeRequired
|
||||
} else {
|
||||
registerAllowed.value = false
|
||||
}
|
||||
} finally {
|
||||
loadingCondition.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function show() {
|
||||
reset()
|
||||
modal.value?.show()
|
||||
await loadCondition()
|
||||
}
|
||||
|
||||
async function sendCode() {
|
||||
if (!canSendCode.value) return
|
||||
sending.value = true
|
||||
try {
|
||||
const result = await skinSiteRegisterEmailVerify(email.value.trim())
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
addNotification({ type: 'success', title: result.payload })
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
sending.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function beginRegister() {
|
||||
if (!canSubmit.value) return
|
||||
if (!passwordsMatch.value) {
|
||||
handleError(new Error(formatMessage(messages.mismatch)))
|
||||
return
|
||||
}
|
||||
captchaModal.value?.show()
|
||||
}
|
||||
|
||||
async function onCaptchaVerified(clientId: string) {
|
||||
working.value = true
|
||||
try {
|
||||
const result = await skinSiteRegister({
|
||||
email: email.value.trim(),
|
||||
emailVerifyCode: code.value.trim(),
|
||||
password: password.value,
|
||||
qq: qq.value.trim() ? Number(qq.value.trim()) : undefined,
|
||||
inviteCode: inviteCode.value.trim() || undefined,
|
||||
clientId,
|
||||
})
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
// Registration returns a JWT; persist it through the normal sign-in path.
|
||||
await signInSkinSite({ username: result.payload.username, password: password.value, clientId })
|
||||
await reloadSkinSiteSession()
|
||||
addNotification({ type: 'success', title: formatMessage(messages.success) })
|
||||
modal.value?.hide()
|
||||
emit('signed-in')
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
working.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
modal.value?.hide()
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
onUnmounted(stopTimer)
|
||||
|
||||
defineExpose({ show })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NewModal ref="modal" :header="formatMessage(messages.title)" @hide="reset">
|
||||
<div v-if="!loadingCondition && !registerAllowed" class="text-secondary">
|
||||
{{ formatMessage(messages.closed) }}
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col gap-4">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.email) }}</span>
|
||||
<StyledInput v-model="email" type="email" autocomplete="email" />
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.code) }}</span>
|
||||
<div class="flex gap-2">
|
||||
<StyledInput v-model="code" type="text" class="flex-1" maxlength="6" />
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-4 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSendCode"
|
||||
@click="sendCode"
|
||||
>
|
||||
{{
|
||||
sending
|
||||
? formatMessage(messages.sending)
|
||||
: countdown > 0
|
||||
? formatMessage(messages.resendIn, { seconds: countdown })
|
||||
: formatMessage(messages.sendCode)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.password) }}</span>
|
||||
<StyledInput v-model="password" type="password" autocomplete="new-password" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.passwordHint) }}</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{
|
||||
formatMessage(messages.repeatPassword)
|
||||
}}</span>
|
||||
<StyledInput v-model="repeatPassword" type="password" autocomplete="new-password" />
|
||||
<span v-if="repeatPassword && !passwordsMatch" class="text-xs text-red">
|
||||
{{ formatMessage(messages.mismatch) }}
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.qq) }}</span>
|
||||
<StyledInput v-model="qq" type="text" inputmode="numeric" />
|
||||
</label>
|
||||
|
||||
<label v-if="inviteRequired" class="flex flex-col gap-1">
|
||||
<span class="font-semibold text-contrast">{{ formatMessage(messages.inviteCode) }}</span>
|
||||
<StyledInput v-model="inviteCode" type="text" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.inviteRequired) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<template #actions>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-secondary hover:bg-button-bg"
|
||||
@click="cancel"
|
||||
>
|
||||
{{ formatMessage(commonMessages.cancelButton) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
@click="beginRegister"
|
||||
>
|
||||
{{ formatMessage(messages.submit) }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</NewModal>
|
||||
|
||||
<SkinSiteCaptchaModal
|
||||
ref="captchaModal"
|
||||
@verified="onCaptchaVerified"
|
||||
@cancel="working = false"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,313 @@
|
||||
<script setup lang="ts">
|
||||
import { CheckCircleIcon, SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, StyledInput, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteReviewCatalog,
|
||||
type SkinSiteReviewPublicPaper,
|
||||
type SkinSiteReviewPublicQuestion,
|
||||
type SkinSiteReviewReceipt,
|
||||
skinSiteSubmitReview,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.review.title', defaultMessage: 'Player review' },
|
||||
back: { id: 'app.skin-site.review.back', defaultMessage: 'Back to home' },
|
||||
subtitle: {
|
||||
id: 'app.skin-site.review.subtitle',
|
||||
defaultMessage: 'Pick an application form and answer its questions.',
|
||||
},
|
||||
loading: { id: 'app.skin-site.review.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.review.failed', defaultMessage: 'Could not load the review forms.' },
|
||||
empty: {
|
||||
id: 'app.skin-site.review.empty',
|
||||
defaultMessage: 'No application forms are available right now.',
|
||||
},
|
||||
email: { id: 'app.skin-site.review.email', defaultMessage: 'Your email' },
|
||||
emailHint: {
|
||||
id: 'app.skin-site.review.email-hint',
|
||||
defaultMessage: 'Results are sent to this address.',
|
||||
},
|
||||
inviteCode: { id: 'app.skin-site.review.invite-code', defaultMessage: 'Invite code' },
|
||||
submit: { id: 'app.skin-site.review.submit', defaultMessage: 'Submit application' },
|
||||
submitting: { id: 'app.skin-site.review.submitting', defaultMessage: 'Submitting…' },
|
||||
backToList: { id: 'app.skin-site.review.back-to-list', defaultMessage: 'Back to forms' },
|
||||
required: { id: 'app.skin-site.review.required', defaultMessage: 'Required' },
|
||||
optional: { id: 'app.skin-site.review.optional', defaultMessage: 'Optional' },
|
||||
submitted: { id: 'app.skin-site.review.submitted', defaultMessage: 'Application submitted.' },
|
||||
resultPending: { id: 'app.skin-site.review.result.pending', defaultMessage: 'Under review' },
|
||||
resultPassed: { id: 'app.skin-site.review.result.passed', defaultMessage: 'Approved' },
|
||||
resultRejected: { id: 'app.skin-site.review.result.rejected', defaultMessage: 'Rejected' },
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ (e: 'back'): void }>()
|
||||
|
||||
const papers = ref<SkinSiteReviewPublicPaper[]>([])
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const activePaper = ref<SkinSiteReviewPublicPaper | null>(null)
|
||||
const email = ref('')
|
||||
const inviteCode = ref('')
|
||||
const answers = ref<Record<string, string | string[]>>({})
|
||||
const submitting = ref(false)
|
||||
const receipt = ref<SkinSiteReviewReceipt | null>(null)
|
||||
|
||||
const emailValid = computed(() => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.value.trim()))
|
||||
|
||||
const requiredAnswered = computed(() => {
|
||||
if (!activePaper.value) return false
|
||||
return activePaper.value.questions.every((q) => {
|
||||
if (q.informationQuestion || q.optional) return true
|
||||
const value = answers.value[q.id]
|
||||
if (Array.isArray(value)) return value.length > 0
|
||||
return typeof value === 'string' ? value.trim().length > 0 : false
|
||||
})
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => emailValid.value && requiredAnswered.value && !submitting.value)
|
||||
|
||||
function defaultAnswer(q: SkinSiteReviewPublicQuestion): string | string[] {
|
||||
if (q.type === 'MULTIPLE' || q.type === 'SINGLE') {
|
||||
const preset = (q.options ?? []).filter((o) => o.defaultSelected).map((o) => o.id)
|
||||
return q.type === 'MULTIPLE' ? preset : (preset[0] ?? '')
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function openPaper(paper: SkinSiteReviewPublicPaper) {
|
||||
activePaper.value = paper
|
||||
answers.value = {}
|
||||
for (const q of paper.questions) answers.value[q.id] = defaultAnswer(q)
|
||||
email.value = ''
|
||||
inviteCode.value = ''
|
||||
receipt.value = null
|
||||
}
|
||||
|
||||
function closePaper() {
|
||||
activePaper.value = null
|
||||
answers.value = {}
|
||||
receipt.value = null
|
||||
}
|
||||
|
||||
function toggleMultiple(q: SkinSiteReviewPublicQuestion, optionId: string, checked: boolean) {
|
||||
const current = Array.isArray(answers.value[q.id]) ? (answers.value[q.id] as string[]) : []
|
||||
answers.value[q.id] = checked
|
||||
? [...current.filter((id) => id !== optionId), optionId]
|
||||
: current.filter((id) => id !== optionId)
|
||||
}
|
||||
async function loadCatalog() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteReviewCatalog()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
papers.value = result.payload?.papers ?? []
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitApplication() {
|
||||
if (!activePaper.value || !canSubmit.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const payloadAnswers: Record<string, unknown> = {}
|
||||
for (const q of activePaper.value.questions) {
|
||||
if (q.informationQuestion) continue
|
||||
payloadAnswers[q.id] = answers.value[q.id] ?? ''
|
||||
}
|
||||
const result = await skinSiteSubmitReview({
|
||||
paperId: activePaper.value.id,
|
||||
email: email.value.trim(),
|
||||
answers: payloadAnswers,
|
||||
...(inviteCode.value.trim() ? { inviteCode: inviteCode.value.trim() } : {}),
|
||||
})
|
||||
if (!result.success) {
|
||||
handleError(new Error(result.errorMessage))
|
||||
return
|
||||
}
|
||||
receipt.value = result.payload
|
||||
addNotification({ type: 'success', title: formatMessage(messages.submitted) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function resultLabel(result?: string): string {
|
||||
switch (result) {
|
||||
case 'PASSED':
|
||||
return formatMessage(messages.resultPassed)
|
||||
case 'REJECTED':
|
||||
return formatMessage(messages.resultRejected)
|
||||
default:
|
||||
return formatMessage(messages.resultPending)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadCatalog)
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-fit items-center gap-1 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="activePaper ? closePaper() : emit('back')"
|
||||
>
|
||||
← {{ activePaper ? formatMessage(messages.backToList) : formatMessage(messages.back) }}
|
||||
</button>
|
||||
|
||||
<template v-if="!activePaper">
|
||||
<header class="flex flex-col gap-1">
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ formatMessage(messages.title) }}</h1>
|
||||
<p class="m-0 text-sm text-secondary">{{ formatMessage(messages.subtitle) }}</p>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!papers.length" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<button
|
||||
v-for="paper in papers"
|
||||
:key="paper.id"
|
||||
type="button"
|
||||
class="flex flex-col items-start gap-1 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3 text-left transition-colors hover:bg-button-bg"
|
||||
@click="openPaper(paper)"
|
||||
>
|
||||
<span class="text-sm font-semibold text-contrast">{{ paper.title }}</span>
|
||||
<span v-if="paper.description" class="text-xs text-secondary">{{ paper.description }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<div
|
||||
v-else-if="receipt"
|
||||
class="flex flex-col items-center gap-3 rounded-2xl border border-solid border-surface-5 bg-bg-raised p-6 text-center"
|
||||
>
|
||||
<CheckCircleIcon class="size-10 text-brand" />
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.submitted) }}</h2>
|
||||
<p class="m-0 text-sm text-secondary">{{ resultLabel(receipt.result) }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast"
|
||||
@click="closePaper"
|
||||
>
|
||||
{{ formatMessage(messages.backToList) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<h1 class="m-0 text-xl font-bold text-contrast">{{ activePaper.title }}</h1>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">{{ formatMessage(messages.email) }}</span>
|
||||
<StyledInput v-model="email" type="email" autocomplete="email" />
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.emailHint) }}</span>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">{{
|
||||
formatMessage(messages.inviteCode)
|
||||
}}</span>
|
||||
<StyledInput v-model="inviteCode" type="text" />
|
||||
</label>
|
||||
|
||||
<div
|
||||
v-for="question in activePaper.questions"
|
||||
:key="question.id"
|
||||
class="flex flex-col gap-2 rounded-xl border border-solid border-surface-5 bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-sm font-semibold text-contrast">{{ question.title }}</span>
|
||||
<span
|
||||
v-if="!question.optional && !question.informationQuestion"
|
||||
class="rounded-full bg-brand-highlight px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.required) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="question.annotation" class="text-xs text-secondary">{{
|
||||
question.annotation
|
||||
}}</span>
|
||||
|
||||
<span v-if="question.informationQuestion" class="text-xs text-secondary">
|
||||
{{ question.answer }}
|
||||
</span>
|
||||
|
||||
<template v-else-if="question.type === 'SINGLE' || question.type === 'TRUE_FALSE'">
|
||||
<label
|
||||
v-for="option in question.options ?? []"
|
||||
:key="option.id"
|
||||
class="flex items-center gap-2 text-sm"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
:name="question.id"
|
||||
:value="option.id"
|
||||
:checked="answers[question.id] === option.id"
|
||||
@change="answers[question.id] = option.id"
|
||||
/>
|
||||
<span class="text-contrast">{{ option.description }}</span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-else-if="question.type === 'MULTIPLE'">
|
||||
<label
|
||||
v-for="option in question.options ?? []"
|
||||
:key="option.id"
|
||||
class="flex items-center gap-2 text-sm"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="
|
||||
Array.isArray(answers[question.id]) &&
|
||||
(answers[question.id] as string[]).includes(option.id)
|
||||
"
|
||||
@change="
|
||||
toggleMultiple(question, option.id, ($event.target as HTMLInputElement).checked)
|
||||
"
|
||||
/>
|
||||
<span class="text-contrast">{{ option.description }}</span>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<StyledInput
|
||||
v-else-if="question.type === 'FILL'"
|
||||
v-model="answers[question.id] as string"
|
||||
type="text"
|
||||
:maxlength="question.maxLength ?? 50"
|
||||
/>
|
||||
|
||||
<textarea
|
||||
v-else
|
||||
v-model="answers[question.id] as string"
|
||||
rows="4"
|
||||
class="w-full rounded-lg border border-solid border-surface-5 bg-button-bg p-2 text-sm text-contrast"
|
||||
:maxlength="question.maxLength ?? 300"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="w-fit self-end rounded-full bg-brand px-5 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
@click="submitApplication"
|
||||
>
|
||||
{{ formatMessage(submitting ? messages.submitting : messages.submit) }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,192 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteWikiPageDetail,
|
||||
skinSiteWikiPage,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
import WikiNodeRenderer from './wiki/WikiNodeRenderer.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const props = withDefaults(defineProps<{ initialTitle?: string }>(), {
|
||||
initialTitle: '',
|
||||
})
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.wiki.title', defaultMessage: 'StarLight Wiki' },
|
||||
searchPlaceholder: {
|
||||
id: 'app.skin-site.wiki.search-placeholder',
|
||||
defaultMessage: 'Enter a page title',
|
||||
},
|
||||
open: { id: 'app.skin-site.wiki.open', defaultMessage: 'Open' },
|
||||
loading: { id: 'app.skin-site.wiki.loading', defaultMessage: 'Loading…' },
|
||||
notFound: {
|
||||
id: 'app.skin-site.wiki.not-found',
|
||||
defaultMessage: 'Page not found.',
|
||||
},
|
||||
empty: {
|
||||
id: 'app.skin-site.wiki.empty',
|
||||
defaultMessage: 'Enter a page title above to start reading.',
|
||||
},
|
||||
updatedAt: {
|
||||
id: 'app.skin-site.wiki.updated-at',
|
||||
defaultMessage: 'Last edited {date} by {author}',
|
||||
},
|
||||
revision: { id: 'app.skin-site.wiki.revision', defaultMessage: 'Revision #{id}' },
|
||||
categories: { id: 'app.skin-site.wiki.categories', defaultMessage: 'Categories' },
|
||||
back: { id: 'app.skin-site.wiki.back', defaultMessage: 'Back' },
|
||||
})
|
||||
|
||||
const titleInput = ref(props.initialTitle)
|
||||
const page = ref<SkinSiteWikiPageDetail | null>(null)
|
||||
const loading = ref(false)
|
||||
const notFound = ref(false)
|
||||
const history = ref<string[]>([])
|
||||
|
||||
const currentTitle = computed(() => page.value?.title ?? '')
|
||||
|
||||
async function openPage(title: string) {
|
||||
const trimmed = title.trim()
|
||||
if (!trimmed) return
|
||||
titleInput.value = trimmed
|
||||
loading.value = true
|
||||
notFound.value = false
|
||||
try {
|
||||
const res = await skinSiteWikiPage(trimmed)
|
||||
if (!res.success) {
|
||||
notFound.value = true
|
||||
page.value = null
|
||||
return
|
||||
}
|
||||
page.value = res.payload
|
||||
if (currentTitle.value && history.value[history.value.length - 1] !== currentTitle.value) {
|
||||
history.value.push(currentTitle.value)
|
||||
}
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
notFound.value = true
|
||||
page.value = null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
const prev = history.value.pop()
|
||||
if (prev) void openPage(prev)
|
||||
}
|
||||
|
||||
function formatDate(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return '—'
|
||||
}
|
||||
}
|
||||
|
||||
function onNavigate(title: string) {
|
||||
if (title) void openPage(title)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.initialTitle) void openPage(props.initialTitle)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
v-if="history.length"
|
||||
type="button"
|
||||
class="rounded-lg bg-button-bg px-3 py-1.5 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="goBack"
|
||||
>
|
||||
← {{ formatMessage(messages.back) }}
|
||||
</button>
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<input
|
||||
v-model="titleInput"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.searchPlaceholder)"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg-raised px-3 py-1.5 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="openPage(titleInput)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand px-3 py-1.5 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openPage(titleInput)"
|
||||
>
|
||||
{{ formatMessage(messages.open) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex min-h-48 items-center justify-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p
|
||||
v-else-if="notFound"
|
||||
class="m-0 rounded-lg border border-solid border-surface-5 bg-bg-raised p-4 text-sm text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.notFound) }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!page"
|
||||
class="m-0 rounded-lg border border-solid border-surface-5 bg-bg-raised p-4 text-sm text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<template v-else>
|
||||
<div class="flex flex-wrap items-baseline justify-between gap-2 border-b border-solid border-surface-5 pb-2">
|
||||
<h1 class="m-0 text-2xl font-bold text-contrast">{{ page.title }}</h1>
|
||||
<span class="text-[11px] text-secondary">
|
||||
{{ formatMessage(messages.revision, { id: page.revisionId }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<p class="m-0 text-[11px] text-secondary">
|
||||
{{
|
||||
formatMessage(messages.updatedAt, {
|
||||
date: formatDate(page.updatedAt),
|
||||
author: page.authorName,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="page.redirectTarget"
|
||||
class="rounded-lg border border-solid border-yellow/40 bg-yellow/10 p-3 text-xs text-yellow"
|
||||
>
|
||||
重定向到
|
||||
<button
|
||||
type="button"
|
||||
class="font-semibold underline underline-offset-2"
|
||||
@click="openPage(page.redirectTarget ?? '')"
|
||||
>
|
||||
{{ page.redirectTarget }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<article class="min-w-0 text-sm leading-7 text-contrast">
|
||||
<WikiNodeRenderer :nodes="page.nodes" @navigate="onNavigate" />
|
||||
</article>
|
||||
|
||||
<div v-if="page.categories.length" class="flex flex-wrap items-center gap-2 pt-2">
|
||||
<span class="text-[11px] text-secondary">{{ formatMessage(messages.categories) }}:</span>
|
||||
<span
|
||||
v-for="category in page.categories"
|
||||
:key="category"
|
||||
class="rounded bg-bg-raised px-2 py-0.5 text-[11px] text-secondary"
|
||||
>
|
||||
{{ category }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,273 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteAccessAudit,
|
||||
type SkinSiteAccessAuditEntry,
|
||||
skinSiteUpdateAccessAuditSettings,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.audit.title', defaultMessage: 'Access audit' },
|
||||
loading: { id: 'app.skin-site.admin.audit.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.audit.failed', defaultMessage: 'Could not load audit log.' },
|
||||
empty: { id: 'app.skin-site.admin.audit.empty', defaultMessage: 'No audit entries.' },
|
||||
subject: { id: 'app.skin-site.admin.audit.subject', defaultMessage: 'Subject' },
|
||||
action: { id: 'app.skin-site.admin.audit.action', defaultMessage: 'Action' },
|
||||
sourceIp: { id: 'app.skin-site.admin.audit.source-ip', defaultMessage: 'Source IP' },
|
||||
reportedIp: {
|
||||
id: 'app.skin-site.admin.audit.reported-ip',
|
||||
defaultMessage: 'Reported player IP',
|
||||
},
|
||||
count: { id: 'app.skin-site.admin.audit.count', defaultMessage: 'Count' },
|
||||
firstAt: { id: 'app.skin-site.admin.audit.first-at', defaultMessage: 'First seen' },
|
||||
lastAt: { id: 'app.skin-site.admin.audit.last-at', defaultMessage: 'Last seen' },
|
||||
proxy: { id: 'app.skin-site.admin.audit.proxy', defaultMessage: 'Proxy' },
|
||||
internal: { id: 'app.skin-site.admin.audit.internal', defaultMessage: 'Internal' },
|
||||
searchSubject: {
|
||||
id: 'app.skin-site.admin.audit.search-subject',
|
||||
defaultMessage: 'Subject',
|
||||
},
|
||||
searchIp: { id: 'app.skin-site.admin.audit.search-ip', defaultMessage: 'IP' },
|
||||
searchAction: { id: 'app.skin-site.admin.audit.search-action', defaultMessage: 'Action' },
|
||||
search: { id: 'app.skin-site.admin.audit.search', defaultMessage: 'Search' },
|
||||
clear: { id: 'app.skin-site.admin.audit.clear', defaultMessage: 'Clear' },
|
||||
loadMore: { id: 'app.skin-site.admin.audit.load-more', defaultMessage: 'Load more' },
|
||||
retention: {
|
||||
id: 'app.skin-site.admin.audit.retention',
|
||||
defaultMessage: 'Retention (days)',
|
||||
},
|
||||
recordLimit: { id: 'app.skin-site.admin.audit.record-limit', defaultMessage: 'Record limit' },
|
||||
saveRetention: {
|
||||
id: 'app.skin-site.admin.audit.save-retention',
|
||||
defaultMessage: 'Save',
|
||||
},
|
||||
retentionSaved: {
|
||||
id: 'app.skin-site.admin.audit.retention-saved',
|
||||
defaultMessage: 'Retention updated.',
|
||||
},
|
||||
})
|
||||
|
||||
const items = ref<SkinSiteAccessAuditEntry[]>([])
|
||||
const nextCursor = ref<number | null>(null)
|
||||
const retentionDays = ref(0)
|
||||
const recordLimit = ref(0)
|
||||
const loading = ref(true)
|
||||
const loadingMore = ref(false)
|
||||
const failed = ref(false)
|
||||
|
||||
const subjectFilter = ref('')
|
||||
const ipFilter = ref('')
|
||||
const actionFilter = ref('')
|
||||
|
||||
const retentionDraft = ref(0)
|
||||
const savingRetention = ref(false)
|
||||
|
||||
function formatDateTime(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
async function load(reset = true) {
|
||||
if (reset) {
|
||||
loading.value = true
|
||||
items.value = []
|
||||
nextCursor.value = null
|
||||
} else {
|
||||
loadingMore.value = true
|
||||
}
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteAccessAudit({
|
||||
before: reset ? undefined : (nextCursor.value ?? undefined),
|
||||
subject: subjectFilter.value.trim() || undefined,
|
||||
ip: ipFilter.value.trim() || undefined,
|
||||
action: actionFilter.value.trim() || undefined,
|
||||
})
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
const page = result.payload
|
||||
items.value = reset ? page.items : [...items.value, ...page.items]
|
||||
nextCursor.value = page.nextCursor
|
||||
retentionDays.value = page.retentionDays
|
||||
recordLimit.value = page.recordLimit
|
||||
retentionDraft.value = page.retentionDays
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function clearFilters() {
|
||||
subjectFilter.value = ''
|
||||
ipFilter.value = ''
|
||||
actionFilter.value = ''
|
||||
void load(true)
|
||||
}
|
||||
|
||||
async function saveRetention() {
|
||||
if (savingRetention.value) return
|
||||
savingRetention.value = true
|
||||
try {
|
||||
const result = await skinSiteUpdateAccessAuditSettings(Number(retentionDraft.value) || 0)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
retentionDays.value = result.payload.retentionDays
|
||||
retentionDraft.value = result.payload.retentionDays
|
||||
addNotification({ type: 'success', title: formatMessage(messages.retentionSaved) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingRetention.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load(true))
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.recordLimit) }}: {{ recordLimit }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-2">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.searchSubject) }}</span>
|
||||
<input
|
||||
v-model="subjectFilter"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="load(true)"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.searchIp) }}</span>
|
||||
<input
|
||||
v-model="ipFilter"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="load(true)"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.searchAction) }}</span>
|
||||
<input
|
||||
v-model="actionFilter"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="load(true)"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="load(true)"
|
||||
>
|
||||
{{ formatMessage(messages.search) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110"
|
||||
@click="clearFilters"
|
||||
>
|
||||
{{ formatMessage(messages.clear) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-2 rounded-xl bg-bg-raised p-3">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.retention) }}</span>
|
||||
<input
|
||||
v-model.number="retentionDraft"
|
||||
type="number"
|
||||
min="1"
|
||||
class="w-24 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="savingRetention"
|
||||
@click="saveRetention"
|
||||
>
|
||||
{{ formatMessage(messages.saveRetention) }}
|
||||
</button>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.retention) }}: {{ retentionDays }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!items.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="entry in items"
|
||||
:key="entry.id"
|
||||
class="flex flex-col gap-1.5 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="shrink-0 text-xs text-secondary">#{{ entry.id }}</span>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
{{ entry.subject }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ entry.action }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">×{{ entry.count }}</span>
|
||||
<span
|
||||
v-if="entry.proxy"
|
||||
class="shrink-0 rounded-full bg-orange px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.proxy) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="entry.internalServer"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.internal) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-xs text-secondary">
|
||||
<span>{{ formatMessage(messages.sourceIp) }}: {{ entry.sourceIp }}</span>
|
||||
<span v-if="entry.reportedPlayerIp">
|
||||
{{ formatMessage(messages.reportedIp) }}: {{ entry.reportedPlayerIp }}
|
||||
</span>
|
||||
<span>{{ formatMessage(messages.firstAt) }}: {{ formatDateTime(entry.firstAt) }}</span>
|
||||
<span>{{ formatMessage(messages.lastAt) }}: {{ formatDateTime(entry.lastAt) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="nextCursor !== null"
|
||||
type="button"
|
||||
class="w-fit self-center rounded-full bg-button-bg px-4 py-2 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="loadingMore"
|
||||
@click="load(false)"
|
||||
>
|
||||
{{ formatMessage(messages.loadMore) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,366 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteBroadcast,
|
||||
type SkinSiteBroadcastInput,
|
||||
skinSiteBroadcasts,
|
||||
skinSiteCreateBroadcast,
|
||||
skinSiteDeleteBroadcast,
|
||||
skinSiteUpdateBroadcast,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.broadcast.title', defaultMessage: 'Announcements' },
|
||||
loading: { id: 'app.skin-site.admin.broadcast.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.broadcast.failed', defaultMessage: 'Could not load.' },
|
||||
empty: { id: 'app.skin-site.admin.broadcast.empty', defaultMessage: 'No announcements yet.' },
|
||||
create: { id: 'app.skin-site.admin.broadcast.create', defaultMessage: 'New announcement' },
|
||||
save: { id: 'app.skin-site.admin.broadcast.save', defaultMessage: 'Save' },
|
||||
cancel: { id: 'app.skin-site.admin.broadcast.cancel', defaultMessage: 'Cancel' },
|
||||
edit: { id: 'app.skin-site.admin.broadcast.edit', defaultMessage: 'Edit' },
|
||||
remove: { id: 'app.skin-site.admin.broadcast.remove', defaultMessage: 'Delete' },
|
||||
titleField: { id: 'app.skin-site.admin.broadcast.title-field', defaultMessage: 'Title' },
|
||||
subtitleField: { id: 'app.skin-site.admin.broadcast.subtitle-field', defaultMessage: 'Subtitle' },
|
||||
contentField: { id: 'app.skin-site.admin.broadcast.content-field', defaultMessage: 'Content' },
|
||||
expireAt: { id: 'app.skin-site.admin.broadcast.expire-at', defaultMessage: 'Expires at' },
|
||||
star: { id: 'app.skin-site.admin.broadcast.star', defaultMessage: 'Highlight' },
|
||||
level: { id: 'app.skin-site.admin.broadcast.level', defaultMessage: 'Importance' },
|
||||
image: { id: 'app.skin-site.admin.broadcast.image', defaultMessage: 'Image' },
|
||||
removeImage: { id: 'app.skin-site.admin.broadcast.remove-image', defaultMessage: 'Remove image' },
|
||||
created: { id: 'app.skin-site.admin.broadcast.created', defaultMessage: 'Announcement created.' },
|
||||
updated: { id: 'app.skin-site.admin.broadcast.updated', defaultMessage: 'Announcement updated.' },
|
||||
deleted: { id: 'app.skin-site.admin.broadcast.deleted', defaultMessage: 'Announcement deleted.' },
|
||||
confirmDelete: {
|
||||
id: 'app.skin-site.admin.broadcast.confirm-delete',
|
||||
defaultMessage: 'Delete “{title}”? This cannot be undone.',
|
||||
},
|
||||
uploader: { id: 'app.skin-site.admin.broadcast.uploader', defaultMessage: 'by {name}' },
|
||||
})
|
||||
|
||||
const items = ref<SkinSiteBroadcast[]>([])
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const saving = ref(false)
|
||||
const deletingId = ref<number | null>(null)
|
||||
|
||||
const editorOpen = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const form = ref({
|
||||
title: '',
|
||||
subtitle: '',
|
||||
content: '',
|
||||
expireAt: '',
|
||||
star: false,
|
||||
importantLevel: 0,
|
||||
})
|
||||
const imageFile = ref<File | null>(null)
|
||||
const removeImage = ref(false)
|
||||
|
||||
const sorted = computed(() => [...items.value].sort((a, b) => b.id - a.id))
|
||||
|
||||
function formatDate(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function toDateInput(ts: number): string {
|
||||
try {
|
||||
const d = new Date(ts)
|
||||
const pad = (n: number) => String(n).padStart(2, '0')
|
||||
return (
|
||||
d.getFullYear() +
|
||||
'-' +
|
||||
pad(d.getMonth() + 1) +
|
||||
'-' +
|
||||
pad(d.getDate()) +
|
||||
'T' +
|
||||
pad(d.getHours()) +
|
||||
':' +
|
||||
pad(d.getMinutes())
|
||||
)
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = {
|
||||
title: '',
|
||||
subtitle: '',
|
||||
content: '',
|
||||
expireAt: '',
|
||||
star: false,
|
||||
importantLevel: 0,
|
||||
}
|
||||
imageFile.value = null
|
||||
removeImage.value = false
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
resetForm()
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function openEdit(item: SkinSiteBroadcast) {
|
||||
form.value = {
|
||||
title: item.title,
|
||||
subtitle: item.subtitle,
|
||||
content: item.content,
|
||||
expireAt: toDateInput(item.expireAt),
|
||||
star: item.star,
|
||||
importantLevel: item.importantLevel,
|
||||
}
|
||||
imageFile.value = null
|
||||
removeImage.value = false
|
||||
editingId.value = item.id
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
editorOpen.value = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function onImageChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
imageFile.value = input.files?.[0] ?? null
|
||||
}
|
||||
|
||||
function buildInput(): SkinSiteBroadcastInput {
|
||||
const ts = form.value.expireAt ? new Date(form.value.expireAt).getTime() : 0
|
||||
return {
|
||||
title: form.value.title.trim(),
|
||||
subtitle: form.value.subtitle.trim(),
|
||||
content: form.value.content,
|
||||
expireAt: Number.isFinite(ts) ? ts : 0,
|
||||
star: form.value.star,
|
||||
importantLevel: Number(form.value.importantLevel) || 0,
|
||||
imageFile: imageFile.value,
|
||||
removeImage: removeImage.value,
|
||||
}
|
||||
}
|
||||
|
||||
const canSave = computed(
|
||||
() => form.value.title.trim().length > 0 && form.value.content.length > 0 && !saving.value,
|
||||
)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteBroadcasts()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
items.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!canSave.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const input = buildInput()
|
||||
const result =
|
||||
editingId.value === null
|
||||
? await skinSiteCreateBroadcast(input)
|
||||
: await skinSiteUpdateBroadcast(editingId.value, input)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({
|
||||
type: 'success',
|
||||
title: formatMessage(editingId.value === null ? messages.created : messages.updated),
|
||||
})
|
||||
closeEditor()
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(item: SkinSiteBroadcast) {
|
||||
if (deletingId.value !== null) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDelete, { title: item.title }))) return
|
||||
deletingId.value = item.id
|
||||
try {
|
||||
const result = await skinSiteDeleteBroadcast(item.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deleted) })
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load())
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="openCreate"
|
||||
>
|
||||
{{ formatMessage(messages.create) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!sorted.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in sorted"
|
||||
:key="item.id"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<span class="shrink-0 text-xs text-secondary">#{{ item.id }}</span>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<span class="truncate text-sm font-semibold text-contrast">{{ item.title }}</span>
|
||||
<span v-if="item.subtitle" class="truncate text-xs text-secondary">
|
||||
{{ item.subtitle }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="shrink-0 text-xs text-secondary">{{ formatDate(item.updateAt) }}</span>
|
||||
<span v-if="item.uploader" class="shrink-0 text-xs text-secondary">
|
||||
{{ formatMessage(messages.uploader, { name: item.uploader }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openEdit(item)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingId !== null"
|
||||
@click="remove(item)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="editorOpen"
|
||||
class="flex flex-col gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.titleField) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.title"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.subtitleField) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.subtitle"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.contentField) }}
|
||||
</span>
|
||||
<textarea
|
||||
v-model="form.content"
|
||||
rows="5"
|
||||
class="w-full resize-y rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.expireAt) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.expireAt"
|
||||
type="datetime-local"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.level) }}
|
||||
</span>
|
||||
<input
|
||||
v-model.number="form.importantLevel"
|
||||
type="number"
|
||||
min="0"
|
||||
max="9"
|
||||
class="w-20 rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 pb-2">
|
||||
<input v-model="form.star" type="checkbox" />
|
||||
<span class="text-sm text-contrast">{{ formatMessage(messages.star) }}</span>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.image) }}
|
||||
</span>
|
||||
<input type="file" accept="image/*" @change="onImageChange" />
|
||||
</label>
|
||||
<label v-if="editingId !== null" class="flex items-center gap-2 pb-2">
|
||||
<input v-model="removeImage" type="checkbox" />
|
||||
<span class="text-sm text-contrast">{{ formatMessage(messages.removeImage) }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="closeEditor"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSave"
|
||||
@click="save"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,366 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteAdminDonations,
|
||||
skinSiteCreateDonation,
|
||||
skinSiteDeleteDonation,
|
||||
type SkinSiteDonationAdminEntry,
|
||||
type SkinSiteDonationSummary,
|
||||
skinSiteUpdateDonation,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.donations.title', defaultMessage: 'Donations' },
|
||||
loading: { id: 'app.skin-site.admin.donations.loading', defaultMessage: 'Loading…' },
|
||||
failed: {
|
||||
id: 'app.skin-site.admin.donations.failed',
|
||||
defaultMessage: 'Could not load donations.',
|
||||
},
|
||||
empty: { id: 'app.skin-site.admin.donations.empty', defaultMessage: 'No donations yet.' },
|
||||
totalAmount: { id: 'app.skin-site.admin.donations.total-amount', defaultMessage: 'Total' },
|
||||
donorCount: { id: 'app.skin-site.admin.donations.donor-count', defaultMessage: 'Donors' },
|
||||
donor: { id: 'app.skin-site.admin.donations.donor', defaultMessage: 'Donor' },
|
||||
amount: { id: 'app.skin-site.admin.donations.amount', defaultMessage: 'Amount' },
|
||||
updatedAt: { id: 'app.skin-site.admin.donations.updated-at', defaultMessage: 'Updated' },
|
||||
external: { id: 'app.skin-site.admin.donations.external', defaultMessage: 'External' },
|
||||
linked: { id: 'app.skin-site.admin.donations.linked', defaultMessage: 'Linked' },
|
||||
create: { id: 'app.skin-site.admin.donations.create', defaultMessage: 'Add donation' },
|
||||
save: { id: 'app.skin-site.admin.donations.save', defaultMessage: 'Save' },
|
||||
cancel: { id: 'app.skin-site.admin.donations.cancel', defaultMessage: 'Cancel' },
|
||||
edit: { id: 'app.skin-site.admin.donations.edit', defaultMessage: 'Edit' },
|
||||
remove: { id: 'app.skin-site.admin.donations.remove', defaultMessage: 'Delete' },
|
||||
amountField: { id: 'app.skin-site.admin.donations.amount-field', defaultMessage: 'Amount' },
|
||||
displayName: {
|
||||
id: 'app.skin-site.admin.donations.display-name',
|
||||
defaultMessage: 'Display name',
|
||||
},
|
||||
userUuid: { id: 'app.skin-site.admin.donations.user-uuid', defaultMessage: 'User UUID' },
|
||||
qq: { id: 'app.skin-site.admin.donations.qq', defaultMessage: 'QQ' },
|
||||
appendMode: {
|
||||
id: 'app.skin-site.admin.donations.append-mode',
|
||||
defaultMessage: 'Append to existing amount',
|
||||
},
|
||||
created: { id: 'app.skin-site.admin.donations.created', defaultMessage: 'Donation created.' },
|
||||
updated: { id: 'app.skin-site.admin.donations.updated', defaultMessage: 'Donation updated.' },
|
||||
deleted: { id: 'app.skin-site.admin.donations.deleted', defaultMessage: 'Donation deleted.' },
|
||||
confirmDelete: {
|
||||
id: 'app.skin-site.admin.donations.confirm-delete',
|
||||
defaultMessage: 'Delete the donation from “{name}”? This cannot be undone.',
|
||||
},
|
||||
loadMore: { id: 'app.skin-site.admin.donations.load-more', defaultMessage: 'Load more' },
|
||||
})
|
||||
|
||||
const items = ref<SkinSiteDonationAdminEntry[]>([])
|
||||
const summary = ref<SkinSiteDonationSummary | null>(null)
|
||||
const hasMore = ref(false)
|
||||
const loading = ref(true)
|
||||
const loadingMore = ref(false)
|
||||
const failed = ref(false)
|
||||
const offset = ref(0)
|
||||
|
||||
const editorOpen = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const editingVersion = ref(0)
|
||||
const saving = ref(false)
|
||||
const deletingId = ref<number | null>(null)
|
||||
|
||||
const form = ref({
|
||||
amount: '',
|
||||
displayName: '',
|
||||
userUuid: '',
|
||||
qq: '',
|
||||
appendMode: false,
|
||||
})
|
||||
|
||||
const canSave = computed(() => form.value.amount.trim().length > 0 && !saving.value)
|
||||
|
||||
function formatDateTime(ts: number): string {
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.value = { amount: '', displayName: '', userUuid: '', qq: '', appendMode: false }
|
||||
editingId.value = null
|
||||
editingVersion.value = 0
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
resetForm()
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function openEdit(entry: SkinSiteDonationAdminEntry) {
|
||||
form.value = {
|
||||
amount: entry.donor.amount,
|
||||
displayName: entry.donor.username,
|
||||
userUuid: entry.userUuid ?? '',
|
||||
qq: entry.qq ?? '',
|
||||
appendMode: false,
|
||||
}
|
||||
editingId.value = entry.donor.id
|
||||
editingVersion.value = entry.version
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
editorOpen.value = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
async function load(reset = true) {
|
||||
if (reset) {
|
||||
loading.value = true
|
||||
items.value = []
|
||||
offset.value = 0
|
||||
} else {
|
||||
loadingMore.value = true
|
||||
}
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteAdminDonations(offset.value)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
const page = result.payload
|
||||
items.value = reset ? page.items : [...items.value, ...page.items]
|
||||
summary.value = page.summary
|
||||
hasMore.value = page.hasMore
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
loadingMore.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMore() {
|
||||
if (!hasMore.value) return
|
||||
offset.value += 20
|
||||
await load(false)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!canSave.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
if (editingId.value === null) {
|
||||
const payload: Parameters<typeof skinSiteCreateDonation>[0] = {
|
||||
amount: form.value.amount.trim(),
|
||||
}
|
||||
if (form.value.userUuid.trim()) payload.userUuid = form.value.userUuid.trim()
|
||||
if (form.value.qq.trim()) payload.qq = form.value.qq.trim()
|
||||
if (form.value.displayName.trim()) payload.displayName = form.value.displayName.trim()
|
||||
const result = await skinSiteCreateDonation(payload)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.created) })
|
||||
} else {
|
||||
const result = await skinSiteUpdateDonation(editingId.value, {
|
||||
amount: form.value.amount.trim(),
|
||||
version: editingVersion.value,
|
||||
displayName: form.value.displayName.trim() || undefined,
|
||||
mode: form.value.appendMode ? 'APPEND' : 'REPLACE',
|
||||
})
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.updated) })
|
||||
}
|
||||
closeEditor()
|
||||
await load(true)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(entry: SkinSiteDonationAdminEntry) {
|
||||
if (deletingId.value !== null) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDelete, { name: entry.donor.username }))) return
|
||||
deletingId.value = entry.donor.id
|
||||
try {
|
||||
const result = await skinSiteDeleteDonation(entry.donor.id, entry.version)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deleted) })
|
||||
await load(true)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load(true))
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="openCreate"
|
||||
>
|
||||
{{ formatMessage(messages.create) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="summary" class="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.totalAmount) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ summary.totalAmount }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.donorCount) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ summary.donorCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!items.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="entry in items"
|
||||
:key="entry.donor.id"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<span class="shrink-0 text-xs text-secondary">#{{ entry.donor.rank }}</span>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<span class="truncate text-sm font-semibold text-contrast">
|
||||
{{ entry.donor.username }}
|
||||
</span>
|
||||
<span class="truncate text-xs text-secondary">
|
||||
{{ formatMessage(messages.updatedAt) }}:
|
||||
{{ formatDateTime(entry.updatedAt) }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="shrink-0 text-sm font-bold text-contrast">{{ entry.donor.amount }}</span>
|
||||
<span
|
||||
v-if="entry.external"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.external) }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="shrink-0 rounded-full bg-green px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.linked) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openEdit(entry)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingId !== null"
|
||||
@click="remove(entry)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="hasMore"
|
||||
type="button"
|
||||
class="w-fit self-center rounded-full bg-button-bg px-4 py-2 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="loadingMore"
|
||||
@click="loadMore"
|
||||
>
|
||||
{{ formatMessage(messages.loadMore) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="editorOpen"
|
||||
class="flex flex-col gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.amountField) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.amount"
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.displayName) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.displayName"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<template v-if="editingId === null">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.userUuid) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.userUuid"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.qq) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.qq"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
<label v-else class="flex items-center gap-2">
|
||||
<input v-model="form.appendMode" type="checkbox" />
|
||||
<span class="text-sm text-contrast">{{ formatMessage(messages.appendMode) }}</span>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="closeEditor"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSave"
|
||||
@click="save"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,576 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteAddDownloadCategory,
|
||||
skinSiteAddDownloadItem,
|
||||
skinSiteBindDownloadCategory,
|
||||
skinSiteDeleteDownloadCategory,
|
||||
skinSiteDeleteDownloadItem,
|
||||
skinSiteDownloadCategories,
|
||||
type SkinSiteDownloadCategory,
|
||||
type SkinSiteDownloadItem,
|
||||
skinSiteDownloadItemCount,
|
||||
skinSiteDownloadItems,
|
||||
type SkinSiteDownloadRoute,
|
||||
type SkinSiteDownloadStatus,
|
||||
skinSiteUnbindDownloadCategory,
|
||||
skinSiteUpdateDownloadItem,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.downloads.title', defaultMessage: 'Downloads' },
|
||||
loading: { id: 'app.skin-site.admin.downloads.loading', defaultMessage: 'Loading…' },
|
||||
failed: {
|
||||
id: 'app.skin-site.admin.downloads.failed',
|
||||
defaultMessage: 'Could not load downloads.',
|
||||
},
|
||||
empty: { id: 'app.skin-site.admin.downloads.empty', defaultMessage: 'No download items.' },
|
||||
categories: { id: 'app.skin-site.admin.downloads.categories', defaultMessage: 'Categories' },
|
||||
all: { id: 'app.skin-site.admin.downloads.all', defaultMessage: 'All items' },
|
||||
addCategory: { id: 'app.skin-site.admin.downloads.add-category', defaultMessage: 'Add' },
|
||||
categoryName: {
|
||||
id: 'app.skin-site.admin.downloads.category-name',
|
||||
defaultMessage: 'Category name',
|
||||
},
|
||||
removeCategory: {
|
||||
id: 'app.skin-site.admin.downloads.remove-category',
|
||||
defaultMessage: 'Remove',
|
||||
},
|
||||
total: { id: 'app.skin-site.admin.downloads.total', defaultMessage: '{count} items' },
|
||||
addItem: { id: 'app.skin-site.admin.downloads.add-item', defaultMessage: 'New item' },
|
||||
save: { id: 'app.skin-site.admin.downloads.save', defaultMessage: 'Save' },
|
||||
cancel: { id: 'app.skin-site.admin.downloads.cancel', defaultMessage: 'Cancel' },
|
||||
edit: { id: 'app.skin-site.admin.downloads.edit', defaultMessage: 'Edit' },
|
||||
remove: { id: 'app.skin-site.admin.downloads.remove', defaultMessage: 'Delete' },
|
||||
filename: { id: 'app.skin-site.admin.downloads.filename', defaultMessage: 'File name' },
|
||||
description: {
|
||||
id: 'app.skin-site.admin.downloads.description',
|
||||
defaultMessage: 'Description',
|
||||
},
|
||||
routes: { id: 'app.skin-site.admin.downloads.routes', defaultMessage: 'Download routes' },
|
||||
routeName: { id: 'app.skin-site.admin.downloads.route-name', defaultMessage: 'Name' },
|
||||
routeUrl: { id: 'app.skin-site.admin.downloads.route-url', defaultMessage: 'URL' },
|
||||
addRoute: { id: 'app.skin-site.admin.downloads.add-route', defaultMessage: 'Add route' },
|
||||
removeRoute: { id: 'app.skin-site.admin.downloads.remove-route', defaultMessage: 'Remove' },
|
||||
statuses: { id: 'app.skin-site.admin.downloads.statuses', defaultMessage: 'Statuses' },
|
||||
bindCategory: {
|
||||
id: 'app.skin-site.admin.downloads.bind-category',
|
||||
defaultMessage: 'Categories',
|
||||
},
|
||||
uploader: { id: 'app.skin-site.admin.downloads.uploader', defaultMessage: 'by {name}' },
|
||||
created: { id: 'app.skin-site.admin.downloads.created', defaultMessage: 'Item created.' },
|
||||
updated: { id: 'app.skin-site.admin.downloads.updated', defaultMessage: 'Item updated.' },
|
||||
deleted: { id: 'app.skin-site.admin.downloads.deleted', defaultMessage: 'Item deleted.' },
|
||||
categoryAdded: {
|
||||
id: 'app.skin-site.admin.downloads.category-added',
|
||||
defaultMessage: 'Category added.',
|
||||
},
|
||||
categoryDeleted: {
|
||||
id: 'app.skin-site.admin.downloads.category-deleted',
|
||||
defaultMessage: 'Category deleted.',
|
||||
},
|
||||
confirmDeleteItem: {
|
||||
id: 'app.skin-site.admin.downloads.confirm-delete-item',
|
||||
defaultMessage: 'Delete “{name}”? This cannot be undone.',
|
||||
},
|
||||
confirmDeleteCategory: {
|
||||
id: 'app.skin-site.admin.downloads.confirm-delete-category',
|
||||
defaultMessage: 'Delete category “{name}”?',
|
||||
},
|
||||
})
|
||||
|
||||
const STATUS_OPTIONS: SkinSiteDownloadStatus[] = ['OK', 'NEW', 'LEGACY', 'OUTDATED', 'REMOVAL']
|
||||
|
||||
const items = ref<SkinSiteDownloadItem[]>([])
|
||||
const categories = ref<SkinSiteDownloadCategory[]>([])
|
||||
const total = ref(0)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const activeCategory = ref<string>('')
|
||||
|
||||
const newCategoryName = ref('')
|
||||
const categoryWorking = ref(false)
|
||||
|
||||
const editorOpen = ref(false)
|
||||
const editingId = ref<number | null>(null)
|
||||
const saving = ref(false)
|
||||
const deletingId = ref<number | null>(null)
|
||||
|
||||
const form = ref({
|
||||
filename: '',
|
||||
description: '',
|
||||
status: [] as SkinSiteDownloadStatus[],
|
||||
routes: [{ name: '', url: '' }] as Array<{ name: string; url: string }>,
|
||||
selectedCategories: [] as number[],
|
||||
})
|
||||
|
||||
const canSave = computed(
|
||||
() =>
|
||||
form.value.filename.trim().length > 0 &&
|
||||
form.value.routes.some((r) => r.url.trim().length > 0) &&
|
||||
!saving.value,
|
||||
)
|
||||
|
||||
function resetForm() {
|
||||
form.value = {
|
||||
filename: '',
|
||||
description: '',
|
||||
status: [],
|
||||
routes: [{ name: '', url: '' }],
|
||||
selectedCategories: [],
|
||||
}
|
||||
editingId.value = null
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
resetForm()
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function openEdit(item: SkinSiteDownloadItem) {
|
||||
form.value = {
|
||||
filename: item.filename,
|
||||
description: item.description,
|
||||
status: [...item.status],
|
||||
routes: item.routes.length
|
||||
? item.routes.map((r) => ({ name: r.name ?? '', url: r.url }))
|
||||
: [{ name: '', url: '' }],
|
||||
selectedCategories: categories.value
|
||||
.filter((c) => item.category.includes(c.name))
|
||||
.map((c) => c.id),
|
||||
}
|
||||
editingId.value = item.id
|
||||
editorOpen.value = true
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
editorOpen.value = false
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function addRouteRow() {
|
||||
form.value.routes.push({ name: '', url: '' })
|
||||
}
|
||||
|
||||
function removeRouteRow(index: number) {
|
||||
if (form.value.routes.length <= 1) return
|
||||
form.value.routes.splice(index, 1)
|
||||
}
|
||||
|
||||
function toggleStatus(status: SkinSiteDownloadStatus) {
|
||||
const i = form.value.status.indexOf(status)
|
||||
if (i >= 0) form.value.status.splice(i, 1)
|
||||
else form.value.status.push(status)
|
||||
}
|
||||
|
||||
async function loadCategories() {
|
||||
try {
|
||||
const result = await skinSiteDownloadCategories()
|
||||
if (result.success) categories.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadItems() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const listResult = await skinSiteDownloadItems({
|
||||
limit: 200,
|
||||
offset: 0,
|
||||
category: activeCategory.value || undefined,
|
||||
})
|
||||
if (!listResult.success) throw new Error(listResult.errorMessage)
|
||||
items.value = listResult.payload ?? []
|
||||
const countResult = await skinSiteDownloadItemCount(activeCategory.value || undefined)
|
||||
if (countResult.success && typeof countResult.payload === 'number') {
|
||||
total.value = countResult.payload
|
||||
}
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function selectCategory(name: string) {
|
||||
activeCategory.value = name
|
||||
await loadItems()
|
||||
}
|
||||
|
||||
async function addCategory() {
|
||||
const name = newCategoryName.value.trim()
|
||||
if (!name || categoryWorking.value) return
|
||||
categoryWorking.value = true
|
||||
try {
|
||||
const result = await skinSiteAddDownloadCategory(name)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
newCategoryName.value = ''
|
||||
addNotification({ type: 'success', title: formatMessage(messages.categoryAdded) })
|
||||
await loadCategories()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
categoryWorking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function removeCategory(category: SkinSiteDownloadCategory) {
|
||||
if (categoryWorking.value) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDeleteCategory, { name: category.name })))
|
||||
return
|
||||
categoryWorking.value = true
|
||||
try {
|
||||
const result = await skinSiteDeleteDownloadCategory(category.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.categoryDeleted) })
|
||||
if (activeCategory.value === category.name) activeCategory.value = ''
|
||||
await loadCategories()
|
||||
await loadItems()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
categoryWorking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (!canSave.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const routes: SkinSiteDownloadRoute[] = form.value.routes
|
||||
.filter((r) => r.url.trim())
|
||||
.map((r) => ({ name: r.name.trim() || null, url: r.url.trim() }))
|
||||
const payload = {
|
||||
routes,
|
||||
filename: form.value.filename.trim(),
|
||||
description: form.value.description,
|
||||
status: form.value.status,
|
||||
}
|
||||
const result =
|
||||
editingId.value === null
|
||||
? await skinSiteAddDownloadItem(payload)
|
||||
: await skinSiteUpdateDownloadItem(editingId.value, payload)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({
|
||||
type: 'success',
|
||||
title: formatMessage(editingId.value === null ? messages.created : messages.updated),
|
||||
})
|
||||
closeEditor()
|
||||
await loadItems()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(item: SkinSiteDownloadItem) {
|
||||
if (deletingId.value !== null) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDeleteItem, { name: item.filename }))) return
|
||||
deletingId.value = item.id
|
||||
try {
|
||||
const result = await skinSiteDeleteDownloadItem(item.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deleted) })
|
||||
await loadItems()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleItemCategory(item: SkinSiteDownloadItem, category: SkinSiteDownloadCategory) {
|
||||
try {
|
||||
const bound = item.category.includes(category.name)
|
||||
const result = bound
|
||||
? await skinSiteUnbindDownloadCategory(item.id, category.id)
|
||||
: await skinSiteBindDownloadCategory(item.id, category.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
await loadItems()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadCategories()
|
||||
await loadItems()
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.total, { count: total }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="openCreate"
|
||||
>
|
||||
{{ formatMessage(messages.addItem) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 gap-4">
|
||||
<aside class="flex w-56 shrink-0 flex-col gap-2">
|
||||
<span class="text-xs font-bold tracking-wide text-secondary uppercase">
|
||||
{{ formatMessage(messages.categories) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-2 py-1.5 text-left text-xs font-semibold"
|
||||
:class="
|
||||
activeCategory === ''
|
||||
? 'bg-brand text-contrast'
|
||||
: 'text-secondary hover:bg-button-bg hover:text-contrast'
|
||||
"
|
||||
@click="selectCategory('')"
|
||||
>
|
||||
{{ formatMessage(messages.all) }}
|
||||
</button>
|
||||
<div v-for="category in categories" :key="category.id" class="flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate rounded-lg px-2 py-1.5 text-left text-xs font-semibold"
|
||||
:class="
|
||||
activeCategory === category.name
|
||||
? 'bg-brand text-contrast'
|
||||
: 'text-secondary hover:bg-button-bg hover:text-contrast'
|
||||
"
|
||||
@click="selectCategory(category.name)"
|
||||
>
|
||||
{{ category.name }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded px-1 text-[10px] text-secondary hover:text-red"
|
||||
:disabled="categoryWorking"
|
||||
@click="removeCategory(category)"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-1 pt-1">
|
||||
<input
|
||||
v-model="newCategoryName"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.categoryName)"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="addCategory"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="categoryWorking || !newCategoryName.trim()"
|
||||
@click="addCategory"
|
||||
>
|
||||
{{ formatMessage(messages.addCategory) }}
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="flex min-w-0 flex-1 flex-col gap-2">
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!items.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
class="flex flex-col gap-2 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="shrink-0 text-xs text-secondary">#{{ item.id }}</span>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
{{ item.filename }}
|
||||
</span>
|
||||
<span
|
||||
v-for="s in item.status"
|
||||
:key="s"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ s }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">
|
||||
{{ formatMessage(messages.uploader, { name: item.uploader }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.description" class="text-xs text-secondary">
|
||||
{{ item.description }}
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<span
|
||||
v-for="route in item.routes"
|
||||
:key="route.url"
|
||||
class="rounded bg-bg px-2 py-0.5 font-mono text-[10px] text-secondary"
|
||||
>
|
||||
{{ route.name ? route.name + ': ' : '' }}{{ route.url }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.bindCategory) }}:
|
||||
</span>
|
||||
<button
|
||||
v-for="category in categories"
|
||||
:key="category.id"
|
||||
type="button"
|
||||
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="
|
||||
item.category.includes(category.name)
|
||||
? 'bg-brand text-contrast'
|
||||
: 'bg-button-bg text-secondary hover:text-contrast'
|
||||
"
|
||||
@click="toggleItemCategory(item, category)"
|
||||
>
|
||||
{{ category.name }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openEdit(item)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingId !== null"
|
||||
@click="remove(item)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="editorOpen"
|
||||
class="flex flex-col gap-3 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.filename) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="form.filename"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.description) }}
|
||||
</span>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="3"
|
||||
class="w-full resize-y rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.statuses) }}
|
||||
</span>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="status in STATUS_OPTIONS"
|
||||
:key="status"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="
|
||||
form.status.includes(status)
|
||||
? 'bg-brand text-contrast'
|
||||
: 'bg-button-bg text-secondary'
|
||||
"
|
||||
@click="toggleStatus(status)"
|
||||
>
|
||||
{{ status }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.routes) }}
|
||||
</span>
|
||||
<div
|
||||
v-for="(route, idx) in form.routes"
|
||||
:key="idx"
|
||||
class="flex flex-wrap items-center gap-2"
|
||||
>
|
||||
<input
|
||||
v-model="route.name"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.routeName)"
|
||||
class="w-32 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<input
|
||||
v-model="route.url"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.routeUrl)"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-1 text-[10px] font-semibold text-secondary hover:text-red disabled:opacity-50"
|
||||
:disabled="form.routes.length <= 1"
|
||||
@click="removeRouteRow(idx)"
|
||||
>
|
||||
{{ formatMessage(messages.removeRoute) }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="w-fit rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110"
|
||||
@click="addRouteRow"
|
||||
>
|
||||
{{ formatMessage(messages.addRoute) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="closeEditor"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="!canSave"
|
||||
@click="save"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,277 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteActivateLauncherRelease,
|
||||
type SkinSiteLauncherAdminState,
|
||||
skinSiteLauncherAdminState,
|
||||
type SkinSiteLauncherRelease,
|
||||
skinSiteUploadLauncherRelease,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.launcher.title', defaultMessage: 'Launcher releases' },
|
||||
loading: { id: 'app.skin-site.admin.launcher.loading', defaultMessage: 'Loading…' },
|
||||
failed: {
|
||||
id: 'app.skin-site.admin.launcher.failed',
|
||||
defaultMessage: 'Could not load releases.',
|
||||
},
|
||||
empty: { id: 'app.skin-site.admin.launcher.empty', defaultMessage: 'No releases uploaded yet.' },
|
||||
latestUrl: { id: 'app.skin-site.admin.launcher.latest-url', defaultMessage: 'Latest URL' },
|
||||
version: { id: 'app.skin-site.admin.launcher.version', defaultMessage: 'Version' },
|
||||
channel: { id: 'app.skin-site.admin.launcher.channel', defaultMessage: 'Channel' },
|
||||
uploader: { id: 'app.skin-site.admin.launcher.uploader', defaultMessage: 'Uploaded by' },
|
||||
uploadedAt: { id: 'app.skin-site.admin.launcher.uploaded-at', defaultMessage: 'Uploaded' },
|
||||
publishedAt: { id: 'app.skin-site.admin.launcher.published-at', defaultMessage: 'Published' },
|
||||
forceUpdate: { id: 'app.skin-site.admin.launcher.force-update', defaultMessage: 'Forced' },
|
||||
active: { id: 'app.skin-site.admin.launcher.active', defaultMessage: 'Active' },
|
||||
activate: { id: 'app.skin-site.admin.launcher.activate', defaultMessage: 'Activate' },
|
||||
activated: { id: 'app.skin-site.admin.launcher.activated', defaultMessage: 'Release activated.' },
|
||||
upload: { id: 'app.skin-site.admin.launcher.upload', defaultMessage: 'Upload release' },
|
||||
uploadHint: {
|
||||
id: 'app.skin-site.admin.launcher.upload-hint',
|
||||
defaultMessage: 'Choose a release ZIP (max 4 GiB).',
|
||||
},
|
||||
uploading: { id: 'app.skin-site.admin.launcher.uploading', defaultMessage: 'Uploading…' },
|
||||
uploadDone: {
|
||||
id: 'app.skin-site.admin.launcher.upload-done',
|
||||
defaultMessage: 'Release uploaded.',
|
||||
},
|
||||
forceFlag: {
|
||||
id: 'app.skin-site.admin.launcher.force-flag',
|
||||
defaultMessage: 'Force update',
|
||||
},
|
||||
prev: { id: 'app.skin-site.admin.launcher.prev', defaultMessage: 'Previous' },
|
||||
next: { id: 'app.skin-site.admin.launcher.next', defaultMessage: 'Next' },
|
||||
page: { id: 'app.skin-site.admin.launcher.page', defaultMessage: 'Page {page}' },
|
||||
total: { id: 'app.skin-site.admin.launcher.total', defaultMessage: '{count} releases' },
|
||||
})
|
||||
|
||||
const PAGE_SIZE = 10
|
||||
|
||||
const state = ref<SkinSiteLauncherAdminState | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const offset = ref(0)
|
||||
|
||||
const uploading = ref(false)
|
||||
const uploadPercent = ref(0)
|
||||
const forceUpdate = ref(false)
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
const activatingId = ref<number | null>(null)
|
||||
|
||||
const releases = computed(() => state.value?.releases ?? [])
|
||||
const total = computed(() => releases.value.length)
|
||||
const page = computed(() => Math.floor(offset.value / PAGE_SIZE) + 1)
|
||||
const pageCount = computed(() => Math.max(1, Math.ceil(total.value / PAGE_SIZE)))
|
||||
const hasPrev = computed(() => offset.value > 0)
|
||||
const hasNext = computed(() => offset.value + PAGE_SIZE < total.value)
|
||||
const visible = computed(() => releases.value.slice(offset.value, offset.value + PAGE_SIZE))
|
||||
|
||||
function formatDateTime(ts?: number | null): string {
|
||||
if (!ts) return '—'
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return '—'
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteLauncherAdminState()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
state.value = result.payload
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function prevPage() {
|
||||
if (hasPrev.value) offset.value = Math.max(0, offset.value - PAGE_SIZE)
|
||||
}
|
||||
function nextPage() {
|
||||
if (hasNext.value) offset.value += PAGE_SIZE
|
||||
}
|
||||
|
||||
async function activate(release: SkinSiteLauncherRelease) {
|
||||
if (activatingId.value !== null) return
|
||||
activatingId.value = release.id
|
||||
try {
|
||||
const result = await skinSiteActivateLauncherRelease(release.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.activated) })
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
activatingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function pickFile() {
|
||||
fileInput.value?.click()
|
||||
}
|
||||
|
||||
async function onFileChosen(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file || uploading.value) return
|
||||
uploading.value = true
|
||||
uploadPercent.value = 0
|
||||
try {
|
||||
const result = await skinSiteUploadLauncherRelease(
|
||||
file,
|
||||
forceUpdate.value,
|
||||
(p) => (uploadPercent.value = Math.round(p)),
|
||||
)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.uploadDone) })
|
||||
offset.value = 0
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
uploading.value = false
|
||||
uploadPercent.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load())
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.total, { count: total }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="state && state.latestUrl"
|
||||
class="flex flex-wrap items-center gap-2 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<span class="text-xs font-semibold text-contrast">
|
||||
{{ formatMessage(messages.latestUrl) }}
|
||||
</span>
|
||||
<code class="min-w-0 flex-1 truncate text-xs text-secondary">{{ state.latestUrl }}</code>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
accept=".zip,application/zip"
|
||||
class="hidden"
|
||||
@change="onFileChosen"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="uploading"
|
||||
@click="pickFile"
|
||||
>
|
||||
{{ formatMessage(messages.upload) }}
|
||||
</button>
|
||||
<label class="flex items-center gap-2 text-xs text-contrast">
|
||||
<input v-model="forceUpdate" type="checkbox" :disabled="uploading" />
|
||||
{{ formatMessage(messages.forceFlag) }}
|
||||
</label>
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.uploadHint) }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="uploading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.uploading) }} {{ uploadPercent }}%
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!total" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="release in visible"
|
||||
:key="release.id"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<span class="truncate text-sm font-semibold text-contrast">
|
||||
{{ release.version }}
|
||||
<span class="text-xs font-normal text-secondary">#{{ release.id }}</span>
|
||||
</span>
|
||||
<span class="truncate text-xs text-secondary">
|
||||
{{ formatMessage(messages.uploader) }}: {{ release.uploadedBy }} ·
|
||||
{{ formatDateTime(release.uploadedAt) }}
|
||||
</span>
|
||||
</div>
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ release.channel }}
|
||||
</span>
|
||||
<span
|
||||
v-if="release.forceUpdate"
|
||||
class="shrink-0 rounded-full bg-orange px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.forceUpdate) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="release.active"
|
||||
class="shrink-0 rounded-full bg-green px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.active) }}
|
||||
</span>
|
||||
<button
|
||||
v-if="!release.active"
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="activatingId !== null"
|
||||
@click="activate(release)"
|
||||
>
|
||||
{{ formatMessage(messages.activate) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-center gap-3 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasPrev"
|
||||
@click="prevPage"
|
||||
>
|
||||
{{ formatMessage(messages.prev) }}
|
||||
</button>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.page, { page }) }} / {{ pageCount }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasNext"
|
||||
@click="nextPage"
|
||||
>
|
||||
{{ formatMessage(messages.next) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,982 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteActivateModRuntime,
|
||||
skinSiteCreateModRuleTag,
|
||||
skinSiteDeleteModFile,
|
||||
skinSiteDeleteModRuleTag,
|
||||
skinSiteDeleteModRuntime,
|
||||
skinSiteDeleteMultiModFile,
|
||||
skinSiteModCount,
|
||||
type SkinSiteModInfo,
|
||||
skinSiteModList,
|
||||
type SkinSiteModRuleTag,
|
||||
skinSiteModRuleTags,
|
||||
type SkinSiteModRuntimeAdminState,
|
||||
type SkinSiteModRuntimeRelease,
|
||||
skinSiteModRuntimeReleases,
|
||||
skinSiteModSearch,
|
||||
skinSiteUpdateModInfo,
|
||||
skinSiteUpdateModRuleTag,
|
||||
skinSiteUpdateMultiModInfo,
|
||||
skinSiteUploadModRuntime,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
import ModUploadModal from './ModUploadModal.vue'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.mods.title', defaultMessage: 'Mods' },
|
||||
tabMods: { id: 'app.skin-site.admin.mods.tab-mods', defaultMessage: 'Mod files' },
|
||||
tabTags: { id: 'app.skin-site.admin.mods.tab-tags', defaultMessage: 'Rule tags' },
|
||||
tabRuntime: { id: 'app.skin-site.admin.mods.tab-runtime', defaultMessage: 'Runtime' },
|
||||
loading: { id: 'app.skin-site.admin.mods.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.mods.failed', defaultMessage: 'Could not load mods.' },
|
||||
empty: { id: 'app.skin-site.admin.mods.empty', defaultMessage: 'No mods found.' },
|
||||
total: { id: 'app.skin-site.admin.mods.total', defaultMessage: '{count} mods' },
|
||||
search: { id: 'app.skin-site.admin.mods.search', defaultMessage: 'Search by name' },
|
||||
filterAll: { id: 'app.skin-site.admin.mods.filter-all', defaultMessage: 'All tags' },
|
||||
prev: { id: 'app.skin-site.admin.mods.prev', defaultMessage: 'Previous' },
|
||||
next: { id: 'app.skin-site.admin.mods.next', defaultMessage: 'Next' },
|
||||
page: { id: 'app.skin-site.admin.mods.page', defaultMessage: 'Page {page}' },
|
||||
name: { id: 'app.skin-site.admin.mods.name', defaultMessage: 'Name' },
|
||||
version: { id: 'app.skin-site.admin.mods.version', defaultMessage: 'Version' },
|
||||
modId: { id: 'app.skin-site.admin.mods.mod-id', defaultMessage: 'Mod ID' },
|
||||
size: { id: 'app.skin-site.admin.mods.size', defaultMessage: 'Size' },
|
||||
loaders: { id: 'app.skin-site.admin.mods.loaders', defaultMessage: 'Loaders' },
|
||||
domainRules: { id: 'app.skin-site.admin.mods.domain-rules', defaultMessage: 'Domain rules' },
|
||||
edit: { id: 'app.skin-site.admin.mods.edit', defaultMessage: 'Edit' },
|
||||
save: { id: 'app.skin-site.admin.mods.save', defaultMessage: 'Save' },
|
||||
cancel: { id: 'app.skin-site.admin.mods.cancel', defaultMessage: 'Cancel' },
|
||||
remove: { id: 'app.skin-site.admin.mods.remove', defaultMessage: 'Delete' },
|
||||
updated: { id: 'app.skin-site.admin.mods.updated', defaultMessage: 'Mod updated.' },
|
||||
deleted: { id: 'app.skin-site.admin.mods.deleted', defaultMessage: 'Mod deleted.' },
|
||||
confirmDelete: {
|
||||
id: 'app.skin-site.admin.mods.confirm-delete',
|
||||
defaultMessage: 'Delete mod “{name}”? This cannot be undone.',
|
||||
},
|
||||
ruleTags: { id: 'app.skin-site.admin.mods.rule-tags', defaultMessage: 'Rule tags' },
|
||||
tagName: { id: 'app.skin-site.admin.mods.tag-name', defaultMessage: 'Tag name' },
|
||||
tagRules: { id: 'app.skin-site.admin.mods.tag-rules', defaultMessage: 'Rules' },
|
||||
tagRulesHint: {
|
||||
id: 'app.skin-site.admin.mods.tag-rules-hint',
|
||||
defaultMessage: 'One rule per line.',
|
||||
},
|
||||
newTag: { id: 'app.skin-site.admin.mods.new-tag', defaultMessage: 'New tag' },
|
||||
tagCreated: { id: 'app.skin-site.admin.mods.tag-created', defaultMessage: 'Tag created.' },
|
||||
tagUpdated: { id: 'app.skin-site.admin.mods.tag-updated', defaultMessage: 'Tag updated.' },
|
||||
tagDeleted: { id: 'app.skin-site.admin.mods.tag-deleted', defaultMessage: 'Tag deleted.' },
|
||||
confirmDeleteTag: {
|
||||
id: 'app.skin-site.admin.mods.confirm-delete-tag',
|
||||
defaultMessage: 'Delete tag “{name}”?',
|
||||
},
|
||||
runtime: { id: 'app.skin-site.admin.mods.runtime', defaultMessage: 'Runtime releases' },
|
||||
manifestUrl: { id: 'app.skin-site.admin.mods.manifest-url', defaultMessage: 'Manifest URL' },
|
||||
uploadRuntime: {
|
||||
id: 'app.skin-site.admin.mods.upload-runtime',
|
||||
defaultMessage: 'Upload runtime',
|
||||
},
|
||||
runtimeVersion: {
|
||||
id: 'app.skin-site.admin.mods.runtime-version',
|
||||
defaultMessage: 'Version',
|
||||
},
|
||||
uploading: { id: 'app.skin-site.admin.mods.uploading', defaultMessage: 'Uploading…' },
|
||||
runtimeUploaded: {
|
||||
id: 'app.skin-site.admin.mods.runtime-uploaded',
|
||||
defaultMessage: 'Runtime uploaded.',
|
||||
},
|
||||
activate: { id: 'app.skin-site.admin.mods.activate', defaultMessage: 'Activate' },
|
||||
activated: { id: 'app.skin-site.admin.mods.activated', defaultMessage: 'Runtime activated.' },
|
||||
available: { id: 'app.skin-site.admin.mods.available', defaultMessage: 'Available' },
|
||||
unavailable: { id: 'app.skin-site.admin.mods.unavailable', defaultMessage: 'Unavailable' },
|
||||
active: { id: 'app.skin-site.admin.mods.active', defaultMessage: 'Active' },
|
||||
uploader: { id: 'app.skin-site.admin.mods.uploader', defaultMessage: 'by {name}' },
|
||||
upload: { id: 'app.skin-site.admin.mods.upload', defaultMessage: 'Upload' },
|
||||
selectMode: {
|
||||
id: 'app.skin-site.admin.mods.select-mode',
|
||||
defaultMessage: 'Select multiple',
|
||||
},
|
||||
exitSelect: {
|
||||
id: 'app.skin-site.admin.mods.exit-select',
|
||||
defaultMessage: 'Done selecting',
|
||||
},
|
||||
selectAll: { id: 'app.skin-site.admin.mods.select-all', defaultMessage: 'Select all' },
|
||||
clearSelection: {
|
||||
id: 'app.skin-site.admin.mods.clear-selection',
|
||||
defaultMessage: 'Clear selection',
|
||||
},
|
||||
selectedCount: {
|
||||
id: 'app.skin-site.admin.mods.selected-count',
|
||||
defaultMessage: '{count} selected',
|
||||
},
|
||||
deleteSelected: {
|
||||
id: 'app.skin-site.admin.mods.delete-selected',
|
||||
defaultMessage: 'Delete selected',
|
||||
},
|
||||
confirmDeleteMulti: {
|
||||
id: 'app.skin-site.admin.mods.confirm-delete-multi',
|
||||
defaultMessage: 'Delete {count} selected mods? This cannot be undone.',
|
||||
},
|
||||
deletedMulti: {
|
||||
id: 'app.skin-site.admin.mods.deleted-multi',
|
||||
defaultMessage: 'Selected mods deleted.',
|
||||
},
|
||||
serverAddress: {
|
||||
id: 'app.skin-site.admin.mods.server-address',
|
||||
defaultMessage: 'Server address',
|
||||
},
|
||||
serverAddressHint: {
|
||||
id: 'app.skin-site.admin.mods.server-address-hint',
|
||||
defaultMessage: 'Filter by server address',
|
||||
},
|
||||
apply: { id: 'app.skin-site.admin.mods.apply', defaultMessage: 'Apply' },
|
||||
clear: { id: 'app.skin-site.admin.mods.clear', defaultMessage: 'Clear' },
|
||||
})
|
||||
|
||||
type Tab = 'mods' | 'tags' | 'runtime'
|
||||
const tab = ref<Tab>('mods')
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const mods = ref<SkinSiteModInfo[]>([])
|
||||
const modTotal = ref(0)
|
||||
const modOffset = ref(0)
|
||||
const modLoading = ref(true)
|
||||
const modFailed = ref(false)
|
||||
const searchKeyword = ref('')
|
||||
const tagFilter = ref<number | null>(null)
|
||||
|
||||
const editingHash = ref<string | null>(null)
|
||||
const editForm = ref({ name: '', modId: '', version: '', domainRules: '' })
|
||||
const savingMod = ref(false)
|
||||
const deletingHash = ref<string | null>(null)
|
||||
|
||||
const selectedHashes = ref<Set<string>>(new Set())
|
||||
const selectionMode = ref(false)
|
||||
const deletingMulti = ref(false)
|
||||
const serverAddressInput = ref('')
|
||||
const serverAddressFilter = ref('')
|
||||
const uploadOpen = ref(false)
|
||||
|
||||
const tags = ref<SkinSiteModRuleTag[]>([])
|
||||
const tagsLoading = ref(false)
|
||||
const tagEditorOpen = ref(false)
|
||||
const editingTagId = ref<number | null>(null)
|
||||
const tagForm = ref({ name: '', rules: '' })
|
||||
const savingTag = ref(false)
|
||||
|
||||
const runtimeState = ref<SkinSiteModRuntimeAdminState | null>(null)
|
||||
const runtimeLoading = ref(false)
|
||||
const runtimeVersion = ref('')
|
||||
const runtimeFile = ref<HTMLInputElement | null>(null)
|
||||
const runtimeUploading = ref(false)
|
||||
const activatingRuntimeId = ref<number | null>(null)
|
||||
const deletingRuntimeId = ref<number | null>(null)
|
||||
|
||||
const modPage = computed(() => Math.floor(modOffset.value / PAGE_SIZE) + 1)
|
||||
const modPageCount = computed(() => Math.max(1, Math.ceil(modTotal.value / PAGE_SIZE)))
|
||||
const hasPrev = computed(() => modOffset.value > 0)
|
||||
const hasNext = computed(() => modOffset.value + PAGE_SIZE < modTotal.value)
|
||||
|
||||
function formatSize(bytes: number): string {
|
||||
if (!Number.isFinite(bytes) || bytes < 0) return '—'
|
||||
const units = ['B', 'KB', 'MB', 'GB']
|
||||
let v = bytes
|
||||
let i = 0
|
||||
while (v >= 1024 && i < units.length - 1) {
|
||||
v /= 1024
|
||||
i++
|
||||
}
|
||||
return v.toFixed(i === 0 ? 0 : 2) + ' ' + units[i]
|
||||
}
|
||||
|
||||
function formatDateTime(ts?: number | null): string {
|
||||
if (!ts) return '—'
|
||||
try {
|
||||
return new Date(ts).toLocaleString()
|
||||
} catch {
|
||||
return '—'
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMods(reset = true) {
|
||||
if (reset) {
|
||||
modLoading.value = true
|
||||
mods.value = []
|
||||
modOffset.value = 0
|
||||
}
|
||||
modFailed.value = false
|
||||
try {
|
||||
const kw = searchKeyword.value.trim()
|
||||
if (kw) {
|
||||
const result = await skinSiteModSearch(kw, tagFilter.value)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
mods.value = result.payload ?? []
|
||||
modTotal.value = mods.value.length
|
||||
} else {
|
||||
const [listResult, countResult] = await Promise.all([
|
||||
skinSiteModList({
|
||||
limit: PAGE_SIZE,
|
||||
offset: modOffset.value,
|
||||
ruleTagId: tagFilter.value,
|
||||
serverAddr: serverAddressFilter.value || undefined,
|
||||
}),
|
||||
skinSiteModCount({
|
||||
ruleTagId: tagFilter.value,
|
||||
serverAddr: serverAddressFilter.value || undefined,
|
||||
}),
|
||||
])
|
||||
if (!listResult.success) throw new Error(listResult.errorMessage)
|
||||
mods.value = listResult.payload ?? []
|
||||
if (countResult.success && typeof countResult.payload === 'number') {
|
||||
modTotal.value = countResult.payload
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
modFailed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
modLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function prevPage() {
|
||||
if (hasPrev.value) {
|
||||
modOffset.value = Math.max(0, modOffset.value - PAGE_SIZE)
|
||||
void loadMods(false)
|
||||
}
|
||||
}
|
||||
function nextPage() {
|
||||
if (hasNext.value) {
|
||||
modOffset.value += PAGE_SIZE
|
||||
void loadMods(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function loadTags() {
|
||||
tagsLoading.value = true
|
||||
try {
|
||||
const result = await skinSiteModRuleTags()
|
||||
if (result.success) tags.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
tagsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRuntime() {
|
||||
runtimeLoading.value = true
|
||||
try {
|
||||
const result = await skinSiteModRuntimeReleases()
|
||||
if (result.success) runtimeState.value = result.payload
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
runtimeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function switchTab(next: Tab) {
|
||||
tab.value = next
|
||||
if (next === 'tags' && !tags.value.length) await loadTags()
|
||||
if (next === 'runtime' && !runtimeState.value) await loadRuntime()
|
||||
}
|
||||
|
||||
function startEdit(mod: SkinSiteModInfo) {
|
||||
editingHash.value = mod.hash
|
||||
editForm.value = {
|
||||
name: mod.metadata.name ?? mod.name,
|
||||
modId: mod.metadata.modId ?? '',
|
||||
version: mod.metadata.version ?? '',
|
||||
domainRules: mod.domainRules.join(', '),
|
||||
}
|
||||
}
|
||||
|
||||
function cancelEdit() {
|
||||
editingHash.value = null
|
||||
}
|
||||
|
||||
async function saveMod(mod: SkinSiteModInfo) {
|
||||
if (savingMod.value) return
|
||||
savingMod.value = true
|
||||
try {
|
||||
const payload: SkinSiteModInfo = {
|
||||
...mod,
|
||||
name: editForm.value.name.trim() || mod.name,
|
||||
domainRules: editForm.value.domainRules
|
||||
.split(',')
|
||||
.map((r) => r.trim())
|
||||
.filter(Boolean),
|
||||
metadata: {
|
||||
...mod.metadata,
|
||||
name: editForm.value.name.trim() || undefined,
|
||||
modId: editForm.value.modId.trim() || undefined,
|
||||
version: editForm.value.version.trim() || undefined,
|
||||
},
|
||||
}
|
||||
const result = await skinSiteUpdateModInfo(payload)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.updated) })
|
||||
cancelEdit()
|
||||
await loadMods(false)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingMod.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function removeMod(mod: SkinSiteModInfo) {
|
||||
if (deletingHash.value !== null) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDelete, { name: mod.name }))) return
|
||||
deletingHash.value = mod.hash
|
||||
try {
|
||||
const result = await skinSiteDeleteModFile(mod.hash)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deleted) })
|
||||
await loadMods(false)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingHash.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelect(hash: string) {
|
||||
const next = new Set(selectedHashes.value)
|
||||
if (next.has(hash)) next.delete(hash)
|
||||
else next.add(hash)
|
||||
selectedHashes.value = next
|
||||
}
|
||||
|
||||
function selectAllVisible() {
|
||||
selectedHashes.value = new Set(mods.value.map((m) => m.hash))
|
||||
}
|
||||
|
||||
function clearSelection() {
|
||||
selectedHashes.value = new Set()
|
||||
}
|
||||
|
||||
function exitSelectionMode() {
|
||||
selectionMode.value = false
|
||||
clearSelection()
|
||||
}
|
||||
|
||||
async function deleteSelected() {
|
||||
if (deletingMulti.value || !selectedHashes.value.size) return
|
||||
const count = selectedHashes.value.size
|
||||
if (!window.confirm(formatMessage(messages.confirmDeleteMulti, { count }))) return
|
||||
deletingMulti.value = true
|
||||
try {
|
||||
const result = await skinSiteDeleteMultiModFile(Array.from(selectedHashes.value))
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deletedMulti) })
|
||||
clearSelection()
|
||||
selectionMode.value = false
|
||||
await loadMods(false)
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingMulti.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function applyServerAddress() {
|
||||
serverAddressFilter.value = serverAddressInput.value.trim()
|
||||
void loadMods(true)
|
||||
}
|
||||
|
||||
function clearServerAddress() {
|
||||
serverAddressInput.value = ''
|
||||
serverAddressFilter.value = ''
|
||||
void loadMods(true)
|
||||
}
|
||||
|
||||
function openNewTag() {
|
||||
editingTagId.value = null
|
||||
tagForm.value = { name: '', rules: '' }
|
||||
tagEditorOpen.value = true
|
||||
}
|
||||
|
||||
function openEditTag(tag: SkinSiteModRuleTag) {
|
||||
editingTagId.value = tag.id
|
||||
tagForm.value = { name: tag.name, rules: tag.rules.join('\n') }
|
||||
tagEditorOpen.value = true
|
||||
}
|
||||
|
||||
function closeTagEditor() {
|
||||
tagEditorOpen.value = false
|
||||
tagForm.value = { name: '', rules: '' }
|
||||
editingTagId.value = null
|
||||
}
|
||||
|
||||
async function saveTag() {
|
||||
const name = tagForm.value.name.trim()
|
||||
if (!name || savingTag.value) return
|
||||
savingTag.value = true
|
||||
try {
|
||||
const rules = tagForm.value.rules
|
||||
.split('\n')
|
||||
.map((r) => r.trim())
|
||||
.filter(Boolean)
|
||||
const result =
|
||||
editingTagId.value === null
|
||||
? await skinSiteCreateModRuleTag(name, rules)
|
||||
: await skinSiteUpdateModRuleTag(editingTagId.value, name, rules)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({
|
||||
type: 'success',
|
||||
title: formatMessage(editingTagId.value === null ? messages.tagCreated : messages.tagUpdated),
|
||||
})
|
||||
closeTagEditor()
|
||||
await loadTags()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
savingTag.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function removeTag(tag: SkinSiteModRuleTag) {
|
||||
if (!window.confirm(formatMessage(messages.confirmDeleteTag, { name: tag.name }))) return
|
||||
try {
|
||||
const result = await skinSiteDeleteModRuleTag(tag.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.tagDeleted) })
|
||||
if (tagFilter.value === tag.id) tagFilter.value = null
|
||||
await loadTags()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
function pickRuntimeFile() {
|
||||
runtimeFile.value?.click()
|
||||
}
|
||||
|
||||
async function onRuntimeFile(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
const version = runtimeVersion.value.trim()
|
||||
if (!file || !version || runtimeUploading.value) return
|
||||
runtimeUploading.value = true
|
||||
try {
|
||||
const result = await skinSiteUploadModRuntime(version, file)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.runtimeUploaded) })
|
||||
runtimeVersion.value = ''
|
||||
await loadRuntime()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
runtimeUploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function activateRuntime(release: SkinSiteModRuntimeRelease) {
|
||||
if (activatingRuntimeId.value !== null) return
|
||||
activatingRuntimeId.value = release.id
|
||||
try {
|
||||
const result = await skinSiteActivateModRuntime(release.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.activated) })
|
||||
await loadRuntime()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
activatingRuntimeId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function removeRuntime(release: SkinSiteModRuntimeRelease) {
|
||||
if (deletingRuntimeId.value !== null) return
|
||||
deletingRuntimeId.value = release.id
|
||||
try {
|
||||
const result = await skinSiteDeleteModRuntime(release.id)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
await loadRuntime()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingRuntimeId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadTags()
|
||||
await loadMods(true)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="tab === 'mods' ? 'bg-brand text-contrast' : 'bg-button-bg text-secondary'"
|
||||
@click="switchTab('mods')"
|
||||
>
|
||||
{{ formatMessage(messages.tabMods) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="tab === 'tags' ? 'bg-brand text-contrast' : 'bg-button-bg text-secondary'"
|
||||
@click="switchTab('tags')"
|
||||
>
|
||||
{{ formatMessage(messages.tabTags) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold"
|
||||
:class="tab === 'runtime' ? 'bg-brand text-contrast' : 'bg-button-bg text-secondary'"
|
||||
@click="switchTab('runtime')"
|
||||
>
|
||||
{{ formatMessage(messages.tabRuntime) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<template v-if="tab === 'mods'">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.search)"
|
||||
class="min-w-0 flex-1 rounded-full border border-solid border-surface-5 bg-bg px-3 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="loadMods(true)"
|
||||
/>
|
||||
<select
|
||||
v-model="tagFilter"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
@change="loadMods(true)"
|
||||
>
|
||||
<option :value="null">{{ formatMessage(messages.filterAll) }}</option>
|
||||
<option v-for="tag in tags" :key="tag.id" :value="tag.id">{{ tag.name }}</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="uploadOpen = true"
|
||||
>
|
||||
{{ formatMessage(messages.upload) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!selectionMode"
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="selectionMode = true"
|
||||
>
|
||||
{{ formatMessage(messages.selectMode) }}
|
||||
</button>
|
||||
<template v-else>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="selectAllVisible"
|
||||
>
|
||||
{{ formatMessage(messages.selectAll) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!selectedHashes.size"
|
||||
@click="clearSelection"
|
||||
>
|
||||
{{ formatMessage(messages.clearSelection) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!selectedHashes.size || deletingMulti"
|
||||
@click="deleteSelected"
|
||||
>
|
||||
{{ formatMessage(messages.deleteSelected) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="exitSelectionMode"
|
||||
>
|
||||
{{ formatMessage(messages.exitSelect) }}
|
||||
</button>
|
||||
</template>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.total, { count: modTotal }) }}
|
||||
</span>
|
||||
<span v-if="selectionMode && selectedHashes.size" class="text-xs font-semibold text-contrast">
|
||||
{{ formatMessage(messages.selectedCount, { count: selectedHashes.size }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="serverAddressInput"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.serverAddressHint)"
|
||||
class="min-w-0 flex-1 rounded-full border border-solid border-surface-5 bg-bg px-3 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="applyServerAddress"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="applyServerAddress"
|
||||
>
|
||||
{{ formatMessage(messages.apply) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!serverAddressFilter"
|
||||
@click="clearServerAddress"
|
||||
>
|
||||
{{ formatMessage(messages.clear) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="modLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="modFailed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!mods.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="mod in mods"
|
||||
:key="mod.hash"
|
||||
class="flex flex-col gap-2 rounded-xl bg-bg-raised p-3"
|
||||
:class="selectionMode && selectedHashes.has(mod.hash) ? 'ring-2 ring-brand' : ''"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-if="selectionMode"
|
||||
type="checkbox"
|
||||
class="size-3.5 shrink-0"
|
||||
:checked="selectedHashes.has(mod.hash)"
|
||||
@change="toggleSelect(mod.hash)"
|
||||
/>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
{{ mod.metadata.name || mod.name }}
|
||||
</span>
|
||||
<span class="shrink-0 text-xs text-secondary">{{ formatSize(mod.size) }}</span>
|
||||
<span
|
||||
v-for="loader in mod.metadata.loaderType"
|
||||
:key="loader"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ loader }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="truncate font-mono text-[10px] text-secondary">{{ mod.hash }}</span>
|
||||
|
||||
<div v-if="editingHash === mod.hash" class="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.name) }}</span>
|
||||
<input
|
||||
v-model="editForm.name"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.modId) }}</span>
|
||||
<input
|
||||
v-model="editForm.modId"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.version) }}</span>
|
||||
<input
|
||||
v-model="editForm.version"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1 sm:col-span-3">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.domainRules) }}</span>
|
||||
<input
|
||||
v-model="editForm.domainRules"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<template v-if="editingHash === mod.hash">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="cancelEdit"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="savingMod"
|
||||
@click="saveMod(mod)"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span
|
||||
v-for="rule in mod.domainRules"
|
||||
:key="rule"
|
||||
class="rounded bg-bg px-2 py-0.5 font-mono text-[10px] text-secondary"
|
||||
>
|
||||
{{ rule }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="startEdit(mod)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingHash !== null"
|
||||
@click="removeMod(mod)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-center gap-3 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasPrev"
|
||||
@click="prevPage"
|
||||
>
|
||||
{{ formatMessage(messages.prev) }}
|
||||
</button>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.page, { page: modPage }) }} / {{ modPageCount }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasNext"
|
||||
@click="nextPage"
|
||||
>
|
||||
{{ formatMessage(messages.next) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="tab === 'tags'">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="openNewTag"
|
||||
>
|
||||
{{ formatMessage(messages.newTag) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="tagsLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<div v-else-if="!tags.length" class="rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</div>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="tag in tags"
|
||||
:key="tag.id"
|
||||
class="flex flex-wrap items-center gap-2 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate text-sm font-semibold text-contrast">
|
||||
{{ tag.name }}
|
||||
</span>
|
||||
<span class="text-xs text-secondary">×{{ tag.rules.length }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="openEditTag(tag)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="removeTag(tag)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="tagEditorOpen"
|
||||
class="flex flex-col gap-2 rounded-xl border border-solid border-surface-5 bg-bg-raised p-4"
|
||||
>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.tagName) }}
|
||||
</span>
|
||||
<input
|
||||
v-model="tagForm.name"
|
||||
type="text"
|
||||
class="rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1">
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.tagRules) }}
|
||||
</span>
|
||||
<textarea
|
||||
v-model="tagForm.rules"
|
||||
rows="5"
|
||||
:placeholder="formatMessage(messages.tagRulesHint)"
|
||||
class="w-full resize-y rounded-lg border border-solid border-surface-5 bg-bg px-3 py-2 font-mono text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
</label>
|
||||
<div class="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="closeTagEditor"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast disabled:opacity-50"
|
||||
:disabled="savingTag || !tagForm.name.trim()"
|
||||
@click="saveTag"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input ref="runtimeFile" type="file" class="hidden" @change="onRuntimeFile" />
|
||||
<input
|
||||
v-model="runtimeVersion"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.runtimeVersion)"
|
||||
class="w-40 rounded-lg border border-solid border-surface-5 bg-bg px-3 py-1.5 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="runtimeUploading || !runtimeVersion.trim()"
|
||||
@click="pickRuntimeFile"
|
||||
>
|
||||
{{
|
||||
runtimeUploading
|
||||
? formatMessage(messages.uploading)
|
||||
: formatMessage(messages.uploadRuntime)
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="runtimeState && runtimeState.manifestUrl"
|
||||
class="flex flex-wrap items-center gap-2 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<span class="text-xs font-semibold text-contrast">
|
||||
{{ formatMessage(messages.manifestUrl) }}
|
||||
</span>
|
||||
<code class="min-w-0 flex-1 truncate text-xs text-secondary">
|
||||
{{ runtimeState.manifestUrl }}
|
||||
</code>
|
||||
</div>
|
||||
|
||||
<div v-if="runtimeLoading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p
|
||||
v-else-if="!runtimeState || !runtimeState.releases.length"
|
||||
class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary"
|
||||
>
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="release in runtimeState.releases"
|
||||
:key="release.id"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<span class="truncate text-sm font-semibold text-contrast">
|
||||
{{ release.version }}
|
||||
<span class="text-xs font-normal text-secondary">#{{ release.id }}</span>
|
||||
</span>
|
||||
<span class="truncate text-xs text-secondary">
|
||||
{{ formatMessage(messages.uploader, { name: release.uploadedBy }) }} ·
|
||||
{{ formatDateTime(release.uploadedAt) }}
|
||||
</span>
|
||||
</div>
|
||||
<span class="shrink-0 text-xs text-secondary">
|
||||
{{ formatSize(release.fileSize) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="release.active"
|
||||
class="shrink-0 rounded-full bg-green px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.active) }}
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="release.available ? 'bg-button-bg text-secondary' : 'bg-orange text-contrast'"
|
||||
>
|
||||
{{
|
||||
release.available
|
||||
? formatMessage(messages.available)
|
||||
: formatMessage(messages.unavailable)
|
||||
}}
|
||||
</span>
|
||||
<button
|
||||
v-if="!release.active"
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="activatingRuntimeId !== null"
|
||||
@click="activateRuntime(release)"
|
||||
>
|
||||
{{ formatMessage(messages.activate) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingRuntimeId !== null || release.active"
|
||||
@click="removeRuntime(release)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<ModUploadModal
|
||||
v-if="uploadOpen"
|
||||
:rule-tags="tags"
|
||||
@finished="uploadOpen = false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,315 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
skinSiteAdminDeletePlayer,
|
||||
type SkinSiteAdminPlayer,
|
||||
skinSiteAdminPlayerCount,
|
||||
skinSiteAdminPlayerList,
|
||||
skinSiteAdminUpdatePlayer,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.players.title', defaultMessage: 'Players' },
|
||||
loading: { id: 'app.skin-site.admin.players.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.players.failed', defaultMessage: 'Could not load players.' },
|
||||
empty: { id: 'app.skin-site.admin.players.empty', defaultMessage: 'No players found.' },
|
||||
search: { id: 'app.skin-site.admin.players.search', defaultMessage: 'Search' },
|
||||
searchName: { id: 'app.skin-site.admin.players.search-name', defaultMessage: 'Name' },
|
||||
searchOwner: { id: 'app.skin-site.admin.players.search-owner', defaultMessage: 'Owner' },
|
||||
searchUuid: { id: 'app.skin-site.admin.players.search-uuid', defaultMessage: 'UUID' },
|
||||
total: { id: 'app.skin-site.admin.players.total', defaultMessage: '{count} players' },
|
||||
prev: { id: 'app.skin-site.admin.players.prev', defaultMessage: 'Previous' },
|
||||
next: { id: 'app.skin-site.admin.players.next', defaultMessage: 'Next' },
|
||||
page: { id: 'app.skin-site.admin.players.page', defaultMessage: 'Page {page}' },
|
||||
name: { id: 'app.skin-site.admin.players.name', defaultMessage: 'Name' },
|
||||
owner: { id: 'app.skin-site.admin.players.owner', defaultMessage: 'Owner' },
|
||||
source: { id: 'app.skin-site.admin.players.source', defaultMessage: 'Source' },
|
||||
legacy: { id: 'app.skin-site.admin.players.legacy', defaultMessage: 'Legacy adapted' },
|
||||
actions: { id: 'app.skin-site.admin.players.actions', defaultMessage: 'Actions' },
|
||||
edit: { id: 'app.skin-site.admin.players.edit', defaultMessage: 'Edit' },
|
||||
save: { id: 'app.skin-site.admin.players.save', defaultMessage: 'Save' },
|
||||
cancel: { id: 'app.skin-site.admin.players.cancel', defaultMessage: 'Cancel' },
|
||||
remove: { id: 'app.skin-site.admin.players.remove', defaultMessage: 'Delete' },
|
||||
updated: { id: 'app.skin-site.admin.players.updated', defaultMessage: 'Player updated.' },
|
||||
deleted: { id: 'app.skin-site.admin.players.deleted', defaultMessage: 'Player deleted.' },
|
||||
confirmDelete: {
|
||||
id: 'app.skin-site.admin.players.confirm-delete',
|
||||
defaultMessage: 'Delete player “{name}”? This cannot be undone.',
|
||||
},
|
||||
mojang: { id: 'app.skin-site.admin.players.mojang', defaultMessage: 'Mojang' },
|
||||
custom: { id: 'app.skin-site.admin.players.custom', defaultMessage: 'Skin site' },
|
||||
})
|
||||
|
||||
const PAGE_SIZE = 20
|
||||
|
||||
const items = ref<SkinSiteAdminPlayer[]>([])
|
||||
const total = ref(0)
|
||||
const offset = ref(0)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
|
||||
const keyword = ref('')
|
||||
const searchField = ref<'name' | 'ownerUsername' | 'uuid'>('name')
|
||||
|
||||
const editingUuid = ref<string | null>(null)
|
||||
const editName = ref('')
|
||||
const editIsMojang = ref(false)
|
||||
const saving = ref(false)
|
||||
const deletingUuid = ref<string | null>(null)
|
||||
|
||||
const page = computed(() => Math.floor(offset.value / PAGE_SIZE) + 1)
|
||||
const pageCount = computed(() => Math.max(1, Math.ceil(total.value / PAGE_SIZE)))
|
||||
const hasPrev = computed(() => offset.value > 0)
|
||||
const hasNext = computed(() => offset.value + PAGE_SIZE < total.value)
|
||||
|
||||
const SEARCH_FIELDS: Array<'name' | 'ownerUsername' | 'uuid'> = ['name', 'ownerUsername', 'uuid']
|
||||
|
||||
function searchFieldLabel(field: string): string {
|
||||
if (field === 'ownerUsername') return formatMessage(messages.searchOwner)
|
||||
if (field === 'uuid') return formatMessage(messages.searchUuid)
|
||||
return formatMessage(messages.searchName)
|
||||
}
|
||||
|
||||
function buildQuery() {
|
||||
const kw = keyword.value.trim()
|
||||
return {
|
||||
limit: PAGE_SIZE,
|
||||
offset: offset.value,
|
||||
searchField: kw ? searchField.value : undefined,
|
||||
keyword: kw || undefined,
|
||||
}
|
||||
}
|
||||
|
||||
async function load(reset = false) {
|
||||
if (reset) offset.value = 0
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const query = buildQuery()
|
||||
const [listResult, countResult] = await Promise.all([
|
||||
skinSiteAdminPlayerList(query),
|
||||
skinSiteAdminPlayerCount(
|
||||
query.keyword ? { searchField: query.searchField, keyword: query.keyword } : undefined,
|
||||
),
|
||||
])
|
||||
if (!listResult.success) throw new Error(listResult.errorMessage)
|
||||
items.value = listResult.payload ?? []
|
||||
if (countResult.success && typeof countResult.payload === 'number') {
|
||||
total.value = countResult.payload
|
||||
}
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function prevPage() {
|
||||
if (!hasPrev.value) return
|
||||
offset.value = Math.max(0, offset.value - PAGE_SIZE)
|
||||
await load()
|
||||
}
|
||||
|
||||
async function nextPage() {
|
||||
if (!hasNext.value) return
|
||||
offset.value += PAGE_SIZE
|
||||
await load()
|
||||
}
|
||||
|
||||
function startEdit(player: SkinSiteAdminPlayer) {
|
||||
editingUuid.value = player.uuid
|
||||
editName.value = player.name
|
||||
editIsMojang.value = player.isMojang
|
||||
}
|
||||
|
||||
function cancelEdit() {
|
||||
editingUuid.value = null
|
||||
editName.value = ''
|
||||
editIsMojang.value = false
|
||||
}
|
||||
|
||||
async function saveEdit() {
|
||||
if (!editingUuid.value || saving.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const result = await skinSiteAdminUpdatePlayer({
|
||||
uuid: editingUuid.value,
|
||||
name: editName.value.trim(),
|
||||
isMojang: editIsMojang.value,
|
||||
})
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.updated) })
|
||||
cancelEdit()
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(player: SkinSiteAdminPlayer) {
|
||||
if (deletingUuid.value !== null) return
|
||||
if (!window.confirm(formatMessage(messages.confirmDelete, { name: player.name }))) return
|
||||
deletingUuid.value = player.uuid
|
||||
try {
|
||||
const result = await skinSiteAdminDeletePlayer(player.uuid)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
addNotification({ type: 'success', title: formatMessage(messages.deleted) })
|
||||
await load()
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
deletingUuid.value = null
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load())
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.total, { count: total }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select
|
||||
v-model="searchField"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast"
|
||||
>
|
||||
<option v-for="f in SEARCH_FIELDS" :key="f" :value="f">
|
||||
{{ searchFieldLabel(f) }}
|
||||
</option>
|
||||
</select>
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.search)"
|
||||
class="min-w-0 flex-1 rounded-full border border-solid border-surface-5 bg-bg px-3 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
@keyup.enter="load(true)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-brand px-4 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="load(true)"
|
||||
>
|
||||
{{ formatMessage(messages.search) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!items.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="player in items"
|
||||
:key="player.uuid"
|
||||
class="flex flex-wrap items-center gap-3 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<input
|
||||
v-if="editingUuid === player.uuid"
|
||||
v-model="editName"
|
||||
type="text"
|
||||
class="w-full rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<span v-else class="truncate text-sm font-semibold text-contrast">
|
||||
{{ player.name }}
|
||||
</span>
|
||||
<span class="truncate font-mono text-[10px] text-secondary">{{ player.uuid }}</span>
|
||||
</div>
|
||||
|
||||
<span class="shrink-0 text-xs text-secondary">{{ player.ownerUsername }}</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-0.5 text-[10px] font-semibold text-secondary"
|
||||
>
|
||||
{{ player.isMojang ? formatMessage(messages.mojang) : formatMessage(messages.custom) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="player.legacyInternalAdapted"
|
||||
class="shrink-0 rounded-full bg-yellow px-2 py-0.5 text-[10px] font-semibold text-contrast"
|
||||
>
|
||||
{{ formatMessage(messages.legacy) }}
|
||||
</span>
|
||||
|
||||
<template v-if="editingUuid === player.uuid">
|
||||
<label class="flex shrink-0 items-center gap-1 text-xs text-contrast">
|
||||
<input v-model="editIsMojang" type="checkbox" />
|
||||
{{ formatMessage(messages.mojang) }}
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="cancelEdit"
|
||||
>
|
||||
{{ formatMessage(messages.cancel) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-brand px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="saving"
|
||||
@click="saveEdit"
|
||||
>
|
||||
{{ formatMessage(messages.save) }}
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="startEdit(player)"
|
||||
>
|
||||
{{ formatMessage(messages.edit) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="deletingUuid !== null"
|
||||
@click="remove(player)"
|
||||
>
|
||||
{{ formatMessage(messages.remove) }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-center gap-3 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasPrev"
|
||||
@click="prevPage"
|
||||
>
|
||||
{{ formatMessage(messages.prev) }}
|
||||
</button>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.page, { page }) }} / {{ pageCount }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="!hasNext"
|
||||
@click="nextPage"
|
||||
>
|
||||
{{ formatMessage(messages.next) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,188 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteMapServer,
|
||||
skinSiteMapServers,
|
||||
skinSiteSaveMapServers,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.servers.title', defaultMessage: 'Map servers' },
|
||||
loading: { id: 'app.skin-site.admin.servers.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.servers.failed', defaultMessage: 'Could not load servers.' },
|
||||
empty: { id: 'app.skin-site.admin.servers.empty', defaultMessage: 'No map servers configured.' },
|
||||
serverName: { id: 'app.skin-site.admin.servers.server-name', defaultMessage: 'Server name' },
|
||||
internal: { id: 'app.skin-site.admin.servers.internal', defaultMessage: 'Internal' },
|
||||
maps: { id: 'app.skin-site.admin.servers.maps', defaultMessage: 'Maps' },
|
||||
mapName: { id: 'app.skin-site.admin.servers.map-name', defaultMessage: 'Map name' },
|
||||
mapUrl: { id: 'app.skin-site.admin.servers.map-url', defaultMessage: 'Map URL' },
|
||||
addMap: { id: 'app.skin-site.admin.servers.add-map', defaultMessage: 'Add map' },
|
||||
removeMap: { id: 'app.skin-site.admin.servers.remove-map', defaultMessage: 'Remove' },
|
||||
addServer: { id: 'app.skin-site.admin.servers.add-server', defaultMessage: 'Add server' },
|
||||
removeServer: {
|
||||
id: 'app.skin-site.admin.servers.remove-server',
|
||||
defaultMessage: 'Remove server',
|
||||
},
|
||||
save: { id: 'app.skin-site.admin.servers.save', defaultMessage: 'Save changes' },
|
||||
saving: { id: 'app.skin-site.admin.servers.saving', defaultMessage: 'Saving…' },
|
||||
saved: { id: 'app.skin-site.admin.servers.saved', defaultMessage: 'Map servers saved.' },
|
||||
})
|
||||
|
||||
const servers = ref<SkinSiteMapServer[]>([])
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const saving = ref(false)
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteMapServers()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
servers.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function addServer() {
|
||||
servers.value.push({ name: '', internal: false, maps: [{ name: '', url: '' }] })
|
||||
}
|
||||
|
||||
function removeServer(index: number) {
|
||||
servers.value.splice(index, 1)
|
||||
}
|
||||
|
||||
function addMap(server: SkinSiteMapServer) {
|
||||
server.maps.push({ name: '', url: '' })
|
||||
}
|
||||
|
||||
function removeMap(server: SkinSiteMapServer, index: number) {
|
||||
server.maps.splice(index, 1)
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (saving.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const cleaned = servers.value.map((s) => ({
|
||||
name: s.name.trim(),
|
||||
internal: s.internal,
|
||||
maps: s.maps
|
||||
.filter((m) => m.name.trim() || m.url.trim())
|
||||
.map((m) => ({ name: m.name.trim(), url: m.url.trim() })),
|
||||
}))
|
||||
const result = await skinSiteSaveMapServers(cleaned)
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
servers.value = result.payload ?? cleaned
|
||||
addNotification({ type: 'success', title: formatMessage(messages.saved) })
|
||||
} catch (error) {
|
||||
handleError(error)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => void load())
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="addServer"
|
||||
>
|
||||
{{ formatMessage(messages.addServer) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-auto rounded-full bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="saving"
|
||||
@click="save"
|
||||
>
|
||||
{{ saving ? formatMessage(messages.saving) : formatMessage(messages.save) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
<p v-else-if="!servers.length" class="m-0 rounded-xl bg-bg-raised p-4 text-sm text-secondary">
|
||||
{{ formatMessage(messages.empty) }}
|
||||
</p>
|
||||
<div v-else class="flex flex-col gap-3">
|
||||
<div
|
||||
v-for="(server, si) in servers"
|
||||
:key="si"
|
||||
class="flex flex-col gap-2 rounded-xl bg-bg-raised p-3"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="server.name"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.serverName)"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg px-3 py-1.5 text-sm text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<label class="flex shrink-0 items-center gap-1.5 text-xs text-contrast">
|
||||
<input v-model="server.internal" type="checkbox" />
|
||||
{{ formatMessage(messages.internal) }}
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-red px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110"
|
||||
@click="removeServer(si)"
|
||||
>
|
||||
{{ formatMessage(messages.removeServer) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<span class="text-xs font-semibold text-secondary">
|
||||
{{ formatMessage(messages.maps) }}
|
||||
</span>
|
||||
<div v-for="(map, mi) in server.maps" :key="mi" class="flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="map.name"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.mapName)"
|
||||
class="w-40 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<input
|
||||
v-model="map.url"
|
||||
type="text"
|
||||
:placeholder="formatMessage(messages.mapUrl)"
|
||||
class="min-w-0 flex-1 rounded-lg border border-solid border-surface-5 bg-bg px-2 py-1 text-xs text-contrast outline-none focus:border-brand"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-full bg-button-bg px-2 py-1 text-[10px] font-semibold text-secondary hover:text-red"
|
||||
@click="removeMap(server, mi)"
|
||||
>
|
||||
{{ formatMessage(messages.removeMap) }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="w-fit rounded-full bg-button-bg px-3 py-1 text-xs font-semibold text-secondary hover:brightness-110"
|
||||
@click="addMap(server)"
|
||||
>
|
||||
{{ formatMessage(messages.addMap) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,124 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
import { type SkinSiteAdminStatus, skinSiteAdminStatus } from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError } = injectNotificationManager()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.summary.title', defaultMessage: 'System overview' },
|
||||
loading: { id: 'app.skin-site.admin.summary.loading', defaultMessage: 'Loading…' },
|
||||
failed: { id: 'app.skin-site.admin.summary.failed', defaultMessage: 'Could not load status.' },
|
||||
uptime: { id: 'app.skin-site.admin.summary.uptime', defaultMessage: 'Uptime' },
|
||||
memory: { id: 'app.skin-site.admin.summary.memory', defaultMessage: 'Memory usage' },
|
||||
users: { id: 'app.skin-site.admin.summary.users', defaultMessage: 'Users' },
|
||||
players: { id: 'app.skin-site.admin.summary.players', defaultMessage: 'Players' },
|
||||
realtimeHint: {
|
||||
id: 'app.skin-site.admin.summary.realtime-hint',
|
||||
defaultMessage:
|
||||
'Live CPU and GC charts require the admin WebSocket, which is not connected yet.',
|
||||
},
|
||||
})
|
||||
|
||||
const status = ref<SkinSiteAdminStatus | null>(null)
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const now = ref(Date.now())
|
||||
let ticker: number | undefined
|
||||
|
||||
const uptime = computed(() => {
|
||||
if (!status.value) return ''
|
||||
let ms = now.value - status.value.bootTime
|
||||
if (ms < 0) ms = 0
|
||||
const totalSeconds = Math.floor(ms / 1000)
|
||||
const days = Math.floor(totalSeconds / 86400)
|
||||
const hours = Math.floor((totalSeconds % 86400) / 3600)
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||
const seconds = totalSeconds % 60
|
||||
const parts: string[] = []
|
||||
if (days) parts.push(days + 'd')
|
||||
if (hours) parts.push(hours + 'h')
|
||||
if (minutes) parts.push(minutes + 'm')
|
||||
parts.push(seconds + 's')
|
||||
return parts.join(' ')
|
||||
})
|
||||
|
||||
function formatSize(bytes: number): string {
|
||||
if (!Number.isFinite(bytes) || bytes < 0) return '—'
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let value = bytes
|
||||
let idx = 0
|
||||
while (value >= 1024 && idx < units.length - 1) {
|
||||
value /= 1024
|
||||
idx++
|
||||
}
|
||||
return value.toFixed(idx === 0 ? 0 : 2) + ' ' + units[idx]
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteAdminStatus()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
status.value = result.payload
|
||||
} catch (error) {
|
||||
failed.value = true
|
||||
handleError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load()
|
||||
ticker = window.setInterval(() => {
|
||||
now.value = Date.now()
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (ticker) clearInterval(ticker)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<h2 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h2>
|
||||
|
||||
<div v-if="loading" class="flex items-center gap-2 text-sm text-secondary">
|
||||
<SpinnerIcon class="size-4 animate-spin" />
|
||||
{{ formatMessage(messages.loading) }}
|
||||
</div>
|
||||
<p v-else-if="failed" class="m-0 text-sm text-secondary">
|
||||
{{ formatMessage(messages.failed) }}
|
||||
</p>
|
||||
|
||||
<template v-else-if="status">
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.uptime) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ uptime }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.memory) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ formatSize(status.memoryUsage) }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.users) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ status.userCount }}</span>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 rounded-xl bg-bg-raised p-4">
|
||||
<span class="text-xs text-secondary">{{ formatMessage(messages.players) }}</span>
|
||||
<span class="text-xl font-bold text-contrast">{{ status.playerCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="m-0 rounded-xl border border-dashed border-surface-5 p-3 text-xs text-secondary">
|
||||
{{ formatMessage(messages.realtimeHint) }}
|
||||
</p>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,440 @@
|
||||
<script setup lang="ts">
|
||||
import { SpinnerIcon } from '@modrinth/assets'
|
||||
import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteModRuleTag,
|
||||
skinSiteModExistsByHash,
|
||||
skinSiteModExistsByName,
|
||||
skinSiteModHashFromFile,
|
||||
skinSiteUploadMod,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const { formatMessage } = useVIntl()
|
||||
const { handleError, addNotification } = injectNotificationManager()
|
||||
|
||||
defineProps<{ ruleTags: SkinSiteModRuleTag[] }>()
|
||||
const emit = defineEmits<{ (e: 'finished'): void }>()
|
||||
|
||||
const messages = defineMessages({
|
||||
title: { id: 'app.skin-site.admin.mods.upload-title', defaultMessage: 'Upload mods' },
|
||||
dropHint: {
|
||||
id: 'app.skin-site.admin.mods.upload-drop',
|
||||
defaultMessage: 'Drag .jar files here, or click to choose',
|
||||
},
|
||||
dropSub: {
|
||||
id: 'app.skin-site.admin.mods.upload-sub',
|
||||
defaultMessage: 'Multiple files supported, up to {size} MB each',
|
||||
},
|
||||
tagsLabel: {
|
||||
id: 'app.skin-site.admin.mods.upload-tags',
|
||||
defaultMessage: 'Attach rule tags',
|
||||
},
|
||||
queue: { id: 'app.skin-site.admin.mods.upload-queue', defaultMessage: 'Files' },
|
||||
statusPending: {
|
||||
id: 'app.skin-site.admin.mods.upload-pending',
|
||||
defaultMessage: 'Pending',
|
||||
},
|
||||
statusChecking: {
|
||||
id: 'app.skin-site.admin.mods.upload-checking',
|
||||
defaultMessage: 'Checking…',
|
||||
},
|
||||
statusUploading: {
|
||||
id: 'app.skin-site.admin.mods.upload-uploading',
|
||||
defaultMessage: 'Uploading…',
|
||||
},
|
||||
statusConflict: {
|
||||
id: 'app.skin-site.admin.mods.upload-conflict',
|
||||
defaultMessage: 'Name exists',
|
||||
},
|
||||
statusSuccess: {
|
||||
id: 'app.skin-site.admin.mods.upload-success',
|
||||
defaultMessage: 'Done',
|
||||
},
|
||||
statusError: {
|
||||
id: 'app.skin-site.admin.mods.upload-error',
|
||||
defaultMessage: 'Failed',
|
||||
},
|
||||
existsAlready: {
|
||||
id: 'app.skin-site.admin.mods.upload-exists',
|
||||
defaultMessage: 'This file already exists on the server.',
|
||||
},
|
||||
nameConflictTitle: {
|
||||
id: 'app.skin-site.admin.mods.upload-name-conflict',
|
||||
defaultMessage: 'A mod with the same file name already exists',
|
||||
},
|
||||
nameConflictHint: {
|
||||
id: 'app.skin-site.admin.mods.upload-name-conflict-hint',
|
||||
defaultMessage: 'Overwrite the existing mod, or skip this file.',
|
||||
},
|
||||
overwrite: { id: 'app.skin-site.admin.mods.upload-overwrite', defaultMessage: 'Overwrite' },
|
||||
skip: { id: 'app.skin-site.admin.mods.upload-skip', defaultMessage: 'Skip' },
|
||||
close: { id: 'app.skin-site.admin.mods.upload-close', defaultMessage: 'Close' },
|
||||
allDone: {
|
||||
id: 'app.skin-site.admin.mods.upload-all-done',
|
||||
defaultMessage: 'All files processed.',
|
||||
},
|
||||
tooLarge: {
|
||||
id: 'app.skin-site.admin.mods.upload-too-large',
|
||||
defaultMessage: 'File too large: {name}',
|
||||
},
|
||||
})
|
||||
|
||||
const MAX_MOD_SIZE_MB = 200
|
||||
const MAX_RETRIES = 3
|
||||
|
||||
type TaskStatus = 'pending' | 'checking' | 'uploading' | 'conflict' | 'success' | 'error'
|
||||
|
||||
interface Task {
|
||||
file: File
|
||||
status: TaskStatus
|
||||
message?: string
|
||||
attempts: number
|
||||
}
|
||||
|
||||
const queue = ref<Task[]>([])
|
||||
const selectedTagIds = ref<Set<number>>(new Set())
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
const busy = ref(false)
|
||||
const conflictTask = ref<Task | null>(null)
|
||||
|
||||
const finishedCount = computed(
|
||||
() => queue.value.filter((t) => t.status === 'success' || t.status === 'error').length,
|
||||
)
|
||||
const allDone = computed(() => queue.value.length > 0 && finishedCount.value === queue.value.length)
|
||||
const hasWork = computed(() => queue.value.length > 0)
|
||||
|
||||
function toggleTag(id: number) {
|
||||
const next = new Set(selectedTagIds.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selectedTagIds.value = next
|
||||
}
|
||||
|
||||
function pickFiles() {
|
||||
if (busy.value) return
|
||||
fileInput.value?.click()
|
||||
}
|
||||
|
||||
function onFileChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const files = Array.from(input.files ?? [])
|
||||
input.value = ''
|
||||
enqueue(files)
|
||||
}
|
||||
|
||||
function onDrop(event: DragEvent) {
|
||||
event.preventDefault()
|
||||
if (busy.value) return
|
||||
enqueue(Array.from(event.dataTransfer?.files ?? []))
|
||||
}
|
||||
|
||||
function enqueue(files: File[]) {
|
||||
const jars = files.filter((f) => f.name.toLowerCase().endsWith('.jar'))
|
||||
if (!jars.length) return
|
||||
const accepted: Task[] = []
|
||||
for (const file of jars) {
|
||||
if (file.size > MAX_MOD_SIZE_MB * 1024 * 1024) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
title: formatMessage(messages.tooLarge, { name: file.name }),
|
||||
})
|
||||
continue
|
||||
}
|
||||
accepted.push({ file, status: 'pending', attempts: 0 })
|
||||
}
|
||||
if (!accepted.length) return
|
||||
queue.value = [...queue.value, ...accepted]
|
||||
void runQueue()
|
||||
}
|
||||
|
||||
async function runQueue() {
|
||||
if (busy.value) return
|
||||
busy.value = true
|
||||
try {
|
||||
for (;;) {
|
||||
const task = queue.value.find((t) => t.status === 'pending')
|
||||
if (!task) break
|
||||
await processTask(task)
|
||||
if (task.status === 'conflict') break
|
||||
}
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
if (allDone.value) {
|
||||
addNotification({ type: 'success', title: formatMessage(messages.allDone) })
|
||||
emit('finished')
|
||||
}
|
||||
}
|
||||
|
||||
async function processTask(task: Task) {
|
||||
task.status = 'checking'
|
||||
task.message = undefined
|
||||
try {
|
||||
const hash = await skinSiteModHashFromFile(task.file)
|
||||
const exists = await skinSiteModExistsByHash(hash)
|
||||
if (exists.success) {
|
||||
task.status = 'error'
|
||||
task.message = formatMessage(messages.existsAlready)
|
||||
return
|
||||
}
|
||||
const nameExists = await skinSiteModExistsByName(task.file.name)
|
||||
if (nameExists.success) {
|
||||
task.status = 'conflict'
|
||||
conflictTask.value = task
|
||||
return
|
||||
}
|
||||
await upload(task, false)
|
||||
} catch (error) {
|
||||
task.status = 'error'
|
||||
task.message = error instanceof Error ? error.message : String(error)
|
||||
handleError(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function upload(task: Task, overwrite: boolean) {
|
||||
task.status = 'uploading'
|
||||
try {
|
||||
const res = await skinSiteUploadMod(task.file, Array.from(selectedTagIds.value), overwrite)
|
||||
if (res.success) {
|
||||
task.status = 'success'
|
||||
return
|
||||
}
|
||||
if (res.errorCode === 429) {
|
||||
task.attempts++
|
||||
if (task.attempts < MAX_RETRIES) {
|
||||
task.status = 'pending'
|
||||
task.message = 'rate limited, retrying'
|
||||
setTimeout(() => void runQueue(), 1500 * task.attempts)
|
||||
} else {
|
||||
task.status = 'error'
|
||||
task.message = res.errorMessage
|
||||
}
|
||||
return
|
||||
}
|
||||
if (res.errorType === 'HashDiff') {
|
||||
task.attempts++
|
||||
if (task.attempts < MAX_RETRIES) {
|
||||
task.status = 'pending'
|
||||
task.message = 'hash mismatch, retrying'
|
||||
setTimeout(() => void runQueue(), 800)
|
||||
} else {
|
||||
task.status = 'error'
|
||||
task.message = res.errorMessage
|
||||
}
|
||||
return
|
||||
}
|
||||
if (res.errorType === 'ModNameConflict') {
|
||||
task.status = 'conflict'
|
||||
conflictTask.value = task
|
||||
return
|
||||
}
|
||||
task.status = 'error'
|
||||
task.message = res.errorMessage
|
||||
} catch (error) {
|
||||
task.status = 'error'
|
||||
task.message = error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveConflict(overwrite: boolean) {
|
||||
const task = conflictTask.value
|
||||
conflictTask.value = null
|
||||
if (!task) return
|
||||
if (overwrite) {
|
||||
busy.value = true
|
||||
try {
|
||||
await upload(task, true)
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
} else {
|
||||
task.status = 'error'
|
||||
task.message = formatMessage(messages.skip)
|
||||
}
|
||||
void runQueue()
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (busy.value) return
|
||||
queue.value = []
|
||||
conflictTask.value = null
|
||||
emit('finished')
|
||||
}
|
||||
|
||||
function statusLabel(status: TaskStatus): string {
|
||||
switch (status) {
|
||||
case 'pending':
|
||||
return formatMessage(messages.statusPending)
|
||||
case 'checking':
|
||||
return formatMessage(messages.statusChecking)
|
||||
case 'uploading':
|
||||
return formatMessage(messages.statusUploading)
|
||||
case 'conflict':
|
||||
return formatMessage(messages.statusConflict)
|
||||
case 'success':
|
||||
return formatMessage(messages.statusSuccess)
|
||||
default:
|
||||
return formatMessage(messages.statusError)
|
||||
}
|
||||
}
|
||||
|
||||
function statusClass(status: TaskStatus): string {
|
||||
switch (status) {
|
||||
case 'success':
|
||||
return 'bg-green text-contrast'
|
||||
case 'error':
|
||||
return 'bg-red text-contrast'
|
||||
case 'conflict':
|
||||
return 'bg-yellow text-contrast'
|
||||
default:
|
||||
return 'bg-button-bg text-secondary'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4" @click.self="close">
|
||||
<div class="flex max-h-[88vh] w-full max-w-2xl flex-col gap-4 overflow-y-auto rounded-xl bg-bg p-6">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<h3 class="m-0 text-lg font-bold text-contrast">{{ formatMessage(messages.title) }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-lg bg-button-bg px-3 py-1 text-xs font-semibold text-contrast hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
@click="close"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex min-h-40 cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-surface-5 p-6 text-center transition-colors hover:bg-bg-raised"
|
||||
:class="busy ? 'cursor-not-allowed opacity-60' : ''"
|
||||
@dragover.prevent
|
||||
@dragenter.prevent
|
||||
@drop.prevent="onDrop"
|
||||
@click="pickFiles"
|
||||
>
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
class="hidden"
|
||||
multiple
|
||||
accept=".jar"
|
||||
@change="onFileChange"
|
||||
/>
|
||||
<span class="text-sm font-semibold text-contrast">
|
||||
{{ formatMessage(messages.dropHint) }}
|
||||
</span>
|
||||
<span class="text-xs text-secondary">
|
||||
{{ formatMessage(messages.dropSub, { size: MAX_MOD_SIZE_MB }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-if="ruleTags.length" class="flex flex-col gap-2">
|
||||
<span class="text-xs font-semibold text-secondary">
|
||||
{{ formatMessage(messages.tagsLabel) }}
|
||||
</span>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="tag in ruleTags"
|
||||
:key="tag.id"
|
||||
type="button"
|
||||
class="rounded-full px-3 py-1 text-xs font-semibold transition-colors"
|
||||
:class="
|
||||
selectedTagIds.has(tag.id)
|
||||
? 'bg-brand text-contrast'
|
||||
: 'bg-button-bg text-secondary hover:text-contrast'
|
||||
"
|
||||
@click="toggleTag(tag.id)"
|
||||
>
|
||||
{{ tag.name }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasWork" class="flex flex-col gap-2">
|
||||
<span class="text-xs font-semibold text-secondary">
|
||||
{{ formatMessage(messages.queue) }} ({{ finishedCount }}/{{ queue.length }})
|
||||
</span>
|
||||
<div class="flex max-h-64 flex-col gap-1.5 overflow-y-auto">
|
||||
<div
|
||||
v-for="(task, index) in queue"
|
||||
:key="task.file.name + index"
|
||||
class="flex flex-wrap items-center gap-2 rounded-lg bg-bg-raised px-3 py-2"
|
||||
>
|
||||
<span class="min-w-0 flex-1 truncate text-xs text-contrast">
|
||||
{{ task.file.name }}
|
||||
</span>
|
||||
<span class="shrink-0 text-[10px] text-secondary">
|
||||
{{ (task.file.size / 1024 / 1024).toFixed(2) }} MB
|
||||
</span>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="statusClass(task.status)"
|
||||
>
|
||||
{{ statusLabel(task.status) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="task.message"
|
||||
class="w-full truncate text-[10px] text-secondary"
|
||||
:title="task.message"
|
||||
>
|
||||
{{ task.message }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="busy"
|
||||
class="flex items-center gap-2 text-xs text-secondary"
|
||||
>
|
||||
<SpinnerIcon class="size-3.5 animate-spin" />
|
||||
{{ formatMessage(messages.statusUploading) }}
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2 border-t border-solid border-surface-5 pt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-button-bg px-4 py-2 text-sm font-semibold text-secondary hover:brightness-110 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
@click="close"
|
||||
>
|
||||
{{ formatMessage(messages.close) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="conflictTask"
|
||||
class="fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4"
|
||||
>
|
||||
<div class="flex w-full max-w-md flex-col gap-3 rounded-xl bg-bg p-6">
|
||||
<h4 class="m-0 text-base font-bold text-contrast">
|
||||
{{ formatMessage(messages.nameConflictTitle) }}
|
||||
</h4>
|
||||
<p class="m-0 text-xs break-all text-secondary">{{ conflictTask.file.name }}</p>
|
||||
<p class="m-0 text-xs text-secondary">{{ formatMessage(messages.nameConflictHint) }}</p>
|
||||
<div class="flex justify-end gap-2 pt-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-button-bg px-4 py-2 text-sm font-semibold text-secondary hover:brightness-110"
|
||||
@click="resolveConflict(false)"
|
||||
>
|
||||
{{ formatMessage(messages.skip) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand px-4 py-2 text-sm font-semibold text-contrast hover:brightness-110"
|
||||
@click="resolveConflict(true)"
|
||||
>
|
||||
{{ formatMessage(messages.overwrite) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
import { skinSiteChatRoomAvatarFetch } from '@/helpers/skin-site-api'
|
||||
|
||||
const avatarUrls = new Map<number, string>()
|
||||
const pending = new Map<number, Promise<string | null>>()
|
||||
|
||||
export function loadCachedRoomAvatar(
|
||||
roomId: number,
|
||||
attachmentId: number,
|
||||
): Promise<string | null> {
|
||||
const cached = avatarUrls.get(attachmentId)
|
||||
if (cached) return Promise.resolve(cached)
|
||||
const running = pending.get(attachmentId)
|
||||
if (running) return running
|
||||
|
||||
const request = skinSiteChatRoomAvatarFetch(roomId).then((blob) => {
|
||||
pending.delete(attachmentId)
|
||||
if (!blob) return null
|
||||
const url = URL.createObjectURL(blob)
|
||||
avatarUrls.set(attachmentId, url)
|
||||
return url
|
||||
})
|
||||
pending.set(attachmentId, request)
|
||||
return request
|
||||
}
|
||||
|
||||
export function forgetRoomAvatar(attachmentId: number) {
|
||||
const url = avatarUrls.get(attachmentId)
|
||||
if (url) URL.revokeObjectURL(url)
|
||||
avatarUrls.delete(attachmentId)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteWikiAttachmentInfo,
|
||||
skinSiteWikiAttachment,
|
||||
skinSiteWikiAttachmentUrl,
|
||||
} from '@/helpers/skin-site-api'
|
||||
|
||||
const props = defineProps<{ name: string; caption?: string | null }>()
|
||||
|
||||
const attachment = ref<SkinSiteWikiAttachmentInfo | null>(null)
|
||||
const loading = ref(true)
|
||||
const viewerOpen = ref(false)
|
||||
|
||||
const contentUrl = computed(() =>
|
||||
attachment.value ? skinSiteWikiAttachmentUrl(attachment.value.id) : '#',
|
||||
)
|
||||
const imageCaption = computed(() => {
|
||||
const caption = props.caption?.trim() ?? ''
|
||||
return caption === props.name || caption === attachment.value?.name ? '' : caption
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await skinSiteWikiAttachment(props.name)
|
||||
if (res.success) attachment.value = res.payload
|
||||
} catch {
|
||||
// ignore
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
v-if="loading"
|
||||
class="inline-flex min-h-20 min-w-32 items-center justify-center rounded-lg border border-solid border-surface-5"
|
||||
>
|
||||
<span class="text-xs text-secondary">…</span>
|
||||
</span>
|
||||
<figure v-else-if="attachment?.image" class="my-5 inline-block max-w-full">
|
||||
<button type="button" class="block max-w-full cursor-zoom-in rounded-lg" @click="viewerOpen = true">
|
||||
<img
|
||||
class="max-h-[70vh] max-w-full rounded-lg border border-solid border-surface-5 object-contain shadow-md"
|
||||
:src="contentUrl"
|
||||
:alt="caption || attachment.name"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</button>
|
||||
<figcaption v-if="imageCaption" class="mt-2 text-center text-sm text-secondary">
|
||||
{{ imageCaption }}
|
||||
</figcaption>
|
||||
</figure>
|
||||
<a
|
||||
v-else-if="attachment"
|
||||
class="inline-flex items-center gap-1 text-brand underline-offset-2 hover:underline"
|
||||
:href="contentUrl"
|
||||
download
|
||||
>
|
||||
{{ caption || attachment.name }}
|
||||
</a>
|
||||
<span v-else class="text-red">附件“{{ name }}”不存在</span>
|
||||
|
||||
<div
|
||||
v-if="viewerOpen"
|
||||
class="fixed inset-0 z-[60] flex items-center justify-center bg-black/80 p-4"
|
||||
@click.self="viewerOpen = false"
|
||||
>
|
||||
<img :src="contentUrl" :alt="caption || attachment?.name" class="max-h-[92vh] max-w-[92vw] object-contain" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,185 @@
|
||||
<script setup lang="ts">
|
||||
import { type SkinSiteWikiNode } from '@/helpers/skin-site-api'
|
||||
|
||||
import { safeExternalUrl, safeWikiColor } from './wiki-color'
|
||||
|
||||
defineOptions({ name: 'WikiNodeRenderer' })
|
||||
|
||||
defineProps<{ nodes: SkinSiteWikiNode[] }>()
|
||||
const emit = defineEmits<{ (e: 'navigate', title: string): void }>()
|
||||
|
||||
function headingTag(level?: number | null): string {
|
||||
return 'h' + Math.min(6, Math.max(1, level ?? 2))
|
||||
}
|
||||
|
||||
function navigate(title?: string | null) {
|
||||
emit('navigate', (title ?? '').replaceAll('_', ' '))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-for="(node, index) in nodes" :key="node.type + '-' + index">
|
||||
<component
|
||||
:is="headingTag(node.level)"
|
||||
v-if="node.type === 'heading'"
|
||||
class="wiki-heading scroll-mt-24"
|
||||
:style="{ textAlign: node.align ?? undefined }"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</component>
|
||||
<p
|
||||
v-else-if="node.type === 'paragraph'"
|
||||
class="my-3 leading-7 break-words whitespace-pre-wrap"
|
||||
:style="{ textAlign: node.align ?? undefined }"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</p>
|
||||
<strong v-else-if="node.type === 'strong'" class="font-bold">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</strong>
|
||||
<small v-else-if="node.type === 'small'">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</small>
|
||||
<span
|
||||
v-else-if="node.type === 'color'"
|
||||
:style="{ color: safeWikiColor(node.color ?? '') ?? undefined }"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</span>
|
||||
<em v-else-if="node.type === 'emphasis'" class="italic">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</em>
|
||||
<u v-else-if="node.type === 'underline'">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</u>
|
||||
<s v-else-if="node.type === 'strike'">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</s>
|
||||
<mark v-else-if="node.type === 'highlight'" class="rounded bg-yellow/25 px-0.5 text-contrast">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</mark>
|
||||
<code v-else-if="node.type === 'inlineCode'" class="rounded bg-button-bg px-1 font-mono text-sm">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</code>
|
||||
<span
|
||||
v-else-if="node.type === 'spoiler'"
|
||||
class="cursor-help rounded bg-contrast text-contrast transition-colors hover:bg-transparent hover:text-inherit"
|
||||
:title="node.tooltip || '我知道你在偷看'"
|
||||
tabindex="0"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</span>
|
||||
<br v-else-if="node.type === 'break'" />
|
||||
<hr v-else-if="node.type === 'rule'" class="my-6 border-surface-5" />
|
||||
<button
|
||||
v-else-if="node.type === 'internalLink'"
|
||||
type="button"
|
||||
class="font-medium underline-offset-2 hover:underline"
|
||||
:class="node.exists === false ? 'text-red' : 'text-brand'"
|
||||
:title="node.exists === false ? '该词条尚未创建' : undefined"
|
||||
@click="navigate(node.title)"
|
||||
>
|
||||
<WikiNodeRenderer v-if="node.children.length" :nodes="node.children" @navigate="navigate" />
|
||||
<template v-else>{{ node.text }}</template>
|
||||
</button>
|
||||
<a
|
||||
v-else-if="node.type === 'externalLink'"
|
||||
class="text-brand underline-offset-2 hover:underline"
|
||||
:href="safeExternalUrl(node.href)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer nofollow"
|
||||
>
|
||||
<WikiNodeRenderer v-if="node.children.length" :nodes="node.children" @navigate="navigate" />
|
||||
<template v-else>{{ node.text }}</template>
|
||||
</a>
|
||||
<ul v-else-if="node.type === 'unorderedList'" class="my-3 list-disc pl-7">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</ul>
|
||||
<ol
|
||||
v-else-if="node.type === 'orderedList'"
|
||||
:start="node.start ?? undefined"
|
||||
class="my-3 list-decimal pl-7"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</ol>
|
||||
<li v-else-if="node.type === 'listItem'" class="my-1">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</li>
|
||||
<blockquote
|
||||
v-else-if="node.type === 'quote'"
|
||||
class="my-4 border-l-4 border-brand/60 bg-brand/5 px-4 py-2"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</blockquote>
|
||||
<pre
|
||||
v-else-if="node.type === 'code'"
|
||||
class="my-4 overflow-x-auto rounded-lg border border-solid border-surface-5 bg-bg-raised p-4 font-mono text-sm"
|
||||
><code>{{ node.text }}</code></pre>
|
||||
<div v-else-if="node.type === 'table'" class="my-5 overflow-x-auto">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<tbody>
|
||||
<WikiNodeRenderer
|
||||
v-if="node.children.length"
|
||||
:nodes="node.children"
|
||||
@navigate="navigate"
|
||||
/>
|
||||
<tr v-for="(row, rowIndex) in node.rows" :key="rowIndex">
|
||||
<td v-for="(cell, cellIndex) in row" :key="cellIndex" class="border border-solid border-surface-5 px-2 py-1">
|
||||
<WikiNodeRenderer :nodes="cell" @navigate="navigate" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<tr v-else-if="node.type === 'tableRow'">
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</tr>
|
||||
<component
|
||||
:is="node.type === 'tableHeader' ? 'th' : 'td'"
|
||||
v-else-if="node.type === 'tableCell' || node.type === 'tableHeader'"
|
||||
class="border border-solid border-surface-5 px-2 py-1"
|
||||
:colspan="node.colspan ?? 1"
|
||||
:rowspan="node.rowspan ?? 1"
|
||||
>
|
||||
<WikiNodeRenderer :nodes="node.children" @navigate="navigate" />
|
||||
</component>
|
||||
<WikiAttachmentNode
|
||||
v-else-if="node.type === 'attachment' && node.title"
|
||||
:name="node.title"
|
||||
:caption="node.text"
|
||||
/>
|
||||
<WikiNotice
|
||||
v-else-if="node.type === 'notice' && node.title"
|
||||
:title="node.title"
|
||||
:description="node.text"
|
||||
:variant="node.variant"
|
||||
>
|
||||
<WikiNodeRenderer v-if="node.children.length" :nodes="node.children" @navigate="navigate" />
|
||||
<p v-else-if="node.text" class="whitespace-pre-wrap">{{ node.text }}</p>
|
||||
</WikiNotice>
|
||||
<span v-else>{{ node.text }}</span>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wiki-heading {
|
||||
margin-top: 1.65rem;
|
||||
margin-bottom: 0.7rem;
|
||||
border-bottom: 1px solid color-mix(in oklab, currentColor 16%, transparent);
|
||||
padding-bottom: 0.4rem;
|
||||
font-weight: 750;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
h1.wiki-heading {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
h2.wiki-heading {
|
||||
font-size: 1.55rem;
|
||||
}
|
||||
|
||||
h3.wiki-heading {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
title: string
|
||||
description?: string | null
|
||||
variant?: string | null
|
||||
}>()
|
||||
|
||||
const variantClass = computed(() => {
|
||||
switch (props.variant) {
|
||||
case 'warning':
|
||||
return 'border-yellow/40 bg-yellow/10 text-yellow'
|
||||
case 'error':
|
||||
return 'border-red/40 bg-red/10 text-red'
|
||||
case 'success':
|
||||
return 'border-green/40 bg-green/10 text-green'
|
||||
default:
|
||||
return 'border-brand/40 bg-brand/10 text-brand'
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-4 rounded-lg border border-solid p-4" :class="variantClass">
|
||||
<p class="m-0 text-sm font-bold">{{ title }}</p>
|
||||
<p v-if="description" class="m-0 mt-1 text-xs whitespace-pre-wrap opacity-90">
|
||||
{{ description }}
|
||||
</p>
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
export function safeWikiColor(value: unknown): string | null {
|
||||
if (typeof value !== 'string') return null
|
||||
const color = value.trim()
|
||||
return color.length <= 80 &&
|
||||
/^(?:[a-z]{1,20}|#[\da-f]{3}|#[\da-f]{4}|#[\da-f]{6}|#[\da-f]{8}|rgba?\([\d\s.,%]+\))$/i.test(color)
|
||||
? color
|
||||
: null
|
||||
}
|
||||
|
||||
export function safeExternalUrl(url?: string | null): string {
|
||||
if (!url) return '#'
|
||||
try {
|
||||
const parsed = new URL(url)
|
||||
return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed.toString() : '#'
|
||||
} catch {
|
||||
return '#'
|
||||
}
|
||||
}
|
||||
@@ -1,714 +0,0 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import {
|
||||
clearHostedSession,
|
||||
HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||
hostedCreate,
|
||||
hostedDefault,
|
||||
hostedSync,
|
||||
onHostedPackAttemptStarted,
|
||||
setInstanceMode,
|
||||
} from '../helpers/hosted-packs.ts'
|
||||
import {
|
||||
openSkinSiteLogin,
|
||||
receiveSkinSiteMessage,
|
||||
requestSkinSiteDownloadToken,
|
||||
requestSkinSiteLuck,
|
||||
requestSkinSitePlayers,
|
||||
requestSkinSiteSkinUpdate,
|
||||
resetSkinSiteSession,
|
||||
setSkinSiteFrame,
|
||||
SKIN_SITE_ORIGIN,
|
||||
skinSiteFrameUrl,
|
||||
skinSitePlayers,
|
||||
skinSitePlayersStatus,
|
||||
skinSiteStatus,
|
||||
skinSiteUser,
|
||||
} from './skin-site-session.ts'
|
||||
import { forgetHostedCreation, useHostedCreation } from './useHostedCreation.ts'
|
||||
import { useHostedSync } from './useHostedSync.ts'
|
||||
|
||||
test('reconnecting the same skin site frame waits for verification instead of reporting signed out', () => {
|
||||
const frame = { postMessage() {} } as unknown as Window
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
assert.equal(skinSiteStatus.value, 'checking')
|
||||
setSkinSiteFrame(null)
|
||||
resetSkinSiteSession()
|
||||
})
|
||||
|
||||
test('hosted installation sends the JWT to native commands while Local needs no session', async () => {
|
||||
const previousWindow = Object.getOwnPropertyDescriptor(globalThis, 'window')
|
||||
const calls: Array<{ command: string; args: Record<string, unknown> }> = []
|
||||
let syncResponse: (() => Promise<unknown>) | undefined
|
||||
let createdId = 'instance'
|
||||
let instanceExists = false
|
||||
let tokenRequests = 0
|
||||
let accounts: Array<{
|
||||
account_type: string
|
||||
yggdrasil?: { api_root: string }
|
||||
}> = [{ account_type: 'microsoft' }]
|
||||
const frame = {
|
||||
postMessage(data: { type: string; requestId: string }) {
|
||||
if (data.type !== 'starlight-pack-token-request') return
|
||||
tokenRequests++
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-pack-token-result',
|
||||
requestId: data.requestId,
|
||||
token: 'site.jwt.secret',
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
},
|
||||
} as unknown as Window
|
||||
Object.defineProperty(globalThis, 'window', {
|
||||
configurable: true,
|
||||
value: {
|
||||
__TAURI_INTERNALS__: {
|
||||
async invoke(command: string, args: Record<string, unknown>) {
|
||||
calls.push({ command, args })
|
||||
if (command === 'plugin:install|hosted_has_game_account')
|
||||
return accounts.some(
|
||||
(account) =>
|
||||
account.account_type === 'microsoft' ||
|
||||
(account.account_type === 'yggdrasil' &&
|
||||
account.yggdrasil?.api_root.replace(/\/+$/, '') ===
|
||||
'https://skin.starlight.cool/yggdrasil'),
|
||||
)
|
||||
if (command === 'plugin:install|hosted_sync' && syncResponse) return syncResponse()
|
||||
if (command === 'plugin:instance|instance_get')
|
||||
return instanceExists ? { id: args.instanceId } : null
|
||||
return command === 'plugin:install|hosted_create' ? createdId : null
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
try {
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'site', username: 'Site' },
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
await hostedDefault()
|
||||
assert.equal(await hostedCreate(), 'instance')
|
||||
await hostedSync('instance')
|
||||
await setInstanceMode('instance', 'starlight')
|
||||
assert.equal(tokenRequests, 4)
|
||||
assert.deepEqual(
|
||||
calls
|
||||
.map(({ command }) => command)
|
||||
.filter(
|
||||
(command) =>
|
||||
command.startsWith('plugin:install|') &&
|
||||
command !== 'plugin:install|hosted_has_game_account',
|
||||
),
|
||||
[
|
||||
'hosted_set_session',
|
||||
'hosted_default',
|
||||
'hosted_set_session',
|
||||
'hosted_create',
|
||||
'hosted_set_session',
|
||||
'hosted_sync',
|
||||
'hosted_set_session',
|
||||
'hosted_set_instance_mode',
|
||||
].map((name) => `plugin:install|${name}`),
|
||||
)
|
||||
for (const call of calls.filter(({ command }) => command.endsWith('hosted_set_session'))) {
|
||||
assert.equal(call.args.token, 'site.jwt.secret')
|
||||
}
|
||||
let rejectSync!: (error: unknown) => void
|
||||
let syncCalls = 0
|
||||
syncResponse = () => {
|
||||
syncCalls++
|
||||
return new Promise((_, reject) => {
|
||||
rejectSync = reject
|
||||
})
|
||||
}
|
||||
const originalPage = useHostedSync(() => 'shared-progress-instance')
|
||||
const pendingSync = originalPage.sync()
|
||||
const reopenedPage = useHostedSync(() => 'shared-progress-instance')
|
||||
assert.equal(reopenedPage.busy.value, true)
|
||||
assert.equal(useHostedSync(() => 'other-instance').busy.value, false)
|
||||
await reopenedPage.sync()
|
||||
await new Promise((resolve) => setImmediate(resolve))
|
||||
assert.equal(syncCalls, 1)
|
||||
rejectSync({ message: 'download interrupted' })
|
||||
await pendingSync
|
||||
assert.equal(reopenedPage.busy.value, false)
|
||||
assert.match(reopenedPage.error.value, /download interrupted/)
|
||||
assert.equal(
|
||||
useHostedSync(() => 'shared-progress-instance').error.value,
|
||||
reopenedPage.error.value,
|
||||
)
|
||||
syncResponse = async () => ({ revision: 'new-version' })
|
||||
await reopenedPage.sync()
|
||||
assert.equal(originalPage.error.value, '')
|
||||
assert.deepEqual(originalPage.result.value, { revision: 'new-version' })
|
||||
|
||||
const creation = useHostedCreation()
|
||||
createdId = 'deleted-instance'
|
||||
syncResponse = async () => {
|
||||
throw new Error('download failed')
|
||||
}
|
||||
await creation.install()
|
||||
assert.equal(creation.createdInstance.value, 'deleted-instance')
|
||||
assert.match(creation.installError.value, /download failed/)
|
||||
createdId = 'replacement-instance'
|
||||
syncResponse = async () => ({
|
||||
version: '1',
|
||||
downloadedBytes: 0,
|
||||
changedFiles: 0,
|
||||
preservedFiles: [],
|
||||
})
|
||||
const retryCallStart = calls.length
|
||||
assert.equal(await creation.install(), 'replacement-instance')
|
||||
assert.equal(calls[retryCallStart].command, 'plugin:instance|instance_get')
|
||||
assert.equal(
|
||||
calls.filter((call) => call.command.endsWith('|hosted_sync')).at(-1)?.args.instanceId,
|
||||
'replacement-instance',
|
||||
)
|
||||
assert.equal(creation.installError.value, '')
|
||||
forgetHostedCreation('unrelated-instance')
|
||||
assert.equal(creation.completed.value, true)
|
||||
forgetHostedCreation('replacement-instance')
|
||||
assert.equal(creation.createdInstance.value, undefined)
|
||||
assert.equal(creation.completed.value, false)
|
||||
createdId = 'third-instance'
|
||||
syncResponse = () =>
|
||||
new Promise((_, reject) => {
|
||||
rejectSync = reject
|
||||
})
|
||||
const deletedDuringSync = creation.install()
|
||||
await new Promise((resolve) => setImmediate(resolve))
|
||||
forgetHostedCreation('third-instance')
|
||||
rejectSync(new Error('Unknown instance'))
|
||||
await deletedDuringSync
|
||||
assert.equal(creation.installError.value, '')
|
||||
assert.equal(creation.createdInstance.value, undefined)
|
||||
createdId = 'existing-instance'
|
||||
syncResponse = async () => {
|
||||
throw new Error('download interrupted')
|
||||
}
|
||||
await creation.install()
|
||||
instanceExists = true
|
||||
syncResponse = async () => ({
|
||||
version: '1',
|
||||
downloadedBytes: 0,
|
||||
changedFiles: 0,
|
||||
preservedFiles: [],
|
||||
})
|
||||
const createCount = calls.filter((call) => call.command.endsWith('|hosted_create')).length
|
||||
assert.equal(await creation.install(), 'existing-instance')
|
||||
assert.equal(
|
||||
calls.filter((call) => call.command.endsWith('|hosted_create')).length,
|
||||
createCount,
|
||||
)
|
||||
creation.acknowledge('existing-instance')
|
||||
const requestsBeforeLogout = tokenRequests
|
||||
resetSkinSiteSession()
|
||||
await clearHostedSession()
|
||||
assert.equal(calls.at(-1)!.args.token, null)
|
||||
await setInstanceMode('instance', 'local')
|
||||
assert.equal(tokenRequests, requestsBeforeLogout)
|
||||
const attempts: string[] = []
|
||||
const stopListening = onHostedPackAttemptStarted((id) => attempts.push(id))
|
||||
accounts = []
|
||||
const installCallsBeforeAccountFailure = calls.filter(
|
||||
({ command }) =>
|
||||
command.startsWith('plugin:install|') &&
|
||||
command !== 'plugin:install|hosted_has_game_account',
|
||||
).length
|
||||
await assert.rejects(hostedSync('failed-instance'), {
|
||||
message: HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||
})
|
||||
await assert.rejects(hostedCreate(), {
|
||||
message: HOSTED_ACCOUNT_REQUIRED_MESSAGE,
|
||||
})
|
||||
assert.deepEqual(attempts, [])
|
||||
assert.equal(
|
||||
calls.filter(
|
||||
({ command }) =>
|
||||
command.startsWith('plugin:install|') &&
|
||||
command !== 'plugin:install|hosted_has_game_account',
|
||||
).length,
|
||||
installCallsBeforeAccountFailure,
|
||||
)
|
||||
const unauthenticatedCreation = useHostedCreation()
|
||||
await unauthenticatedCreation.install()
|
||||
assert.equal(unauthenticatedCreation.installError.value, HOSTED_ACCOUNT_REQUIRED_MESSAGE)
|
||||
assert.equal(unauthenticatedCreation.createdInstance.value, undefined)
|
||||
accounts = [{ account_type: 'microsoft' }]
|
||||
const unauthenticatedRetry = hostedSync('failed-instance')
|
||||
await assert.rejects(unauthenticatedRetry)
|
||||
assert.deepEqual(attempts, ['failed-instance'])
|
||||
stopListening()
|
||||
await assert.rejects(hostedSync('failed-instance'))
|
||||
assert.equal(attempts.length, 1)
|
||||
await assert.rejects(hostedCreate(), /无需选择玩家/)
|
||||
} finally {
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(null)
|
||||
if (previousWindow) Object.defineProperty(globalThis, 'window', previousWindow)
|
||||
else Reflect.deleteProperty(globalThis, 'window')
|
||||
}
|
||||
})
|
||||
|
||||
test('pack download gets the site JWT without choosing a player and rejects stale replies', async () => {
|
||||
const sent: Array<{ type: string; requestId: string }> = []
|
||||
const frame = {
|
||||
postMessage(data: { type: string; requestId: string }) {
|
||||
sent.push(data)
|
||||
},
|
||||
} as unknown as Window
|
||||
const receive = (data: unknown, origin = SKIN_SITE_ORIGIN) =>
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin,
|
||||
source: frame,
|
||||
data,
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
await assert.rejects(requestSkinSiteDownloadToken(), /无需选择玩家/)
|
||||
receive({
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'site-user', username: 'Site' },
|
||||
})
|
||||
const token = requestSkinSiteDownloadToken()
|
||||
const requestId = sent.at(-1)!.requestId
|
||||
const reply = { type: 'starlight-pack-token-result', requestId, token: 'site.jwt.secret' }
|
||||
assert.equal(receive(reply, 'https://evil.example'), false)
|
||||
assert.equal(receive(reply), true)
|
||||
assert.equal(await token, 'site.jwt.secret')
|
||||
assert.equal(skinSitePlayers.value.length, 0)
|
||||
assert.equal(JSON.stringify(skinSiteUser.value).includes('secret'), false)
|
||||
const stale = requestSkinSiteDownloadToken()
|
||||
const staleId = sent.at(-1)!.requestId
|
||||
const rejected = assert.rejects(stale, /登录状态已变化/)
|
||||
resetSkinSiteSession()
|
||||
await rejected
|
||||
assert.equal(receive({ ...reply, requestId: staleId }), false)
|
||||
setSkinSiteFrame(null)
|
||||
})
|
||||
|
||||
test('skin site session accepts only the embedded origin and window, and redirects after verification', () => {
|
||||
const frame = {} as Window
|
||||
const message = (status: string, user?: unknown) =>
|
||||
({
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: { type: 'starlight-skin-session', status, user },
|
||||
}) as MessageEvent
|
||||
resetSkinSiteSession()
|
||||
openSkinSiteLogin()
|
||||
assert.equal(skinSiteFrameUrl.value, `${SKIN_SITE_ORIGIN}/login`)
|
||||
const signedIn = message('signed-in', {
|
||||
uuid: 'test-user',
|
||||
username: '测试用户',
|
||||
jwt: 'must-not-copy',
|
||||
})
|
||||
assert.equal(
|
||||
receiveSkinSiteMessage({ ...signedIn, origin: 'https://evil.example' } as MessageEvent, frame),
|
||||
false,
|
||||
)
|
||||
assert.equal(receiveSkinSiteMessage(signedIn, {} as Window), false)
|
||||
assert.equal(receiveSkinSiteMessage(message('signed-in', {}), frame), false)
|
||||
assert.equal(skinSiteUser.value, null)
|
||||
assert.equal(receiveSkinSiteMessage(signedIn, frame), true)
|
||||
assert.deepEqual(skinSiteUser.value, { uuid: 'test-user', username: '测试用户' })
|
||||
assert.equal(skinSiteStatus.value, 'signed-in')
|
||||
assert.equal(skinSiteFrameUrl.value, `${SKIN_SITE_ORIGIN}/profile`)
|
||||
assert.equal(receiveSkinSiteMessage(message('checking'), frame), true)
|
||||
assert.equal(skinSiteUser.value, null)
|
||||
receiveSkinSiteMessage(message('signed-in', { uuid: 'second', username: '另一个账号' }), frame)
|
||||
assert.deepEqual(skinSiteUser.value, { uuid: 'second', username: '另一个账号' })
|
||||
receiveSkinSiteMessage(message('signed-out'), frame)
|
||||
assert.equal(skinSiteUser.value, null)
|
||||
assert.equal(skinSiteStatus.value, 'signed-out')
|
||||
receiveSkinSiteMessage(message('error'), frame)
|
||||
assert.equal(skinSiteStatus.value, 'error')
|
||||
resetSkinSiteSession()
|
||||
})
|
||||
|
||||
test('luck requests use only the connected skin site frame and validate its result', async () => {
|
||||
const sent: Array<{ data: unknown; targetOrigin: string }> = []
|
||||
const frame = {
|
||||
postMessage(data: unknown, targetOrigin: string) {
|
||||
sent.push({ data, targetOrigin })
|
||||
},
|
||||
} as unknown as Window
|
||||
const sessionMessage = {
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'lucky-user', username: 'Lucky' },
|
||||
},
|
||||
} as MessageEvent
|
||||
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
receiveSkinSiteMessage(sessionMessage, frame)
|
||||
const automaticPlayersRequest = sent.at(-1)?.data as { type: string; requestId: string }
|
||||
assert.equal(automaticPlayersRequest.type, 'starlight-skin-players-request')
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: automaticPlayersRequest.requestId,
|
||||
ok: true,
|
||||
players: [],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
const result = requestSkinSiteLuck()
|
||||
assert.equal(sent.at(-1)?.targetOrigin, SKIN_SITE_ORIGIN)
|
||||
const request = sent.at(-1)?.data as { type: string; requestId: string }
|
||||
assert.equal(request.type, 'starlight-skin-luck-request')
|
||||
assert.match(request.requestId, /^skin-luck-\d+-\d+$/)
|
||||
assert.equal(
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-luck-result',
|
||||
requestId: request.requestId,
|
||||
ok: true,
|
||||
luck: 88,
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
),
|
||||
true,
|
||||
)
|
||||
assert.equal(await result, 88)
|
||||
setSkinSiteFrame(null)
|
||||
resetSkinSiteSession()
|
||||
})
|
||||
|
||||
test('player requests validate identities and replace the collection atomically', async () => {
|
||||
const sent: Array<{ data: unknown; targetOrigin: string }> = []
|
||||
const frame = {
|
||||
postMessage(data: unknown, targetOrigin: string) {
|
||||
sent.push({ data, targetOrigin })
|
||||
},
|
||||
} as unknown as Window
|
||||
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'skin-user', username: 'Skin User' },
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
const automaticRequest = sent.at(-1)?.data as { requestId: string }
|
||||
assert.equal(skinSitePlayersStatus.value, 'checking')
|
||||
assert.equal(
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: automaticRequest.requestId,
|
||||
ok: true,
|
||||
players: [
|
||||
{
|
||||
uuid: '0123456789abcdef0123456789abcdef',
|
||||
name: 'PlayerOne',
|
||||
isMojang: false,
|
||||
skinState: 'ready',
|
||||
headDataUrl: 'data:image/png;base64,SEVBRERBVEE=',
|
||||
skinDataUrl: 'data:image/png;base64,SEVBRERBVEE=',
|
||||
model: 'slim',
|
||||
},
|
||||
{
|
||||
uuid: 'fedcba9876543210fedcba9876543210',
|
||||
name: 'NoSkinPlayer',
|
||||
isMojang: false,
|
||||
skinState: 'empty',
|
||||
},
|
||||
{ uuid: 'invalid', name: 'Ignored', isMojang: false },
|
||||
],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
),
|
||||
true,
|
||||
)
|
||||
assert.deepEqual(skinSitePlayers.value, [
|
||||
{
|
||||
uuid: '0123456789abcdef0123456789abcdef',
|
||||
name: 'PlayerOne',
|
||||
isMojang: false,
|
||||
skinState: 'ready',
|
||||
headDataUrl: 'data:image/png;base64,SEVBRERBVEE=',
|
||||
skinDataUrl: 'data:image/png;base64,SEVBRERBVEE=',
|
||||
model: 'slim',
|
||||
},
|
||||
{
|
||||
uuid: 'fedcba9876543210fedcba9876543210',
|
||||
name: 'NoSkinPlayer',
|
||||
isMojang: false,
|
||||
skinState: 'empty',
|
||||
},
|
||||
])
|
||||
assert.equal(skinSitePlayersStatus.value, 'ready')
|
||||
|
||||
const transientFailure = requestSkinSitePlayers()
|
||||
const transientFailureRequest = sent.at(-1)?.data as { requestId: string }
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: transientFailureRequest.requestId,
|
||||
ok: true,
|
||||
players: [
|
||||
{
|
||||
uuid: '0123456789abcdef0123456789abcdef',
|
||||
name: 'PlayerOne Renamed',
|
||||
isMojang: false,
|
||||
skinState: 'error',
|
||||
},
|
||||
],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
assert.equal((await transientFailure)[0].skinState, 'ready')
|
||||
assert.equal(skinSitePlayers.value[0].name, 'PlayerOne Renamed')
|
||||
assert.equal(skinSitePlayers.value[0].headDataUrl, 'data:image/png;base64,SEVBRERBVEE=')
|
||||
|
||||
const retry = requestSkinSitePlayers()
|
||||
const retryRequest = sent.at(-1)?.data as { requestId: string }
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: retryRequest.requestId,
|
||||
ok: true,
|
||||
players: [],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
assert.deepEqual(await retry, [])
|
||||
assert.deepEqual(skinSitePlayers.value, [])
|
||||
setSkinSiteFrame(null)
|
||||
resetSkinSiteSession()
|
||||
})
|
||||
|
||||
test('skin updates are restricted to known non-Mojang players and validated results', async () => {
|
||||
const sent: Array<{ data: unknown; targetOrigin: string }> = []
|
||||
const frame = {
|
||||
postMessage(data: unknown, targetOrigin: string) {
|
||||
sent.push({ data, targetOrigin })
|
||||
},
|
||||
} as unknown as Window
|
||||
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'skin-user', username: 'Skin User' },
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
const automaticRequest = sent.at(-1)?.data as { requestId: string }
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: automaticRequest.requestId,
|
||||
ok: true,
|
||||
players: [
|
||||
{
|
||||
uuid: '0123456789abcdef0123456789abcdef',
|
||||
name: 'PlayerOne',
|
||||
isMojang: false,
|
||||
skinState: 'empty',
|
||||
},
|
||||
],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
|
||||
const result = requestSkinSiteSkinUpdate(
|
||||
'0123456789abcdef0123456789abcdef',
|
||||
'data:image/png;base64,SEVBRERBVEE=',
|
||||
'slim',
|
||||
)
|
||||
const request = sent.at(-1)?.data as { type: string; requestId: string; playerId: string }
|
||||
assert.equal(request.type, 'starlight-skin-update-request')
|
||||
assert.equal(request.playerId, '0123456789abcdef0123456789abcdef')
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: { type: 'starlight-skin-update-result', requestId: request.requestId, ok: true },
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
await result
|
||||
await assert.rejects(
|
||||
requestSkinSiteSkinUpdate(
|
||||
'fedcba9876543210fedcba9876543210',
|
||||
'data:image/png;base64,SEVBRERBVEE=',
|
||||
'default',
|
||||
),
|
||||
)
|
||||
setSkinSiteFrame(null)
|
||||
resetSkinSiteSession()
|
||||
})
|
||||
|
||||
test('hosted create auto-authenticates the first skin site player when no game account exists', async () => {
|
||||
const previousWindow = Object.getOwnPropertyDescriptor(globalThis, 'window')
|
||||
const calls: Array<{ command: string; args: Record<string, unknown> }> = []
|
||||
let accounts: Array<{
|
||||
account_type: string
|
||||
yggdrasil?: { api_root: string }
|
||||
}> = []
|
||||
const frame = {
|
||||
postMessage(data: { type: string; requestId: string }) {
|
||||
if (data.type === 'starlight-pack-token-request') {
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-pack-token-result',
|
||||
requestId: data.requestId,
|
||||
token: 'site.jwt.secret',
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
return
|
||||
}
|
||||
if (data.type === 'starlight-skin-players-request') {
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-players-result',
|
||||
requestId: data.requestId,
|
||||
ok: true,
|
||||
players: [
|
||||
{
|
||||
uuid: '11111111-1111-1111-1111-111111111111',
|
||||
name: 'AutoPlayer',
|
||||
isMojang: false,
|
||||
skinState: 'empty',
|
||||
},
|
||||
],
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
}
|
||||
},
|
||||
} as unknown as Window
|
||||
Object.defineProperty(globalThis, 'window', {
|
||||
configurable: true,
|
||||
value: {
|
||||
__TAURI_INTERNALS__: {
|
||||
async invoke(command: string, args: Record<string, unknown>) {
|
||||
calls.push({ command, args })
|
||||
if (command === 'plugin:install|hosted_has_game_account') {
|
||||
return accounts.some(
|
||||
(account) =>
|
||||
account.account_type === 'microsoft' ||
|
||||
(account.account_type === 'yggdrasil' &&
|
||||
account.yggdrasil?.api_root.replace(/\/+$/, '') ===
|
||||
'https://skin.starlight.cool/yggdrasil'),
|
||||
)
|
||||
}
|
||||
if (command === 'plugin:auth|login_skin_site_player') {
|
||||
accounts = [
|
||||
{
|
||||
account_type: 'yggdrasil',
|
||||
yggdrasil: { api_root: 'https://skin.starlight.cool/yggdrasil' },
|
||||
},
|
||||
]
|
||||
return null
|
||||
}
|
||||
if (command === 'plugin:instance|instance_get') return null
|
||||
return command === 'plugin:install|hosted_create' ? 'auto-instance' : null
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
try {
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(frame)
|
||||
receiveSkinSiteMessage(
|
||||
{
|
||||
origin: SKIN_SITE_ORIGIN,
|
||||
source: frame,
|
||||
data: {
|
||||
type: 'starlight-skin-session',
|
||||
status: 'signed-in',
|
||||
user: { uuid: 'site-user', username: 'Site' },
|
||||
},
|
||||
} as MessageEvent,
|
||||
frame,
|
||||
)
|
||||
await requestSkinSitePlayers().catch(() => {})
|
||||
assert.equal(await hostedCreate(), 'auto-instance')
|
||||
assert.ok(
|
||||
calls.some(({ command }) => command === 'plugin:auth|login_skin_site_player'),
|
||||
'expected automatic player authentication',
|
||||
)
|
||||
} finally {
|
||||
resetSkinSiteSession()
|
||||
setSkinSiteFrame(null)
|
||||
if (previousWindow) Object.defineProperty(globalThis, 'window', previousWindow)
|
||||
else delete (globalThis as { window?: unknown }).window
|
||||
}
|
||||
})
|
||||
@@ -1,7 +1,25 @@
|
||||
import { readonly, ref, watch } from 'vue'
|
||||
import { readonly, ref } from 'vue'
|
||||
|
||||
import {
|
||||
clearSkinSiteToken,
|
||||
getSkinSiteToken,
|
||||
setSkinSiteToken,
|
||||
skinSiteCurrentUser,
|
||||
skinSiteLogin,
|
||||
skinSiteLuck,
|
||||
skinSitePlayerList,
|
||||
type SkinSitePlayerSkin,
|
||||
skinSitePlayerSkin,
|
||||
skinSiteRefresh,
|
||||
type SkinSiteResponse,
|
||||
skinSiteUploadTexture,
|
||||
type SkinSiteUser as ApiSkinSiteUser,
|
||||
} from '@/helpers/skin-site-api'
|
||||
import { fetchImageAsDataUrl, renderSkinHead } from '@/helpers/skin-site-render'
|
||||
|
||||
export const SKIN_SITE_ORIGIN = 'https://skin.starlight.cool'
|
||||
export type SkinSiteUser = { uuid: string; username: string }
|
||||
|
||||
export type SkinSiteUser = { uuid: string; username: string; permissions: string[] }
|
||||
export type SkinSiteStatus = 'checking' | 'signed-out' | 'signed-in' | 'error'
|
||||
export type SkinSitePlayer = {
|
||||
uuid: string
|
||||
@@ -15,152 +33,227 @@ export type SkinSitePlayer = {
|
||||
export type SkinSitePlayersStatus = 'idle' | 'checking' | 'ready' | 'error'
|
||||
|
||||
const user = ref<SkinSiteUser | null>(null)
|
||||
const status = ref<SkinSiteStatus>('signed-out')
|
||||
const status = ref<SkinSiteStatus>('checking')
|
||||
const players = ref<SkinSitePlayer[]>([])
|
||||
const playersStatus = ref<SkinSitePlayersStatus>('idle')
|
||||
const selectedPlayerId = ref<string | null>(null)
|
||||
const frameUrl = ref(`${SKIN_SITE_ORIGIN}/`)
|
||||
let connectedFrame: Window | null = null
|
||||
let luckRequestSequence = 0
|
||||
let playersRequestSequence = 0
|
||||
let skinUpdateRequestSequence = 0
|
||||
let packTokenRequestSequence = 0
|
||||
const pendingPackTokens = new Map<
|
||||
string,
|
||||
{
|
||||
resolve: (token: string) => void
|
||||
reject: (error: Error) => void
|
||||
timeout: ReturnType<typeof setTimeout>
|
||||
}
|
||||
>()
|
||||
|
||||
function rejectPendingPackTokens() {
|
||||
for (const request of pendingPackTokens.values()) {
|
||||
clearTimeout(request.timeout)
|
||||
request.reject(new Error('StarLight 登录状态已变化,请重试。'))
|
||||
}
|
||||
pendingPackTokens.clear()
|
||||
}
|
||||
|
||||
export function requestSkinSiteDownloadToken(): Promise<string> {
|
||||
if (!connectedFrame || status.value !== 'signed-in' || !user.value) {
|
||||
return Promise.reject(
|
||||
new Error('请先在启动器中登录 StarLight 皮肤站,再下载整合包。无需选择玩家。'),
|
||||
)
|
||||
}
|
||||
const requestId = `pack-token-${Date.now()}-${++packTokenRequestSequence}`
|
||||
return new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
pendingPackTokens.delete(requestId)
|
||||
reject(new Error('获取 StarLight 登录凭据超时,请重试。'))
|
||||
}, 10_000)
|
||||
pendingPackTokens.set(requestId, { resolve, reject, timeout })
|
||||
try {
|
||||
connectedFrame?.postMessage(
|
||||
{ type: 'starlight-pack-token-request', requestId },
|
||||
SKIN_SITE_ORIGIN,
|
||||
)
|
||||
} catch {
|
||||
clearTimeout(timeout)
|
||||
pendingPackTokens.delete(requestId)
|
||||
reject(new Error('无法读取 StarLight 登录状态,请重新登录。'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
type PendingLuckRequest = {
|
||||
resolve: (luck: number) => void
|
||||
reject: (error: Error) => void
|
||||
timeout: ReturnType<typeof setTimeout>
|
||||
}
|
||||
|
||||
const pendingLuckRequests = new Map<string, PendingLuckRequest>()
|
||||
type PendingPlayersRequest = {
|
||||
resolve: (players: SkinSitePlayer[]) => void
|
||||
reject: (error: Error) => void
|
||||
timeout: ReturnType<typeof setTimeout>
|
||||
}
|
||||
const pendingPlayersRequests = new Map<string, PendingPlayersRequest>()
|
||||
type PendingSkinUpdateRequest = {
|
||||
resolve: () => void
|
||||
reject: (error: Error) => void
|
||||
timeout: ReturnType<typeof setTimeout>
|
||||
}
|
||||
const pendingSkinUpdateRequests = new Map<string, PendingSkinUpdateRequest>()
|
||||
|
||||
function isSafePngDataUrl(value: unknown, maxLength: number) {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
value.length <= maxLength &&
|
||||
/^data:image\/png;base64,[a-z0-9+/]+={0,2}$/i.test(value)
|
||||
)
|
||||
}
|
||||
|
||||
function hasSafeSkinHead(player: SkinSitePlayer) {
|
||||
if (!['ready', 'empty', 'error'].includes(player.skinState)) return false
|
||||
if (player.skinState !== 'ready') return player.headDataUrl === undefined
|
||||
return (
|
||||
isSafePngDataUrl(player.headDataUrl, 100_000) &&
|
||||
(player.skinDataUrl === undefined || isSafePngDataUrl(player.skinDataUrl, 2_000_000)) &&
|
||||
(player.model === undefined || player.model === 'default' || player.model === 'slim')
|
||||
)
|
||||
}
|
||||
let playersRequest: Promise<SkinSitePlayer[]> | null = null
|
||||
|
||||
export const skinSiteUser = readonly(user)
|
||||
export const skinSiteStatus = readonly(status)
|
||||
export const skinSitePlayers = readonly(players)
|
||||
export const skinSitePlayersStatus = readonly(playersStatus)
|
||||
export const selectedSkinSitePlayerId = readonly(selectedPlayerId)
|
||||
export const skinSiteFrameUrl = readonly(frameUrl)
|
||||
|
||||
export async function waitForSkinSiteSession() {
|
||||
if (status.value !== 'checking') return
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const stop = watch(status, next => {
|
||||
if (next === 'checking') return
|
||||
clearTimeout(timer)
|
||||
stop()
|
||||
resolve()
|
||||
})
|
||||
const timer = setTimeout(() => {
|
||||
stop()
|
||||
reject(new Error('皮肤站登录状态仍在检查,请稍后重试。'))
|
||||
}, 10_000)
|
||||
})
|
||||
}
|
||||
|
||||
function rejectPendingLuckRequests(message: string) {
|
||||
for (const request of pendingLuckRequests.values()) {
|
||||
clearTimeout(request.timeout)
|
||||
request.reject(new Error(message))
|
||||
function toUser(raw: ApiSkinSiteUser): SkinSiteUser {
|
||||
return {
|
||||
uuid: raw.uuid,
|
||||
username: raw.username,
|
||||
permissions: Array.isArray(raw.permissions) ? raw.permissions : [],
|
||||
}
|
||||
pendingLuckRequests.clear()
|
||||
}
|
||||
|
||||
function rejectPendingPlayersRequests(message: string) {
|
||||
for (const request of pendingPlayersRequests.values()) {
|
||||
clearTimeout(request.timeout)
|
||||
request.reject(new Error(message))
|
||||
function clearSessionState() {
|
||||
user.value = null
|
||||
players.value = []
|
||||
playersStatus.value = 'idle'
|
||||
selectedPlayerId.value = null
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Session lifecycle
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
let initialized: Promise<void> | null = null
|
||||
|
||||
/**
|
||||
* Resolve the current session from the stored JWT. Safe to call repeatedly;
|
||||
* the first call performs the actual work and later ones reuse it.
|
||||
*/
|
||||
export function initSkinSiteSession(): Promise<void> {
|
||||
if (initialized) return initialized
|
||||
initialized = (async () => {
|
||||
const token = getSkinSiteToken()
|
||||
if (!token) {
|
||||
status.value = 'signed-out'
|
||||
return
|
||||
}
|
||||
status.value = 'checking'
|
||||
const result = await skinSiteCurrentUser()
|
||||
if (result.success) {
|
||||
user.value = toUser(result.payload)
|
||||
status.value = 'signed-in'
|
||||
void requestSkinSitePlayers().catch(() => {})
|
||||
} else if (result.errorCode === 401 || result.errorCode === 403) {
|
||||
clearSkinSiteToken()
|
||||
clearSessionState()
|
||||
status.value = 'signed-out'
|
||||
} else {
|
||||
status.value = 'error'
|
||||
}
|
||||
})()
|
||||
return initialized
|
||||
}
|
||||
|
||||
/** Force a re-check (e.g. after the user signs in from another view). */
|
||||
export function reloadSkinSiteSession(): Promise<void> {
|
||||
initialized = null
|
||||
return initSkinSiteSession()
|
||||
}
|
||||
|
||||
export async function signInSkinSite(payload: {
|
||||
username: string
|
||||
password: string
|
||||
clientId: string
|
||||
}): Promise<SkinSiteResponse<{ username: string; jwt: string }>> {
|
||||
const result = await skinSiteLogin(payload)
|
||||
if (result.success) {
|
||||
setSkinSiteToken(result.payload.jwt)
|
||||
const current = await skinSiteCurrentUser()
|
||||
if (current.success) {
|
||||
user.value = toUser(current.payload)
|
||||
status.value = 'signed-in'
|
||||
void requestSkinSitePlayers().catch(() => {})
|
||||
} else {
|
||||
user.value = { uuid: '', username: result.payload.username, permissions: [] }
|
||||
status.value = 'signed-in'
|
||||
}
|
||||
}
|
||||
pendingPlayersRequests.clear()
|
||||
return result
|
||||
}
|
||||
|
||||
function rejectPendingSkinUpdateRequests(message: string) {
|
||||
for (const request of pendingSkinUpdateRequests.values()) {
|
||||
clearTimeout(request.timeout)
|
||||
request.reject(new Error(message))
|
||||
export function signOutSkinSite() {
|
||||
clearSkinSiteToken()
|
||||
clearSessionState()
|
||||
status.value = 'signed-out'
|
||||
initialized = null
|
||||
}
|
||||
|
||||
/** Refresh the JWT; returns true when a new token was stored. */
|
||||
export async function refreshSkinSiteSession(): Promise<boolean> {
|
||||
if (status.value !== 'signed-in') return false
|
||||
const result = await skinSiteRefresh()
|
||||
if (result.success) {
|
||||
setSkinSiteToken(result.payload.jwt)
|
||||
return true
|
||||
}
|
||||
pendingSkinUpdateRequests.clear()
|
||||
if (result.errorCode === 401 || result.errorCode === 403) signOutSkinSite()
|
||||
return false
|
||||
}
|
||||
|
||||
export function setSkinSiteFrame(frame: Window | null) {
|
||||
if (frame && !user.value) status.value = 'checking'
|
||||
if (connectedFrame === frame) return
|
||||
rejectPendingPackTokens()
|
||||
rejectPendingLuckRequests('The skin site connection changed.')
|
||||
rejectPendingPlayersRequests('The skin site connection changed.')
|
||||
rejectPendingSkinUpdateRequests('The skin site connection changed.')
|
||||
connectedFrame = frame
|
||||
// ---------------------------------------------------------------------------
|
||||
// Compatibility shims for the old iframe-based API
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** @deprecated The session is no longer driven by an iframe. No-op. */
|
||||
export function setSkinSiteFrame(_frame: Window | null) {}
|
||||
|
||||
/** @deprecated The session is no longer driven by an iframe. No-op. */
|
||||
export function receiveSkinSiteMessage(_event: MessageEvent, _frame: Window | null): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
/** @deprecated Use the in-app login view instead. No-op. */
|
||||
export function openSkinSiteLogin() {}
|
||||
|
||||
export function resetSkinSiteSession() {
|
||||
clearSessionState()
|
||||
status.value = getSkinSiteToken() ? 'checking' : 'signed-out'
|
||||
initialized = null
|
||||
}
|
||||
|
||||
/** Resolves once the initial session check has settled. */
|
||||
export async function waitForSkinSiteSession(): Promise<void> {
|
||||
await initSkinSiteSession()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Download token (the launcher's hosted pack downloader)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The hosted pack downloader authenticates with the skin site JWT. We hold it
|
||||
* locally now, so this simply surfaces it (refreshing once if it is missing).
|
||||
*/
|
||||
export async function requestSkinSiteDownloadToken(): Promise<string> {
|
||||
if (status.value !== 'signed-in') {
|
||||
await initSkinSiteSession()
|
||||
}
|
||||
if (status.value !== 'signed-in') {
|
||||
throw new Error('请先在启动器中登录 StarLight 皮肤站,再下载整合包。')
|
||||
}
|
||||
let token = getSkinSiteToken()
|
||||
if (!token) {
|
||||
if (await refreshSkinSiteSession()) token = getSkinSiteToken()
|
||||
}
|
||||
if (!token) throw new Error('StarLight 登录凭据不可用,请重新登录。')
|
||||
return token
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Players
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function buildPlayer(entry: {
|
||||
uuid: string
|
||||
name: string
|
||||
isMojang: boolean
|
||||
}): Promise<SkinSitePlayer> {
|
||||
const base: SkinSitePlayer = {
|
||||
uuid: entry.uuid,
|
||||
name: entry.name,
|
||||
isMojang: entry.isMojang,
|
||||
skinState: 'empty',
|
||||
}
|
||||
const skinResult = await skinSitePlayerSkin(entry.uuid)
|
||||
if (!skinResult.success) return { ...base, skinState: 'error' }
|
||||
|
||||
const texture: SkinSitePlayerSkin = skinResult.payload ?? {}
|
||||
if (!texture.skin) return base
|
||||
|
||||
try {
|
||||
const [headDataUrl, skinDataUrl] = await Promise.all([
|
||||
renderSkinHead(texture.skin),
|
||||
fetchImageAsDataUrl(texture.skin),
|
||||
])
|
||||
return {
|
||||
...base,
|
||||
skinState: 'ready',
|
||||
headDataUrl,
|
||||
skinDataUrl,
|
||||
model: texture.model === 'slim' ? 'slim' : 'default',
|
||||
}
|
||||
} catch {
|
||||
return { ...base, skinState: 'error' }
|
||||
}
|
||||
}
|
||||
|
||||
export function requestSkinSitePlayers(): Promise<SkinSitePlayer[]> {
|
||||
if (playersRequest) return playersRequest
|
||||
if (status.value !== 'signed-in' || !user.value) {
|
||||
return Promise.reject(new Error('请先登录 StarLight 皮肤站。'))
|
||||
}
|
||||
|
||||
playersStatus.value = 'checking'
|
||||
playersRequest = (async () => {
|
||||
try {
|
||||
const list = await skinSitePlayerList()
|
||||
if (!list.success) throw new Error(list.errorMessage)
|
||||
const built = await Promise.all(list.payload.map(buildPlayer))
|
||||
players.value = built
|
||||
if (selectedPlayerId.value && !built.some((p) => p.uuid === selectedPlayerId.value)) {
|
||||
selectedPlayerId.value = null
|
||||
}
|
||||
playersStatus.value = 'ready'
|
||||
return players.value
|
||||
} catch (error) {
|
||||
playersStatus.value = 'error'
|
||||
throw error
|
||||
} finally {
|
||||
playersRequest = null
|
||||
}
|
||||
})()
|
||||
return playersRequest
|
||||
}
|
||||
|
||||
export function selectSkinSitePlayer(playerId: string | null) {
|
||||
@@ -171,267 +264,59 @@ export function selectSkinSitePlayer(playerId: string | null) {
|
||||
if (players.value.some((player) => player.uuid === playerId)) selectedPlayerId.value = playerId
|
||||
}
|
||||
|
||||
export function openSkinSiteLogin() {
|
||||
frameUrl.value = `${SKIN_SITE_ORIGIN}/login`
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Luck
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function resetSkinSiteSession() {
|
||||
rejectPendingPackTokens()
|
||||
rejectPendingLuckRequests('The skin site session ended.')
|
||||
rejectPendingPlayersRequests('The skin site session ended.')
|
||||
rejectPendingSkinUpdateRequests('The skin site session ended.')
|
||||
user.value = null
|
||||
status.value = 'signed-out'
|
||||
players.value = []
|
||||
playersStatus.value = 'idle'
|
||||
selectedPlayerId.value = null
|
||||
export async function requestSkinSiteLuck(): Promise<number> {
|
||||
if (status.value !== 'signed-in') throw new Error('请先登录 StarLight 皮肤站。')
|
||||
const result = await skinSiteLuck()
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
return result.payload.luck
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// Legacy compatibility
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function requestSkinSiteSkinUpdate(
|
||||
/**
|
||||
* Replace a player's skin texture.
|
||||
*
|
||||
* The caller hands us a base64 PNG (what the in-app editor produces); we turn
|
||||
* it back into a File and upload it through the skin site's texture endpoint.
|
||||
*/
|
||||
export async function requestSkinSiteSkinUpdate(
|
||||
playerId: string,
|
||||
textureDataUrl: string,
|
||||
model: 'default' | 'slim',
|
||||
) {
|
||||
): Promise<void> {
|
||||
if (status.value !== 'signed-in' || !user.value) {
|
||||
throw new Error('请先登录 StarLight 皮肤站。')
|
||||
}
|
||||
const player = players.value.find((candidate) => candidate.uuid === playerId)
|
||||
if (!connectedFrame || status.value !== 'signed-in' || !user.value) {
|
||||
return Promise.reject(new Error('Sign in to the skin site before changing a skin.'))
|
||||
}
|
||||
if (!player || player.isMojang) {
|
||||
return Promise.reject(new Error('This skin site player cannot be changed.'))
|
||||
throw new Error('该玩家无法修改皮肤。')
|
||||
}
|
||||
if (!isSafePngDataUrl(textureDataUrl, 2_000_000)) {
|
||||
return Promise.reject(new Error('The selected skin texture is invalid or too large.'))
|
||||
if (!/^data:image\/png;base64,[a-z0-9+/]+={0,2}$/i.test(textureDataUrl)) {
|
||||
throw new Error('皮肤图片无效或过大。')
|
||||
}
|
||||
|
||||
const requestId = `skin-update-${Date.now()}-${++skinUpdateRequestSequence}`
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
pendingSkinUpdateRequests.delete(requestId)
|
||||
reject(new Error('The skin site update timed out.'))
|
||||
}, 20_000)
|
||||
pendingSkinUpdateRequests.set(requestId, { resolve, reject, timeout })
|
||||
try {
|
||||
connectedFrame?.postMessage(
|
||||
{
|
||||
type: 'starlight-skin-update-request',
|
||||
requestId,
|
||||
playerId,
|
||||
textureDataUrl,
|
||||
model,
|
||||
},
|
||||
SKIN_SITE_ORIGIN,
|
||||
)
|
||||
} catch (error) {
|
||||
clearTimeout(timeout)
|
||||
pendingSkinUpdateRequests.delete(requestId)
|
||||
reject(error instanceof Error ? error : new Error(String(error)))
|
||||
}
|
||||
})
|
||||
const file = await dataUrlToFile(textureDataUrl, `${player.name}.png`)
|
||||
const result = await skinSiteUploadTexture(playerId, file, 'SKIN', { model })
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
|
||||
const refreshed = await skinSitePlayerSkin(playerId)
|
||||
if (refreshed.success && refreshed.payload?.skin) {
|
||||
const updated = await buildPlayer({
|
||||
uuid: player.uuid,
|
||||
name: player.name,
|
||||
isMojang: player.isMojang,
|
||||
})
|
||||
players.value = players.value.map((entry) => (entry.uuid === playerId ? updated : entry))
|
||||
}
|
||||
}
|
||||
|
||||
export function requestSkinSitePlayers() {
|
||||
if (!connectedFrame || status.value !== 'signed-in' || !user.value) {
|
||||
return Promise.reject(new Error('Sign in to the skin site before requesting players.'))
|
||||
}
|
||||
|
||||
playersStatus.value = 'checking'
|
||||
const requestId = `skin-players-${Date.now()}-${++playersRequestSequence}`
|
||||
return new Promise<SkinSitePlayer[]>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
pendingPlayersRequests.delete(requestId)
|
||||
playersStatus.value = 'error'
|
||||
reject(new Error('The skin site player request timed out.'))
|
||||
}, 30_000)
|
||||
pendingPlayersRequests.set(requestId, { resolve, reject, timeout })
|
||||
try {
|
||||
connectedFrame?.postMessage(
|
||||
{ type: 'starlight-skin-players-request', requestId },
|
||||
SKIN_SITE_ORIGIN,
|
||||
)
|
||||
} catch (error) {
|
||||
clearTimeout(timeout)
|
||||
pendingPlayersRequests.delete(requestId)
|
||||
playersStatus.value = 'error'
|
||||
reject(error instanceof Error ? error : new Error(String(error)))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function requestSkinSiteLuck() {
|
||||
if (!connectedFrame || status.value !== 'signed-in' || !user.value) {
|
||||
return Promise.reject(new Error('Sign in to the skin site before requesting luck.'))
|
||||
}
|
||||
|
||||
const requestId = `skin-luck-${Date.now()}-${++luckRequestSequence}`
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
pendingLuckRequests.delete(requestId)
|
||||
reject(new Error('The skin site luck request timed out.'))
|
||||
}, 12_000)
|
||||
pendingLuckRequests.set(requestId, { resolve, reject, timeout })
|
||||
try {
|
||||
connectedFrame?.postMessage(
|
||||
{ type: 'starlight-skin-luck-request', requestId },
|
||||
SKIN_SITE_ORIGIN,
|
||||
)
|
||||
} catch (error) {
|
||||
clearTimeout(timeout)
|
||||
pendingLuckRequests.delete(requestId)
|
||||
reject(error instanceof Error ? error : new Error(String(error)))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function receiveSkinSiteMessage(event: MessageEvent, frame: Window | null) {
|
||||
if (!frame || event.source !== frame || event.origin !== SKIN_SITE_ORIGIN) return false
|
||||
const data = event.data
|
||||
if (!data || typeof data !== 'object') return false
|
||||
if (data.type === 'starlight-pack-token-result') {
|
||||
const pending = pendingPackTokens.get(data.requestId)
|
||||
if (!pending) return false
|
||||
clearTimeout(pending.timeout)
|
||||
pendingPackTokens.delete(data.requestId)
|
||||
if (
|
||||
status.value === 'signed-in' &&
|
||||
typeof data.token === 'string' &&
|
||||
data.token.length > 0 &&
|
||||
data.token.length <= 16_384 &&
|
||||
!/\s/.test(data.token)
|
||||
) {
|
||||
pending.resolve(data.token)
|
||||
} else pending.reject(new Error('StarLight 登录凭据不可用,请重新登录。'))
|
||||
return true
|
||||
}
|
||||
|
||||
if (data.type === 'starlight-skin-players-result') {
|
||||
if (typeof data.requestId !== 'string') return false
|
||||
const pending = pendingPlayersRequests.get(data.requestId)
|
||||
if (!pending) return false
|
||||
clearTimeout(pending.timeout)
|
||||
pendingPlayersRequests.delete(data.requestId)
|
||||
if (data.ok === true && Array.isArray(data.players)) {
|
||||
const nextPlayers = data.players.filter(
|
||||
(player: unknown): player is SkinSitePlayer =>
|
||||
typeof player === 'object' &&
|
||||
player !== null &&
|
||||
typeof (player as SkinSitePlayer).uuid === 'string' &&
|
||||
/^[0-9a-f-]{32,36}$/i.test((player as SkinSitePlayer).uuid) &&
|
||||
typeof (player as SkinSitePlayer).name === 'string' &&
|
||||
(player as SkinSitePlayer).name.length > 0 &&
|
||||
(player as SkinSitePlayer).name.length <= 64 &&
|
||||
typeof (player as SkinSitePlayer).isMojang === 'boolean' &&
|
||||
hasSafeSkinHead(player as SkinSitePlayer),
|
||||
)
|
||||
const previousPlayers = new Map(players.value.map((player) => [player.uuid, player]))
|
||||
players.value = nextPlayers.map((player) => {
|
||||
const previous = previousPlayers.get(player.uuid)
|
||||
return player.skinState === 'error' && previous?.skinState === 'ready'
|
||||
? { ...player, ...previous, name: player.name, isMojang: player.isMojang }
|
||||
: player
|
||||
})
|
||||
if (
|
||||
selectedPlayerId.value &&
|
||||
!nextPlayers.some((player) => player.uuid === selectedPlayerId.value)
|
||||
) {
|
||||
selectedPlayerId.value = null
|
||||
}
|
||||
playersStatus.value = 'ready'
|
||||
pending.resolve(players.value)
|
||||
} else {
|
||||
playersStatus.value = 'error'
|
||||
pending.reject(
|
||||
new Error(
|
||||
typeof data.error === 'string' && data.error
|
||||
? data.error.slice(0, 300)
|
||||
: 'The skin site returned an invalid player list.',
|
||||
),
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if (data.type === 'starlight-skin-luck-result') {
|
||||
if (typeof data.requestId !== 'string') return false
|
||||
const pending = pendingLuckRequests.get(data.requestId)
|
||||
if (!pending) return false
|
||||
clearTimeout(pending.timeout)
|
||||
pendingLuckRequests.delete(data.requestId)
|
||||
if (
|
||||
data.ok === true &&
|
||||
typeof data.luck === 'number' &&
|
||||
Number.isFinite(data.luck) &&
|
||||
data.luck >= 0 &&
|
||||
data.luck <= 100
|
||||
) {
|
||||
pending.resolve(data.luck)
|
||||
} else {
|
||||
pending.reject(
|
||||
new Error(
|
||||
typeof data.error === 'string' && data.error
|
||||
? data.error.slice(0, 300)
|
||||
: 'The skin site returned an invalid luck result.',
|
||||
),
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if (data.type === 'starlight-skin-update-result') {
|
||||
if (typeof data.requestId !== 'string') return false
|
||||
const pending = pendingSkinUpdateRequests.get(data.requestId)
|
||||
if (!pending) return false
|
||||
clearTimeout(pending.timeout)
|
||||
pendingSkinUpdateRequests.delete(data.requestId)
|
||||
if (data.ok === true) pending.resolve()
|
||||
else {
|
||||
pending.reject(
|
||||
new Error(
|
||||
typeof data.error === 'string' && data.error
|
||||
? data.error.slice(0, 300)
|
||||
: 'The skin site rejected the skin update.',
|
||||
),
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if (data.type !== 'starlight-skin-session') return false
|
||||
if (!['checking', 'signed-out', 'signed-in', 'error'].includes(data.status)) return false
|
||||
let refreshPlayers = false
|
||||
if (data.status === 'signed-in') {
|
||||
if (
|
||||
!data.user ||
|
||||
typeof data.user.uuid !== 'string' ||
|
||||
typeof data.user.username !== 'string' ||
|
||||
!data.user.uuid ||
|
||||
!data.user.username ||
|
||||
data.user.username.length > 256
|
||||
)
|
||||
return false
|
||||
if (user.value?.uuid && user.value.uuid !== data.user.uuid) {
|
||||
rejectPendingPackTokens()
|
||||
rejectPendingPlayersRequests('The skin site account changed.')
|
||||
rejectPendingSkinUpdateRequests('The skin site account changed.')
|
||||
players.value = []
|
||||
playersStatus.value = 'idle'
|
||||
selectedPlayerId.value = null
|
||||
}
|
||||
user.value = { uuid: data.user.uuid, username: data.user.username }
|
||||
if ([`${SKIN_SITE_ORIGIN}/`, `${SKIN_SITE_ORIGIN}/login`].includes(frameUrl.value)) {
|
||||
frameUrl.value = `${SKIN_SITE_ORIGIN}/profile`
|
||||
}
|
||||
refreshPlayers = true
|
||||
} else {
|
||||
rejectPendingPackTokens()
|
||||
rejectPendingLuckRequests('The skin site session is unavailable.')
|
||||
rejectPendingPlayersRequests('The skin site session is unavailable.')
|
||||
rejectPendingSkinUpdateRequests('The skin site session is unavailable.')
|
||||
user.value = null
|
||||
players.value = []
|
||||
playersStatus.value = 'idle'
|
||||
selectedPlayerId.value = null
|
||||
}
|
||||
status.value = data.status
|
||||
if (refreshPlayers) void requestSkinSitePlayers().catch(() => {})
|
||||
return true
|
||||
async function dataUrlToFile(dataUrl: string, filename: string): Promise<File> {
|
||||
const response = await fetch(dataUrl)
|
||||
const blob = await response.blob()
|
||||
return new File([blob], filename, { type: 'image/png' })
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
import {
|
||||
type KeyBinding,
|
||||
bindingMatchesKeyboardEvent,
|
||||
bindingMatchesMouseEvent,
|
||||
bindingMatchesWheelEvent,
|
||||
useModalStack,
|
||||
} from '@modrinth/ui'
|
||||
import { computed, onUnmounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
||||
import {
|
||||
SCROLL_ACTIONS,
|
||||
SHORTCUT_ACTIONS,
|
||||
type ShortcutAction,
|
||||
} from '@/helpers/shortcut-actions'
|
||||
import { resolveAllBindings } from '@/helpers/shortcut-bindings'
|
||||
import { getNavShortcutEnabled } from '@/helpers/nav-shortcut-state'
|
||||
import { getQuickScrollEnabled } from '@/helpers/scroll-top-state'
|
||||
import { useTheming } from '@/store/theme'
|
||||
|
||||
/** Editing surfaces keep these keys for themselves. */
|
||||
function isEditableTarget(target: EventTarget | null) {
|
||||
return (
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement ||
|
||||
(target instanceof HTMLElement && target.isContentEditable)
|
||||
)
|
||||
}
|
||||
|
||||
function scrollsAtOwnLevel(element: Element) {
|
||||
const { overflowY } = getComputedStyle(element)
|
||||
return /(auto|scroll|overlay)/.test(overflowY) && element.scrollHeight > element.clientHeight
|
||||
}
|
||||
|
||||
/** A container that scrolls the page itself rather than a widget on it. */
|
||||
function isPageScroller(element: Element) {
|
||||
return scrollsAtOwnLevel(element) && element.clientHeight >= window.innerHeight / 2
|
||||
}
|
||||
|
||||
/** Nearest scrolling ancestor, whatever its size. */
|
||||
function nearestScrollContainer(target: EventTarget | null) {
|
||||
let element = target instanceof Element ? target : null
|
||||
while (element) {
|
||||
if (scrollsAtOwnLevel(element)) return element
|
||||
element = element.parentElement
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* The page's own scroller. Most pages scroll inside `.app-viewport`, but some
|
||||
* screens (settings, consoles, studios) turn that element's scrolling off and
|
||||
* host a full-height container inside it, so fall back to whatever fills the
|
||||
* middle of the viewport.
|
||||
*/
|
||||
function resolvePageScroller() {
|
||||
const viewport = document.querySelector<HTMLElement>('.app-viewport')
|
||||
if (!viewport) return null
|
||||
if (isPageScroller(viewport)) return viewport
|
||||
|
||||
const bounds = viewport.getBoundingClientRect()
|
||||
let element: Element | null = document.elementFromPoint(
|
||||
bounds.left + bounds.width / 2,
|
||||
bounds.top + bounds.height / 2,
|
||||
)
|
||||
while (element) {
|
||||
if (isPageScroller(element)) return element
|
||||
element = element.parentElement
|
||||
}
|
||||
|
||||
return viewport
|
||||
}
|
||||
|
||||
export function setupKeyboardShortcuts() {
|
||||
const themeStore = useTheming()
|
||||
const { hasModal } = useModalStack()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { offline } = useNetworkStatus()
|
||||
|
||||
themeStore.quickScrollEnabled = getQuickScrollEnabled()
|
||||
for (const shortcut of SHORTCUT_ACTIONS) {
|
||||
if (shortcut.group === 'nav') themeStore[shortcut.enabledField] = getNavShortcutEnabled(shortcut.id)
|
||||
}
|
||||
themeStore.shortcutBindings = resolveAllBindings()
|
||||
|
||||
/** The combination an action answers to now: recorded if there is one, default otherwise. */
|
||||
function bindingFor(action: ShortcutAction): KeyBinding {
|
||||
return themeStore.shortcutBindings[action.id] ?? action.defaultBinding
|
||||
}
|
||||
|
||||
/** Whether an action is switched on and reachable in the current state. */
|
||||
function shortcutIsAvailable(action: ShortcutAction): boolean {
|
||||
if (!themeStore[action.enabledField]) return false
|
||||
return !action.unavailable?.({
|
||||
worldsTabEnabled: themeStore.featureFlags.worlds_tab,
|
||||
offline: offline.value,
|
||||
})
|
||||
}
|
||||
|
||||
function findShortcut<E extends Event>(
|
||||
event: E,
|
||||
matches: (binding: KeyBinding, event: E) => boolean,
|
||||
{ includeDisabled = false }: { includeDisabled?: boolean } = {},
|
||||
): ShortcutAction | null {
|
||||
if (hasModal.value) return null
|
||||
if (isEditableTarget(event.target)) return null
|
||||
|
||||
for (const action of SHORTCUT_ACTIONS) {
|
||||
if (!includeDisabled && !shortcutIsAvailable(action)) continue
|
||||
if (matches(bindingFor(action), event)) return action
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/** Does what an action is for. Scrolling actions move the page's own scroller. */
|
||||
function runShortcut(action: ShortcutAction, event: Event) {
|
||||
if (action.target) {
|
||||
router.push(action.target(route))
|
||||
return
|
||||
}
|
||||
|
||||
const focusedContainer = nearestScrollContainer(event.target)
|
||||
if (focusedContainer && !isPageScroller(focusedContainer)) return
|
||||
|
||||
const scroller = resolvePageScroller()
|
||||
if (!scroller) return
|
||||
|
||||
action.applyScroll?.(scroller)
|
||||
}
|
||||
|
||||
function handleScrollShortcutKey(event: KeyboardEvent) {
|
||||
if (event.isComposing) return
|
||||
|
||||
const match = findShortcut(event, bindingMatchesKeyboardEvent, { includeDisabled: true })
|
||||
if (match?.group !== 'scroll') return
|
||||
|
||||
const focusedContainer = nearestScrollContainer(event.target)
|
||||
if (focusedContainer && !isPageScroller(focusedContainer)) return
|
||||
|
||||
const scroller = resolvePageScroller()
|
||||
if (!scroller) return
|
||||
|
||||
event.preventDefault()
|
||||
if (!shortcutIsAvailable(match)) return
|
||||
|
||||
match.applyScroll?.(scroller)
|
||||
}
|
||||
|
||||
function handleNavShortcutKey(event: KeyboardEvent) {
|
||||
if (event.isComposing) return
|
||||
|
||||
const match = findShortcut(event, bindingMatchesKeyboardEvent)
|
||||
if (match?.group !== 'nav') return
|
||||
|
||||
event.preventDefault()
|
||||
runShortcut(match, event)
|
||||
}
|
||||
|
||||
const hasPointerBindings = computed(() =>
|
||||
SHORTCUT_ACTIONS.some((action) => bindingFor(action).device === 'mouse'),
|
||||
)
|
||||
|
||||
function handleShortcutMouse(event: MouseEvent) {
|
||||
if (!hasPointerBindings.value) return
|
||||
|
||||
const match = findShortcut(event, bindingMatchesMouseEvent)
|
||||
if (!match) return
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
runShortcut(match, event)
|
||||
}
|
||||
|
||||
function handleShortcutWheel(event: WheelEvent) {
|
||||
if (!hasPointerBindings.value) return
|
||||
|
||||
const match = findShortcut(event, bindingMatchesWheelEvent)
|
||||
if (!match) return
|
||||
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
runShortcut(match, event)
|
||||
}
|
||||
|
||||
function handleGlobalKeydown(event: KeyboardEvent) {
|
||||
const key = event.key.toLowerCase()
|
||||
const isFindShortcut = key === 'f' && (event.ctrlKey || event.metaKey)
|
||||
const isBlockedDevtoolsShortcut = event.key === 'F12' && !themeStore.devMode
|
||||
|
||||
if (isFindShortcut || isBlockedDevtoolsShortcut) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}
|
||||
|
||||
handleScrollShortcutKey(event)
|
||||
handleNavShortcutKey(event)
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleGlobalKeydown, true)
|
||||
window.addEventListener('mousedown', handleShortcutMouse, true)
|
||||
// Not passive: a bound wheel direction has to keep the page from scrolling.
|
||||
window.addEventListener('wheel', handleShortcutWheel, { capture: true, passive: false })
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleGlobalKeydown, true)
|
||||
window.removeEventListener('mousedown', handleShortcutMouse, true)
|
||||
window.removeEventListener('wheel', handleShortcutWheel, { capture: true, passive: false })
|
||||
})
|
||||
|
||||
return { bindingFor, shortcutIsAvailable, SCROLL_ACTIONS }
|
||||
}
|
||||
@@ -160,6 +160,10 @@ export async function notification_listener(callback) {
|
||||
return await listen('notification', (event) => callback(event.payload))
|
||||
}
|
||||
|
||||
export async function logshare_ai_listener(callback) {
|
||||
return await listen('logshare_ai', (event) => callback(event.payload))
|
||||
}
|
||||
|
||||
/// Payload for the 'log' event
|
||||
/*
|
||||
LogPayload {
|
||||
|
||||
@@ -95,6 +95,50 @@ export async function undo_added_mod(instanceId, filename, expectedHash) {
|
||||
return await invoke('plugin:logs|logs_undo_added_mod', { instanceId, filename, expectedHash })
|
||||
}
|
||||
|
||||
export async function get_log_share_settings() {
|
||||
return await invoke('plugin:logs|logs_get_log_share_settings')
|
||||
}
|
||||
|
||||
export async function update_log_share_settings(settings) {
|
||||
return await invoke('plugin:logs|logs_update_log_share_settings', { settings })
|
||||
}
|
||||
|
||||
export async function logshare_upload_crash(instanceId) {
|
||||
return await invoke('plugin:logs|logs_logshare_upload_crash', { instanceId })
|
||||
}
|
||||
|
||||
export async function logshare_get_insights(id) {
|
||||
return await invoke('plugin:logs|logs_logshare_get_insights', { id })
|
||||
}
|
||||
|
||||
export async function logshare_analyse_crash_direct(instanceId) {
|
||||
return await invoke('plugin:logs|logs_logshare_analyse_crash_direct', { instanceId })
|
||||
}
|
||||
|
||||
export async function logshare_ai_analyze_stored(instanceId, id) {
|
||||
return await invoke('plugin:logs|logs_logshare_ai_analyze_stored', { instanceId, id })
|
||||
}
|
||||
|
||||
export async function logshare_ai_analyze_direct(instanceId) {
|
||||
return await invoke('plugin:logs|logs_logshare_ai_analyze_direct', { instanceId })
|
||||
}
|
||||
|
||||
export async function logshare_delete(id, token) {
|
||||
return await invoke('plugin:logs|logs_logshare_delete', { id, token })
|
||||
}
|
||||
|
||||
export async function list_shared_logs() {
|
||||
return await invoke('plugin:logs|logs_list_shared_logs')
|
||||
}
|
||||
|
||||
export async function record_shared_log(log) {
|
||||
return await invoke('plugin:logs|logs_record_shared_log', { log })
|
||||
}
|
||||
|
||||
export async function delete_shared_log(id, token) {
|
||||
return await invoke('plugin:logs|logs_delete_shared_log', { id, token })
|
||||
}
|
||||
|
||||
/// Export the censored files and local analysis from an instance's latest run.
|
||||
export async function export_crash_context(instanceId, instanceName) {
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-')
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const NAV_SHORTCUT_STORAGE_PREFIX = 'starlight-shortcut-nav-'
|
||||
|
||||
/**
|
||||
* Whether a navigation shortcut is enabled. Shortcuts are off by default;
|
||||
* each one is turned on individually from the Shortcut settings page.
|
||||
*/
|
||||
export function getNavShortcutEnabled(id: string): boolean {
|
||||
const value = localStorage.getItem(NAV_SHORTCUT_STORAGE_PREFIX + id)
|
||||
return value === 'true'
|
||||
}
|
||||
|
||||
export function setNavShortcutEnabled(id: string, enabled: boolean) {
|
||||
localStorage.setItem(NAV_SHORTCUT_STORAGE_PREFIX + id, String(enabled))
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
const SHOW_SCROLL_TOP_STORAGE_KEY = 'starlight-show-scroll-top'
|
||||
const QUICK_SCROLL_ENABLED_STORAGE_KEY = 'starlight-quick-scroll-enabled'
|
||||
|
||||
export function getShowScrollTop(): boolean {
|
||||
const value = localStorage.getItem(SHOW_SCROLL_TOP_STORAGE_KEY)
|
||||
return value !== 'false'
|
||||
}
|
||||
|
||||
export function setShowScrollTop(show: boolean) {
|
||||
localStorage.setItem(SHOW_SCROLL_TOP_STORAGE_KEY, String(show))
|
||||
}
|
||||
|
||||
export function getQuickScrollEnabled(): boolean {
|
||||
const value = localStorage.getItem(QUICK_SCROLL_ENABLED_STORAGE_KEY)
|
||||
return value === 'true'
|
||||
}
|
||||
|
||||
export function setQuickScrollEnabled(enabled: boolean) {
|
||||
localStorage.setItem(QUICK_SCROLL_ENABLED_STORAGE_KEY, String(enabled))
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
import { defineMessages, type KeyBinding, type MessageDescriptor } from '@modrinth/ui'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
|
||||
import { getLastBrowseContentProjectType, isBrowseContentProjectType } from '@/helpers/settings'
|
||||
|
||||
/** Which half of the settings page an action belongs to. */
|
||||
export type ShortcutGroupId = 'scroll' | 'nav'
|
||||
|
||||
/** Theme store fields that switch an action on. */
|
||||
export type ShortcutEnabledField =
|
||||
| 'quickScrollEnabled'
|
||||
| 'shortcutNavHome'
|
||||
| 'shortcutNavWorlds'
|
||||
| 'shortcutNavDiscover'
|
||||
| 'shortcutNavSkins'
|
||||
| 'shortcutNavMultiplayer'
|
||||
| 'shortcutNavLibrary'
|
||||
| 'shortcutNavLab'
|
||||
| 'shortcutNavDownloads'
|
||||
| 'shortcutNavCreate'
|
||||
| 'shortcutNavSettings'
|
||||
|
||||
export interface ShortcutContext {
|
||||
worldsTabEnabled: boolean
|
||||
offline: boolean
|
||||
}
|
||||
|
||||
export interface ShortcutAction {
|
||||
/** Stable id, used for the binding, the enable flag and the settings row. */
|
||||
id: string
|
||||
group: ShortcutGroupId
|
||||
enabledField: ShortcutEnabledField
|
||||
defaultBinding: KeyBinding
|
||||
label: MessageDescriptor
|
||||
description: MessageDescriptor
|
||||
/** Navigation actions know where they lead. */
|
||||
target?: (route: RouteLocationNormalizedLoaded) => string
|
||||
/** Navigation actions that are not reachable right now. */
|
||||
unavailable?: (context: ShortcutContext) => boolean
|
||||
/** Scrolling actions move the page's own scroller. */
|
||||
applyScroll?: (scroller: HTMLElement) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Declared here rather than assembled from the action ids, so the extractor can
|
||||
* see them; an id built at runtime is one a translation pass would drop.
|
||||
*/
|
||||
const messages = defineMessages({
|
||||
scrollTop: {
|
||||
id: 'app.shortcut-settings.home-action',
|
||||
defaultMessage: 'Scroll to the top',
|
||||
},
|
||||
scrollTopDescription: {
|
||||
id: 'app.shortcut-settings.home-action-description',
|
||||
defaultMessage: 'Moves the page you are reading to the top.',
|
||||
},
|
||||
scrollBottom: {
|
||||
id: 'app.shortcut-settings.end-action',
|
||||
defaultMessage: 'Scroll to the bottom',
|
||||
},
|
||||
scrollBottomDescription: {
|
||||
id: 'app.shortcut-settings.end-action-description',
|
||||
defaultMessage: 'Moves the page you are reading to the bottom.',
|
||||
},
|
||||
scrollUp: {
|
||||
id: 'app.shortcut-settings.page-up-action',
|
||||
defaultMessage: 'Scroll up one screen',
|
||||
},
|
||||
scrollUpDescription: {
|
||||
id: 'app.shortcut-settings.page-up-action-description',
|
||||
defaultMessage: 'Moves the page you are reading up by one screen.',
|
||||
},
|
||||
scrollDown: {
|
||||
id: 'app.shortcut-settings.page-down-action',
|
||||
defaultMessage: 'Scroll down one screen',
|
||||
},
|
||||
scrollDownDescription: {
|
||||
id: 'app.shortcut-settings.page-down-action-description',
|
||||
defaultMessage: 'Moves the page you are reading down by one screen.',
|
||||
},
|
||||
navHome: { id: 'app.shortcut-settings.nav-home', defaultMessage: 'Home' },
|
||||
navHomeDescription: {
|
||||
id: 'app.shortcut-settings.nav-home-description',
|
||||
defaultMessage: 'Jump to the Home page.',
|
||||
},
|
||||
navWorlds: { id: 'app.shortcut-settings.nav-worlds', defaultMessage: 'Worlds' },
|
||||
navWorldsDescription: {
|
||||
id: 'app.shortcut-settings.nav-worlds-description',
|
||||
defaultMessage: 'Jump to your worlds.',
|
||||
},
|
||||
navDiscover: {
|
||||
id: 'app.shortcut-settings.nav-discover',
|
||||
defaultMessage: 'Discover content',
|
||||
},
|
||||
navDiscoverDescription: {
|
||||
id: 'app.shortcut-settings.nav-discover-description',
|
||||
defaultMessage: 'Jump to browsing content.',
|
||||
},
|
||||
navSkins: { id: 'app.shortcut-settings.nav-skins', defaultMessage: 'Skin selector' },
|
||||
navSkinsDescription: {
|
||||
id: 'app.shortcut-settings.nav-skins-description',
|
||||
defaultMessage: 'Jump to the skin selector.',
|
||||
},
|
||||
navMultiplayer: { id: 'app.shortcut-settings.nav-multiplayer', defaultMessage: 'Multiplayer' },
|
||||
navMultiplayerDescription: {
|
||||
id: 'app.shortcut-settings.nav-multiplayer-description',
|
||||
defaultMessage: 'Jump to multiplayer.',
|
||||
},
|
||||
navLibrary: { id: 'app.shortcut-settings.nav-library', defaultMessage: 'Library' },
|
||||
navLibraryDescription: {
|
||||
id: 'app.shortcut-settings.nav-library-description',
|
||||
defaultMessage: 'Jump to your library.',
|
||||
},
|
||||
navLab: { id: 'app.shortcut-settings.nav-lab', defaultMessage: 'Lab' },
|
||||
navLabDescription: {
|
||||
id: 'app.shortcut-settings.nav-lab-description',
|
||||
defaultMessage: 'Jump to the Lab.',
|
||||
},
|
||||
navDownloads: { id: 'app.shortcut-settings.nav-downloads', defaultMessage: 'Downloads' },
|
||||
navDownloadsDescription: {
|
||||
id: 'app.shortcut-settings.nav-downloads-description',
|
||||
defaultMessage: 'Jump to downloads.',
|
||||
},
|
||||
navCreate: { id: 'app.shortcut-settings.nav-create', defaultMessage: 'Create new instance' },
|
||||
navCreateDescription: {
|
||||
id: 'app.shortcut-settings.nav-create-description',
|
||||
defaultMessage: 'Jump to creating a new instance.',
|
||||
},
|
||||
navSettings: { id: 'app.shortcut-settings.nav-settings', defaultMessage: 'Settings' },
|
||||
navSettingsDescription: {
|
||||
id: 'app.shortcut-settings.nav-settings-description',
|
||||
defaultMessage: 'Jump to the settings.',
|
||||
},
|
||||
})
|
||||
|
||||
function keyboard(code: string, mod = false, alt = false, shift = false): KeyBinding {
|
||||
return { device: 'keyboard', code, mod, alt, shift }
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the Discover content target from the current route, so the nav
|
||||
* button and the keyboard shortcut share one source of truth.
|
||||
*/
|
||||
export function discoverContentTarget(route: RouteLocationNormalizedLoaded): string {
|
||||
const projectType = route.params.projectType
|
||||
if (
|
||||
!route.query.i &&
|
||||
!route.query.sid &&
|
||||
!route.query.wid &&
|
||||
typeof projectType === 'string' &&
|
||||
isBrowseContentProjectType(projectType)
|
||||
) {
|
||||
return `/browse/${projectType}`
|
||||
}
|
||||
|
||||
return `/browse/${getLastBrowseContentProjectType()}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Every shortcut the launcher answers to. The binding here is the one a fresh
|
||||
* install uses; a recorded binding is stored separately and wins over it.
|
||||
*/
|
||||
export const SHORTCUT_ACTIONS: ShortcutAction[] = [
|
||||
{
|
||||
id: 'shortcutScrollTop',
|
||||
group: 'scroll',
|
||||
enabledField: 'quickScrollEnabled',
|
||||
defaultBinding: keyboard('Home'),
|
||||
label: messages.scrollTop,
|
||||
description: messages.scrollTopDescription,
|
||||
applyScroll: (scroller) => scroller.scrollTo({ top: 0, behavior: 'smooth' }),
|
||||
},
|
||||
{
|
||||
id: 'shortcutScrollBottom',
|
||||
group: 'scroll',
|
||||
enabledField: 'quickScrollEnabled',
|
||||
defaultBinding: keyboard('End'),
|
||||
label: messages.scrollBottom,
|
||||
description: messages.scrollBottomDescription,
|
||||
applyScroll: (scroller) =>
|
||||
scroller.scrollTo({ top: scroller.scrollHeight, behavior: 'smooth' }),
|
||||
},
|
||||
{
|
||||
id: 'shortcutScrollUp',
|
||||
group: 'scroll',
|
||||
enabledField: 'quickScrollEnabled',
|
||||
defaultBinding: keyboard('PageUp'),
|
||||
label: messages.scrollUp,
|
||||
description: messages.scrollUpDescription,
|
||||
applyScroll: (scroller) => {
|
||||
// Immediate scrolling keeps rapid key repeats responsive.
|
||||
scroller.scrollTop = Math.max(0, scroller.scrollTop - scroller.clientHeight * 0.9)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'shortcutScrollDown',
|
||||
group: 'scroll',
|
||||
enabledField: 'quickScrollEnabled',
|
||||
defaultBinding: keyboard('PageDown'),
|
||||
label: messages.scrollDown,
|
||||
description: messages.scrollDownDescription,
|
||||
applyScroll: (scroller) => {
|
||||
scroller.scrollTop = Math.min(
|
||||
scroller.scrollHeight,
|
||||
scroller.scrollTop + scroller.clientHeight * 0.9,
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavHome',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavHome',
|
||||
defaultBinding: keyboard('Digit1', true),
|
||||
label: messages.navHome,
|
||||
description: messages.navHomeDescription,
|
||||
target: () => '/',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavWorlds',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavWorlds',
|
||||
defaultBinding: keyboard('Digit2', true),
|
||||
label: messages.navWorlds,
|
||||
description: messages.navWorldsDescription,
|
||||
target: () => '/worlds',
|
||||
unavailable: (context) => !context.worldsTabEnabled,
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavDiscover',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavDiscover',
|
||||
defaultBinding: keyboard('Digit3', true),
|
||||
label: messages.navDiscover,
|
||||
description: messages.navDiscoverDescription,
|
||||
target: (route) => discoverContentTarget(route),
|
||||
unavailable: (context) => context.offline,
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavSkins',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavSkins',
|
||||
defaultBinding: keyboard('Digit4', true),
|
||||
label: messages.navSkins,
|
||||
description: messages.navSkinsDescription,
|
||||
target: () => '/skins',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavMultiplayer',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavMultiplayer',
|
||||
defaultBinding: keyboard('Digit5', true),
|
||||
label: messages.navMultiplayer,
|
||||
description: messages.navMultiplayerDescription,
|
||||
target: () => '/multiplayer',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavLibrary',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavLibrary',
|
||||
defaultBinding: keyboard('Digit6', true),
|
||||
label: messages.navLibrary,
|
||||
description: messages.navLibraryDescription,
|
||||
target: () => '/library',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavLab',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavLab',
|
||||
defaultBinding: keyboard('Digit7', true),
|
||||
label: messages.navLab,
|
||||
description: messages.navLabDescription,
|
||||
target: () => '/lab',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavDownloads',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavDownloads',
|
||||
defaultBinding: keyboard('Digit8', true),
|
||||
label: messages.navDownloads,
|
||||
description: messages.navDownloadsDescription,
|
||||
target: () => '/downloads',
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavCreate',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavCreate',
|
||||
defaultBinding: keyboard('Digit9', true),
|
||||
label: messages.navCreate,
|
||||
description: messages.navCreateDescription,
|
||||
target: () => '/create',
|
||||
unavailable: (context) => context.offline,
|
||||
},
|
||||
{
|
||||
id: 'shortcutNavSettings',
|
||||
group: 'nav',
|
||||
enabledField: 'shortcutNavSettings',
|
||||
defaultBinding: keyboard('Comma', true),
|
||||
label: messages.navSettings,
|
||||
description: messages.navSettingsDescription,
|
||||
target: () => '/settings',
|
||||
},
|
||||
]
|
||||
|
||||
export const SCROLL_ACTIONS = SHORTCUT_ACTIONS.filter((action) => action.group === 'scroll')
|
||||
export const NAV_ACTIONS = SHORTCUT_ACTIONS.filter((action) => action.group === 'nav')
|
||||
|
||||
export function shortcutAction(id: string): ShortcutAction | undefined {
|
||||
return SHORTCUT_ACTIONS.find((action) => action.id === id)
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { BindingConflict, KeyBinding } from '@modrinth/ui'
|
||||
|
||||
import { SHORTCUT_ACTIONS, shortcutAction } from '@/helpers/shortcut-actions'
|
||||
|
||||
const BINDING_STORAGE_PREFIX = 'starlight-shortcut-binding-'
|
||||
|
||||
/**
|
||||
* Combinations the shell or the operating system answers to before the launcher
|
||||
* sees them. Saved shortcuts may not take these over.
|
||||
*/
|
||||
export const RESERVED_BINDINGS: BindingConflict[] = [
|
||||
{
|
||||
id: 'system-find',
|
||||
label: 'Find in page (Ctrl/Cmd + F)',
|
||||
binding: keyboard('KeyF', true),
|
||||
reserved: true,
|
||||
},
|
||||
{
|
||||
id: 'system-devtools',
|
||||
label: 'Developer tools (F12)',
|
||||
binding: keyboard('F12'),
|
||||
reserved: true,
|
||||
},
|
||||
{
|
||||
id: 'system-close',
|
||||
label: 'Close window (Ctrl/Cmd + W)',
|
||||
binding: keyboard('KeyW', true),
|
||||
reserved: true,
|
||||
},
|
||||
{
|
||||
id: 'system-quit',
|
||||
label: 'Quit (Ctrl/Cmd + Q)',
|
||||
binding: keyboard('KeyQ', true),
|
||||
reserved: true,
|
||||
},
|
||||
{
|
||||
id: 'system-reload',
|
||||
label: 'Reload (Ctrl/Cmd + R)',
|
||||
binding: keyboard('KeyR', true),
|
||||
reserved: true,
|
||||
},
|
||||
{ id: 'system-refresh', label: 'Refresh (F5)', binding: keyboard('F5'), reserved: true },
|
||||
{
|
||||
id: 'system-exit',
|
||||
label: 'Close window (Alt + F4)',
|
||||
binding: keyboard('F4', false, true),
|
||||
reserved: true,
|
||||
},
|
||||
]
|
||||
|
||||
function keyboard(code: string, mod = false, alt = false, shift = false): KeyBinding {
|
||||
return { device: 'keyboard', code, mod, alt, shift }
|
||||
}
|
||||
|
||||
function isKeyBinding(value: unknown): value is KeyBinding {
|
||||
if (!value || typeof value !== 'object') return false
|
||||
const candidate = value as Partial<KeyBinding>
|
||||
return (
|
||||
(candidate.device === 'keyboard' || candidate.device === 'mouse') &&
|
||||
typeof candidate.code === 'string' &&
|
||||
candidate.code.length > 0 &&
|
||||
typeof candidate.mod === 'boolean' &&
|
||||
typeof candidate.shift === 'boolean' &&
|
||||
typeof candidate.alt === 'boolean'
|
||||
)
|
||||
}
|
||||
|
||||
/** The combination recorded for an action, if it has one. */
|
||||
export function readStoredBinding(id: string): KeyBinding | null {
|
||||
const raw = localStorage.getItem(BINDING_STORAGE_PREFIX + id)
|
||||
if (!raw) return null
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw)
|
||||
return isKeyBinding(parsed) ? parsed : null
|
||||
} catch {
|
||||
// A value that cannot be read is treated as unset, so the action keeps
|
||||
// working with its default rather than becoming unreachable.
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function storeBinding(id: string, binding: KeyBinding) {
|
||||
localStorage.setItem(BINDING_STORAGE_PREFIX + id, JSON.stringify(binding))
|
||||
}
|
||||
|
||||
/** Drops the recorded combination, putting the action back on its default. */
|
||||
export function clearStoredBinding(id: string) {
|
||||
if (readStoredBinding(id)) localStorage.removeItem(BINDING_STORAGE_PREFIX + id)
|
||||
}
|
||||
|
||||
/** The combination an action answers to now: the recorded one, or its default. */
|
||||
export function resolveBinding(id: string): KeyBinding | null {
|
||||
const action = shortcutAction(id)
|
||||
if (!action) return null
|
||||
return readStoredBinding(id) ?? action.defaultBinding
|
||||
}
|
||||
|
||||
export function resolveAllBindings(): Record<string, KeyBinding> {
|
||||
const bindings: Record<string, KeyBinding> = {}
|
||||
for (const action of SHORTCUT_ACTIONS) {
|
||||
bindings[action.id] = resolveBinding(action.id) ?? action.defaultBinding
|
||||
}
|
||||
return bindings
|
||||
}
|
||||
|
||||
/**
|
||||
* Everything a new combination would collide with: the other actions, plus the
|
||||
* combinations the shell owns. `label` is what the dialog names in the error.
|
||||
*/
|
||||
export function buildConflicts(exceptId: string, label: (id: string) => string): BindingConflict[] {
|
||||
const conflicts = SHORTCUT_ACTIONS.filter((action) => action.id !== exceptId).flatMap(
|
||||
(action) => {
|
||||
const binding = resolveBinding(action.id)
|
||||
return binding ? [{ id: action.id, label: label(action.id), binding }] : []
|
||||
},
|
||||
)
|
||||
|
||||
return [...conflicts, ...RESERVED_BINDINGS]
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Renders a player's skin into a base64 head image, mirroring the skin site's
|
||||
* own head cropper (front face at 8,8 plus the hat overlay at 40,8).
|
||||
*
|
||||
* The skin image is loaded through the Tauri HTTP client first so cross-origin
|
||||
* textures do not taint the canvas, then drawn once as a data URL.
|
||||
*/
|
||||
const HEAD_BUFFER_SIZE = 18
|
||||
const HEAD_FACE = { sx: 8, sy: 8, sw: 8, sh: 8, dx: 1, dy: 1, dw: 16, dh: 16 }
|
||||
const HEAD_HAT = { sx: 40, sy: 8, sw: 8, sh: 8, dx: 0, dy: 0, dw: 18, dh: 18 }
|
||||
|
||||
let buffer: HTMLCanvasElement | null = null
|
||||
|
||||
function getBuffer(): { canvas: HTMLCanvasElement; ctx: CanvasRenderingContext2D } {
|
||||
if (!buffer) buffer = document.createElement('canvas')
|
||||
const ctx = buffer.getContext('2d')
|
||||
if (!ctx) throw new Error('无法创建皮肤渲染画布')
|
||||
return { canvas: buffer, ctx }
|
||||
}
|
||||
|
||||
function loadImage(src: string): Promise<HTMLImageElement> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const img = new Image()
|
||||
img.crossOrigin = 'anonymous'
|
||||
img.onload = () => resolve(img)
|
||||
img.onerror = () => reject(new Error('无法加载皮肤图片'))
|
||||
img.src = src
|
||||
})
|
||||
}
|
||||
|
||||
/** Crop the head (and hat overlay) out of a skin image URL. Returns a data URL. */
|
||||
export async function renderSkinHead(skinUrl: string, scale = 2): Promise<string> {
|
||||
const img = await loadImage(skinUrl)
|
||||
const { canvas, ctx } = getBuffer()
|
||||
|
||||
canvas.width = HEAD_BUFFER_SIZE
|
||||
canvas.height = HEAD_BUFFER_SIZE
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
||||
ctx.imageSmoothingEnabled = false
|
||||
|
||||
ctx.drawImage(
|
||||
img,
|
||||
HEAD_FACE.sx,
|
||||
HEAD_FACE.sy,
|
||||
HEAD_FACE.sw,
|
||||
HEAD_FACE.sh,
|
||||
HEAD_FACE.dx,
|
||||
HEAD_FACE.dy,
|
||||
HEAD_FACE.dw,
|
||||
HEAD_FACE.dh,
|
||||
)
|
||||
ctx.globalCompositeOperation = 'source-over'
|
||||
ctx.drawImage(
|
||||
img,
|
||||
HEAD_HAT.sx,
|
||||
HEAD_HAT.sy,
|
||||
HEAD_HAT.sw,
|
||||
HEAD_HAT.sh,
|
||||
HEAD_HAT.dx,
|
||||
HEAD_HAT.dy,
|
||||
HEAD_HAT.dw,
|
||||
HEAD_HAT.dh,
|
||||
)
|
||||
|
||||
if (scale <= 1) return canvas.toDataURL('image/png')
|
||||
|
||||
const small = await createImageBitmap(canvas)
|
||||
canvas.width = Math.floor(HEAD_BUFFER_SIZE * scale)
|
||||
canvas.height = Math.floor(HEAD_BUFFER_SIZE * scale)
|
||||
ctx.imageSmoothingEnabled = false
|
||||
ctx.drawImage(small, 0, 0, HEAD_BUFFER_SIZE, HEAD_BUFFER_SIZE, 0, 0, canvas.width, canvas.height)
|
||||
return canvas.toDataURL('image/png')
|
||||
}
|
||||
|
||||
/** Fetch an image URL as a data URL (used to keep full skin textures local). */
|
||||
export async function fetchImageAsDataUrl(url: string): Promise<string> {
|
||||
const response = await fetch(url)
|
||||
if (!response.ok) throw new Error(`无法加载图片(HTTP ${response.status})`)
|
||||
const blob = await response.blob()
|
||||
return await new Promise<string>((resolve, reject) => {
|
||||
const reader = new FileReader()
|
||||
reader.onload = () => resolve(String(reader.result ?? ''))
|
||||
reader.onerror = () => reject(new Error('无法读取图片数据'))
|
||||
reader.readAsDataURL(blob)
|
||||
})
|
||||
}
|
||||
@@ -11600,4 +11600,839 @@
|
||||
"app.library.context-menu.unpin-instance": {"message": "Unpin instance"},
|
||||
"app.library.group.new": {"message": "New group"},
|
||||
"app.library.selection.new-group": {"message": "New group"},
|
||||
"app.library.selection.remove-from-group": {"message": "Remove from group"}}
|
||||
"app.library.selection.remove-from-group": {"message": "Remove from group"},
|
||||
"app.log-share.settings.title": {"message": "Log sharing & AI analysis"},
|
||||
"app.log-share.settings.description": {"message": "Share crash diagnostics with LogShare for a structured summary and optional AI analysis. LogShare is preferred; mclo.gs is used as a fallback."},
|
||||
"app.log-share.settings.share-provider": {"message": "Log sharing service"},
|
||||
"app.log-share.settings.share-provider-description": {"message": "Where the diagnostic link is uploaded when you share it."},
|
||||
"app.log-share.settings.ai-source": {"message": "AI analysis source"},
|
||||
"app.log-share.settings.ai-source-logshare": {"message": "LogShare AI"},
|
||||
"app.log-share.settings.ai-source-custom": {"message": "Custom AI provider"},
|
||||
"app.log-share.settings.ai-source-description": {"message": "Both sources send a sanitized and shortened crash context. AI output may be inaccurate."},
|
||||
"app.log-share.settings.auto-upload": {"message": "Upload to get a structured summary automatically"},
|
||||
"app.log-share.settings.auto-upload-description": {"message": "Only effective in LogShare AI mode."},
|
||||
"app.log-share.settings.multi-file": {"message": "Multi-file upload"},
|
||||
"app.log-share.settings.multi-file-description": {"message": "Upload latest.log, crash reports, hs_err and launcher logs together."},
|
||||
"app.log-share.settings.no-storage": {"message": "Analyze without storing logs"},
|
||||
"app.log-share.settings.no-storage-description": {"message": "Submit content directly for analysis and skip the stored upload. Disables the automatic summary."},
|
||||
"app.log-share.settings.show-progress": {"message": "Show AI analysis progress"},
|
||||
"app.log-share.settings.show-progress-description": {"message": "Display thinking, tool and limit status while LogShare AI is working."},
|
||||
"app.log-share.shared-logs.title": {"message": "Shared logs"},
|
||||
"app.log-share.shared-logs.description": {"message": "Every diagnostic you have shared is listed here. Delete an entry to remove it from your history and request its removal from the sharing service."},
|
||||
"app.log-share.shared-logs.empty": {"message": "No shared logs yet."},
|
||||
"app.log-share.shared-logs.delete": {"message": "Delete"},
|
||||
"app.log-share.shared-logs.deleting": {"message": "Deleting…"},
|
||||
"app.log-share.shared-logs.deleted": {"message": "Shared log removed."},
|
||||
"app.log-share.shared-logs.delete-failed": {"message": "Failed to delete the shared log."},
|
||||
"app.log-share.shared-logs.truncated": {"message": "Truncated"},
|
||||
"app.minecraft-crash.share-fallback": {"message": "LogShare is unavailable, so the diagnostic was shared via mclo.gs."},
|
||||
"app.log-share.ai.action": {"message": "Deep AI analysis"},
|
||||
"app.log-share.summary.title": {"message": "LogShare analysis"},
|
||||
"app.log-share.summary.loading": {"message": "Loading structured summary..."},
|
||||
"app.log-share.summary.empty": {"message": "LogShare did not return a structured summary for these logs."},
|
||||
"app.log-share.summary.no-storage": {"message": "Structured summary is unavailable while no-storage mode is enabled."},
|
||||
"app.log-share.summary.failed": {"message": "Could not load the LogShare summary: {message}"},
|
||||
"app.log-share.summary.problems": {"message": "Problems"},
|
||||
"app.log-share.summary.information": {"message": "Information"},
|
||||
"app.minecraft-crash.logs.loading": {"message": "Loading crash logs..."},
|
||||
"app.minecraft-crash.logs.empty": {"message": "No logs from this launch were found."},
|
||||
"app.minecraft-crash.logs.failed": {"message": "Could not load the crash logs: {message}"},
|
||||
"app.minecraft-crash.log-file.loading": {"message": "Loading log file..."},
|
||||
"app.minecraft-crash.log-file.failed": {"message": "Could not load this log file: {message}"},
|
||||
"app.log-share.ai.tab": {"message": "LogAgent detailed analysis"},
|
||||
"app.log-share.ai.root-cause": {"message": "Core root cause"},
|
||||
"app.log-share.ai.confidence": {"message": "Diagnostic confidence"},
|
||||
"app.log-share.ai.steps": {"message": "Recommended troubleshooting steps"},
|
||||
"app.log-share.ai.evidence": {"message": "Supporting evidence"},
|
||||
"app.log-share.ai.thinking": {"message": "Thinking…"},
|
||||
"app.log-share.ai.queued": {"message": "Queued, about {position} ahead"},
|
||||
"app.log-share.ai.queued-front": {"message": "Queued, waiting for a free slot"},
|
||||
"app.log-share.ai.tool": {"message": "Using tool: {name}"},
|
||||
"app.log-share.ai.unknown-tool": {"message": "tool"},
|
||||
"app.log-share.ai.tool-result": {"message": "Tool result received"},
|
||||
"app.log-share.ai.limit": {"message": "Reached tool loop limit"},
|
||||
"app.log-share.ai.working": {"message": "Analyzing with LogAgent…"},
|
||||
"app.log-share.ai.failed": {"message": "LogAgent analysis failed: {message}"},
|
||||
"app.shortcut-settings.change-shortcut": {"message": "Change the shortcut for {action}"},
|
||||
"app.shortcut-settings.enable": {"message": "Enable quick scrolling"},
|
||||
"app.shortcut-settings.end-action": {"message": "Scroll to the bottom"},
|
||||
"app.shortcut-settings.end-action-description": {"message": "Moves the page you are reading to the bottom."},
|
||||
"app.shortcut-settings.home-action": {"message": "Scroll to the top"},
|
||||
"app.shortcut-settings.home-action-description": {"message": "Moves the page you are reading to the top."},
|
||||
"app.shortcut-settings.nav-create": {"message": "Create new instance"},
|
||||
"app.shortcut-settings.nav-create-description": {"message": "Jump to creating a new instance."},
|
||||
"app.shortcut-settings.nav-description": {"message": "Jump to a menu item with its shortcut. Each shortcut is off until enabled."},
|
||||
"app.shortcut-settings.nav-discover": {"message": "Discover content"},
|
||||
"app.shortcut-settings.nav-discover-description": {"message": "Jump to browsing content."},
|
||||
"app.shortcut-settings.nav-downloads": {"message": "Downloads"},
|
||||
"app.shortcut-settings.nav-downloads-description": {"message": "Jump to downloads."},
|
||||
"app.shortcut-settings.nav-home": {"message": "Home"},
|
||||
"app.shortcut-settings.nav-home-description": {"message": "Jump to the Home page."},
|
||||
"app.shortcut-settings.nav-lab": {"message": "Lab"},
|
||||
"app.shortcut-settings.nav-lab-description": {"message": "Jump to the Lab."},
|
||||
"app.shortcut-settings.nav-library": {"message": "Library"},
|
||||
"app.shortcut-settings.nav-library-description": {"message": "Jump to your library."},
|
||||
"app.shortcut-settings.nav-multiplayer": {"message": "Multiplayer"},
|
||||
"app.shortcut-settings.nav-multiplayer-description": {"message": "Jump to multiplayer."},
|
||||
"app.shortcut-settings.nav-settings": {"message": "Settings"},
|
||||
"app.shortcut-settings.nav-settings-description": {"message": "Jump to the settings."},
|
||||
"app.shortcut-settings.nav-skins": {"message": "Skin selector"},
|
||||
"app.shortcut-settings.nav-skins-description": {"message": "Jump to the skin selector."},
|
||||
"app.shortcut-settings.nav-title": {"message": "Navigation shortcuts"},
|
||||
"app.shortcut-settings.nav-worlds": {"message": "Worlds"},
|
||||
"app.shortcut-settings.nav-worlds-description": {"message": "Jump to your worlds."},
|
||||
"app.shortcut-settings.page-down-action": {"message": "Scroll down one screen"},
|
||||
"app.shortcut-settings.page-down-action-description": {"message": "Moves the page you are reading down by one screen."},
|
||||
"app.shortcut-settings.page-up-action": {"message": "Scroll up one screen"},
|
||||
"app.shortcut-settings.page-up-action-description": {"message": "Moves the page you are reading up by one screen."},
|
||||
"app.shortcut-settings.scroll-description": {"message": "Move through long pages with the keyboard."},
|
||||
"app.shortcut-settings.scroll-title": {"message": "Quick scrolling"},
|
||||
"app.settings.tabs.shortcut-settings": {"message": "Keyboard shortcuts"},
|
||||
"app.skin-site.bugs.title": {"message": "Bugs & suggestions"},
|
||||
"app.skin-site.bugs.back": {"message": "Back to home"},
|
||||
"app.skin-site.bugs.subtitle": {"message": "Report issues and follow their progress."},
|
||||
"app.skin-site.bugs.loading": {"message": "Loading…"},
|
||||
"app.skin-site.bugs.failed": {"message": "Could not load issues."},
|
||||
"app.skin-site.bugs.empty": {"message": "No issues match these filters."},
|
||||
"app.skin-site.bugs.all": {"message": "All"},
|
||||
"app.skin-site.bugs.more": {"message": "Load more"},
|
||||
"app.skin-site.bugs.open-only": {"message": "Open only"},
|
||||
"app.skin-site.bugs.comments": {"message": "{count} comments"},
|
||||
"app.skin-site.bugs.type.bug": {"message": "Bug"},
|
||||
"app.skin-site.bugs.type.feature": {"message": "Feature"},
|
||||
"app.skin-site.bugs.type.improvement": {"message": "Improvement"},
|
||||
"app.skin-site.bugs.status.pending": {"message": "Pending"},
|
||||
"app.skin-site.bugs.status.confirmed": {"message": "Confirmed"},
|
||||
"app.skin-site.bugs.status.needs-info": {"message": "Needs info"},
|
||||
"app.skin-site.bugs.status.in-progress": {"message": "In progress"},
|
||||
"app.skin-site.bugs.status.verifying": {"message": "Verifying"},
|
||||
"app.skin-site.bugs.status.closed": {"message": "Closed"},
|
||||
"app.skin-site.bugs.priority.critical": {"message": "Critical"},
|
||||
"app.skin-site.bugs.priority.high": {"message": "High"},
|
||||
"app.skin-site.bugs.priority.normal": {"message": "Normal"},
|
||||
"app.skin-site.bugs.priority.low": {"message": "Low"},
|
||||
"app.skin-site.bugs.resolution.fixed": {"message": "Fixed"},
|
||||
"app.skin-site.bugs.resolution.wont-fix": {"message": "Won’t fix"},
|
||||
"app.skin-site.bugs.resolution.by-design": {"message": "By design"},
|
||||
"app.skin-site.bugs.resolution.duplicate": {"message": "Duplicate"},
|
||||
"app.skin-site.bugs.resolution.cannot-reproduce": {"message": "Cannot reproduce"},
|
||||
"app.skin-site.bugs.resolution.invalid": {"message": "Invalid"},
|
||||
"app.skin-site.bug-detail.back": {"message": "Back to list"},
|
||||
"app.skin-site.bug-detail.loading": {"message": "Loading…"},
|
||||
"app.skin-site.bug-detail.failed": {"message": "Could not load this issue."},
|
||||
"app.skin-site.bug-detail.issue-no": {"message": "Issue #{id}"},
|
||||
"app.skin-site.bug-detail.by": {"message": "by {name}"},
|
||||
"app.skin-site.bug-detail.assignee": {"message": "Assignee: {name}"},
|
||||
"app.skin-site.bug-detail.unassigned": {"message": "Unassigned"},
|
||||
"app.skin-site.bug-detail.description-empty": {"message": "No description provided."},
|
||||
"app.skin-site.bug-detail.resolution": {"message": "Resolution: {name}"},
|
||||
"app.skin-site.bug-detail.comments-title": {"message": "Comments"},
|
||||
"app.skin-site.bug-detail.comments-empty": {"message": "No comments yet. Be the first to reply."},
|
||||
"app.skin-site.bug-detail.comments-loading": {"message": "Loading comments…"},
|
||||
"app.skin-site.bug-detail.comment-placeholder": {"message": "Write a comment…"},
|
||||
"app.skin-site.bug-detail.comment-submit": {"message": "Comment"},
|
||||
"app.skin-site.bug-detail.comment-sending": {"message": "Sending…"},
|
||||
"app.skin-site.bug-detail.comment-empty-error": {"message": "Comment cannot be empty."},
|
||||
"app.skin-site.bug-detail.comment-posted": {"message": "Comment posted."},
|
||||
"app.skin-site.bug-detail.comment-deleted": {"message": "Comment deleted."},
|
||||
"app.skin-site.bug-detail.delete": {"message": "Delete"},
|
||||
"app.skin-site.bug-detail.deleting": {"message": "Deleting…"},
|
||||
"app.skin-site.bug-detail.system": {"message": "System"},
|
||||
"app.skin-site.bug-create.title": {"message": "New issue"},
|
||||
"app.skin-site.bug-create.type": {"message": "Type"},
|
||||
"app.skin-site.bug-create.title-field": {"message": "Title"},
|
||||
"app.skin-site.bug-create.title-placeholder": {"message": "A short summary of the problem"},
|
||||
"app.skin-site.bug-create.description": {"message": "Description"},
|
||||
"app.skin-site.bug-create.description-placeholder": {"message": "What happened, and how can it be reproduced?"},
|
||||
"app.skin-site.bug-create.private": {"message": "Private issue"},
|
||||
"app.skin-site.bug-create.private-hint": {"message": "Only you and the maintainers can see it."},
|
||||
"app.skin-site.bug-create.images": {"message": "Images"},
|
||||
"app.skin-site.bug-create.images-hint": {"message": "Optional, up to 5 images."},
|
||||
"app.skin-site.bug-create.submit": {"message": "Create issue"},
|
||||
"app.skin-site.bug-create.submitting": {"message": "Creating…"},
|
||||
"app.skin-site.bug-create.created": {"message": "Issue created."},
|
||||
"app.skin-site.bug-create.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.bug-notifications.title": {"message": "Notifications"},
|
||||
"app.skin-site.bug-notifications.back": {"message": "Back to home"},
|
||||
"app.skin-site.bug-notifications.subtitle": {"message": "Activity on issues you reported or follow."},
|
||||
"app.skin-site.bug-notifications.loading": {"message": "Loading…"},
|
||||
"app.skin-site.bug-notifications.failed": {"message": "Could not load notifications."},
|
||||
"app.skin-site.bug-notifications.empty": {"message": "No new notifications."},
|
||||
"app.skin-site.bug-notifications.item": {"message": "{name} updated issue #{id}"},
|
||||
"app.skin-site.bug-notifications.mark-all": {"message": "Mark all as read"},
|
||||
"app.skin-site.bug-notifications.marked-all": {"message": "All notifications marked as read."},
|
||||
"app.skin-site.bugs.create": {"message": "New issue"},
|
||||
"app.skin-site.bugs.notifications": {"message": "Notifications"},
|
||||
"app.skin-site.home.title": {"message": "StarLight Skin Site"},
|
||||
"app.skin-site.home.subtitle": {"message": "The wardrobe for StarLight Server players."},
|
||||
"app.skin-site.home.address": {"message": "Skin site address"},
|
||||
"app.skin-site.home.copied": {"message": "Address copied."},
|
||||
"app.skin-site.home.copy": {"message": "Copy"},
|
||||
"app.skin-site.admin.title": {"message": "Admin console"},
|
||||
"app.skin-site.admin.back": {"message": "Back to home"},
|
||||
"app.skin-site.admin.no-access": {"message": "You do not have access."},
|
||||
"app.skin-site.admin.no-access-hint": {"message": "Sign in with an administrator account to use this console."},
|
||||
"app.skin-site.admin.group.security": {"message": "Security"},
|
||||
"app.skin-site.admin.group.users": {"message": "Users"},
|
||||
"app.skin-site.admin.group.community": {"message": "Community"},
|
||||
"app.skin-site.admin.group.resources": {"message": "Resources"},
|
||||
"app.skin-site.admin.item.servers": {"message": "Servers"},
|
||||
"app.skin-site.admin.item.summary": {"message": "Summary"},
|
||||
"app.skin-site.admin.item.access-audit": {"message": "Access audit"},
|
||||
"app.skin-site.admin.item.users": {"message": "Users"},
|
||||
"app.skin-site.admin.item.players": {"message": "Players"},
|
||||
"app.skin-site.admin.item.review": {"message": "Player review"},
|
||||
"app.skin-site.admin.item.broadcast": {"message": "Broadcast"},
|
||||
"app.skin-site.admin.item.chat": {"message": "Chat rooms"},
|
||||
"app.skin-site.admin.item.wiki": {"message": "Wiki"},
|
||||
"app.skin-site.admin.item.donations": {"message": "Donations"},
|
||||
"app.skin-site.admin.item.mods": {"message": "Mods"},
|
||||
"app.skin-site.admin.item.launcher": {"message": "Launcher"},
|
||||
"app.skin-site.admin.item.downloads": {"message": "Downloads"},
|
||||
"app.skin-site.home.admin": {"message": "Admin"},
|
||||
"app.skin-site.home.settings": {"message": "Account"},
|
||||
"app.skin-site.home.sign-in": {"message": "Sign in"},
|
||||
"app.skin-site.home.players": {"message": "Players"},
|
||||
"app.skin-site.home.my-players": {"message": "My players"},
|
||||
"app.skin-site.home.no-players": {"message": "No players linked yet."},
|
||||
"app.skin-site.home.loading": {"message": "Loading…"},
|
||||
"app.skin-site.home.error": {"message": "Could not load."},
|
||||
"app.skin-site.home.luck": {"message": "Luck"},
|
||||
"app.skin-site.home.luck-unavailable": {"message": "Unavailable"},
|
||||
"app.skin-site.home.signed-out-title": {"message": "Not signed in"},
|
||||
"app.skin-site.home.signed-out-body": {"message": "Sign in to manage your account and textures."},
|
||||
"app.skin-site.admin.summary.title": {"message": "System overview"},
|
||||
"app.skin-site.admin.summary.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.summary.failed": {"message": "Could not load status."},
|
||||
"app.skin-site.admin.summary.uptime": {"message": "Uptime"},
|
||||
"app.skin-site.admin.summary.memory": {"message": "Memory usage"},
|
||||
"app.skin-site.admin.summary.users": {"message": "Users"},
|
||||
"app.skin-site.admin.summary.players": {"message": "Players"},
|
||||
"app.skin-site.admin.summary.realtime-hint": {"message": "Live CPU and GC charts require the admin WebSocket, which is not connected yet."},
|
||||
"app.skin-site.admin.broadcast.title": {"message": "Announcements"},
|
||||
"app.skin-site.admin.broadcast.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.broadcast.failed": {"message": "Could not load."},
|
||||
"app.skin-site.admin.broadcast.empty": {"message": "No announcements yet."},
|
||||
"app.skin-site.admin.broadcast.create": {"message": "New announcement"},
|
||||
"app.skin-site.admin.broadcast.save": {"message": "Save"},
|
||||
"app.skin-site.admin.broadcast.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.broadcast.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.broadcast.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.broadcast.title-field": {"message": "Title"},
|
||||
"app.skin-site.admin.broadcast.subtitle-field": {"message": "Subtitle"},
|
||||
"app.skin-site.admin.broadcast.content-field": {"message": "Content"},
|
||||
"app.skin-site.admin.broadcast.expire-at": {"message": "Expires at"},
|
||||
"app.skin-site.admin.broadcast.star": {"message": "Highlight"},
|
||||
"app.skin-site.admin.broadcast.level": {"message": "Importance"},
|
||||
"app.skin-site.admin.broadcast.image": {"message": "Image"},
|
||||
"app.skin-site.admin.broadcast.remove-image": {"message": "Remove image"},
|
||||
"app.skin-site.admin.broadcast.created": {"message": "Announcement created."},
|
||||
"app.skin-site.admin.broadcast.updated": {"message": "Announcement updated."},
|
||||
"app.skin-site.admin.broadcast.deleted": {"message": "Announcement deleted."},
|
||||
"app.skin-site.admin.broadcast.confirm-delete": {"message": "Delete “{title}”? This cannot be undone."},
|
||||
"app.skin-site.admin.broadcast.uploader": {"message": "by {name}"},
|
||||
"app.skin-site.admin.players.title": {"message": "Players"},
|
||||
"app.skin-site.admin.players.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.players.failed": {"message": "Could not load players."},
|
||||
"app.skin-site.admin.players.empty": {"message": "No players found."},
|
||||
"app.skin-site.admin.players.search": {"message": "Search"},
|
||||
"app.skin-site.admin.players.search-name": {"message": "Name"},
|
||||
"app.skin-site.admin.players.search-owner": {"message": "Owner"},
|
||||
"app.skin-site.admin.players.search-uuid": {"message": "UUID"},
|
||||
"app.skin-site.admin.players.total": {"message": "{count} players"},
|
||||
"app.skin-site.admin.players.prev": {"message": "Previous"},
|
||||
"app.skin-site.admin.players.next": {"message": "Next"},
|
||||
"app.skin-site.admin.players.page": {"message": "Page {page}"},
|
||||
"app.skin-site.admin.players.name": {"message": "Name"},
|
||||
"app.skin-site.admin.players.owner": {"message": "Owner"},
|
||||
"app.skin-site.admin.players.source": {"message": "Source"},
|
||||
"app.skin-site.admin.players.legacy": {"message": "Legacy adapted"},
|
||||
"app.skin-site.admin.players.actions": {"message": "Actions"},
|
||||
"app.skin-site.admin.players.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.players.save": {"message": "Save"},
|
||||
"app.skin-site.admin.players.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.players.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.players.updated": {"message": "Player updated."},
|
||||
"app.skin-site.admin.players.deleted": {"message": "Player deleted."},
|
||||
"app.skin-site.admin.players.confirm-delete": {"message": "Delete player “{name}”? This cannot be undone."},
|
||||
"app.skin-site.admin.players.mojang": {"message": "Mojang"},
|
||||
"app.skin-site.admin.players.custom": {"message": "Skin site"},
|
||||
"app.skin-site.admin.users.title": {"message": "Users"},
|
||||
"app.skin-site.admin.users.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.users.failed": {"message": "Could not load users."},
|
||||
"app.skin-site.admin.users.empty": {"message": "No users found."},
|
||||
"app.skin-site.admin.users.search": {"message": "Search"},
|
||||
"app.skin-site.admin.users.search-name": {"message": "Username"},
|
||||
"app.skin-site.admin.users.search-email": {"message": "Email"},
|
||||
"app.skin-site.admin.users.search-uuid": {"message": "UUID"},
|
||||
"app.skin-site.admin.users.total": {"message": "{count} users"},
|
||||
"app.skin-site.admin.users.prev": {"message": "Previous"},
|
||||
"app.skin-site.admin.users.next": {"message": "Next"},
|
||||
"app.skin-site.admin.users.page": {"message": "Page {page}"},
|
||||
"app.skin-site.admin.users.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.users.save": {"message": "Save"},
|
||||
"app.skin-site.admin.users.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.users.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.users.players": {"message": "Players"},
|
||||
"app.skin-site.admin.users.updated": {"message": "User updated."},
|
||||
"app.skin-site.admin.users.deleted": {"message": "User deleted."},
|
||||
"app.skin-site.admin.users.confirm-delete": {"message": "Delete user “{name}”? This cannot be undone."},
|
||||
"app.skin-site.admin.users.username": {"message": "Username"},
|
||||
"app.skin-site.admin.users.email": {"message": "Email"},
|
||||
"app.skin-site.admin.users.qq": {"message": "QQ"},
|
||||
"app.skin-site.admin.users.password": {"message": "New password"},
|
||||
"app.skin-site.admin.users.password-hint": {"message": "Leave empty to keep the current password."},
|
||||
"app.skin-site.admin.users.banned": {"message": "Banned"},
|
||||
"app.skin-site.admin.users.permissions": {"message": "Permissions"},
|
||||
"app.skin-site.admin.users.permissions-hint": {"message": "Comma separated, e.g. WEB_ADMIN, SERVER_ADMIN."},
|
||||
"app.skin-site.admin.users.no-players": {"message": "No linked players."},
|
||||
"app.skin-site.admin.users.registered": {"message": "Registered"},
|
||||
"app.skin-site.admin.review.title": {"message": "Player review"},
|
||||
"app.skin-site.admin.review.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.review.failed": {"message": "Could not load submissions."},
|
||||
"app.skin-site.admin.review.empty": {"message": "No submissions found."},
|
||||
"app.skin-site.admin.review.total": {"message": "{count} submissions"},
|
||||
"app.skin-site.admin.review.filter-all": {"message": "All"},
|
||||
"app.skin-site.admin.review.filter-pending": {"message": "Pending"},
|
||||
"app.skin-site.admin.review.filter-passed": {"message": "Passed"},
|
||||
"app.skin-site.admin.review.filter-rejected": {"message": "Rejected"},
|
||||
"app.skin-site.admin.review.result-pending": {"message": "Pending"},
|
||||
"app.skin-site.admin.review.result-passed": {"message": "Passed"},
|
||||
"app.skin-site.admin.review.result-rejected": {"message": "Rejected"},
|
||||
"app.skin-site.admin.review.mode-auto": {"message": "Auto"},
|
||||
"app.skin-site.admin.review.mode-manual": {"message": "Manual"},
|
||||
"app.skin-site.admin.review.applicant": {"message": "Applicant"},
|
||||
"app.skin-site.admin.review.submitted-at": {"message": "Submitted"},
|
||||
"app.skin-site.admin.review.score": {"message": "Score"},
|
||||
"app.skin-site.admin.review.reviewer": {"message": "Reviewer"},
|
||||
"app.skin-site.admin.review.details": {"message": "Details"},
|
||||
"app.skin-site.admin.review.hide": {"message": "Hide"},
|
||||
"app.skin-site.admin.review.answers": {"message": "Answers"},
|
||||
"app.skin-site.admin.review.no-answers": {"message": "No answers."},
|
||||
"app.skin-site.admin.review.auto-checks": {"message": "Automatic checks"},
|
||||
"app.skin-site.admin.review.context": {"message": "Submission context"},
|
||||
"app.skin-site.admin.review.ip": {"message": "IP"},
|
||||
"app.skin-site.admin.review.user-agent": {"message": "User agent"},
|
||||
"app.skin-site.admin.review.activity": {"message": "Activity"},
|
||||
"app.skin-site.admin.review.duration": {"message": "Duration"},
|
||||
"app.skin-site.admin.review.hidden-time": {"message": "Hidden time"},
|
||||
"app.skin-site.admin.review.screen-switches": {"message": "Screen switches"},
|
||||
"app.skin-site.admin.review.history": {"message": "Decision history"},
|
||||
"app.skin-site.admin.review.accept": {"message": "Accept"},
|
||||
"app.skin-site.admin.review.reject": {"message": "Reject"},
|
||||
"app.skin-site.admin.review.reason": {"message": "Reason"},
|
||||
"app.skin-site.admin.review.accept-done": {"message": "Submission accepted."},
|
||||
"app.skin-site.admin.review.reject-done": {"message": "Submission rejected."},
|
||||
"app.skin-site.admin.review.regen-invite": {"message": "Regenerate invite"},
|
||||
"app.skin-site.admin.review.invite-regenerated": {"message": "Invite code regenerated."},
|
||||
"app.skin-site.admin.review.invite-sent": {"message": "Email sent."},
|
||||
"app.skin-site.admin.review.invite-not-sent": {"message": "Email not sent."},
|
||||
"app.skin-site.admin.review.prev": {"message": "Previous"},
|
||||
"app.skin-site.admin.review.next": {"message": "Next"},
|
||||
"app.skin-site.admin.review.page": {"message": "Page {page}"},
|
||||
"app.skin-site.admin.launcher.title": {"message": "Launcher releases"},
|
||||
"app.skin-site.admin.launcher.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.launcher.failed": {"message": "Could not load releases."},
|
||||
"app.skin-site.admin.launcher.empty": {"message": "No releases uploaded yet."},
|
||||
"app.skin-site.admin.launcher.latest-url": {"message": "Latest URL"},
|
||||
"app.skin-site.admin.launcher.version": {"message": "Version"},
|
||||
"app.skin-site.admin.launcher.channel": {"message": "Channel"},
|
||||
"app.skin-site.admin.launcher.uploader": {"message": "Uploaded by"},
|
||||
"app.skin-site.admin.launcher.uploaded-at": {"message": "Uploaded"},
|
||||
"app.skin-site.admin.launcher.published-at": {"message": "Published"},
|
||||
"app.skin-site.admin.launcher.force-update": {"message": "Forced"},
|
||||
"app.skin-site.admin.launcher.active": {"message": "Active"},
|
||||
"app.skin-site.admin.launcher.activate": {"message": "Activate"},
|
||||
"app.skin-site.admin.launcher.activated": {"message": "Release activated."},
|
||||
"app.skin-site.admin.launcher.upload": {"message": "Upload release"},
|
||||
"app.skin-site.admin.launcher.upload-hint": {"message": "Choose a release ZIP (max 4 GiB)."},
|
||||
"app.skin-site.admin.launcher.uploading": {"message": "Uploading…"},
|
||||
"app.skin-site.admin.launcher.upload-done": {"message": "Release uploaded."},
|
||||
"app.skin-site.admin.launcher.force-flag": {"message": "Force update"},
|
||||
"app.skin-site.admin.launcher.prev": {"message": "Previous"},
|
||||
"app.skin-site.admin.launcher.next": {"message": "Next"},
|
||||
"app.skin-site.admin.launcher.page": {"message": "Page {page}"},
|
||||
"app.skin-site.admin.launcher.total": {"message": "{count} releases"},
|
||||
"app.skin-site.admin.downloads.title": {"message": "Downloads"},
|
||||
"app.skin-site.admin.downloads.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.downloads.failed": {"message": "Could not load downloads."},
|
||||
"app.skin-site.admin.downloads.empty": {"message": "No download items."},
|
||||
"app.skin-site.admin.downloads.categories": {"message": "Categories"},
|
||||
"app.skin-site.admin.downloads.all": {"message": "All items"},
|
||||
"app.skin-site.admin.downloads.add-category": {"message": "Add"},
|
||||
"app.skin-site.admin.downloads.category-name": {"message": "Category name"},
|
||||
"app.skin-site.admin.downloads.remove-category": {"message": "Remove"},
|
||||
"app.skin-site.admin.downloads.total": {"message": "{count} items"},
|
||||
"app.skin-site.admin.downloads.add-item": {"message": "New item"},
|
||||
"app.skin-site.admin.downloads.save": {"message": "Save"},
|
||||
"app.skin-site.admin.downloads.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.downloads.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.downloads.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.downloads.filename": {"message": "File name"},
|
||||
"app.skin-site.admin.downloads.description": {"message": "Description"},
|
||||
"app.skin-site.admin.downloads.routes": {"message": "Download routes"},
|
||||
"app.skin-site.admin.downloads.route-name": {"message": "Name"},
|
||||
"app.skin-site.admin.downloads.route-url": {"message": "URL"},
|
||||
"app.skin-site.admin.downloads.add-route": {"message": "Add route"},
|
||||
"app.skin-site.admin.downloads.remove-route": {"message": "Remove"},
|
||||
"app.skin-site.admin.downloads.statuses": {"message": "Statuses"},
|
||||
"app.skin-site.admin.downloads.bind-category": {"message": "Categories"},
|
||||
"app.skin-site.admin.downloads.uploader": {"message": "by {name}"},
|
||||
"app.skin-site.admin.downloads.created": {"message": "Item created."},
|
||||
"app.skin-site.admin.downloads.updated": {"message": "Item updated."},
|
||||
"app.skin-site.admin.downloads.deleted": {"message": "Item deleted."},
|
||||
"app.skin-site.admin.downloads.category-added": {"message": "Category added."},
|
||||
"app.skin-site.admin.downloads.category-deleted": {"message": "Category deleted."},
|
||||
"app.skin-site.admin.downloads.confirm-delete-item": {"message": "Delete “{name}”? This cannot be undone."},
|
||||
"app.skin-site.admin.downloads.confirm-delete-category": {"message": "Delete category “{name}”?"},
|
||||
"app.skin-site.admin.servers.title": {"message": "Map servers"},
|
||||
"app.skin-site.admin.servers.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.servers.failed": {"message": "Could not load servers."},
|
||||
"app.skin-site.admin.servers.empty": {"message": "No map servers configured."},
|
||||
"app.skin-site.admin.servers.server-name": {"message": "Server name"},
|
||||
"app.skin-site.admin.servers.internal": {"message": "Internal"},
|
||||
"app.skin-site.admin.servers.maps": {"message": "Maps"},
|
||||
"app.skin-site.admin.servers.map-name": {"message": "Map name"},
|
||||
"app.skin-site.admin.servers.map-url": {"message": "Map URL"},
|
||||
"app.skin-site.admin.servers.add-map": {"message": "Add map"},
|
||||
"app.skin-site.admin.servers.remove-map": {"message": "Remove"},
|
||||
"app.skin-site.admin.servers.add-server": {"message": "Add server"},
|
||||
"app.skin-site.admin.servers.remove-server": {"message": "Remove server"},
|
||||
"app.skin-site.admin.servers.save": {"message": "Save changes"},
|
||||
"app.skin-site.admin.servers.saving": {"message": "Saving…"},
|
||||
"app.skin-site.admin.servers.saved": {"message": "Map servers saved."},
|
||||
"app.skin-site.admin.audit.title": {"message": "Access audit"},
|
||||
"app.skin-site.admin.audit.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.audit.failed": {"message": "Could not load audit log."},
|
||||
"app.skin-site.admin.audit.empty": {"message": "No audit entries."},
|
||||
"app.skin-site.admin.audit.subject": {"message": "Subject"},
|
||||
"app.skin-site.admin.audit.action": {"message": "Action"},
|
||||
"app.skin-site.admin.audit.source-ip": {"message": "Source IP"},
|
||||
"app.skin-site.admin.audit.reported-ip": {"message": "Reported player IP"},
|
||||
"app.skin-site.admin.audit.count": {"message": "Count"},
|
||||
"app.skin-site.admin.audit.first-at": {"message": "First seen"},
|
||||
"app.skin-site.admin.audit.last-at": {"message": "Last seen"},
|
||||
"app.skin-site.admin.audit.proxy": {"message": "Proxy"},
|
||||
"app.skin-site.admin.audit.internal": {"message": "Internal"},
|
||||
"app.skin-site.admin.audit.search-subject": {"message": "Subject"},
|
||||
"app.skin-site.admin.audit.search-ip": {"message": "IP"},
|
||||
"app.skin-site.admin.audit.search-action": {"message": "Action"},
|
||||
"app.skin-site.admin.audit.search": {"message": "Search"},
|
||||
"app.skin-site.admin.audit.clear": {"message": "Clear"},
|
||||
"app.skin-site.admin.audit.load-more": {"message": "Load more"},
|
||||
"app.skin-site.admin.audit.retention": {"message": "Retention (days)"},
|
||||
"app.skin-site.admin.audit.record-limit": {"message": "Record limit"},
|
||||
"app.skin-site.admin.audit.save-retention": {"message": "Save"},
|
||||
"app.skin-site.admin.audit.retention-saved": {"message": "Retention updated."},
|
||||
"app.skin-site.admin.donations.title": {"message": "Donations"},
|
||||
"app.skin-site.admin.donations.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.donations.failed": {"message": "Could not load donations."},
|
||||
"app.skin-site.admin.donations.empty": {"message": "No donations yet."},
|
||||
"app.skin-site.admin.donations.total-amount": {"message": "Total"},
|
||||
"app.skin-site.admin.donations.donor-count": {"message": "Donors"},
|
||||
"app.skin-site.admin.donations.donor": {"message": "Donor"},
|
||||
"app.skin-site.admin.donations.amount": {"message": "Amount"},
|
||||
"app.skin-site.admin.donations.updated-at": {"message": "Updated"},
|
||||
"app.skin-site.admin.donations.external": {"message": "External"},
|
||||
"app.skin-site.admin.donations.linked": {"message": "Linked"},
|
||||
"app.skin-site.admin.donations.create": {"message": "Add donation"},
|
||||
"app.skin-site.admin.donations.save": {"message": "Save"},
|
||||
"app.skin-site.admin.donations.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.donations.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.donations.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.donations.amount-field": {"message": "Amount"},
|
||||
"app.skin-site.admin.donations.display-name": {"message": "Display name"},
|
||||
"app.skin-site.admin.donations.user-uuid": {"message": "User UUID"},
|
||||
"app.skin-site.admin.donations.qq": {"message": "QQ"},
|
||||
"app.skin-site.admin.donations.append-mode": {"message": "Append to existing amount"},
|
||||
"app.skin-site.admin.donations.created": {"message": "Donation created."},
|
||||
"app.skin-site.admin.donations.updated": {"message": "Donation updated."},
|
||||
"app.skin-site.admin.donations.deleted": {"message": "Donation deleted."},
|
||||
"app.skin-site.admin.donations.confirm-delete": {"message": "Delete the donation from “{name}”? This cannot be undone."},
|
||||
"app.skin-site.admin.donations.load-more": {"message": "Load more"},
|
||||
"app.skin-site.admin.mods.title": {"message": "Mods"},
|
||||
"app.skin-site.admin.mods.tab-mods": {"message": "Mod files"},
|
||||
"app.skin-site.admin.mods.tab-tags": {"message": "Rule tags"},
|
||||
"app.skin-site.admin.mods.tab-runtime": {"message": "Runtime"},
|
||||
"app.skin-site.admin.mods.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.mods.failed": {"message": "Could not load mods."},
|
||||
"app.skin-site.admin.mods.empty": {"message": "No mods found."},
|
||||
"app.skin-site.admin.mods.total": {"message": "{count} mods"},
|
||||
"app.skin-site.admin.mods.search": {"message": "Search by name"},
|
||||
"app.skin-site.admin.mods.filter-all": {"message": "All tags"},
|
||||
"app.skin-site.admin.mods.prev": {"message": "Previous"},
|
||||
"app.skin-site.admin.mods.next": {"message": "Next"},
|
||||
"app.skin-site.admin.mods.page": {"message": "Page {page}"},
|
||||
"app.skin-site.admin.mods.name": {"message": "Name"},
|
||||
"app.skin-site.admin.mods.version": {"message": "Version"},
|
||||
"app.skin-site.admin.mods.mod-id": {"message": "Mod ID"},
|
||||
"app.skin-site.admin.mods.size": {"message": "Size"},
|
||||
"app.skin-site.admin.mods.loaders": {"message": "Loaders"},
|
||||
"app.skin-site.admin.mods.domain-rules": {"message": "Domain rules"},
|
||||
"app.skin-site.admin.mods.edit": {"message": "Edit"},
|
||||
"app.skin-site.admin.mods.save": {"message": "Save"},
|
||||
"app.skin-site.admin.mods.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.admin.mods.remove": {"message": "Delete"},
|
||||
"app.skin-site.admin.mods.updated": {"message": "Mod updated."},
|
||||
"app.skin-site.admin.mods.deleted": {"message": "Mod deleted."},
|
||||
"app.skin-site.admin.mods.confirm-delete": {"message": "Delete mod “{name}”? This cannot be undone."},
|
||||
"app.skin-site.admin.mods.rule-tags": {"message": "Rule tags"},
|
||||
"app.skin-site.admin.mods.tag-name": {"message": "Tag name"},
|
||||
"app.skin-site.admin.mods.tag-rules": {"message": "Rules"},
|
||||
"app.skin-site.admin.mods.tag-rules-hint": {"message": "One rule per line."},
|
||||
"app.skin-site.admin.mods.new-tag": {"message": "New tag"},
|
||||
"app.skin-site.admin.mods.tag-created": {"message": "Tag created."},
|
||||
"app.skin-site.admin.mods.tag-updated": {"message": "Tag updated."},
|
||||
"app.skin-site.admin.mods.tag-deleted": {"message": "Tag deleted."},
|
||||
"app.skin-site.admin.mods.confirm-delete-tag": {"message": "Delete tag “{name}”?"},
|
||||
"app.skin-site.admin.mods.runtime": {"message": "Runtime releases"},
|
||||
"app.skin-site.admin.mods.manifest-url": {"message": "Manifest URL"},
|
||||
"app.skin-site.admin.mods.upload-runtime": {"message": "Upload runtime"},
|
||||
"app.skin-site.admin.mods.runtime-version": {"message": "Version"},
|
||||
"app.skin-site.admin.mods.uploading": {"message": "Uploading…"},
|
||||
"app.skin-site.admin.mods.runtime-uploaded": {"message": "Runtime uploaded."},
|
||||
"app.skin-site.admin.mods.activate": {"message": "Activate"},
|
||||
"app.skin-site.admin.mods.activated": {"message": "Runtime activated."},
|
||||
"app.skin-site.admin.mods.available": {"message": "Available"},
|
||||
"app.skin-site.admin.mods.unavailable": {"message": "Unavailable"},
|
||||
"app.skin-site.admin.mods.active": {"message": "Active"},
|
||||
"app.skin-site.admin.mods.uploader": {"message": "by {name}"},
|
||||
"app.skin-site.home.nav.title": {"message": "Skin site"},
|
||||
"app.skin-site.home.nav.download": {"message": "Downloads"},
|
||||
"app.skin-site.home.nav.download-desc": {"message": "Browse files shared by the server."},
|
||||
"app.skin-site.home.nav.review": {"message": "Player review"},
|
||||
"app.skin-site.home.nav.review-desc": {"message": "Submit and review player applications."},
|
||||
"app.skin-site.home.nav.wiki": {"message": "Server wiki"},
|
||||
"app.skin-site.home.nav.wiki-desc": {"message": "Guides and documentation for the server."},
|
||||
"app.skin-site.home.nav.bugs": {"message": "Bug tracker"},
|
||||
"app.skin-site.home.nav.bugs-desc": {"message": "Report issues and follow their progress."},
|
||||
"app.skin-site.home.nav.map": {"message": "Server map"},
|
||||
"app.skin-site.home.nav.map-desc": {"message": "Explore the live world map."},
|
||||
"app.skin-site.home.nav.profile": {"message": "Profile"},
|
||||
"app.skin-site.home.nav.profile-desc": {"message": "Manage your account and textures."},
|
||||
"app.skin-site.admin.wiki.title": {"message": "Wiki"},
|
||||
"app.skin-site.admin.wiki.tab-page": {"message": "Page"},
|
||||
"app.skin-site.admin.wiki.tab-audit": {"message": "Audit log"},
|
||||
"app.skin-site.admin.wiki.tab-settings": {"message": "Settings"},
|
||||
"app.skin-site.admin.wiki.loading": {"message": "Loading…"},
|
||||
"app.skin-site.admin.wiki.page-path": {"message": "Page path"},
|
||||
"app.skin-site.admin.wiki.load-page": {"message": "Load page"},
|
||||
"app.skin-site.admin.wiki.page-not-found": {"message": "Page not found."},
|
||||
"app.skin-site.admin.wiki.revision": {"message": "Revision"},
|
||||
"app.skin-site.admin.wiki.author": {"message": "Author"},
|
||||
"app.skin-site.admin.wiki.updated-at": {"message": "Updated"},
|
||||
"app.skin-site.admin.wiki.categories": {"message": "Categories"},
|
||||
"app.skin-site.admin.wiki.read-policy": {"message": "Read policy"},
|
||||
"app.skin-site.admin.wiki.edit-policy": {"message": "Edit policy"},
|
||||
"app.skin-site.admin.wiki.save-protect": {"message": "Save policies"},
|
||||
"app.skin-site.admin.wiki.protect-saved": {"message": "Page policies updated."},
|
||||
"app.skin-site.admin.wiki.set-home": {"message": "Set as home page"},
|
||||
"app.skin-site.admin.wiki.home-set": {"message": "Home page updated."},
|
||||
"app.skin-site.admin.wiki.set-deleted": {"message": "Mark as deleted"},
|
||||
"app.skin-site.admin.wiki.set-restored": {"message": "Restore page"},
|
||||
"app.skin-site.admin.wiki.deleted-updated": {"message": "Page deletion state updated."},
|
||||
"app.skin-site.admin.wiki.audit-empty": {"message": "No audit entries."},
|
||||
"app.skin-site.admin.wiki.audit-target": {"message": "Target"},
|
||||
"app.skin-site.admin.wiki.load-more": {"message": "Load more"},
|
||||
"app.skin-site.admin.wiki.settings-hint": {"message": "Comma separated domains."},
|
||||
"app.skin-site.admin.wiki.domains": {"message": "Domains"},
|
||||
"app.skin-site.admin.wiki.home-page": {"message": "Home page"},
|
||||
"app.skin-site.admin.wiki.default-skin": {"message": "Default skin"},
|
||||
"app.skin-site.admin.wiki.max-page-bytes": {"message": "Max page bytes"},
|
||||
"app.skin-site.admin.wiki.max-attachment-bytes": {"message": "Max attachment bytes"},
|
||||
"app.skin-site.admin.wiki.save-settings": {"message": "Save settings"},
|
||||
"app.skin-site.admin.wiki.settings-saved": {"message": "Settings saved."},
|
||||
"app.skin-site.admin.review.tab-list": {"message": "Submissions"},
|
||||
"app.skin-site.admin.review.tab-papers": {"message": "Papers"},
|
||||
"app.skin-site.admin.review.papers-empty": {"message": "No review papers yet."},
|
||||
"app.skin-site.admin.review.new-paper": {"message": "New paper"},
|
||||
"app.skin-site.admin.review.edit-paper": {"message": "Edit"},
|
||||
"app.skin-site.admin.review.paper-title": {"message": "Title"},
|
||||
"app.skin-site.admin.review.paper-annotation": {"message": "Description"},
|
||||
"app.skin-site.admin.review.paper-enabled": {"message": "Enabled"},
|
||||
"app.skin-site.admin.review.paper-mode": {"message": "Mode"},
|
||||
"app.skin-site.admin.review.paper-pass-score": {"message": "Pass score"},
|
||||
"app.skin-site.admin.review.paper-target-permissions": {"message": "Target permissions"},
|
||||
"app.skin-site.admin.review.paper-questions": {"message": "Questions"},
|
||||
"app.skin-site.admin.review.add-question": {"message": "Add question"},
|
||||
"app.skin-site.admin.review.question-title": {"message": "Question title"},
|
||||
"app.skin-site.admin.review.question-type": {"message": "Type"},
|
||||
"app.skin-site.admin.review.question-score": {"message": "Score"},
|
||||
"app.skin-site.admin.review.question-annotation": {"message": "Annotation"},
|
||||
"app.skin-site.admin.review.add-option": {"message": "Add option"},
|
||||
"app.skin-site.admin.review.option-description": {"message": "Option text"},
|
||||
"app.skin-site.admin.review.option-correct": {"message": "Correct"},
|
||||
"app.skin-site.admin.review.remove-question": {"message": "Remove"},
|
||||
"app.skin-site.admin.review.question-no": {"message": "Question {n}"},
|
||||
"app.skin-site.admin.review.paper-created": {"message": "Paper created."},
|
||||
"app.skin-site.admin.review.paper-saved": {"message": "Paper saved."},
|
||||
"app.skin-site.admin.review.mail-title": {"message": "Pass mail"},
|
||||
"app.skin-site.admin.review.mail-enabled": {"message": "Send mail on pass"},
|
||||
"app.skin-site.admin.review.mail-subject": {"message": "Subject"},
|
||||
"app.skin-site.admin.review.mail-message": {"message": "Body"},
|
||||
"app.skin-site.admin.review.mail-extra": {"message": "Extra text"},
|
||||
"app.skin-site.admin.review.mail-include-invite": {"message": "Include invite code"},
|
||||
"app.skin-site.admin.review.prevent-duplicate": {"message": "Reject duplicate submissions"},
|
||||
"app.skin-site.admin.review.copy-link": {"message": "Copy link"},
|
||||
"app.skin-site.admin.review.link-copied": {"message": "Link copied."},
|
||||
"app.skin-site.admin.review.move-up": {"message": "Move up"},
|
||||
"app.skin-site.admin.review.move-down": {"message": "Move down"},
|
||||
"app.skin-site.admin.review.mail-subject-required": {"message": "Subject is required when mail is enabled."},
|
||||
"app.skin-site.admin.review.mail-message-required": {"message": "Body is required when mail is enabled."},
|
||||
"app.skin-site.admin.users.actions": {"message": "Actions"},
|
||||
"app.skin-site.admin.users.audit": {"message": "Audit"},
|
||||
"app.skin-site.admin.users.audit-empty": {"message": "No audit records yet."},
|
||||
"app.skin-site.admin.users.audit-more": {"message": "Load earlier"},
|
||||
"app.skin-site.admin.users.audit-title": {"message": "User management audit"},
|
||||
"app.skin-site.admin.users.bot": {"message": "Bot"},
|
||||
"app.skin-site.admin.users.bot-active": {"message": "Token valid"},
|
||||
"app.skin-site.admin.users.bot-ban": {"message": "Ban bot creation"},
|
||||
"app.skin-site.admin.users.bot-creation-banned": {"message": "Token creation banned"},
|
||||
"app.skin-site.admin.users.bot-exists": {"message": "Bot created"},
|
||||
"app.skin-site.admin.users.bot-inactive": {"message": "Token invalidated"},
|
||||
"app.skin-site.admin.users.bot-invalidate": {"message": "Invalidate token"},
|
||||
"app.skin-site.admin.users.bot-not-exists": {"message": "No bot yet"},
|
||||
"app.skin-site.admin.users.bot-save-username": {"message": "Save bot username"},
|
||||
"app.skin-site.admin.users.bot-title": {"message": "Bot management"},
|
||||
"app.skin-site.admin.users.bot-token-hint": {"message": "Token hint"},
|
||||
"app.skin-site.admin.users.bot-unban": {"message": "Unban bot creation"},
|
||||
"app.skin-site.admin.users.bot-username": {"message": "Bot username"},
|
||||
"app.skin-site.admin.users.bound-players-title": {"message": "Linked players"},
|
||||
"app.skin-site.admin.users.frequency": {"message": "Rate limit"},
|
||||
"app.skin-site.admin.users.frequency-clear": {"message": "Clear limit"},
|
||||
"app.skin-site.admin.users.frequency-current": {"message": "Currently {percent}%"},
|
||||
"app.skin-site.admin.users.frequency-hint": {"message": "Packets from this user will be dropped at the given rate."},
|
||||
"app.skin-site.admin.users.frequency-none": {"message": "Not enabled"},
|
||||
"app.skin-site.admin.users.frequency-range": {"message": "Only integer values from 10% to 100% are allowed."},
|
||||
"app.skin-site.admin.users.frequency-save": {"message": "Save limit"},
|
||||
"app.skin-site.admin.users.frequency-title": {"message": "Rate limit"},
|
||||
"app.skin-site.admin.users.invite": {"message": "Invite user"},
|
||||
"app.skin-site.admin.users.invite-copied": {"message": "Invite code copied."},
|
||||
"app.skin-site.admin.users.invite-copy": {"message": "Copy"},
|
||||
"app.skin-site.admin.users.invite-email": {"message": "Email"},
|
||||
"app.skin-site.admin.users.invite-email-invalid": {"message": "Enter a valid email address."},
|
||||
"app.skin-site.admin.users.invite-generate": {"message": "Generate invite code"},
|
||||
"app.skin-site.admin.users.invite-title": {"message": "Invite user"},
|
||||
"app.skin-site.admin.users.legacy-adapted": {"message": "Legacy internal adapted"},
|
||||
"app.skin-site.admin.users.registered-at": {"message": "Registered at"},
|
||||
"app.skin-site.admin.users.status": {"message": "Status"},
|
||||
"app.skin-site.admin.users.status-banned": {"message": "Banned"},
|
||||
"app.skin-site.admin.users.status-normal": {"message": "Normal"},
|
||||
"app.skin-site.admin.mods.upload": {"message": "Upload"},
|
||||
"app.skin-site.admin.mods.select-mode": {"message": "Select multiple"},
|
||||
"app.skin-site.admin.mods.exit-select": {"message": "Done selecting"},
|
||||
"app.skin-site.admin.mods.select-all": {"message": "Select all"},
|
||||
"app.skin-site.admin.mods.clear-selection": {"message": "Clear selection"},
|
||||
"app.skin-site.admin.mods.selected-count": {"message": "{count} selected"},
|
||||
"app.skin-site.admin.mods.delete-selected": {"message": "Delete selected"},
|
||||
"app.skin-site.admin.mods.confirm-delete-multi": {"message": "Delete {count} selected mods? This cannot be undone."},
|
||||
"app.skin-site.admin.mods.deleted-multi": {"message": "Selected mods deleted."},
|
||||
"app.skin-site.admin.mods.server-address": {"message": "Server address"},
|
||||
"app.skin-site.admin.mods.server-address-hint": {"message": "Filter by server address"},
|
||||
"app.skin-site.admin.mods.apply": {"message": "Apply"},
|
||||
"app.skin-site.admin.mods.clear": {"message": "Clear"},
|
||||
"app.skin-site.admin.mods.upload-title": {"message": "Upload mods"},
|
||||
"app.skin-site.admin.mods.upload-drop": {"message": "Drag .jar files here, or click to choose"},
|
||||
"app.skin-site.admin.mods.upload-sub": {"message": "Multiple files supported, up to {size} MB each"},
|
||||
"app.skin-site.admin.mods.upload-tags": {"message": "Attach rule tags"},
|
||||
"app.skin-site.admin.mods.upload-queue": {"message": "Files"},
|
||||
"app.skin-site.admin.mods.upload-pending": {"message": "Pending"},
|
||||
"app.skin-site.admin.mods.upload-checking": {"message": "Checking…"},
|
||||
"app.skin-site.admin.mods.upload-uploading": {"message": "Uploading…"},
|
||||
"app.skin-site.admin.mods.upload-conflict": {"message": "Name exists"},
|
||||
"app.skin-site.admin.mods.upload-success": {"message": "Done"},
|
||||
"app.skin-site.admin.mods.upload-error": {"message": "Failed"},
|
||||
"app.skin-site.admin.mods.upload-exists": {"message": "This file already exists on the server."},
|
||||
"app.skin-site.admin.mods.upload-name-conflict": {"message": "A mod with the same file name already exists"},
|
||||
"app.skin-site.admin.mods.upload-name-conflict-hint": {"message": "Overwrite the existing mod, or skip this file."},
|
||||
"app.skin-site.admin.mods.upload-overwrite": {"message": "Overwrite"},
|
||||
"app.skin-site.admin.mods.upload-skip": {"message": "Skip"},
|
||||
"app.skin-site.admin.mods.upload-close": {"message": "Close"},
|
||||
"app.skin-site.admin.mods.upload-all-done": {"message": "All files processed."},
|
||||
"app.skin-site.admin.mods.upload-too-large": {"message": "File too large: {name}"},
|
||||
"app.skin-site.chat.avatar.label": {"message": "Room avatar"},
|
||||
"app.skin-site.chat.avatar.upload": {"message": "Upload avatar"},
|
||||
"app.skin-site.chat.avatar.replace": {"message": "Replace avatar"},
|
||||
"app.skin-site.chat.avatar.remove": {"message": "Remove avatar"},
|
||||
"app.skin-site.chat.avatar.hint": {"message": "PNG, JPEG or WebP, up to 8192 px per side and 5 MB."},
|
||||
"app.skin-site.chat.avatar.bad-format": {"message": "Only PNG, JPEG and WebP are supported."},
|
||||
"app.skin-site.chat.avatar.too-large": {"message": "Avatar must not exceed 5 MB."},
|
||||
"app.skin-site.chat.avatar.not-image": {"message": "Avatar must be an image."},
|
||||
"app.skin-site.chat.admin.title": {"message": "Chat rooms"},
|
||||
"app.skin-site.chat.admin.subtitle": {"message": "Create public or private rooms and hand daily moderation to trusted members."},
|
||||
"app.skin-site.chat.admin.create-room": {"message": "Create room"},
|
||||
"app.skin-site.chat.admin.loading": {"message": "Loading…"},
|
||||
"app.skin-site.chat.admin.failed": {"message": "Could not load rooms."},
|
||||
"app.skin-site.chat.admin.empty": {"message": "No chat rooms yet."},
|
||||
"app.skin-site.chat.admin.edit": {"message": "Edit"},
|
||||
"app.skin-site.chat.admin.remove": {"message": "Delete"},
|
||||
"app.skin-site.chat.admin.save": {"message": "Save"},
|
||||
"app.skin-site.chat.admin.cancel": {"message": "Cancel"},
|
||||
"app.skin-site.chat.admin.name": {"message": "Name"},
|
||||
"app.skin-site.chat.admin.description": {"message": "Description"},
|
||||
"app.skin-site.chat.admin.visibility": {"message": "Visibility"},
|
||||
"app.skin-site.chat.admin.visibility-public": {"message": "Public"},
|
||||
"app.skin-site.chat.admin.visibility-private": {"message": "Private"},
|
||||
"app.skin-site.chat.admin.kind": {"message": "Kind"},
|
||||
"app.skin-site.chat.admin.kind-standard": {"message": "Standard"},
|
||||
"app.skin-site.chat.admin.kind-settlement": {"message": "Settlement"},
|
||||
"app.skin-site.chat.admin.prerequisite-mode": {"message": "Prerequisite mode"},
|
||||
"app.skin-site.chat.admin.prerequisite-any": {"message": "Any"},
|
||||
"app.skin-site.chat.admin.prerequisite-all": {"message": "All"},
|
||||
"app.skin-site.chat.admin.prerequisite-permissions": {"message": "Required permissions"},
|
||||
"app.skin-site.chat.admin.prerequisite-hint": {"message": "Comma separated. Leave empty for no restriction."},
|
||||
"app.skin-site.chat.admin.created": {"message": "Room created."},
|
||||
"app.skin-site.chat.admin.updated": {"message": "Room updated."},
|
||||
"app.skin-site.chat.admin.deleted": {"message": "Room deleted."},
|
||||
"app.skin-site.chat.admin.confirm-delete": {"message": "Permanently delete room “{name}” and all its messages?"},
|
||||
"app.skin-site.chat.admin.manager-badge": {"message": "Manager"},
|
||||
"app.skin-site.chat.admin.voice-badge": {"message": "Voice"},
|
||||
"app.skin-site.chat.user-picker.label": {"message": "Pick a user"},
|
||||
"app.skin-site.chat.user-picker.placeholder": {"message": "Search username, email or account ID"},
|
||||
"app.skin-site.chat.user-picker.by-user": {"message": "By user"},
|
||||
"app.skin-site.chat.user-picker.by-player": {"message": "By player"},
|
||||
"app.skin-site.chat.user-picker.hint": {"message": "Fuzzy search on username and email, or search by account ID."},
|
||||
"app.skin-site.chat.user-picker.player-hint": {"message": "Enter a player name to find the bound user."},
|
||||
"app.skin-site.chat.user-picker.empty": {"message": "No matching user."},
|
||||
"app.skin-site.chat.user-picker.banned": {"message": "This account is banned."},
|
||||
"app.skin-site.chat.user-picker.guest": {"message": "Guests cannot become a manager or settlement owner."},
|
||||
"app.skin-site.chat.user-picker.already-in": {"message": "This user is already in the room."},
|
||||
"app.skin-site.chat.user-picker.not-allowed": {"message": "This user is outside the allowed range."},
|
||||
"app.skin-site.chat.user-picker.select": {"message": "Select"},
|
||||
"app.skin-site.chat.user-picker.selected": {"message": "Selected"},
|
||||
"app.skin-site.chat.user-picker.id": {"message": "ID"},
|
||||
"app.skin-site.chat.admin.managers": {"message": "Managers"},
|
||||
"app.skin-site.chat.admin.manager-title": {"message": "Room manager"},
|
||||
"app.skin-site.chat.admin.manager-hint": {"message": "Managers can moderate members, messages and files in this room."},
|
||||
"app.skin-site.chat.admin.grant": {"message": "Grant"},
|
||||
"app.skin-site.chat.admin.revoke": {"message": "Revoke"},
|
||||
"app.skin-site.chat.admin.manager-granted": {"message": "Manager granted."},
|
||||
"app.skin-site.chat.admin.manager-revoked": {"message": "Manager revoked."},
|
||||
"app.skin-site.chat.admin.owner-title": {"message": "Settlement owner"},
|
||||
"app.skin-site.chat.admin.owner-hint": {"message": "Assign the first settlement owner for this room."},
|
||||
"app.skin-site.chat.admin.owner-assigned": {"message": "Settlement owner assigned."},
|
||||
"app.skin-site.chat.admin.owner-current": {"message": "Current owner: {name}"},
|
||||
"app.skin-site.chat.admin.owner-none": {"message": "No settlement owner yet."},
|
||||
"app.skin-site.chat.admin.audit": {"message": "Audit"},
|
||||
"app.skin-site.chat.admin.audit-title": {"message": "Room audit"},
|
||||
"app.skin-site.chat.admin.audit-empty": {"message": "No audit records yet."},
|
||||
"app.skin-site.chat.admin.audit-target": {"message": "Target: {name}"},
|
||||
"app.skin-site.chat.admin.close": {"message": "Close"},
|
||||
"app.skin-site.chat.voice-runtime-title": {"message": "Realtime voice runtime"},
|
||||
"app.skin-site.chat.voice-logs": {"message": "View logs"},
|
||||
"app.skin-site.chat.voice-config": {"message": "Configure runtime"},
|
||||
"app.skin-site.chat.voice-retry": {"message": "Retry deployment"},
|
||||
"app.skin-site.chat.voice-config-title": {"message": "Voice runtime configuration"},
|
||||
"app.skin-site.chat.voice-logs-title": {"message": "LiveKit logs"},
|
||||
"app.skin-site.chat.voice-capacity-title": {"message": "Voice capacity"},
|
||||
"app.skin-site.chat.voice-capacity": {"message": "Voice capacity"},
|
||||
"app.skin-site.chat.participant-limit": {"message": "Participant limit"},
|
||||
"app.skin-site.chat.listener-limit": {"message": "Listener limit"},
|
||||
"app.skin-site.chat.voice-capacity-updated": {"message": "Voice capacity updated."},
|
||||
"app.skin-site.chat.voice-enabled": {"message": "Enable realtime voice"},
|
||||
"app.skin-site.chat.voice-runtime-path": {"message": "Runtime directory"},
|
||||
"app.skin-site.chat.voice-mirror": {"message": "Mirror base URL"},
|
||||
"app.skin-site.chat.voice-public-url": {"message": "Public URL"},
|
||||
"app.skin-site.chat.voice-bind": {"message": "Bind address"},
|
||||
"app.skin-site.chat.voice-signal-port": {"message": "Signal port"},
|
||||
"app.skin-site.chat.voice-rtc-tcp-port": {"message": "Media TCP port"},
|
||||
"app.skin-site.chat.voice-rtc-udp-port": {"message": "Media UDP port"},
|
||||
"app.skin-site.chat.voice-startup-timeout": {"message": "Startup timeout (s)"},
|
||||
"app.skin-site.chat.voice-use-external-ip": {"message": "Use external IP"},
|
||||
"app.skin-site.chat.voice-node-ip": {"message": "Node IP"},
|
||||
"app.skin-site.chat.voice-saved": {"message": "Voice configuration saved."},
|
||||
"app.skin-site.chat.voice-logs-auto-refresh": {"message": "Auto refresh"},
|
||||
"app.skin-site.chat.voice-logs-refresh": {"message": "Refresh"},
|
||||
"app.skin-site.chat.voice-logs-empty": {"message": "No logs yet."},
|
||||
"app.skin-site.chat.admin.voice-runtime-title": {"message": "Realtime voice runtime"},
|
||||
"app.skin-site.chat.admin.voice-logs": {"message": "View logs"},
|
||||
"app.skin-site.chat.admin.voice-config": {"message": "Configure runtime"},
|
||||
"app.skin-site.chat.admin.voice-retry": {"message": "Retry deployment"},
|
||||
"app.skin-site.chat.admin.voice-config-title": {"message": "Voice runtime configuration"},
|
||||
"app.skin-site.chat.admin.voice-logs-title": {"message": "LiveKit logs"},
|
||||
"app.skin-site.chat.admin.voice-capacity-title": {"message": "Voice capacity"},
|
||||
"app.skin-site.chat.admin.voice-capacity": {"message": "Voice capacity"},
|
||||
"app.skin-site.chat.admin.participant-limit": {"message": "Participant limit"},
|
||||
"app.skin-site.chat.admin.listener-limit": {"message": "Listener limit"},
|
||||
"app.skin-site.chat.admin.voice-capacity-updated": {"message": "Voice capacity updated."},
|
||||
"app.skin-site.chat.admin.voice-enabled": {"message": "Enable realtime voice"},
|
||||
"app.skin-site.chat.admin.voice-runtime-path": {"message": "Runtime directory"},
|
||||
"app.skin-site.chat.admin.voice-mirror": {"message": "Mirror base URL"},
|
||||
"app.skin-site.chat.admin.voice-public-url": {"message": "Public URL"},
|
||||
"app.skin-site.chat.admin.voice-bind": {"message": "Bind address"},
|
||||
"app.skin-site.chat.admin.voice-signal-port": {"message": "Signal port"},
|
||||
"app.skin-site.chat.admin.voice-rtc-tcp-port": {"message": "Media TCP port"},
|
||||
"app.skin-site.chat.admin.voice-rtc-udp-port": {"message": "Media UDP port"},
|
||||
"app.skin-site.chat.admin.voice-startup-timeout": {"message": "Startup timeout (s)"},
|
||||
"app.skin-site.chat.admin.voice-use-external-ip": {"message": "Use external IP"},
|
||||
"app.skin-site.chat.admin.voice-node-ip": {"message": "Node IP"},
|
||||
"app.skin-site.chat.admin.voice-saved": {"message": "Voice configuration saved."},
|
||||
"app.skin-site.chat.admin.voice-logs-auto-refresh": {"message": "Auto refresh"},
|
||||
"app.skin-site.chat.admin.voice-logs-refresh": {"message": "Refresh"},
|
||||
"app.skin-site.chat.admin.voice-logs-empty": {"message": "No logs yet."},
|
||||
"app.skin-site.admin.wiki.tab-migration": {"message": "Migration"},
|
||||
"app.skin-site.admin.wiki.migration-title": {"message": "MediaWiki migration"},
|
||||
"app.skin-site.admin.wiki.migration-hint": {"message": "Migrated content lands in a hidden staging area and is published in one batch after every page is reviewed."},
|
||||
"app.skin-site.admin.wiki.auto-title": {"message": "Read from MediaWiki API"},
|
||||
"app.skin-site.admin.wiki.api-url": {"message": "api.php URL"},
|
||||
"app.skin-site.admin.wiki.bot-username": {"message": "Bot username (optional)"},
|
||||
"app.skin-site.admin.wiki.bot-password": {"message": "Bot password (optional)"},
|
||||
"app.skin-site.admin.wiki.credentials-hint": {"message": "Credentials stay in memory for this job only. HTTPS is required when supplied."},
|
||||
"app.skin-site.admin.wiki.allow-private": {"message": "Allow private network source"},
|
||||
"app.skin-site.admin.wiki.allow-private-hint": {"message": "Private sources may reach services inside the server network."},
|
||||
"app.skin-site.admin.wiki.start-auto": {"message": "Create automatic migration job"},
|
||||
"app.skin-site.admin.wiki.xml-title": {"message": "Import MediaWiki XML"},
|
||||
"app.skin-site.admin.wiki.xml-file": {"message": "Export file"},
|
||||
"app.skin-site.admin.wiki.start-xml": {"message": "Upload and stage"},
|
||||
"app.skin-site.admin.wiki.stale-rules": {"message": "Stale page detection rules"},
|
||||
"app.skin-site.admin.wiki.stale-days": {"message": "Days without update"},
|
||||
"app.skin-site.admin.wiki.maintainer-window": {"message": "Maintainer window (days)"},
|
||||
"app.skin-site.admin.wiki.max-maintainers": {"message": "Max maintainers"},
|
||||
"app.skin-site.admin.wiki.stale-markers": {"message": "Stale categories, templates or text"},
|
||||
"app.skin-site.admin.wiki.stale-markers-hint": {"message": "Comma separated"},
|
||||
"app.skin-site.admin.wiki.jobs": {"message": "Migration jobs"},
|
||||
"app.skin-site.admin.wiki.refresh-jobs": {"message": "Refresh"},
|
||||
"app.skin-site.admin.wiki.jobs-empty": {"message": "No migration jobs yet."},
|
||||
"app.skin-site.admin.wiki.reviewed-count": {"message": "Reviewed {reviewed} / {total}"},
|
||||
"app.skin-site.admin.wiki.imported-excluded": {"message": "Imported {imported} · Excluded {excluded}"},
|
||||
"app.skin-site.admin.wiki.view-job": {"message": "View job"},
|
||||
"app.skin-site.admin.wiki.delete-job": {"message": "Delete job record"},
|
||||
"app.skin-site.admin.wiki.confirm-delete-job": {"message": "Delete migration job #{id}? This cannot be undone."},
|
||||
"app.skin-site.admin.wiki.candidates": {"message": "Candidate pages"},
|
||||
"app.skin-site.admin.wiki.candidates-empty": {"message": "Select a job to review its pages."},
|
||||
"app.skin-site.admin.wiki.last-updated": {"message": "Updated {date}"},
|
||||
"app.skin-site.admin.wiki.maintainer-count": {"message": "{count} maintainers"},
|
||||
"app.skin-site.admin.wiki.conflict": {"message": "Title conflict"},
|
||||
"app.skin-site.admin.wiki.target-title": {"message": "Target title"},
|
||||
"app.skin-site.admin.wiki.overwrite": {"message": "Overwrite"},
|
||||
"app.skin-site.admin.wiki.import": {"message": "Import"},
|
||||
"app.skin-site.admin.wiki.exclude": {"message": "Exclude"},
|
||||
"app.skin-site.admin.wiki.publish": {"message": "Publish batch"},
|
||||
"app.skin-site.admin.wiki.rollback": {"message": "Roll back"},
|
||||
"app.skin-site.admin.wiki.confirm-rollback": {"message": "Roll back this migration batch? Published pages will be reverted."},
|
||||
"app.skin-site.admin.wiki.state-importing": {"message": "Importing"},
|
||||
"app.skin-site.admin.wiki.state-review": {"message": "Waiting review"},
|
||||
"app.skin-site.admin.wiki.state-publishing": {"message": "Publishing"},
|
||||
"app.skin-site.admin.wiki.state-published": {"message": "Published"},
|
||||
"app.skin-site.admin.wiki.state-failed": {"message": "Failed"},
|
||||
"app.skin-site.admin.wiki.state-rolled-back": {"message": "Rolled back"},
|
||||
"app.skin-site.admin.wiki.decision-pending": {"message": "Pending"},
|
||||
"app.skin-site.admin.wiki.decision-import": {"message": "Import"},
|
||||
"app.skin-site.admin.wiki.decision-exclude": {"message": "Exclude"},
|
||||
"app.skin-site.admin.wiki.migration-started": {"message": "Migration job created."},
|
||||
"app.skin-site.admin.wiki.xml-staged": {"message": "XML parsed and staged for review."},
|
||||
"app.skin-site.admin.wiki.published": {"message": "Published {imported} pages, overwrote {overwritten}."},
|
||||
"app.skin-site.admin.wiki.rolled-back": {"message": "Migration batch rolled back."},
|
||||
"app.skin-site.admin.wiki.job-deleted": {"message": "Migration record deleted."},
|
||||
"app.skin-site.admin.wiki.select-xml": {"message": "Choose a MediaWiki XML file first."},
|
||||
"app.skin-site.wiki.title": {"message": "StarLight Wiki"},
|
||||
"app.skin-site.wiki.search-placeholder": {"message": "Enter a page title"},
|
||||
"app.skin-site.wiki.open": {"message": "Open"},
|
||||
"app.skin-site.wiki.loading": {"message": "Loading…"},
|
||||
"app.skin-site.wiki.not-found": {"message": "Page not found."},
|
||||
"app.skin-site.wiki.empty": {"message": "Enter a page title above to start reading."},
|
||||
"app.skin-site.wiki.updated-at": {"message": "Last edited {date} by {author}"},
|
||||
"app.skin-site.wiki.revision": {"message": "Revision #{id}"},
|
||||
"app.skin-site.wiki.categories": {"message": "Categories"},
|
||||
"app.skin-site.wiki.back": {"message": "Back"}
|
||||
}
|
||||
@@ -11431,4 +11431,839 @@
|
||||
"app.library.context-menu.unpin-instance": {"message": "取消置顶"},
|
||||
"app.library.group.new": {"message": "新建分组"},
|
||||
"app.library.selection.new-group": {"message": "新建分组"},
|
||||
"app.library.selection.remove-from-group": {"message": "移出分组"}}
|
||||
"app.library.selection.remove-from-group": {"message": "移出分组"},
|
||||
"app.log-share.settings.title": {"message": "日志分享与 AI 分析"},
|
||||
"app.log-share.settings.description": {"message": "将崩溃诊断分享到 LogShare,获取结构化摘要与可选的 AI 分析。优先使用 LogShare,不可用时回退到 mclo.gs。"},
|
||||
"app.log-share.settings.share-provider": {"message": "日志分享服务"},
|
||||
"app.log-share.settings.share-provider-description": {"message": "分享诊断链接时上传到的目标服务。"},
|
||||
"app.log-share.settings.ai-source": {"message": "AI 分析来源"},
|
||||
"app.log-share.settings.ai-source-logshare": {"message": "LogShare AI"},
|
||||
"app.log-share.settings.ai-source-custom": {"message": "自定义 AI 服务商"},
|
||||
"app.log-share.settings.ai-source-description": {"message": "LogShare AI 在云端分析;自定义则使用下方配置的服务商。"},
|
||||
"app.log-share.settings.auto-upload": {"message": "自动上传以获取结构化摘要"},
|
||||
"app.log-share.settings.auto-upload-description": {"message": "仅在 LogShare 模式下生效。"},
|
||||
"app.log-share.settings.multi-file": {"message": "多文件上传"},
|
||||
"app.log-share.settings.multi-file-description": {"message": "同时上传 latest.log、崩溃报告、hs_err 以及启动器日志。"},
|
||||
"app.log-share.settings.no-storage": {"message": "不落盘直接分析"},
|
||||
"app.log-share.settings.no-storage-description": {"message": "直接提交内容进行分析并跳过存储上传。会关闭自动摘要。"},
|
||||
"app.log-share.settings.show-progress": {"message": "显示 AI 分析进度"},
|
||||
"app.log-share.settings.show-progress-description": {"message": "展示 LogAgent 运行期间的思考、工具及上限状态。"},
|
||||
"app.log-share.shared-logs.title": {"message": "已分享日志"},
|
||||
"app.log-share.shared-logs.description": {"message": "你分享过的所有诊断都记录在这里。删除条目会将其从记录中移除,并向分享服务请求删除。"},
|
||||
"app.log-share.shared-logs.empty": {"message": "暂无已分享的日志。"},
|
||||
"app.log-share.shared-logs.delete": {"message": "删除"},
|
||||
"app.log-share.shared-logs.deleting": {"message": "删除中…"},
|
||||
"app.log-share.shared-logs.deleted": {"message": "已删除共享日志。"},
|
||||
"app.log-share.shared-logs.delete-failed": {"message": "删除已分享日志失败。"},
|
||||
"app.log-share.shared-logs.truncated": {"message": "已截断"},
|
||||
"app.minecraft-crash.share-fallback": {"message": "LogShare 不可用,已改用 mclo.gs 分享诊断信息。"},
|
||||
"app.log-share.ai.action": {"message": "AI 深度分析"},
|
||||
"app.log-share.summary.title": {"message": "LogShare 分析"},
|
||||
"app.log-share.summary.loading": {"message": "正在加载结构化摘要…"},
|
||||
"app.log-share.summary.empty": {"message": "LogShare 未返回这些日志的结构化摘要。"},
|
||||
"app.log-share.summary.no-storage": {"message": "启用不落盘模式时无法获取结构化摘要。"},
|
||||
"app.log-share.summary.failed": {"message": "无法加载 LogShare 摘要:{message}"},
|
||||
"app.log-share.summary.problems": {"message": "问题"},
|
||||
"app.log-share.summary.information": {"message": "信息"},
|
||||
"app.minecraft-crash.logs.loading": {"message": "正在加载崩溃日志…"},
|
||||
"app.minecraft-crash.logs.empty": {"message": "未找到本次启动产生的日志。"},
|
||||
"app.minecraft-crash.logs.failed": {"message": "无法加载崩溃日志:{message}"},
|
||||
"app.minecraft-crash.log-file.loading": {"message": "正在加载日志文件…"},
|
||||
"app.minecraft-crash.log-file.failed": {"message": "无法加载此日志文件:{message}"},
|
||||
"app.log-share.ai.tab": {"message": "LogAgent 深度分析"},
|
||||
"app.log-share.ai.root-cause": {"message": "核心根因"},
|
||||
"app.log-share.ai.confidence": {"message": "诊断置信度"},
|
||||
"app.log-share.ai.steps": {"message": "推荐排障步骤"},
|
||||
"app.log-share.ai.evidence": {"message": "支撑证据链"},
|
||||
"app.log-share.ai.thinking": {"message": "思考中…"},
|
||||
"app.log-share.ai.queued": {"message": "排队中,前方约 {position} 个任务"},
|
||||
"app.log-share.ai.queued-front": {"message": "排队中,正在等待空闲槽位"},
|
||||
"app.log-share.ai.tool": {"message": "正在使用工具:{name}"},
|
||||
"app.log-share.ai.unknown-tool": {"message": "工具"},
|
||||
"app.log-share.ai.tool-result": {"message": "已收到工具结果"},
|
||||
"app.log-share.ai.limit": {"message": "已达到工具调用上限"},
|
||||
"app.log-share.ai.working": {"message": "正在使用 LogAgent 分析…"},
|
||||
"app.log-share.ai.failed": {"message": "LogAgent 分析失败:{message}"},
|
||||
"app.shortcut-settings.change-shortcut": {"message": "更改「{action}」的快捷键"},
|
||||
"app.shortcut-settings.enable": {"message": "启用快捷滚动"},
|
||||
"app.shortcut-settings.end-action": {"message": "滚动到页面底部"},
|
||||
"app.shortcut-settings.end-action-description": {"message": "将当前页面移动到底部。"},
|
||||
"app.shortcut-settings.home-action": {"message": "滚动到页面顶部"},
|
||||
"app.shortcut-settings.home-action-description": {"message": "将当前页面移动到顶部。"},
|
||||
"app.shortcut-settings.nav-create": {"message": "新建实例"},
|
||||
"app.shortcut-settings.nav-create-description": {"message": "前往新建实例。"},
|
||||
"app.shortcut-settings.nav-description": {"message": "使用各自的快捷键跳转到对应菜单项。每个快捷键默认关闭,需逐个启用。"},
|
||||
"app.shortcut-settings.nav-discover": {"message": "发现内容"},
|
||||
"app.shortcut-settings.nav-discover-description": {"message": "前往浏览内容。"},
|
||||
"app.shortcut-settings.nav-downloads": {"message": "下载"},
|
||||
"app.shortcut-settings.nav-downloads-description": {"message": "前往下载。"},
|
||||
"app.shortcut-settings.nav-home": {"message": "首页"},
|
||||
"app.shortcut-settings.nav-home-description": {"message": "前往首页。"},
|
||||
"app.shortcut-settings.nav-lab": {"message": "实验室"},
|
||||
"app.shortcut-settings.nav-lab-description": {"message": "前往实验室。"},
|
||||
"app.shortcut-settings.nav-library": {"message": "内容库"},
|
||||
"app.shortcut-settings.nav-library-description": {"message": "前往内容库。"},
|
||||
"app.shortcut-settings.nav-multiplayer": {"message": "多人游戏"},
|
||||
"app.shortcut-settings.nav-multiplayer-description": {"message": "前往多人游戏。"},
|
||||
"app.shortcut-settings.nav-settings": {"message": "设置"},
|
||||
"app.shortcut-settings.nav-settings-description": {"message": "前往设置。"},
|
||||
"app.shortcut-settings.nav-skins": {"message": "皮肤选择器"},
|
||||
"app.shortcut-settings.nav-skins-description": {"message": "前往皮肤选择器。"},
|
||||
"app.shortcut-settings.nav-title": {"message": "导航快捷键"},
|
||||
"app.shortcut-settings.nav-worlds": {"message": "世界"},
|
||||
"app.shortcut-settings.nav-worlds-description": {"message": "前往你的世界。"},
|
||||
"app.shortcut-settings.page-down-action": {"message": "向下滚动一屏"},
|
||||
"app.shortcut-settings.page-down-action-description": {"message": "将当前页面向下移动一屏。"},
|
||||
"app.shortcut-settings.page-up-action": {"message": "向上滚动一屏"},
|
||||
"app.shortcut-settings.page-up-action-description": {"message": "将当前页面向上移动一屏。"},
|
||||
"app.shortcut-settings.scroll-description": {"message": "使用键盘在长页面中快速滚动。"},
|
||||
"app.shortcut-settings.scroll-title": {"message": "快速滚动"},
|
||||
"app.settings.tabs.shortcut-settings": {"message": "键盘快捷键"},
|
||||
"app.skin-site.bugs.title": {"message": "问题与建议"},
|
||||
"app.skin-site.bugs.back": {"message": "返回主页"},
|
||||
"app.skin-site.bugs.subtitle": {"message": "反馈问题并跟踪处理进度。"},
|
||||
"app.skin-site.bugs.loading": {"message": "加载中…"},
|
||||
"app.skin-site.bugs.failed": {"message": "无法加载问题列表。"},
|
||||
"app.skin-site.bugs.empty": {"message": "没有符合筛选条件的问题。"},
|
||||
"app.skin-site.bugs.all": {"message": "全部"},
|
||||
"app.skin-site.bugs.more": {"message": "加载更多"},
|
||||
"app.skin-site.bugs.open-only": {"message": "仅显示未关闭"},
|
||||
"app.skin-site.bugs.comments": {"message": "{count} 条评论"},
|
||||
"app.skin-site.bugs.type.bug": {"message": "缺陷"},
|
||||
"app.skin-site.bugs.type.feature": {"message": "功能建议"},
|
||||
"app.skin-site.bugs.type.improvement": {"message": "改进"},
|
||||
"app.skin-site.bugs.status.pending": {"message": "待处理"},
|
||||
"app.skin-site.bugs.status.confirmed": {"message": "已确认"},
|
||||
"app.skin-site.bugs.status.needs-info": {"message": "待补充信息"},
|
||||
"app.skin-site.bugs.status.in-progress": {"message": "处理中"},
|
||||
"app.skin-site.bugs.status.verifying": {"message": "验证中"},
|
||||
"app.skin-site.bugs.status.closed": {"message": "已关闭"},
|
||||
"app.skin-site.bugs.priority.critical": {"message": "紧急"},
|
||||
"app.skin-site.bugs.priority.high": {"message": "高"},
|
||||
"app.skin-site.bugs.priority.normal": {"message": "普通"},
|
||||
"app.skin-site.bugs.priority.low": {"message": "低"},
|
||||
"app.skin-site.bugs.resolution.fixed": {"message": "已修复"},
|
||||
"app.skin-site.bugs.resolution.wont-fix": {"message": "不予修复"},
|
||||
"app.skin-site.bugs.resolution.by-design": {"message": "设计如此"},
|
||||
"app.skin-site.bugs.resolution.duplicate": {"message": "重复问题"},
|
||||
"app.skin-site.bugs.resolution.cannot-reproduce": {"message": "无法复现"},
|
||||
"app.skin-site.bugs.resolution.invalid": {"message": "无效"},
|
||||
"app.skin-site.bug-detail.back": {"message": "返回列表"},
|
||||
"app.skin-site.bug-detail.loading": {"message": "加载中…"},
|
||||
"app.skin-site.bug-detail.failed": {"message": "无法加载该问题。"},
|
||||
"app.skin-site.bug-detail.issue-no": {"message": "问题 #{id}"},
|
||||
"app.skin-site.bug-detail.by": {"message": "由 {name} 提交"},
|
||||
"app.skin-site.bug-detail.assignee": {"message": "负责人:{name}"},
|
||||
"app.skin-site.bug-detail.unassigned": {"message": "未分配"},
|
||||
"app.skin-site.bug-detail.description-empty": {"message": "未提供描述。"},
|
||||
"app.skin-site.bug-detail.resolution": {"message": "处理结果:{name}"},
|
||||
"app.skin-site.bug-detail.comments-title": {"message": "评论"},
|
||||
"app.skin-site.bug-detail.comments-empty": {"message": "还没有评论,来抢沙发吧。"},
|
||||
"app.skin-site.bug-detail.comments-loading": {"message": "加载评论中…"},
|
||||
"app.skin-site.bug-detail.comment-placeholder": {"message": "写下你的评论…"},
|
||||
"app.skin-site.bug-detail.comment-submit": {"message": "发表评论"},
|
||||
"app.skin-site.bug-detail.comment-sending": {"message": "发送中…"},
|
||||
"app.skin-site.bug-detail.comment-empty-error": {"message": "评论内容不能为空。"},
|
||||
"app.skin-site.bug-detail.comment-posted": {"message": "评论已发表。"},
|
||||
"app.skin-site.bug-detail.comment-deleted": {"message": "评论已删除。"},
|
||||
"app.skin-site.bug-detail.delete": {"message": "删除"},
|
||||
"app.skin-site.bug-detail.deleting": {"message": "删除中…"},
|
||||
"app.skin-site.bug-detail.system": {"message": "系统"},
|
||||
"app.skin-site.bug-create.title": {"message": "新建问题"},
|
||||
"app.skin-site.bug-create.type": {"message": "类型"},
|
||||
"app.skin-site.bug-create.title-field": {"message": "标题"},
|
||||
"app.skin-site.bug-create.title-placeholder": {"message": "简要描述问题"},
|
||||
"app.skin-site.bug-create.description": {"message": "描述"},
|
||||
"app.skin-site.bug-create.description-placeholder": {"message": "发生了什么?如何复现?"},
|
||||
"app.skin-site.bug-create.private": {"message": "私密问题"},
|
||||
"app.skin-site.bug-create.private-hint": {"message": "仅你和维护者可见。"},
|
||||
"app.skin-site.bug-create.images": {"message": "图片"},
|
||||
"app.skin-site.bug-create.images-hint": {"message": "可选,最多 5 张图片。"},
|
||||
"app.skin-site.bug-create.submit": {"message": "创建问题"},
|
||||
"app.skin-site.bug-create.submitting": {"message": "创建中…"},
|
||||
"app.skin-site.bug-create.created": {"message": "问题已创建。"},
|
||||
"app.skin-site.bug-create.cancel": {"message": "取消"},
|
||||
"app.skin-site.bug-notifications.title": {"message": "通知"},
|
||||
"app.skin-site.bug-notifications.back": {"message": "返回主页"},
|
||||
"app.skin-site.bug-notifications.subtitle": {"message": "你提交或关注的问题动态。"},
|
||||
"app.skin-site.bug-notifications.loading": {"message": "加载中…"},
|
||||
"app.skin-site.bug-notifications.failed": {"message": "无法加载通知。"},
|
||||
"app.skin-site.bug-notifications.empty": {"message": "暂无新通知。"},
|
||||
"app.skin-site.bug-notifications.item": {"message": "{name} 更新了问题 #{id}"},
|
||||
"app.skin-site.bug-notifications.mark-all": {"message": "全部标为已读"},
|
||||
"app.skin-site.bug-notifications.marked-all": {"message": "已将全部通知标为已读。"},
|
||||
"app.skin-site.bugs.create": {"message": "新建问题"},
|
||||
"app.skin-site.bugs.notifications": {"message": "通知"},
|
||||
"app.skin-site.home.title": {"message": "星光皮肤站"},
|
||||
"app.skin-site.home.subtitle": {"message": "星光服务器玩家的衣柜。"},
|
||||
"app.skin-site.home.address": {"message": "皮肤站地址"},
|
||||
"app.skin-site.home.copied": {"message": "地址已复制。"},
|
||||
"app.skin-site.home.copy": {"message": "复制"},
|
||||
"app.skin-site.admin.title": {"message": "管理控制台"},
|
||||
"app.skin-site.admin.back": {"message": "返回主页"},
|
||||
"app.skin-site.admin.no-access": {"message": "你没有访问权限。"},
|
||||
"app.skin-site.admin.no-access-hint": {"message": "请使用管理员账号登录后使用本控制台。"},
|
||||
"app.skin-site.admin.group.security": {"message": "系统安全"},
|
||||
"app.skin-site.admin.group.users": {"message": "用户管理"},
|
||||
"app.skin-site.admin.group.community": {"message": "社区管理"},
|
||||
"app.skin-site.admin.group.resources": {"message": "资源分发"},
|
||||
"app.skin-site.admin.item.servers": {"message": "服务器管理"},
|
||||
"app.skin-site.admin.item.summary": {"message": "状态概览"},
|
||||
"app.skin-site.admin.item.access-audit": {"message": "登录与认证审计"},
|
||||
"app.skin-site.admin.item.users": {"message": "用户信息"},
|
||||
"app.skin-site.admin.item.players": {"message": "玩家信息"},
|
||||
"app.skin-site.admin.item.review": {"message": "玩家审核"},
|
||||
"app.skin-site.admin.item.broadcast": {"message": "公告操作"},
|
||||
"app.skin-site.admin.item.chat": {"message": "聊天室管理"},
|
||||
"app.skin-site.admin.item.wiki": {"message": "维基管理"},
|
||||
"app.skin-site.admin.item.donations": {"message": "捐赠管理"},
|
||||
"app.skin-site.admin.item.mods": {"message": "Mod 管理"},
|
||||
"app.skin-site.admin.item.launcher": {"message": "启动器管理"},
|
||||
"app.skin-site.admin.item.downloads": {"message": "下载管理"},
|
||||
"app.skin-site.home.admin": {"message": "管理"},
|
||||
"app.skin-site.home.settings": {"message": "账号"},
|
||||
"app.skin-site.home.sign-in": {"message": "登录"},
|
||||
"app.skin-site.home.players": {"message": "角色"},
|
||||
"app.skin-site.home.my-players": {"message": "我的角色"},
|
||||
"app.skin-site.home.no-players": {"message": "尚未绑定角色。"},
|
||||
"app.skin-site.home.loading": {"message": "加载中…"},
|
||||
"app.skin-site.home.error": {"message": "加载失败。"},
|
||||
"app.skin-site.home.luck": {"message": "幸运值"},
|
||||
"app.skin-site.home.luck-unavailable": {"message": "不可用"},
|
||||
"app.skin-site.home.signed-out-title": {"message": "未登录"},
|
||||
"app.skin-site.home.signed-out-body": {"message": "登录后可管理你的账号与皮肤。"},
|
||||
"app.skin-site.admin.summary.title": {"message": "系统概况"},
|
||||
"app.skin-site.admin.summary.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.summary.failed": {"message": "无法加载状态。"},
|
||||
"app.skin-site.admin.summary.uptime": {"message": "运行时长"},
|
||||
"app.skin-site.admin.summary.memory": {"message": "内存占用"},
|
||||
"app.skin-site.admin.summary.users": {"message": "用户数量"},
|
||||
"app.skin-site.admin.summary.players": {"message": "玩家数量"},
|
||||
"app.skin-site.admin.summary.realtime-hint": {"message": "实时 CPU 与 GC 图表依赖管理端 WebSocket,目前尚未接入。"},
|
||||
"app.skin-site.admin.broadcast.title": {"message": "公告"},
|
||||
"app.skin-site.admin.broadcast.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.broadcast.failed": {"message": "加载失败。"},
|
||||
"app.skin-site.admin.broadcast.empty": {"message": "尚未发布过任何公告。"},
|
||||
"app.skin-site.admin.broadcast.create": {"message": "发布新公告"},
|
||||
"app.skin-site.admin.broadcast.save": {"message": "保存"},
|
||||
"app.skin-site.admin.broadcast.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.broadcast.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.broadcast.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.broadcast.title-field": {"message": "标题"},
|
||||
"app.skin-site.admin.broadcast.subtitle-field": {"message": "副标题"},
|
||||
"app.skin-site.admin.broadcast.content-field": {"message": "内容"},
|
||||
"app.skin-site.admin.broadcast.expire-at": {"message": "过期时间"},
|
||||
"app.skin-site.admin.broadcast.star": {"message": "标星"},
|
||||
"app.skin-site.admin.broadcast.level": {"message": "重要程度"},
|
||||
"app.skin-site.admin.broadcast.image": {"message": "图片"},
|
||||
"app.skin-site.admin.broadcast.remove-image": {"message": "移除图片"},
|
||||
"app.skin-site.admin.broadcast.created": {"message": "公告已发布。"},
|
||||
"app.skin-site.admin.broadcast.updated": {"message": "公告已更新。"},
|
||||
"app.skin-site.admin.broadcast.deleted": {"message": "公告已删除。"},
|
||||
"app.skin-site.admin.broadcast.confirm-delete": {"message": "确定删除「{title}」吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.broadcast.uploader": {"message": "由 {name} 发布"},
|
||||
"app.skin-site.admin.players.title": {"message": "玩家"},
|
||||
"app.skin-site.admin.players.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.players.failed": {"message": "无法加载玩家列表。"},
|
||||
"app.skin-site.admin.players.empty": {"message": "没有找到玩家。"},
|
||||
"app.skin-site.admin.players.search": {"message": "搜索"},
|
||||
"app.skin-site.admin.players.search-name": {"message": "名称"},
|
||||
"app.skin-site.admin.players.search-owner": {"message": "所有者"},
|
||||
"app.skin-site.admin.players.search-uuid": {"message": "UUID"},
|
||||
"app.skin-site.admin.players.total": {"message": "共 {count} 名玩家"},
|
||||
"app.skin-site.admin.players.prev": {"message": "上一页"},
|
||||
"app.skin-site.admin.players.next": {"message": "下一页"},
|
||||
"app.skin-site.admin.players.page": {"message": "第 {page} 页"},
|
||||
"app.skin-site.admin.players.name": {"message": "名称"},
|
||||
"app.skin-site.admin.players.owner": {"message": "所有者"},
|
||||
"app.skin-site.admin.players.source": {"message": "来源"},
|
||||
"app.skin-site.admin.players.legacy": {"message": "旧版适配"},
|
||||
"app.skin-site.admin.players.actions": {"message": "操作"},
|
||||
"app.skin-site.admin.players.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.players.save": {"message": "保存"},
|
||||
"app.skin-site.admin.players.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.players.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.players.updated": {"message": "玩家已更新。"},
|
||||
"app.skin-site.admin.players.deleted": {"message": "玩家已删除。"},
|
||||
"app.skin-site.admin.players.confirm-delete": {"message": "确定删除玩家「{name}」吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.players.mojang": {"message": "正版"},
|
||||
"app.skin-site.admin.players.custom": {"message": "皮肤站"},
|
||||
"app.skin-site.admin.users.title": {"message": "用户"},
|
||||
"app.skin-site.admin.users.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.users.failed": {"message": "无法加载用户列表。"},
|
||||
"app.skin-site.admin.users.empty": {"message": "没有找到用户。"},
|
||||
"app.skin-site.admin.users.search": {"message": "搜索"},
|
||||
"app.skin-site.admin.users.search-name": {"message": "用户名"},
|
||||
"app.skin-site.admin.users.search-email": {"message": "邮箱"},
|
||||
"app.skin-site.admin.users.search-uuid": {"message": "UUID"},
|
||||
"app.skin-site.admin.users.total": {"message": "共 {count} 名用户"},
|
||||
"app.skin-site.admin.users.prev": {"message": "上一页"},
|
||||
"app.skin-site.admin.users.next": {"message": "下一页"},
|
||||
"app.skin-site.admin.users.page": {"message": "第 {page} 页"},
|
||||
"app.skin-site.admin.users.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.users.save": {"message": "保存"},
|
||||
"app.skin-site.admin.users.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.users.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.users.players": {"message": "角色"},
|
||||
"app.skin-site.admin.users.updated": {"message": "用户已更新。"},
|
||||
"app.skin-site.admin.users.deleted": {"message": "用户已删除。"},
|
||||
"app.skin-site.admin.users.confirm-delete": {"message": "确定删除用户「{name}」吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.users.username": {"message": "用户名"},
|
||||
"app.skin-site.admin.users.email": {"message": "邮箱"},
|
||||
"app.skin-site.admin.users.qq": {"message": "QQ"},
|
||||
"app.skin-site.admin.users.password": {"message": "新密码"},
|
||||
"app.skin-site.admin.users.password-hint": {"message": "留空则保持原密码不变。"},
|
||||
"app.skin-site.admin.users.banned": {"message": "封禁"},
|
||||
"app.skin-site.admin.users.permissions": {"message": "权限"},
|
||||
"app.skin-site.admin.users.permissions-hint": {"message": "以逗号分隔,例如 WEB_ADMIN, SERVER_ADMIN。"},
|
||||
"app.skin-site.admin.users.no-players": {"message": "没有绑定的角色。"},
|
||||
"app.skin-site.admin.users.registered": {"message": "注册时间"},
|
||||
"app.skin-site.admin.review.title": {"message": "玩家审核"},
|
||||
"app.skin-site.admin.review.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.review.failed": {"message": "无法加载申请列表。"},
|
||||
"app.skin-site.admin.review.empty": {"message": "没有找到申请。"},
|
||||
"app.skin-site.admin.review.total": {"message": "共 {count} 份申请"},
|
||||
"app.skin-site.admin.review.filter-all": {"message": "全部"},
|
||||
"app.skin-site.admin.review.filter-pending": {"message": "待处理"},
|
||||
"app.skin-site.admin.review.filter-passed": {"message": "已通过"},
|
||||
"app.skin-site.admin.review.filter-rejected": {"message": "已拒绝"},
|
||||
"app.skin-site.admin.review.result-pending": {"message": "待处理"},
|
||||
"app.skin-site.admin.review.result-passed": {"message": "已通过"},
|
||||
"app.skin-site.admin.review.result-rejected": {"message": "已拒绝"},
|
||||
"app.skin-site.admin.review.mode-auto": {"message": "自动"},
|
||||
"app.skin-site.admin.review.mode-manual": {"message": "人工"},
|
||||
"app.skin-site.admin.review.applicant": {"message": "申请人"},
|
||||
"app.skin-site.admin.review.submitted-at": {"message": "提交时间"},
|
||||
"app.skin-site.admin.review.score": {"message": "得分"},
|
||||
"app.skin-site.admin.review.reviewer": {"message": "审核人"},
|
||||
"app.skin-site.admin.review.details": {"message": "详情"},
|
||||
"app.skin-site.admin.review.hide": {"message": "收起"},
|
||||
"app.skin-site.admin.review.answers": {"message": "作答内容"},
|
||||
"app.skin-site.admin.review.no-answers": {"message": "没有作答记录。"},
|
||||
"app.skin-site.admin.review.auto-checks": {"message": "自动检查"},
|
||||
"app.skin-site.admin.review.context": {"message": "提交环境"},
|
||||
"app.skin-site.admin.review.ip": {"message": "IP"},
|
||||
"app.skin-site.admin.review.user-agent": {"message": "浏览器标识"},
|
||||
"app.skin-site.admin.review.activity": {"message": "行为记录"},
|
||||
"app.skin-site.admin.review.duration": {"message": "时长"},
|
||||
"app.skin-site.admin.review.hidden-time": {"message": "切出时长"},
|
||||
"app.skin-site.admin.review.screen-switches": {"message": "切屏次数"},
|
||||
"app.skin-site.admin.review.history": {"message": "审核记录"},
|
||||
"app.skin-site.admin.review.accept": {"message": "通过"},
|
||||
"app.skin-site.admin.review.reject": {"message": "拒绝"},
|
||||
"app.skin-site.admin.review.reason": {"message": "理由"},
|
||||
"app.skin-site.admin.review.accept-done": {"message": "申请已通过。"},
|
||||
"app.skin-site.admin.review.reject-done": {"message": "申请已拒绝。"},
|
||||
"app.skin-site.admin.review.regen-invite": {"message": "重发邀请码"},
|
||||
"app.skin-site.admin.review.invite-regenerated": {"message": "邀请码已重新生成。"},
|
||||
"app.skin-site.admin.review.invite-sent": {"message": "邮件已发送。"},
|
||||
"app.skin-site.admin.review.invite-not-sent": {"message": "邮件未发送。"},
|
||||
"app.skin-site.admin.review.prev": {"message": "上一页"},
|
||||
"app.skin-site.admin.review.next": {"message": "下一页"},
|
||||
"app.skin-site.admin.review.page": {"message": "第 {page} 页"},
|
||||
"app.skin-site.admin.launcher.title": {"message": "启动器版本"},
|
||||
"app.skin-site.admin.launcher.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.launcher.failed": {"message": "无法加载版本列表。"},
|
||||
"app.skin-site.admin.launcher.empty": {"message": "尚未上传任何版本。"},
|
||||
"app.skin-site.admin.launcher.latest-url": {"message": "最新版本地址"},
|
||||
"app.skin-site.admin.launcher.version": {"message": "版本"},
|
||||
"app.skin-site.admin.launcher.channel": {"message": "渠道"},
|
||||
"app.skin-site.admin.launcher.uploader": {"message": "上传者"},
|
||||
"app.skin-site.admin.launcher.uploaded-at": {"message": "上传时间"},
|
||||
"app.skin-site.admin.launcher.published-at": {"message": "发布时间"},
|
||||
"app.skin-site.admin.launcher.force-update": {"message": "强制更新"},
|
||||
"app.skin-site.admin.launcher.active": {"message": "当前版本"},
|
||||
"app.skin-site.admin.launcher.activate": {"message": "设为当前"},
|
||||
"app.skin-site.admin.launcher.activated": {"message": "已设为当前版本。"},
|
||||
"app.skin-site.admin.launcher.upload": {"message": "上传版本"},
|
||||
"app.skin-site.admin.launcher.upload-hint": {"message": "选择发布包 ZIP(最大 4 GiB)。"},
|
||||
"app.skin-site.admin.launcher.uploading": {"message": "上传中…"},
|
||||
"app.skin-site.admin.launcher.upload-done": {"message": "版本已上传。"},
|
||||
"app.skin-site.admin.launcher.force-flag": {"message": "强制更新"},
|
||||
"app.skin-site.admin.launcher.prev": {"message": "上一页"},
|
||||
"app.skin-site.admin.launcher.next": {"message": "下一页"},
|
||||
"app.skin-site.admin.launcher.page": {"message": "第 {page} 页"},
|
||||
"app.skin-site.admin.launcher.total": {"message": "共 {count} 个版本"},
|
||||
"app.skin-site.admin.downloads.title": {"message": "资源下载"},
|
||||
"app.skin-site.admin.downloads.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.downloads.failed": {"message": "无法加载资源列表。"},
|
||||
"app.skin-site.admin.downloads.empty": {"message": "没有下载条目。"},
|
||||
"app.skin-site.admin.downloads.categories": {"message": "分类"},
|
||||
"app.skin-site.admin.downloads.all": {"message": "全部条目"},
|
||||
"app.skin-site.admin.downloads.add-category": {"message": "添加"},
|
||||
"app.skin-site.admin.downloads.category-name": {"message": "分类名称"},
|
||||
"app.skin-site.admin.downloads.remove-category": {"message": "移除"},
|
||||
"app.skin-site.admin.downloads.total": {"message": "共 {count} 个条目"},
|
||||
"app.skin-site.admin.downloads.add-item": {"message": "新建条目"},
|
||||
"app.skin-site.admin.downloads.save": {"message": "保存"},
|
||||
"app.skin-site.admin.downloads.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.downloads.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.downloads.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.downloads.filename": {"message": "文件名"},
|
||||
"app.skin-site.admin.downloads.description": {"message": "描述"},
|
||||
"app.skin-site.admin.downloads.routes": {"message": "下载线路"},
|
||||
"app.skin-site.admin.downloads.route-name": {"message": "名称"},
|
||||
"app.skin-site.admin.downloads.route-url": {"message": "URL"},
|
||||
"app.skin-site.admin.downloads.add-route": {"message": "添加线路"},
|
||||
"app.skin-site.admin.downloads.remove-route": {"message": "移除"},
|
||||
"app.skin-site.admin.downloads.statuses": {"message": "状态"},
|
||||
"app.skin-site.admin.downloads.bind-category": {"message": "所属分类"},
|
||||
"app.skin-site.admin.downloads.uploader": {"message": "由 {name} 上传"},
|
||||
"app.skin-site.admin.downloads.created": {"message": "条目已创建。"},
|
||||
"app.skin-site.admin.downloads.updated": {"message": "条目已更新。"},
|
||||
"app.skin-site.admin.downloads.deleted": {"message": "条目已删除。"},
|
||||
"app.skin-site.admin.downloads.category-added": {"message": "分类已添加。"},
|
||||
"app.skin-site.admin.downloads.category-deleted": {"message": "分类已删除。"},
|
||||
"app.skin-site.admin.downloads.confirm-delete-item": {"message": "确定删除「{name}」吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.downloads.confirm-delete-category": {"message": "确定删除分类「{name}」吗?"},
|
||||
"app.skin-site.admin.servers.title": {"message": "地图服务器"},
|
||||
"app.skin-site.admin.servers.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.servers.failed": {"message": "无法加载服务器列表。"},
|
||||
"app.skin-site.admin.servers.empty": {"message": "尚未配置地图服务器。"},
|
||||
"app.skin-site.admin.servers.server-name": {"message": "服务器名称"},
|
||||
"app.skin-site.admin.servers.internal": {"message": "内部"},
|
||||
"app.skin-site.admin.servers.maps": {"message": "地图"},
|
||||
"app.skin-site.admin.servers.map-name": {"message": "地图名称"},
|
||||
"app.skin-site.admin.servers.map-url": {"message": "地图地址"},
|
||||
"app.skin-site.admin.servers.add-map": {"message": "添加地图"},
|
||||
"app.skin-site.admin.servers.remove-map": {"message": "移除"},
|
||||
"app.skin-site.admin.servers.add-server": {"message": "添加服务器"},
|
||||
"app.skin-site.admin.servers.remove-server": {"message": "删除服务器"},
|
||||
"app.skin-site.admin.servers.save": {"message": "保存更改"},
|
||||
"app.skin-site.admin.servers.saving": {"message": "保存中…"},
|
||||
"app.skin-site.admin.servers.saved": {"message": "地图服务器已保存。"},
|
||||
"app.skin-site.admin.audit.title": {"message": "登录与认证审计"},
|
||||
"app.skin-site.admin.audit.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.audit.failed": {"message": "无法加载审计日志。"},
|
||||
"app.skin-site.admin.audit.empty": {"message": "没有审计记录。"},
|
||||
"app.skin-site.admin.audit.subject": {"message": "主体"},
|
||||
"app.skin-site.admin.audit.action": {"message": "操作"},
|
||||
"app.skin-site.admin.audit.source-ip": {"message": "来源 IP"},
|
||||
"app.skin-site.admin.audit.reported-ip": {"message": "上报玩家 IP"},
|
||||
"app.skin-site.admin.audit.count": {"message": "次数"},
|
||||
"app.skin-site.admin.audit.first-at": {"message": "首次出现"},
|
||||
"app.skin-site.admin.audit.last-at": {"message": "最近出现"},
|
||||
"app.skin-site.admin.audit.proxy": {"message": "代理"},
|
||||
"app.skin-site.admin.audit.internal": {"message": "内部"},
|
||||
"app.skin-site.admin.audit.search-subject": {"message": "主体"},
|
||||
"app.skin-site.admin.audit.search-ip": {"message": "IP"},
|
||||
"app.skin-site.admin.audit.search-action": {"message": "操作"},
|
||||
"app.skin-site.admin.audit.search": {"message": "搜索"},
|
||||
"app.skin-site.admin.audit.clear": {"message": "清空"},
|
||||
"app.skin-site.admin.audit.load-more": {"message": "加载更多"},
|
||||
"app.skin-site.admin.audit.retention": {"message": "保留天数"},
|
||||
"app.skin-site.admin.audit.record-limit": {"message": "记录上限"},
|
||||
"app.skin-site.admin.audit.save-retention": {"message": "保存"},
|
||||
"app.skin-site.admin.audit.retention-saved": {"message": "保留天数已更新。"},
|
||||
"app.skin-site.admin.donations.title": {"message": "捐赠管理"},
|
||||
"app.skin-site.admin.donations.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.donations.failed": {"message": "无法加载捐赠列表。"},
|
||||
"app.skin-site.admin.donations.empty": {"message": "暂无捐赠记录。"},
|
||||
"app.skin-site.admin.donations.total-amount": {"message": "总额"},
|
||||
"app.skin-site.admin.donations.donor-count": {"message": "捐赠人数"},
|
||||
"app.skin-site.admin.donations.donor": {"message": "捐赠者"},
|
||||
"app.skin-site.admin.donations.amount": {"message": "金额"},
|
||||
"app.skin-site.admin.donations.updated-at": {"message": "更新时间"},
|
||||
"app.skin-site.admin.donations.external": {"message": "外部"},
|
||||
"app.skin-site.admin.donations.linked": {"message": "已绑定"},
|
||||
"app.skin-site.admin.donations.create": {"message": "新增捐赠"},
|
||||
"app.skin-site.admin.donations.save": {"message": "保存"},
|
||||
"app.skin-site.admin.donations.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.donations.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.donations.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.donations.amount-field": {"message": "金额"},
|
||||
"app.skin-site.admin.donations.display-name": {"message": "显示名称"},
|
||||
"app.skin-site.admin.donations.user-uuid": {"message": "用户 UUID"},
|
||||
"app.skin-site.admin.donations.qq": {"message": "QQ"},
|
||||
"app.skin-site.admin.donations.append-mode": {"message": "在原有金额上累加"},
|
||||
"app.skin-site.admin.donations.created": {"message": "捐赠记录已创建。"},
|
||||
"app.skin-site.admin.donations.updated": {"message": "捐赠记录已更新。"},
|
||||
"app.skin-site.admin.donations.deleted": {"message": "捐赠记录已删除。"},
|
||||
"app.skin-site.admin.donations.confirm-delete": {"message": "确定删除「{name}」的捐赠记录吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.donations.load-more": {"message": "加载更多"},
|
||||
"app.skin-site.admin.mods.title": {"message": "Mod 管理"},
|
||||
"app.skin-site.admin.mods.tab-mods": {"message": "Mod 文件"},
|
||||
"app.skin-site.admin.mods.tab-tags": {"message": "规则标签"},
|
||||
"app.skin-site.admin.mods.tab-runtime": {"message": "运行时"},
|
||||
"app.skin-site.admin.mods.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.mods.failed": {"message": "无法加载 Mod 列表。"},
|
||||
"app.skin-site.admin.mods.empty": {"message": "没有找到 Mod。"},
|
||||
"app.skin-site.admin.mods.total": {"message": "共 {count} 个 Mod"},
|
||||
"app.skin-site.admin.mods.search": {"message": "按名称搜索"},
|
||||
"app.skin-site.admin.mods.filter-all": {"message": "全部标签"},
|
||||
"app.skin-site.admin.mods.prev": {"message": "上一页"},
|
||||
"app.skin-site.admin.mods.next": {"message": "下一页"},
|
||||
"app.skin-site.admin.mods.page": {"message": "第 {page} 页"},
|
||||
"app.skin-site.admin.mods.name": {"message": "名称"},
|
||||
"app.skin-site.admin.mods.version": {"message": "版本"},
|
||||
"app.skin-site.admin.mods.mod-id": {"message": "Mod ID"},
|
||||
"app.skin-site.admin.mods.size": {"message": "大小"},
|
||||
"app.skin-site.admin.mods.loaders": {"message": "加载器"},
|
||||
"app.skin-site.admin.mods.domain-rules": {"message": "域名规则"},
|
||||
"app.skin-site.admin.mods.edit": {"message": "编辑"},
|
||||
"app.skin-site.admin.mods.save": {"message": "保存"},
|
||||
"app.skin-site.admin.mods.cancel": {"message": "取消"},
|
||||
"app.skin-site.admin.mods.remove": {"message": "删除"},
|
||||
"app.skin-site.admin.mods.updated": {"message": "Mod 已更新。"},
|
||||
"app.skin-site.admin.mods.deleted": {"message": "Mod 已删除。"},
|
||||
"app.skin-site.admin.mods.confirm-delete": {"message": "确定删除 Mod「{name}」吗?此操作不可撤销。"},
|
||||
"app.skin-site.admin.mods.rule-tags": {"message": "规则标签"},
|
||||
"app.skin-site.admin.mods.tag-name": {"message": "标签名称"},
|
||||
"app.skin-site.admin.mods.tag-rules": {"message": "规则"},
|
||||
"app.skin-site.admin.mods.tag-rules-hint": {"message": "每行一条规则。"},
|
||||
"app.skin-site.admin.mods.new-tag": {"message": "新建标签"},
|
||||
"app.skin-site.admin.mods.tag-created": {"message": "标签已创建。"},
|
||||
"app.skin-site.admin.mods.tag-updated": {"message": "标签已更新。"},
|
||||
"app.skin-site.admin.mods.tag-deleted": {"message": "标签已删除。"},
|
||||
"app.skin-site.admin.mods.confirm-delete-tag": {"message": "确定删除标签「{name}」吗?"},
|
||||
"app.skin-site.admin.mods.runtime": {"message": "运行时版本"},
|
||||
"app.skin-site.admin.mods.manifest-url": {"message": "清单地址"},
|
||||
"app.skin-site.admin.mods.upload-runtime": {"message": "上传运行时"},
|
||||
"app.skin-site.admin.mods.runtime-version": {"message": "版本"},
|
||||
"app.skin-site.admin.mods.uploading": {"message": "上传中…"},
|
||||
"app.skin-site.admin.mods.runtime-uploaded": {"message": "运行时已上传。"},
|
||||
"app.skin-site.admin.mods.activate": {"message": "设为当前"},
|
||||
"app.skin-site.admin.mods.activated": {"message": "运行时已启用。"},
|
||||
"app.skin-site.admin.mods.available": {"message": "可用"},
|
||||
"app.skin-site.admin.mods.unavailable": {"message": "不可用"},
|
||||
"app.skin-site.admin.mods.active": {"message": "当前版本"},
|
||||
"app.skin-site.admin.mods.uploader": {"message": "由 {name} 上传"},
|
||||
"app.skin-site.home.nav.title": {"message": "皮肤站"},
|
||||
"app.skin-site.home.nav.download": {"message": "资源下载"},
|
||||
"app.skin-site.home.nav.download-desc": {"message": "浏览服务器分享的文件。"},
|
||||
"app.skin-site.home.nav.review": {"message": "玩家审核"},
|
||||
"app.skin-site.home.nav.review-desc": {"message": "提交并审核玩家申请。"},
|
||||
"app.skin-site.home.nav.wiki": {"message": "服务器维基"},
|
||||
"app.skin-site.home.nav.wiki-desc": {"message": "服务器的指南与文档。"},
|
||||
"app.skin-site.home.nav.bugs": {"message": "问题追踪"},
|
||||
"app.skin-site.home.nav.bugs-desc": {"message": "反馈问题并跟踪处理进度。"},
|
||||
"app.skin-site.home.nav.map": {"message": "服务器地图"},
|
||||
"app.skin-site.home.nav.map-desc": {"message": "探索实时世界地图。"},
|
||||
"app.skin-site.home.nav.profile": {"message": "个人资料"},
|
||||
"app.skin-site.home.nav.profile-desc": {"message": "管理你的账号与皮肤。"},
|
||||
"app.skin-site.admin.wiki.title": {"message": "维基管理"},
|
||||
"app.skin-site.admin.wiki.tab-page": {"message": "页面"},
|
||||
"app.skin-site.admin.wiki.tab-audit": {"message": "审计日志"},
|
||||
"app.skin-site.admin.wiki.tab-settings": {"message": "设置"},
|
||||
"app.skin-site.admin.wiki.loading": {"message": "加载中…"},
|
||||
"app.skin-site.admin.wiki.page-path": {"message": "页面路径"},
|
||||
"app.skin-site.admin.wiki.load-page": {"message": "加载页面"},
|
||||
"app.skin-site.admin.wiki.page-not-found": {"message": "未找到该页面。"},
|
||||
"app.skin-site.admin.wiki.revision": {"message": "版本"},
|
||||
"app.skin-site.admin.wiki.author": {"message": "作者"},
|
||||
"app.skin-site.admin.wiki.updated-at": {"message": "更新时间"},
|
||||
"app.skin-site.admin.wiki.categories": {"message": "分类"},
|
||||
"app.skin-site.admin.wiki.read-policy": {"message": "阅读权限"},
|
||||
"app.skin-site.admin.wiki.edit-policy": {"message": "编辑权限"},
|
||||
"app.skin-site.admin.wiki.save-protect": {"message": "保存权限"},
|
||||
"app.skin-site.admin.wiki.protect-saved": {"message": "页面权限已更新。"},
|
||||
"app.skin-site.admin.wiki.set-home": {"message": "设为首页"},
|
||||
"app.skin-site.admin.wiki.home-set": {"message": "首页已更新。"},
|
||||
"app.skin-site.admin.wiki.set-deleted": {"message": "标记为已删除"},
|
||||
"app.skin-site.admin.wiki.set-restored": {"message": "恢复页面"},
|
||||
"app.skin-site.admin.wiki.deleted-updated": {"message": "页面删除状态已更新。"},
|
||||
"app.skin-site.admin.wiki.audit-empty": {"message": "没有审计记录。"},
|
||||
"app.skin-site.admin.wiki.audit-target": {"message": "目标"},
|
||||
"app.skin-site.admin.wiki.load-more": {"message": "加载更多"},
|
||||
"app.skin-site.admin.wiki.settings-hint": {"message": "以逗号分隔域名。"},
|
||||
"app.skin-site.admin.wiki.domains": {"message": "域名"},
|
||||
"app.skin-site.admin.wiki.home-page": {"message": "首页"},
|
||||
"app.skin-site.admin.wiki.default-skin": {"message": "默认皮肤"},
|
||||
"app.skin-site.admin.wiki.max-page-bytes": {"message": "页面最大字节数"},
|
||||
"app.skin-site.admin.wiki.max-attachment-bytes": {"message": "附件最大字节数"},
|
||||
"app.skin-site.admin.wiki.save-settings": {"message": "保存设置"},
|
||||
"app.skin-site.admin.wiki.settings-saved": {"message": "设置已保存。"},
|
||||
"app.skin-site.admin.review.tab-list": {"message": "申请列表"},
|
||||
"app.skin-site.admin.review.tab-papers": {"message": "试卷管理"},
|
||||
"app.skin-site.admin.review.papers-empty": {"message": "还没有审核试卷。"},
|
||||
"app.skin-site.admin.review.new-paper": {"message": "新建试卷"},
|
||||
"app.skin-site.admin.review.edit-paper": {"message": "编辑"},
|
||||
"app.skin-site.admin.review.paper-title": {"message": "试卷标题"},
|
||||
"app.skin-site.admin.review.paper-annotation": {"message": "描述"},
|
||||
"app.skin-site.admin.review.paper-enabled": {"message": "启用"},
|
||||
"app.skin-site.admin.review.paper-mode": {"message": "阅卷模式"},
|
||||
"app.skin-site.admin.review.paper-pass-score": {"message": "通过分数"},
|
||||
"app.skin-site.admin.review.paper-target-permissions": {"message": "通过后获得的身份"},
|
||||
"app.skin-site.admin.review.paper-questions": {"message": "题目"},
|
||||
"app.skin-site.admin.review.add-question": {"message": "添加题目"},
|
||||
"app.skin-site.admin.review.question-title": {"message": "题目"},
|
||||
"app.skin-site.admin.review.question-type": {"message": "题型"},
|
||||
"app.skin-site.admin.review.question-score": {"message": "分数"},
|
||||
"app.skin-site.admin.review.question-annotation": {"message": "题目注解"},
|
||||
"app.skin-site.admin.review.add-option": {"message": "添加选项"},
|
||||
"app.skin-site.admin.review.option-description": {"message": "选项文本"},
|
||||
"app.skin-site.admin.review.option-correct": {"message": "正确"},
|
||||
"app.skin-site.admin.review.remove-question": {"message": "删除"},
|
||||
"app.skin-site.admin.review.question-no": {"message": "第 {n} 题"},
|
||||
"app.skin-site.admin.review.paper-created": {"message": "试卷已创建。"},
|
||||
"app.skin-site.admin.review.paper-saved": {"message": "试卷已保存。"},
|
||||
"app.skin-site.admin.review.mail-title": {"message": "通过邮件"},
|
||||
"app.skin-site.admin.review.mail-enabled": {"message": "审核通过后发送邮件"},
|
||||
"app.skin-site.admin.review.mail-subject": {"message": "邮件标题"},
|
||||
"app.skin-site.admin.review.mail-message": {"message": "邮件正文"},
|
||||
"app.skin-site.admin.review.mail-extra": {"message": "邮件补充说明"},
|
||||
"app.skin-site.admin.review.mail-include-invite": {"message": "附带邀请码"},
|
||||
"app.skin-site.admin.review.prevent-duplicate": {"message": "禁止重复作答"},
|
||||
"app.skin-site.admin.review.copy-link": {"message": "复制直链"},
|
||||
"app.skin-site.admin.review.link-copied": {"message": "直链已复制。"},
|
||||
"app.skin-site.admin.review.move-up": {"message": "上移"},
|
||||
"app.skin-site.admin.review.move-down": {"message": "下移"},
|
||||
"app.skin-site.admin.review.mail-subject-required": {"message": "开启邮件后必须填写邮件标题。"},
|
||||
"app.skin-site.admin.review.mail-message-required": {"message": "开启邮件后必须填写邮件正文。"},
|
||||
"app.skin-site.admin.users.actions": {"message": "操作"},
|
||||
"app.skin-site.admin.users.audit": {"message": "审计"},
|
||||
"app.skin-site.admin.users.audit-empty": {"message": "暂无管理审计记录。"},
|
||||
"app.skin-site.admin.users.audit-more": {"message": "加载更早记录"},
|
||||
"app.skin-site.admin.users.audit-title": {"message": "用户管理审计"},
|
||||
"app.skin-site.admin.users.bot": {"message": "机器人"},
|
||||
"app.skin-site.admin.users.bot-active": {"message": "Token 有效"},
|
||||
"app.skin-site.admin.users.bot-ban": {"message": "封禁 Bot 创建"},
|
||||
"app.skin-site.admin.users.bot-creation-banned": {"message": "禁止创建 Token"},
|
||||
"app.skin-site.admin.users.bot-exists": {"message": "已创建 Bot"},
|
||||
"app.skin-site.admin.users.bot-inactive": {"message": "Token 已失效"},
|
||||
"app.skin-site.admin.users.bot-invalidate": {"message": "使 Token 失效"},
|
||||
"app.skin-site.admin.users.bot-not-exists": {"message": "尚未创建 Bot"},
|
||||
"app.skin-site.admin.users.bot-save-username": {"message": "保存机器人用户名"},
|
||||
"app.skin-site.admin.users.bot-title": {"message": "Bot 管理"},
|
||||
"app.skin-site.admin.users.bot-token-hint": {"message": "Token 标识"},
|
||||
"app.skin-site.admin.users.bot-unban": {"message": "解除 Bot 封禁"},
|
||||
"app.skin-site.admin.users.bot-username": {"message": "机器人用户名"},
|
||||
"app.skin-site.admin.users.bound-players-title": {"message": "绑定玩家"},
|
||||
"app.skin-site.admin.users.frequency": {"message": "频率限制"},
|
||||
"app.skin-site.admin.users.frequency-clear": {"message": "取消限制"},
|
||||
"app.skin-site.admin.users.frequency-current": {"message": "当前 {percent}%"},
|
||||
"app.skin-site.admin.users.frequency-hint": {"message": "以下列频率对指定用户进行丢包处理,限制其进入服务器的频率。"},
|
||||
"app.skin-site.admin.users.frequency-none": {"message": "当前未启用"},
|
||||
"app.skin-site.admin.users.frequency-range": {"message": "仅允许设置 10% 至 100% 的整数。"},
|
||||
"app.skin-site.admin.users.frequency-save": {"message": "保存限制"},
|
||||
"app.skin-site.admin.users.frequency-title": {"message": "频率限制"},
|
||||
"app.skin-site.admin.users.invite": {"message": "邀请用户"},
|
||||
"app.skin-site.admin.users.invite-copied": {"message": "邀请码已复制。"},
|
||||
"app.skin-site.admin.users.invite-copy": {"message": "复制"},
|
||||
"app.skin-site.admin.users.invite-email": {"message": "邮箱"},
|
||||
"app.skin-site.admin.users.invite-email-invalid": {"message": "请输入正确格式的邮箱。"},
|
||||
"app.skin-site.admin.users.invite-generate": {"message": "生成邀请码"},
|
||||
"app.skin-site.admin.users.invite-title": {"message": "邀请用户"},
|
||||
"app.skin-site.admin.users.legacy-adapted": {"message": "已适配旧内服"},
|
||||
"app.skin-site.admin.users.registered-at": {"message": "注册时间"},
|
||||
"app.skin-site.admin.users.status": {"message": "状态"},
|
||||
"app.skin-site.admin.users.status-banned": {"message": "已封禁"},
|
||||
"app.skin-site.admin.users.status-normal": {"message": "正常"},
|
||||
"app.skin-site.admin.mods.upload": {"message": "上传"},
|
||||
"app.skin-site.admin.mods.select-mode": {"message": "选择多个"},
|
||||
"app.skin-site.admin.mods.exit-select": {"message": "完成选择"},
|
||||
"app.skin-site.admin.mods.select-all": {"message": "全选本页"},
|
||||
"app.skin-site.admin.mods.clear-selection": {"message": "取消全选"},
|
||||
"app.skin-site.admin.mods.selected-count": {"message": "已选择 {count} 项"},
|
||||
"app.skin-site.admin.mods.delete-selected": {"message": "删除所选"},
|
||||
"app.skin-site.admin.mods.confirm-delete-multi": {"message": "确定删除选中的 {count} 个 Mod?此操作不可撤销。"},
|
||||
"app.skin-site.admin.mods.deleted-multi": {"message": "已删除所选 Mod。"},
|
||||
"app.skin-site.admin.mods.server-address": {"message": "服务器地址"},
|
||||
"app.skin-site.admin.mods.server-address-hint": {"message": "按服务器地址过滤"},
|
||||
"app.skin-site.admin.mods.apply": {"message": "应用"},
|
||||
"app.skin-site.admin.mods.clear": {"message": "清除"},
|
||||
"app.skin-site.admin.mods.upload-title": {"message": "上传 Mod"},
|
||||
"app.skin-site.admin.mods.upload-drop": {"message": "拖拽 .jar 文件到此处,或点击选择"},
|
||||
"app.skin-site.admin.mods.upload-sub": {"message": "支持多文件,单个不超过 {size} MB"},
|
||||
"app.skin-site.admin.mods.upload-tags": {"message": "附加规则标签"},
|
||||
"app.skin-site.admin.mods.upload-queue": {"message": "文件列表"},
|
||||
"app.skin-site.admin.mods.upload-pending": {"message": "等待中"},
|
||||
"app.skin-site.admin.mods.upload-checking": {"message": "检查中…"},
|
||||
"app.skin-site.admin.mods.upload-uploading": {"message": "上传中…"},
|
||||
"app.skin-site.admin.mods.upload-conflict": {"message": "名称已存在"},
|
||||
"app.skin-site.admin.mods.upload-success": {"message": "完成"},
|
||||
"app.skin-site.admin.mods.upload-error": {"message": "失败"},
|
||||
"app.skin-site.admin.mods.upload-exists": {"message": "该文件已存在于服务器。"},
|
||||
"app.skin-site.admin.mods.upload-name-conflict": {"message": "已存在同名 Mod"},
|
||||
"app.skin-site.admin.mods.upload-name-conflict-hint": {"message": "覆盖已有 Mod,或跳过此文件。"},
|
||||
"app.skin-site.admin.mods.upload-overwrite": {"message": "覆盖"},
|
||||
"app.skin-site.admin.mods.upload-skip": {"message": "跳过"},
|
||||
"app.skin-site.admin.mods.upload-close": {"message": "关闭"},
|
||||
"app.skin-site.admin.mods.upload-all-done": {"message": "全部文件处理完成。"},
|
||||
"app.skin-site.admin.mods.upload-too-large": {"message": "文件过大:{name}"},
|
||||
"app.skin-site.chat.avatar.label": {"message": "房间头像"},
|
||||
"app.skin-site.chat.avatar.upload": {"message": "上传头像"},
|
||||
"app.skin-site.chat.avatar.replace": {"message": "更换头像"},
|
||||
"app.skin-site.chat.avatar.remove": {"message": "移除头像"},
|
||||
"app.skin-site.chat.avatar.hint": {"message": "支持 PNG、JPEG、WebP,单边不超过 8192 像素,文件不超过 5 MB。"},
|
||||
"app.skin-site.chat.avatar.bad-format": {"message": "房间头像仅支持 PNG、JPEG 和 WebP 格式。"},
|
||||
"app.skin-site.chat.avatar.too-large": {"message": "房间头像大小不能超过 5 MB。"},
|
||||
"app.skin-site.chat.avatar.not-image": {"message": "房间头像必须是图片。"},
|
||||
"app.skin-site.chat.admin.title": {"message": "聊天室管理"},
|
||||
"app.skin-site.chat.admin.subtitle": {"message": "创建公开或私有房间,并将日常管理权限交给合适的成员。"},
|
||||
"app.skin-site.chat.admin.create-room": {"message": "创建房间"},
|
||||
"app.skin-site.chat.admin.loading": {"message": "加载中…"},
|
||||
"app.skin-site.chat.admin.failed": {"message": "无法加载房间列表。"},
|
||||
"app.skin-site.chat.admin.empty": {"message": "还没有聊天室。"},
|
||||
"app.skin-site.chat.admin.edit": {"message": "编辑"},
|
||||
"app.skin-site.chat.admin.remove": {"message": "删除"},
|
||||
"app.skin-site.chat.admin.save": {"message": "保存"},
|
||||
"app.skin-site.chat.admin.cancel": {"message": "取消"},
|
||||
"app.skin-site.chat.admin.name": {"message": "房间名称"},
|
||||
"app.skin-site.chat.admin.description": {"message": "房间简介"},
|
||||
"app.skin-site.chat.admin.visibility": {"message": "可见性"},
|
||||
"app.skin-site.chat.admin.visibility-public": {"message": "公开"},
|
||||
"app.skin-site.chat.admin.visibility-private": {"message": "私有"},
|
||||
"app.skin-site.chat.admin.kind": {"message": "房间类型"},
|
||||
"app.skin-site.chat.admin.kind-standard": {"message": "普通房间"},
|
||||
"app.skin-site.chat.admin.kind-settlement": {"message": "聚落房间"},
|
||||
"app.skin-site.chat.admin.prerequisite-mode": {"message": "前置条件判定"},
|
||||
"app.skin-site.chat.admin.prerequisite-any": {"message": "满足任一"},
|
||||
"app.skin-site.chat.admin.prerequisite-all": {"message": "满足全部"},
|
||||
"app.skin-site.chat.admin.prerequisite-permissions": {"message": "所需权限"},
|
||||
"app.skin-site.chat.admin.prerequisite-hint": {"message": "以逗号分隔;留空表示无限制。"},
|
||||
"app.skin-site.chat.admin.created": {"message": "房间已创建。"},
|
||||
"app.skin-site.chat.admin.updated": {"message": "房间资料已更新。"},
|
||||
"app.skin-site.chat.admin.deleted": {"message": "房间已删除。"},
|
||||
"app.skin-site.chat.admin.confirm-delete": {"message": "确认永久删除房间“{name}”及其中全部消息吗?"},
|
||||
"app.skin-site.chat.admin.manager-badge": {"message": "管理"},
|
||||
"app.skin-site.chat.admin.voice-badge": {"message": "语音"},
|
||||
"app.skin-site.chat.user-picker.label": {"message": "选择用户"},
|
||||
"app.skin-site.chat.user-picker.placeholder": {"message": "搜索用户名、邮箱或账号 ID"},
|
||||
"app.skin-site.chat.user-picker.by-user": {"message": "按用户信息"},
|
||||
"app.skin-site.chat.user-picker.by-player": {"message": "按玩家 ID"},
|
||||
"app.skin-site.chat.user-picker.hint": {"message": "支持按用户名、邮箱模糊搜索,也可输入账号 ID 搜索。"},
|
||||
"app.skin-site.chat.user-picker.player-hint": {"message": "输入玩家名称,查找绑定该玩家 ID 的用户。"},
|
||||
"app.skin-site.chat.user-picker.empty": {"message": "没有找到匹配的用户"},
|
||||
"app.skin-site.chat.user-picker.banned": {"message": "该账号已被封禁,不能执行此操作。"},
|
||||
"app.skin-site.chat.user-picker.guest": {"message": "游客不能成为房管、聚落主或聚落成员。"},
|
||||
"app.skin-site.chat.user-picker.already-in": {"message": "该用户已经在当前房间中。"},
|
||||
"app.skin-site.chat.user-picker.not-allowed": {"message": "该用户不在当前允许选择的范围内"},
|
||||
"app.skin-site.chat.user-picker.select": {"message": "选择此用户"},
|
||||
"app.skin-site.chat.user-picker.selected": {"message": "已选择此用户"},
|
||||
"app.skin-site.chat.user-picker.id": {"message": "ID"},
|
||||
"app.skin-site.chat.admin.managers": {"message": "房管"},
|
||||
"app.skin-site.chat.admin.manager-title": {"message": "任命房管"},
|
||||
"app.skin-site.chat.admin.manager-hint": {"message": "房管可以管理该房间的成员、消息与文件。"},
|
||||
"app.skin-site.chat.admin.grant": {"message": "任命"},
|
||||
"app.skin-site.chat.admin.revoke": {"message": "撤销"},
|
||||
"app.skin-site.chat.admin.manager-granted": {"message": "已任命房管。"},
|
||||
"app.skin-site.chat.admin.manager-revoked": {"message": "已撤销房管。"},
|
||||
"app.skin-site.chat.admin.owner-title": {"message": "聚落主"},
|
||||
"app.skin-site.chat.admin.owner-hint": {"message": "为该房间任命首任聚落主。"},
|
||||
"app.skin-site.chat.admin.owner-assigned": {"message": "已任命聚落主。"},
|
||||
"app.skin-site.chat.admin.owner-current": {"message": "当前聚落主:{name}"},
|
||||
"app.skin-site.chat.admin.owner-none": {"message": "尚未设置聚落主。"},
|
||||
"app.skin-site.chat.admin.audit": {"message": "审计"},
|
||||
"app.skin-site.chat.admin.audit-title": {"message": "房间审计"},
|
||||
"app.skin-site.chat.admin.audit-empty": {"message": "暂无审计记录。"},
|
||||
"app.skin-site.chat.admin.audit-target": {"message": "对象:{name}"},
|
||||
"app.skin-site.chat.admin.close": {"message": "关闭"},
|
||||
"app.skin-site.chat.voice-runtime-title": {"message": "实时语音库"},
|
||||
"app.skin-site.chat.voice-logs": {"message": "查看日志"},
|
||||
"app.skin-site.chat.voice-config": {"message": "配置语音库"},
|
||||
"app.skin-site.chat.voice-retry": {"message": "重新部署"},
|
||||
"app.skin-site.chat.voice-config-title": {"message": "语音库配置"},
|
||||
"app.skin-site.chat.voice-logs-title": {"message": "LiveKit 日志"},
|
||||
"app.skin-site.chat.voice-capacity-title": {"message": "语音容量"},
|
||||
"app.skin-site.chat.voice-capacity": {"message": "语音容量"},
|
||||
"app.skin-site.chat.participant-limit": {"message": "参与人数上限"},
|
||||
"app.skin-site.chat.listener-limit": {"message": "旁听人数上限"},
|
||||
"app.skin-site.chat.voice-capacity-updated": {"message": "语音容量已更新。"},
|
||||
"app.skin-site.chat.voice-enabled": {"message": "启用实时语音"},
|
||||
"app.skin-site.chat.voice-runtime-path": {"message": "语音库目录"},
|
||||
"app.skin-site.chat.voice-mirror": {"message": "镜像基础地址"},
|
||||
"app.skin-site.chat.voice-public-url": {"message": "公网访问地址"},
|
||||
"app.skin-site.chat.voice-bind": {"message": "监听地址"},
|
||||
"app.skin-site.chat.voice-signal-port": {"message": "信令端口"},
|
||||
"app.skin-site.chat.voice-rtc-tcp-port": {"message": "媒体 TCP 端口"},
|
||||
"app.skin-site.chat.voice-rtc-udp-port": {"message": "媒体 UDP 端口"},
|
||||
"app.skin-site.chat.voice-startup-timeout": {"message": "启动等待时间(秒)"},
|
||||
"app.skin-site.chat.voice-use-external-ip": {"message": "使用外部 IP"},
|
||||
"app.skin-site.chat.voice-node-ip": {"message": "节点 IP"},
|
||||
"app.skin-site.chat.voice-saved": {"message": "语音库配置已保存。"},
|
||||
"app.skin-site.chat.voice-logs-auto-refresh": {"message": "自动刷新"},
|
||||
"app.skin-site.chat.voice-logs-refresh": {"message": "刷新"},
|
||||
"app.skin-site.chat.voice-logs-empty": {"message": "暂无日志。"},
|
||||
"app.skin-site.chat.admin.voice-runtime-title": {"message": "实时语音库"},
|
||||
"app.skin-site.chat.admin.voice-logs": {"message": "查看日志"},
|
||||
"app.skin-site.chat.admin.voice-config": {"message": "配置语音库"},
|
||||
"app.skin-site.chat.admin.voice-retry": {"message": "重新部署"},
|
||||
"app.skin-site.chat.admin.voice-config-title": {"message": "语音库配置"},
|
||||
"app.skin-site.chat.admin.voice-logs-title": {"message": "LiveKit 日志"},
|
||||
"app.skin-site.chat.admin.voice-capacity-title": {"message": "语音容量"},
|
||||
"app.skin-site.chat.admin.voice-capacity": {"message": "语音容量"},
|
||||
"app.skin-site.chat.admin.participant-limit": {"message": "参与人数上限"},
|
||||
"app.skin-site.chat.admin.listener-limit": {"message": "旁听人数上限"},
|
||||
"app.skin-site.chat.admin.voice-capacity-updated": {"message": "语音容量已更新。"},
|
||||
"app.skin-site.chat.admin.voice-enabled": {"message": "启用实时语音"},
|
||||
"app.skin-site.chat.admin.voice-runtime-path": {"message": "语音库目录"},
|
||||
"app.skin-site.chat.admin.voice-mirror": {"message": "镜像基础地址"},
|
||||
"app.skin-site.chat.admin.voice-public-url": {"message": "公网访问地址"},
|
||||
"app.skin-site.chat.admin.voice-bind": {"message": "监听地址"},
|
||||
"app.skin-site.chat.admin.voice-signal-port": {"message": "信令端口"},
|
||||
"app.skin-site.chat.admin.voice-rtc-tcp-port": {"message": "媒体 TCP 端口"},
|
||||
"app.skin-site.chat.admin.voice-rtc-udp-port": {"message": "媒体 UDP 端口"},
|
||||
"app.skin-site.chat.admin.voice-startup-timeout": {"message": "启动等待时间(秒)"},
|
||||
"app.skin-site.chat.admin.voice-use-external-ip": {"message": "使用外部 IP"},
|
||||
"app.skin-site.chat.admin.voice-node-ip": {"message": "节点 IP"},
|
||||
"app.skin-site.chat.admin.voice-saved": {"message": "语音库配置已保存。"},
|
||||
"app.skin-site.chat.admin.voice-logs-auto-refresh": {"message": "自动刷新"},
|
||||
"app.skin-site.chat.admin.voice-logs-refresh": {"message": "刷新"},
|
||||
"app.skin-site.chat.admin.voice-logs-empty": {"message": "暂无日志。"},
|
||||
"app.skin-site.admin.wiki.tab-migration": {"message": "迁移中心"},
|
||||
"app.skin-site.admin.wiki.migration-title": {"message": "MediaWiki 迁移"},
|
||||
"app.skin-site.admin.wiki.migration-hint": {"message": "迁移内容会先进入不可见暂存区,所有页面完成导入或排除审核后才能整批发布。"},
|
||||
"app.skin-site.admin.wiki.auto-title": {"message": "从 MediaWiki API 自动读取"},
|
||||
"app.skin-site.admin.wiki.api-url": {"message": "api.php 地址"},
|
||||
"app.skin-site.admin.wiki.bot-username": {"message": "Bot 用户名(选填)"},
|
||||
"app.skin-site.admin.wiki.bot-password": {"message": "Bot 密码(选填)"},
|
||||
"app.skin-site.admin.wiki.credentials-hint": {"message": "凭据只存在于本次后台任务的内存中,携带凭据时必须使用 HTTPS。"},
|
||||
"app.skin-site.admin.wiki.allow-private": {"message": "明确允许访问内网来源"},
|
||||
"app.skin-site.admin.wiki.allow-private-hint": {"message": "内网来源可能访问皮肤站所在网络中的服务,请只对可信地址启用。"},
|
||||
"app.skin-site.admin.wiki.start-auto": {"message": "创建自动迁移任务"},
|
||||
"app.skin-site.admin.wiki.xml-title": {"message": "导入 MediaWiki XML"},
|
||||
"app.skin-site.admin.wiki.xml-file": {"message": "导出文件"},
|
||||
"app.skin-site.admin.wiki.start-xml": {"message": "上传并建立暂存任务"},
|
||||
"app.skin-site.admin.wiki.stale-rules": {"message": "疑似过时页面筛选规则"},
|
||||
"app.skin-site.admin.wiki.stale-days": {"message": "未更新天数"},
|
||||
"app.skin-site.admin.wiki.maintainer-window": {"message": "维护者统计天数"},
|
||||
"app.skin-site.admin.wiki.max-maintainers": {"message": "维护者人数不超过"},
|
||||
"app.skin-site.admin.wiki.stale-markers": {"message": "过时分类、模板或文字标记"},
|
||||
"app.skin-site.admin.wiki.stale-markers-hint": {"message": "使用逗号分隔"},
|
||||
"app.skin-site.admin.wiki.jobs": {"message": "迁移任务"},
|
||||
"app.skin-site.admin.wiki.refresh-jobs": {"message": "刷新"},
|
||||
"app.skin-site.admin.wiki.jobs-empty": {"message": "还没有迁移任务。"},
|
||||
"app.skin-site.admin.wiki.reviewed-count": {"message": "已审核 {reviewed} / {total}"},
|
||||
"app.skin-site.admin.wiki.imported-excluded": {"message": "导入 {imported} · 排除 {excluded}"},
|
||||
"app.skin-site.admin.wiki.view-job": {"message": "查看任务"},
|
||||
"app.skin-site.admin.wiki.delete-job": {"message": "删除迁移记录"},
|
||||
"app.skin-site.admin.wiki.confirm-delete-job": {"message": "确认删除迁移任务 #{id}?此操作不可恢复。"},
|
||||
"app.skin-site.admin.wiki.candidates": {"message": "候选页面"},
|
||||
"app.skin-site.admin.wiki.candidates-empty": {"message": "选择任务后查看其页面。"},
|
||||
"app.skin-site.admin.wiki.last-updated": {"message": "更新于 {date}"},
|
||||
"app.skin-site.admin.wiki.maintainer-count": {"message": "{count} 位维护者"},
|
||||
"app.skin-site.admin.wiki.conflict": {"message": "标题冲突"},
|
||||
"app.skin-site.admin.wiki.target-title": {"message": "目标标题"},
|
||||
"app.skin-site.admin.wiki.overwrite": {"message": "覆盖"},
|
||||
"app.skin-site.admin.wiki.import": {"message": "导入"},
|
||||
"app.skin-site.admin.wiki.exclude": {"message": "排除"},
|
||||
"app.skin-site.admin.wiki.publish": {"message": "整批发布"},
|
||||
"app.skin-site.admin.wiki.rollback": {"message": "回滚"},
|
||||
"app.skin-site.admin.wiki.confirm-rollback": {"message": "确认回滚本批迁移?已发布的页面将被还原。"},
|
||||
"app.skin-site.admin.wiki.state-importing": {"message": "正在读取"},
|
||||
"app.skin-site.admin.wiki.state-review": {"message": "等待审核"},
|
||||
"app.skin-site.admin.wiki.state-publishing": {"message": "正在发布"},
|
||||
"app.skin-site.admin.wiki.state-published": {"message": "已发布"},
|
||||
"app.skin-site.admin.wiki.state-failed": {"message": "失败"},
|
||||
"app.skin-site.admin.wiki.state-rolled-back": {"message": "已回滚"},
|
||||
"app.skin-site.admin.wiki.decision-pending": {"message": "待审核"},
|
||||
"app.skin-site.admin.wiki.decision-import": {"message": "导入"},
|
||||
"app.skin-site.admin.wiki.decision-exclude": {"message": "排除"},
|
||||
"app.skin-site.admin.wiki.migration-started": {"message": "迁移任务已创建。"},
|
||||
"app.skin-site.admin.wiki.xml-staged": {"message": "XML 已解析并进入逐页审核阶段。"},
|
||||
"app.skin-site.admin.wiki.published": {"message": "已发布 {imported} 个页面,覆盖 {overwritten} 个。"},
|
||||
"app.skin-site.admin.wiki.rolled-back": {"message": "迁移批次已安全回滚。"},
|
||||
"app.skin-site.admin.wiki.job-deleted": {"message": "迁移记录已删除。"},
|
||||
"app.skin-site.admin.wiki.select-xml": {"message": "请先选择 MediaWiki XML 文件。"},
|
||||
"app.skin-site.wiki.title": {"message": "StarLight 维基"},
|
||||
"app.skin-site.wiki.search-placeholder": {"message": "输入页面标题"},
|
||||
"app.skin-site.wiki.open": {"message": "打开"},
|
||||
"app.skin-site.wiki.loading": {"message": "加载中…"},
|
||||
"app.skin-site.wiki.not-found": {"message": "页面不存在。"},
|
||||
"app.skin-site.wiki.empty": {"message": "在上方输入页面标题开始阅读。"},
|
||||
"app.skin-site.wiki.updated-at": {"message": "最后编辑于 {date},编辑者 {author}"},
|
||||
"app.skin-site.wiki.revision": {"message": "修订 #{id}"},
|
||||
"app.skin-site.wiki.categories": {"message": "分类"},
|
||||
"app.skin-site.wiki.back": {"message": "返回"}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import HomeLaunchProgress from '@/components/home/HomeLaunchProgress.vue'
|
||||
import HomeMinecraftNews from '@/components/home/HomeMinecraftNews.vue'
|
||||
import HomeMinimal from '@/components/home/HomeMinimal.vue'
|
||||
import HomePlayInsights from '@/components/home/HomePlayInsights.vue'
|
||||
import SkinSiteFrame from '@/components/ui/SkinSiteFrame.vue'
|
||||
import SkinSiteHome from '@/components/ui/skin-site/SkinSiteHome.vue'
|
||||
import { useNetworkStatus } from '@/composables/useNetworkStatus'
|
||||
import { get_default_user, users } from '@/helpers/auth'
|
||||
import { DIRECT_LINKS_SYNCED_EVENT } from '@/helpers/direct-link-sync'
|
||||
@@ -162,7 +162,7 @@ onUnmounted(() => {
|
||||
@select="selectMinimalInstance"
|
||||
/>
|
||||
<div class="home-content" :class="{ 'is-minimal': isMinimal }">
|
||||
<SkinSiteFrame v-if="!isMinimal" />
|
||||
<SkinSiteHome v-if="!isMinimal" />
|
||||
|
||||
<HomeMinimal
|
||||
v-else
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import SkinSiteFrame from '@/components/ui/SkinSiteFrame.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<SkinSiteFrame />
|
||||
</div>
|
||||
</template>
|
||||
@@ -93,14 +93,6 @@ export default new createRouter({
|
||||
discordActivity: 'Changing skins...',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/starlight-skin',
|
||||
name: 'Starlight skin',
|
||||
component: () => import('@/pages/StarlightSkin.vue'),
|
||||
meta: {
|
||||
breadcrumb: [{ name: 'Starlight skin' }],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/screenshots',
|
||||
name: 'Screenshots',
|
||||
|
||||
@@ -6,6 +6,18 @@ import {
|
||||
resolveFontFamily,
|
||||
} from '@/helpers/font-family.ts'
|
||||
|
||||
/**
|
||||
* Mirrors `KeyBinding` from `@modrinth/ui`. Declared here so this module stays
|
||||
* loadable without the UI package.
|
||||
*/
|
||||
export interface ShortcutBinding {
|
||||
device: 'keyboard' | 'mouse'
|
||||
code: string
|
||||
mod: boolean
|
||||
shift: boolean
|
||||
alt: boolean
|
||||
}
|
||||
|
||||
let systemThemeMq: MediaQueryList | null = null
|
||||
|
||||
export const DEFAULT_FEATURE_FLAGS = {
|
||||
@@ -135,8 +147,30 @@ export type ThemeStore = {
|
||||
minimalHomeInstanceId: string | null
|
||||
closeBehavior: CloseBehavior
|
||||
|
||||
/** Whether the floating "back to top" button is shown on scrollable pages. */
|
||||
showScrollTop: boolean
|
||||
/** Whether quick scrolling shortcuts (Home/End/PageUp/PageDown) are active. */
|
||||
quickScrollEnabled: boolean
|
||||
/** Per-nav-item quick jump shortcuts (Ctrl/Cmd + number), off by default. */
|
||||
shortcutNavHome: boolean
|
||||
shortcutNavWorlds: boolean
|
||||
shortcutNavDiscover: boolean
|
||||
shortcutNavSkins: boolean
|
||||
shortcutNavMultiplayer: boolean
|
||||
shortcutNavLibrary: boolean
|
||||
shortcutNavLab: boolean
|
||||
shortcutNavDownloads: boolean
|
||||
shortcutNavCreate: boolean
|
||||
shortcutNavSettings: boolean
|
||||
|
||||
/**
|
||||
* The combination every shortcut answers to, keyed by action id. Kept here so
|
||||
* pages re-render when one is recorded; the value itself lives in local
|
||||
* storage, next to the enable flags.
|
||||
*/
|
||||
shortcutBindings: Record<string, ShortcutBinding>
|
||||
|
||||
devMode: boolean
|
||||
featureFlags: FeatureFlags
|
||||
|
||||
uiFont: string | null
|
||||
monoFont: string | null
|
||||
@@ -162,6 +196,22 @@ export const DEFAULT_THEME_STORE: ThemeStore = {
|
||||
minimalHomeInstanceId: null,
|
||||
closeBehavior: 'ask',
|
||||
|
||||
showScrollTop: true,
|
||||
quickScrollEnabled: false,
|
||||
|
||||
shortcutNavHome: false,
|
||||
shortcutNavWorlds: false,
|
||||
shortcutNavDiscover: false,
|
||||
shortcutNavSkins: false,
|
||||
shortcutNavMultiplayer: false,
|
||||
shortcutNavLibrary: false,
|
||||
shortcutNavLab: false,
|
||||
shortcutNavDownloads: false,
|
||||
shortcutNavCreate: false,
|
||||
shortcutNavSettings: false,
|
||||
|
||||
shortcutBindings: {},
|
||||
|
||||
devMode: false,
|
||||
featureFlags: DEFAULT_FEATURE_FLAGS,
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "theseus_gui"
|
||||
# The actual version is set by the theseus-build workflow on tagging
|
||||
version = "1.0.2-beta4"
|
||||
version = "1.0.2-beta7"
|
||||
edition.workspace = true
|
||||
description = "Axolotl Launcher is a cross-platform Minecraft launcher"
|
||||
homepage = "https://www.ghs.red"
|
||||
|
||||
@@ -300,6 +300,17 @@ fn main() {
|
||||
"logs_explain_crash_with_ai",
|
||||
"logs_undo_added_mod",
|
||||
"logs_export_crash_context",
|
||||
"logs_get_log_share_settings",
|
||||
"logs_update_log_share_settings",
|
||||
"logs_logshare_upload_crash",
|
||||
"logs_logshare_get_insights",
|
||||
"logs_logshare_analyse_crash_direct",
|
||||
"logs_logshare_ai_analyze_stored",
|
||||
"logs_logshare_ai_analyze_direct",
|
||||
"logs_logshare_delete",
|
||||
"logs_list_shared_logs",
|
||||
"logs_record_shared_log",
|
||||
"logs_delete_shared_log",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
|
||||
@@ -4,7 +4,8 @@ use std::path::PathBuf;
|
||||
use theseus::logs::LogType;
|
||||
use theseus::logs::{
|
||||
self, CensoredString, CrashAnalysis, CrashAnalysisAiExplanation,
|
||||
CrashAnalysisAiSettings, LatestLogCursor, LiveLogSnapshot, Logs,
|
||||
CrashAnalysisAiSettings, LatestLogCursor, LiveLogSnapshot,
|
||||
LogShareSettings, LogShareUploadResponse, Logs, SharedLog,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -34,6 +35,17 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
logs_explain_crash_with_ai,
|
||||
logs_undo_added_mod,
|
||||
logs_export_crash_context,
|
||||
logs_get_log_share_settings,
|
||||
logs_update_log_share_settings,
|
||||
logs_logshare_upload_crash,
|
||||
logs_logshare_get_insights,
|
||||
logs_logshare_analyse_crash_direct,
|
||||
logs_logshare_ai_analyze_stored,
|
||||
logs_logshare_ai_analyze_direct,
|
||||
logs_logshare_delete,
|
||||
logs_list_shared_logs,
|
||||
logs_record_shared_log,
|
||||
logs_delete_shared_log,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
@@ -172,3 +184,81 @@ pub async fn logs_export_crash_context(
|
||||
writer.close().await.map_err(crate::api::utils::zip_error)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the log share settings.
|
||||
#[tauri::command]
|
||||
pub async fn logs_get_log_share_settings() -> Result<LogShareSettings> {
|
||||
Ok(logs::get_log_share_settings().await?)
|
||||
}
|
||||
|
||||
/// Update the log share settings.
|
||||
#[tauri::command]
|
||||
pub async fn logs_update_log_share_settings(
|
||||
settings: LogShareSettings,
|
||||
) -> Result<()> {
|
||||
Ok(logs::update_log_share_settings(settings).await?)
|
||||
}
|
||||
|
||||
/// Upload the latest run's crash logs to LogShare.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_upload_crash(
|
||||
instance_id: &str,
|
||||
) -> Result<LogShareUploadResponse> {
|
||||
Ok(logs::upload_crash(instance_id).await?)
|
||||
}
|
||||
|
||||
/// Fetch structured insights for a shared log.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_get_insights(id: &str) -> Result<serde_json::Value> {
|
||||
Ok(logs::get_insights(id).await?)
|
||||
}
|
||||
|
||||
/// Analyse the latest run's crash logs directly.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_analyse_crash_direct(
|
||||
instance_id: &str,
|
||||
) -> Result<serde_json::Value> {
|
||||
Ok(logs::analyse_crash_direct(instance_id).await?)
|
||||
}
|
||||
|
||||
/// Stream an AI analysis for a stored shared log.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_ai_analyze_stored(
|
||||
instance_id: &str,
|
||||
id: &str,
|
||||
) -> Result<String> {
|
||||
Ok(logs::ai_analyze_stored(instance_id, id).await?)
|
||||
}
|
||||
|
||||
/// Stream an AI analysis for the latest run's crash logs.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_ai_analyze_direct(
|
||||
instance_id: &str,
|
||||
) -> Result<String> {
|
||||
Ok(logs::ai_analyze_direct(instance_id).await?)
|
||||
}
|
||||
|
||||
/// Delete a shared log remotely and locally.
|
||||
#[tauri::command]
|
||||
pub async fn logs_logshare_delete(id: &str, token: &str) -> Result<()> {
|
||||
logs::delete_log(id, token).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// List locally recorded shared logs.
|
||||
#[tauri::command]
|
||||
pub async fn logs_list_shared_logs() -> Result<Vec<SharedLog>> {
|
||||
Ok(logs::list_shared_logs().await?)
|
||||
}
|
||||
|
||||
/// Record a shared log locally.
|
||||
#[tauri::command]
|
||||
pub async fn logs_record_shared_log(log: SharedLog) -> Result<()> {
|
||||
Ok(logs::record_shared_log(log).await?)
|
||||
}
|
||||
|
||||
/// Remove a shared log record locally and remotely.
|
||||
#[tauri::command]
|
||||
pub async fn logs_delete_shared_log(id: String, token: String) -> Result<()> {
|
||||
Ok(logs::delete_shared_log(id, token).await?)
|
||||
}
|
||||
@@ -324,12 +324,9 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {
|
||||
/// external game-directory root for the one-click StarLight install flow.
|
||||
#[tauri::command]
|
||||
fn get_launcher_root_dir() -> api::Result<String> {
|
||||
let exe = std::env::current_exe().map_err(|error| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(error.to_string()))
|
||||
})?;
|
||||
let dir = exe.parent().ok_or_else(|| {
|
||||
let dir = theseus::default_game_dir_root().ok_or_else(|| {
|
||||
theseus::Error::from(theseus::ErrorKind::FSError(
|
||||
"Launcher executable has no parent directory".to_string(),
|
||||
"Could not determine a default game directory root".to_string(),
|
||||
))
|
||||
})?;
|
||||
Ok(dir.to_string_lossy().into_owned())
|
||||
@@ -339,7 +336,7 @@ fn get_launcher_root_dir() -> api::Result<String> {
|
||||
fn get_update_channel(app: tauri::AppHandle) -> api::Result<String> {
|
||||
let channel = read_update_channel_state(&app)?
|
||||
.active_channel
|
||||
.unwrap_or_else(|| "release".to_string());
|
||||
.unwrap_or_else(|| theseus::default_update_channel().to_string());
|
||||
|
||||
match channel.as_str() {
|
||||
"release" | "beta" => Ok(channel),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "theseus"
|
||||
# The actual version is set by the theseus-build workflow on tagging
|
||||
version = "1.0.2-beta4"
|
||||
version = "1.0.2-beta7"
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE log_share_settings (
|
||||
id INTEGER NOT NULL CHECK (id = 0),
|
||||
share_provider TEXT NOT NULL DEFAULT 'logshare',
|
||||
ai_source TEXT NOT NULL DEFAULT 'logshare',
|
||||
auto_upload INTEGER NOT NULL DEFAULT TRUE,
|
||||
multi_file INTEGER NOT NULL DEFAULT TRUE,
|
||||
no_storage INTEGER NOT NULL DEFAULT FALSE,
|
||||
show_progress INTEGER NOT NULL DEFAULT TRUE,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
INSERT INTO log_share_settings (id) VALUES (0);
|
||||
|
||||
CREATE TABLE shared_logs (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
url TEXT NOT NULL,
|
||||
raw TEXT NOT NULL,
|
||||
token TEXT NOT NULL,
|
||||
provider TEXT NOT NULL DEFAULT 'logshare',
|
||||
instance_id TEXT NULL,
|
||||
instance_name TEXT NULL,
|
||||
truncated INTEGER NOT NULL DEFAULT FALSE,
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX shared_logs_created_at_idx ON shared_logs (created_at DESC);
|
||||
@@ -19,7 +19,7 @@ use uuid::Uuid;
|
||||
|
||||
use crate::{ErrorKind, State};
|
||||
|
||||
const CATALOG_SOURCE: &str = "LobeHub 906b10e03029648655e0257bda4f785a9e0973f0";
|
||||
const CATALOG_SOURCE: &str = "LobeHub 6c7a6fb033e443bc27bf34cbd5509ab3db7f22f3";
|
||||
const KEYRING_PREFIX: &str = "ai-provider";
|
||||
const OAUTH_CREDENTIAL: &str = "oauth";
|
||||
const API_KEY_CREDENTIAL: &str = "api-key";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"source": "LobeHub 906b10e03029648655e0257bda4f785a9e0973f0 model-bank chat models",
|
||||
"source": "LobeHub 6c7a6fb033e443bc27bf34cbd5509ab3db7f22f3 model-bank chat models",
|
||||
"providers": {
|
||||
"ai21": [
|
||||
{
|
||||
@@ -203,6 +203,16 @@
|
||||
}
|
||||
],
|
||||
"aihubmix": [
|
||||
{
|
||||
"id": "gpt-6-sol",
|
||||
"name": "GPT-6 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-luna",
|
||||
"name": "GPT-6 Luna",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.5",
|
||||
"name": "GPT-5.5",
|
||||
@@ -343,6 +353,11 @@
|
||||
"name": "ChatGPT-4o",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "grok-4.7",
|
||||
"name": "Grok 4.7",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "grok-4-20-non-reasoning",
|
||||
"name": "Grok 4.20 (Non-Reasoning)",
|
||||
@@ -368,6 +383,11 @@
|
||||
"name": "Grok 3 Mini",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "claude-opus-5-5",
|
||||
"name": "Claude Opus 5.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "claude-opus-4-7",
|
||||
"name": "Claude Opus 4.7",
|
||||
@@ -383,11 +403,6 @@
|
||||
"name": "Claude Opus 4.5",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "claude-opus-4-1-20250805",
|
||||
"name": "Claude Opus 4.1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "claude-sonnet-4-6",
|
||||
"name": "Claude Sonnet 4.6",
|
||||
@@ -403,6 +418,21 @@
|
||||
"name": "Claude Haiku 4.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.6-pro",
|
||||
"name": "MiMo-V2.6 Pro",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.6-pro-ultraspeed",
|
||||
"name": "MiMo-V2.6 Pro UltraSpeed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.6-flash",
|
||||
"name": "MiMo-V2.6 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "DeepSeek-V3.1-Think",
|
||||
"name": "DeepSeek V3.1 (Think)",
|
||||
@@ -542,11 +572,6 @@
|
||||
"name": "Ring-2.6-1T",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Ring-2.5-1T",
|
||||
"name": "Ring-2.5-1T",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Ling-3.0-flash",
|
||||
"name": "Ling-3.0-flash",
|
||||
@@ -561,14 +586,14 @@
|
||||
"id": "Ling-2.6-flash",
|
||||
"name": "Ling-2.6-flash",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Ling-2.5-1T",
|
||||
"name": "Ling-2.5-1T",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"anthropic": [
|
||||
{
|
||||
"id": "claude-opus-5-5",
|
||||
"name": "Claude Opus 5.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "claude-fable-5-1",
|
||||
"name": "Claude Fable 5.1",
|
||||
@@ -623,14 +648,24 @@
|
||||
"id": "claude-haiku-4-5-20251001",
|
||||
"name": "Claude Haiku 4.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "claude-opus-4-1-20250805",
|
||||
"name": "Claude Opus 4.1",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"azure": [
|
||||
{
|
||||
"id": "gpt-6-astra",
|
||||
"name": "GPT-6 Astra",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-sol",
|
||||
"name": "GPT-6 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-luna",
|
||||
"name": "GPT-6 Luna",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4",
|
||||
"name": "GPT-5.4",
|
||||
@@ -914,6 +949,11 @@
|
||||
}
|
||||
],
|
||||
"bedrock": [
|
||||
{
|
||||
"id": "global.anthropic.claude-opus-5-5",
|
||||
"name": "Claude Opus 5.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "global.anthropic.claude-opus-4-7",
|
||||
"name": "Claude Opus 4.7",
|
||||
@@ -1030,14 +1070,29 @@
|
||||
"id": "gpt-oss-120b",
|
||||
"name": "GPT OSS 120B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "zai-glm-4.7",
|
||||
"name": "GLM-4.7",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"chatgpt": [
|
||||
{
|
||||
"id": "gpt-6.1-sol",
|
||||
"name": "GPT-6.1 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-astra",
|
||||
"name": "GPT-6 Astra",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-sol",
|
||||
"name": "GPT-6 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-luna",
|
||||
"name": "GPT-6 Luna",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.6-sol",
|
||||
"name": "GPT-5.6 Sol",
|
||||
@@ -1056,7 +1111,7 @@
|
||||
{
|
||||
"id": "gpt-5.5",
|
||||
"name": "GPT-5.5",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"cloudflare": [
|
||||
@@ -1883,10 +1938,15 @@
|
||||
"name": "Gemini Flash-Lite Latest",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.8-flash",
|
||||
"name": "Gemini 3.8 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.7-flash",
|
||||
"name": "Gemini 3.7 Flash",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.6-flash",
|
||||
@@ -1972,26 +2032,6 @@
|
||||
"id": "gemini-2.5-flash-lite",
|
||||
"name": "Gemini 2.5 Flash-Lite",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-2.0-flash",
|
||||
"name": "Gemini 2.0 Flash",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-2.0-flash-001",
|
||||
"name": "Gemini 2.0 Flash 001",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-2.0-flash-lite",
|
||||
"name": "Gemini 2.0 Flash-Lite",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-2.0-flash-lite-001",
|
||||
"name": "Gemini 2.0 Flash-Lite 001",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"groq": [
|
||||
@@ -2005,10 +2045,15 @@
|
||||
"name": "Compound Mini",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "qwen/qwen3.8-27b",
|
||||
"name": "Qwen3.8 27B",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "qwen/qwen3.6-27b",
|
||||
"name": "Qwen3.6 27B",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "minimaxai/minimax-m2.7",
|
||||
@@ -2025,16 +2070,6 @@
|
||||
"name": "GPT OSS 20B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "llama-3.1-8b-instant",
|
||||
"name": "Llama 3.1 8B Instant",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "llama-3.3-70b-versatile",
|
||||
"name": "Llama 3.3 70B Versatile",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "meta-llama/llama-prompt-guard-2-22m",
|
||||
"name": "Llama Prompt Guard 2 22M",
|
||||
@@ -3575,13 +3610,13 @@
|
||||
],
|
||||
"mistral": [
|
||||
{
|
||||
"id": "mistral-medium-3.5",
|
||||
"name": "Mistral Medium 3.5",
|
||||
"enabled": true
|
||||
"id": "zai-glm-5-2",
|
||||
"name": "Z.ai GLM 5.2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "devstral-2512",
|
||||
"name": "Devstral 2",
|
||||
"id": "mistral-medium-3.5",
|
||||
"name": "Mistral Medium 3.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
@@ -3589,61 +3624,21 @@
|
||||
"name": "Devstral Small 2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "mistral-medium-2508",
|
||||
"name": "Mistral Medium 3.1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "magistral-medium-2509",
|
||||
"name": "Magistral Medium 1.2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "magistral-small-2509",
|
||||
"name": "Magistral Small 1.2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "open-mistral-nemo",
|
||||
"name": "Mistral Nemo",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "mistral-small-2603",
|
||||
"name": "Mistral Small 4",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "mistral-small-2506",
|
||||
"name": "Mistral Small 3.2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "mistral-large-2512",
|
||||
"name": "Mistral Large 3",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mistral-large-2411",
|
||||
"name": "Mistral Large 2.1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "codestral-latest",
|
||||
"name": "Codestral 2508",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "pixtral-large-latest",
|
||||
"name": "Pixtral Large",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "pixtral-12b-2409",
|
||||
"name": "Pixtral 12B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "ministral-3b-latest",
|
||||
"name": "Ministral 3B",
|
||||
@@ -3653,16 +3648,6 @@
|
||||
"id": "ministral-8b-latest",
|
||||
"name": "Ministral 8B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "open-codestral-mamba",
|
||||
"name": "Codestral Mamba",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "labs-leanstral-2603",
|
||||
"name": "Leanstral",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"modelscope": [
|
||||
@@ -3676,30 +3661,10 @@
|
||||
"name": "Qwen3 Next 80B A3B Instruct",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-ai/DeepSeek-V3.2",
|
||||
"name": "DeepSeek V3.2",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "deepseek-ai/DeepSeek-V3.2-Exp",
|
||||
"name": "DeepSeek V3.2 Exp",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-ai/DeepSeek-V3.1",
|
||||
"name": "DeepSeek V3.1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Qwen/Qwen3-235B-A22B",
|
||||
"name": "Qwen3 235B A22B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Qwen/Qwen3-32B",
|
||||
"name": "Qwen3 32B",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"moonshot": [
|
||||
@@ -3722,41 +3687,6 @@
|
||||
"id": "kimi-k2.6",
|
||||
"name": "Kimi K2.6",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "kimi-k2.5",
|
||||
"name": "Kimi K2.5",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-8k",
|
||||
"name": "Moonshot V1 8K",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-32k",
|
||||
"name": "Moonshot V1 32K",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-128k",
|
||||
"name": "Moonshot V1 128K",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-8k-vision-preview",
|
||||
"name": "Moonshot V1 8K Vision Preview",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-32k-vision-preview",
|
||||
"name": "Moonshot V1 32K Vision Preview",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "moonshot-v1-128k-vision-preview",
|
||||
"name": "Moonshot V1 128K Vision Preview",
|
||||
"enabled": false
|
||||
}
|
||||
],
|
||||
"nebius": [
|
||||
@@ -4424,16 +4354,6 @@
|
||||
"name": "Qwen3.5 397B A17B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "minimax-m2.5",
|
||||
"name": "MiniMax M2.5",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "kimi-k2.5",
|
||||
"name": "Kimi K2.5",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gpt-oss:20b",
|
||||
"name": "GPT-OSS 20B",
|
||||
@@ -4451,6 +4371,26 @@
|
||||
}
|
||||
],
|
||||
"openai": [
|
||||
{
|
||||
"id": "gpt-6.1-sol",
|
||||
"name": "GPT-6.1 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-astra",
|
||||
"name": "GPT-6 Astra",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-sol",
|
||||
"name": "GPT-6 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gpt-6-luna",
|
||||
"name": "GPT-6 Luna",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "chat-latest",
|
||||
"name": "Chat Latest",
|
||||
@@ -4474,7 +4414,7 @@
|
||||
{
|
||||
"id": "gpt-5.5",
|
||||
"name": "GPT-5.5",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.5-pro",
|
||||
@@ -4484,7 +4424,7 @@
|
||||
{
|
||||
"id": "gpt-5.4",
|
||||
"name": "GPT-5.4",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-pro",
|
||||
@@ -4494,7 +4434,7 @@
|
||||
{
|
||||
"id": "gpt-5.4-mini",
|
||||
"name": "GPT-5.4 mini",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gpt-5.4-nano",
|
||||
@@ -4708,6 +4648,16 @@
|
||||
"name": "MiniMax M3",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "muse-spark-1.2-contributor",
|
||||
"name": "Muse Spark 1.2 Contributor",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "muse-spark-1.3-contributor",
|
||||
"name": "Muse Spark 1.3 Contributor",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "qwen3.6-plus",
|
||||
"name": "Qwen3.6 Plus",
|
||||
@@ -4912,6 +4862,41 @@
|
||||
"name": "Auto (best for prompt)",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "anthropic/claude-opus-5.5",
|
||||
"name": "Claude Opus 5.5",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "openai/gpt-6-sol",
|
||||
"name": "GPT-6 Sol",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "openai/gpt-6-luna",
|
||||
"name": "GPT-6 Luna",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "x-ai/grok-4.7",
|
||||
"name": "Grok 4.7",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "xiaomi/mimo-v2.6-pro",
|
||||
"name": "MiMo-V2.6 Pro",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "xiaomi/mimo-v2.6-pro-ultraspeed",
|
||||
"name": "MiMo-V2.6 Pro UltraSpeed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "xiaomi/mimo-v2.6-flash",
|
||||
"name": "MiMo-V2.6 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "deepseek/deepseek-chat-v3.1",
|
||||
"name": "DeepSeek V3.1",
|
||||
@@ -5260,6 +5245,26 @@
|
||||
}
|
||||
],
|
||||
"qwen": [
|
||||
{
|
||||
"id": "deepseek-v4-pro-0813",
|
||||
"name": "DeepSeek V4 Pro 0813",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-v4-flash-0731",
|
||||
"name": "DeepSeek V4 Flash 0731",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "qwen3.8-max-0902",
|
||||
"name": "Qwen3.8 Max 0902",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "qwen3.8-max",
|
||||
"name": "Qwen3.8 Max",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "kimi-k2.6",
|
||||
"name": "Kimi K2.6",
|
||||
@@ -5490,10 +5495,15 @@
|
||||
"name": "QwQ Plus",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "qwen3.8-flash",
|
||||
"name": "Qwen3.8 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "qwen3.7-flash",
|
||||
"name": "Qwen3.7 Flash",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "qwen3.6-flash",
|
||||
@@ -5802,75 +5812,40 @@
|
||||
}
|
||||
],
|
||||
"sambanova": [
|
||||
{
|
||||
"id": "MiniMax-M2.7",
|
||||
"name": "MiniMax M2.7",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "DeepSeek-V3.1",
|
||||
"name": "DeepSeek V3.1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.3-70B-Instruct",
|
||||
"name": "Meta Llama 3.3 70B Instruct",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.2-1B-Instruct",
|
||||
"name": "Meta Llama 3.2 1B Instruct",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.2-3B-Instruct",
|
||||
"name": "Meta Llama 3.2 3B Instruct",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Llama-3.2-11B-Vision-Instruct",
|
||||
"name": "Meta Llama 3.2 11B Vision Instruct",
|
||||
"id": "gpt-oss-120b",
|
||||
"name": "GPT OSS 120B",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Llama-3.2-90B-Vision-Instruct",
|
||||
"name": "Meta Llama 3.2 90B Vision Instruct",
|
||||
"id": "MiniMax-M3",
|
||||
"name": "MiniMax M3",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.1-8B-Instruct",
|
||||
"name": "Meta Llama 3.1 8B Instruct",
|
||||
"id": "DeepSeek-V3.2",
|
||||
"name": "DeepSeek V3.2",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.1-70B-Instruct",
|
||||
"name": "Meta Llama 3.1 70B Instruct",
|
||||
"id": "gemma-4-31B-it",
|
||||
"name": "Gemma 4 31B IT",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Meta-Llama-3.1-405B-Instruct",
|
||||
"name": "Meta Llama 3.1 405B Instruct",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "Llama-3.1-Tulu-3-405B",
|
||||
"name": "Llama 3.1 Tulu 3 405B",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "DeepSeek-R1",
|
||||
"name": "DeepSeek R1",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "DeepSeek-R1-Distill-Llama-70B",
|
||||
"name": "DeepSeek R1 Distill Llama 70B",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "QwQ-32B-Preview",
|
||||
"name": "QwQ 32B Preview",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Qwen2.5-72B-Instruct",
|
||||
"name": "Qwen2.5 72B Instruct",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "Qwen2.5-Coder-32B-Instruct",
|
||||
"name": "Qwen2.5 Coder 32B Instruct",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"search1api": [
|
||||
@@ -6262,6 +6237,11 @@
|
||||
}
|
||||
],
|
||||
"stepfun": [
|
||||
{
|
||||
"id": "step-5-preview",
|
||||
"name": "Step 5 Preview",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "step-3.7-flash",
|
||||
"name": "Step 3.7 Flash",
|
||||
@@ -6407,6 +6387,16 @@
|
||||
}
|
||||
],
|
||||
"supergrok": [
|
||||
{
|
||||
"id": "grok-4.7",
|
||||
"name": "Grok 4.7",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "grok-4.6",
|
||||
"name": "Grok 4.6",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "grok-4.5",
|
||||
"name": "Grok 4.5",
|
||||
@@ -7166,10 +7156,15 @@
|
||||
}
|
||||
],
|
||||
"vertexai": [
|
||||
{
|
||||
"id": "gemini-3.8-flash",
|
||||
"name": "Gemini 3.8 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.7-flash",
|
||||
"name": "Gemini 3.7 Flash",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "gemini-3.6-flash",
|
||||
@@ -7345,20 +7340,30 @@
|
||||
"name": "Doubao Seed 2.1 Turbo",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "deepseek-v4-pro-ga",
|
||||
"name": "DeepSeek V4 Pro 0813",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-v4-flash-ga",
|
||||
"name": "DeepSeek V4 Flash 0731",
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "glm-5-2",
|
||||
"name": "GLM-5.2",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-v4-pro",
|
||||
"name": "DeepSeek V4 Pro",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "deepseek-v4-flash",
|
||||
"name": "DeepSeek V4 Flash",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"id": "doubao-seed-2.0-pro",
|
||||
@@ -7701,6 +7706,16 @@
|
||||
}
|
||||
],
|
||||
"xai": [
|
||||
{
|
||||
"id": "grok-4.7",
|
||||
"name": "Grok 4.7",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "grok-4.6",
|
||||
"name": "Grok 4.6",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "grok-4.5",
|
||||
"name": "Grok 4.5",
|
||||
@@ -7728,6 +7743,21 @@
|
||||
}
|
||||
],
|
||||
"xiaomimimo": [
|
||||
{
|
||||
"id": "mimo-v2.6-pro",
|
||||
"name": "MiMo-V2.6 Pro",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.6-pro-ultraspeed",
|
||||
"name": "MiMo-V2.6 Pro UltraSpeed",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.6-flash",
|
||||
"name": "MiMo-V2.6 Flash",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"id": "mimo-v2.5-pro",
|
||||
"name": "MiMo-V2.5 Pro",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fmt::Write as _;
|
||||
use std::io::{BufRead, Read, SeekFrom};
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::SystemTime;
|
||||
|
||||
use futures::TryFutureExt;
|
||||
@@ -27,6 +27,15 @@ pub use crash_analysis::{
|
||||
update_crash_analysis_ai_settings,
|
||||
};
|
||||
|
||||
mod logshare;
|
||||
pub use logshare::{
|
||||
LogShareDeleteResponse, LogShareSettings, LogShareUploadResponse,
|
||||
SharedLog, ai_analyze_direct, ai_analyze_stored, analyse_crash_direct,
|
||||
delete_log, delete_shared_log, get_insights, get_log_share_settings,
|
||||
list_shared_logs, record_shared_log, update_log_share_settings,
|
||||
upload_crash,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct Logs {
|
||||
pub log_type: LogType,
|
||||
@@ -39,6 +48,54 @@ pub struct Logs {
|
||||
pub enum LogType {
|
||||
InfoLog,
|
||||
CrashReport,
|
||||
JvmCrash,
|
||||
LauncherLog,
|
||||
}
|
||||
|
||||
fn isolated_minecraft_root(instance_root: &Path) -> Option<PathBuf> {
|
||||
let versions_dir = instance_root.parent()?;
|
||||
if versions_dir
|
||||
.file_name()
|
||||
.is_some_and(|name| name.eq_ignore_ascii_case("versions"))
|
||||
{
|
||||
versions_dir.parent().map(Path::to_path_buf)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn log_directories_for_type(
|
||||
state: &State,
|
||||
game_dir: &Path,
|
||||
log_type: LogType,
|
||||
) -> Vec<PathBuf> {
|
||||
match log_type {
|
||||
LogType::InfoLog => vec![state.directories.game_logs_dir(game_dir)],
|
||||
LogType::CrashReport => {
|
||||
vec![state.directories.game_crash_reports_dir(game_dir)]
|
||||
}
|
||||
LogType::JvmCrash | LogType::LauncherLog => {
|
||||
let mut directories = vec![game_dir.to_path_buf()];
|
||||
if let Some(root) = isolated_minecraft_root(game_dir) {
|
||||
directories.push(root);
|
||||
}
|
||||
directories
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_log_file_for_type(log_type: LogType, file_name: &str) -> bool {
|
||||
match log_type {
|
||||
LogType::JvmCrash => {
|
||||
let lower = file_name.to_ascii_lowercase();
|
||||
lower.starts_with("hs_err") && lower.ends_with(".log")
|
||||
}
|
||||
LogType::LauncherLog => matches!(
|
||||
file_name.to_ascii_lowercase().as_str(),
|
||||
"launcher_log.txt" | "latest_stdout.log"
|
||||
),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
const LOG_COMPACTION_THRESHOLD: usize = 20;
|
||||
@@ -448,14 +505,11 @@ pub async fn get_logs_from_type(
|
||||
.directories
|
||||
.resolve_game_dir(&instance_path, game_dir_override.as_deref());
|
||||
|
||||
let logs_folder = match log_type {
|
||||
LogType::InfoLog => state.directories.game_logs_dir(&game_dir),
|
||||
LogType::CrashReport => {
|
||||
state.directories.game_crash_reports_dir(&game_dir)
|
||||
let mut seen_files = std::collections::HashSet::new();
|
||||
for logs_folder in log_directories_for_type(&state, &game_dir, log_type) {
|
||||
if !logs_folder.exists() {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
if logs_folder.exists() {
|
||||
for entry in std::fs::read_dir(&logs_folder)
|
||||
.map_err(|e| IOError::with_path(e, &logs_folder))?
|
||||
{
|
||||
@@ -471,6 +525,12 @@ pub async fn get_logs_from_type(
|
||||
}
|
||||
if let Some(file_name) = path.file_name() {
|
||||
let file_name = file_name.to_string_lossy().to_string();
|
||||
if !is_log_file_for_type(log_type, &file_name) {
|
||||
continue;
|
||||
}
|
||||
if !seen_files.insert(file_name.clone()) {
|
||||
continue;
|
||||
}
|
||||
logs.push(
|
||||
Logs::build(
|
||||
log_type,
|
||||
@@ -507,6 +567,20 @@ pub async fn get_logs(
|
||||
&mut logs,
|
||||
)
|
||||
.await?;
|
||||
get_logs_from_type(
|
||||
instance_id,
|
||||
LogType::JvmCrash,
|
||||
clear_contents,
|
||||
&mut logs,
|
||||
)
|
||||
.await?;
|
||||
get_logs_from_type(
|
||||
instance_id,
|
||||
LogType::LauncherLog,
|
||||
clear_contents,
|
||||
&mut logs,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut logs = logs.into_iter().collect::<crate::Result<Vec<Logs>>>()?;
|
||||
logs.sort_by(|a, b| b.age.cmp(&a.age).then(b.filename.cmp(&a.filename)));
|
||||
@@ -526,13 +600,15 @@ pub async fn get_logs_by_filename(
|
||||
.directories
|
||||
.resolve_game_dir(&instance_path, game_dir_override.as_deref());
|
||||
|
||||
let path = match log_type {
|
||||
LogType::InfoLog => state.directories.game_logs_dir(&game_dir),
|
||||
LogType::CrashReport => {
|
||||
state.directories.game_crash_reports_dir(&game_dir)
|
||||
}
|
||||
}
|
||||
.join(&filename);
|
||||
let path = log_directories_for_type(&state, &game_dir, log_type)
|
||||
.into_iter()
|
||||
.map(|directory| directory.join(&filename))
|
||||
.find(|path| path.is_file())
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Log file not found: {filename}"
|
||||
))
|
||||
})?;
|
||||
|
||||
let metadata = std::fs::metadata(&path)?;
|
||||
let age = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
@@ -546,14 +622,15 @@ async fn get_output_by_filename_from_path(
|
||||
log_type: LogType,
|
||||
file_name: &str,
|
||||
) -> crate::Result<CensoredString> {
|
||||
let logs_folder = match log_type {
|
||||
LogType::InfoLog => state.directories.game_logs_dir(game_dir),
|
||||
LogType::CrashReport => {
|
||||
state.directories.game_crash_reports_dir(game_dir)
|
||||
}
|
||||
};
|
||||
|
||||
let path = logs_folder.join(file_name);
|
||||
let path = log_directories_for_type(state, game_dir, log_type)
|
||||
.into_iter()
|
||||
.map(|directory| directory.join(file_name))
|
||||
.find(|path| path.is_file())
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Log file not found: {file_name}"
|
||||
))
|
||||
})?;
|
||||
|
||||
let credentials = Credentials::get_all(&state.pool)
|
||||
.await?
|
||||
@@ -650,14 +727,15 @@ pub async fn delete_logs_by_filename(
|
||||
.directories
|
||||
.resolve_game_dir(&instance_path, game_dir_override.as_deref());
|
||||
|
||||
let logs_folder = match log_type {
|
||||
LogType::InfoLog => state.directories.game_logs_dir(&game_dir),
|
||||
LogType::CrashReport => {
|
||||
state.directories.game_crash_reports_dir(&game_dir)
|
||||
}
|
||||
};
|
||||
|
||||
let path = logs_folder.join(filename);
|
||||
let path = log_directories_for_type(&state, &game_dir, log_type)
|
||||
.into_iter()
|
||||
.map(|directory| directory.join(filename))
|
||||
.find(|path| path.is_file())
|
||||
.ok_or_else(|| {
|
||||
crate::ErrorKind::OtherError(format!(
|
||||
"Log file not found: {filename}"
|
||||
))
|
||||
})?;
|
||||
io::remove_file(&path).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ pub struct CrashAnalysisMod {
|
||||
struct SourceCandidate {
|
||||
path: PathBuf,
|
||||
filename: String,
|
||||
upload_name: String,
|
||||
source_type: &'static str,
|
||||
modified: SystemTime,
|
||||
}
|
||||
@@ -116,10 +117,25 @@ struct SourceCandidate {
|
||||
#[derive(Debug)]
|
||||
struct SourceText {
|
||||
filename: String,
|
||||
upload_name: String,
|
||||
source_type: &'static str,
|
||||
modified: SystemTime,
|
||||
content: String,
|
||||
}
|
||||
pub(super) struct CollectedCrashLog {
|
||||
pub name: String,
|
||||
pub content: CensoredString,
|
||||
}
|
||||
|
||||
pub(super) struct CollectedCrashLogs {
|
||||
pub combined_log: CensoredString,
|
||||
pub sources: Vec<CollectedCrashLog>,
|
||||
}
|
||||
|
||||
struct CrashContext {
|
||||
sources: Vec<SourceText>,
|
||||
credentials: Vec<Credentials>,
|
||||
}
|
||||
|
||||
struct Rule {
|
||||
id: &'static str,
|
||||
@@ -1185,20 +1201,25 @@ async fn collect_candidates(
|
||||
) -> crate::Result<Vec<SourceCandidate>> {
|
||||
let mut candidates = Vec::new();
|
||||
let mut locations = vec![
|
||||
(directories.game_logs_dir(instance_root), "minecraft_log"),
|
||||
(
|
||||
directories.game_logs_dir(instance_root),
|
||||
"minecraft_log",
|
||||
None,
|
||||
),
|
||||
(
|
||||
directories.game_crash_reports_dir(instance_root),
|
||||
"crash_report",
|
||||
Some("crash-reports"),
|
||||
),
|
||||
(instance_root.to_path_buf(), "instance_log"),
|
||||
(instance_root.to_path_buf(), "instance_log", None),
|
||||
];
|
||||
if let Some(dot_minecraft) = isolated_minecraft_root(instance_root) {
|
||||
// PCL-CE also searches the shared `.minecraft` root for JVM crash
|
||||
// logs when a version-isolated instance is active.
|
||||
locations.push((dot_minecraft, "minecraft_root_log"));
|
||||
locations.push((dot_minecraft, "minecraft_root_log", None));
|
||||
}
|
||||
|
||||
for (directory, default_type) in locations {
|
||||
for (directory, default_type, upload_prefix) in locations {
|
||||
if !tokio::fs::try_exists(&directory).await? {
|
||||
continue;
|
||||
}
|
||||
@@ -1248,6 +1269,9 @@ async fn collect_candidates(
|
||||
};
|
||||
candidates.push(SourceCandidate {
|
||||
path: entry.path(),
|
||||
upload_name: upload_prefix
|
||||
.map(|prefix| format!("{prefix}/{filename}"))
|
||||
.unwrap_or_else(|| filename.clone()),
|
||||
filename,
|
||||
source_type,
|
||||
modified: metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH),
|
||||
@@ -1257,6 +1281,53 @@ async fn collect_candidates(
|
||||
Ok(candidates)
|
||||
}
|
||||
|
||||
async fn collect_crash_context(
|
||||
instance_id: &str,
|
||||
) -> crate::Result<CrashContext> {
|
||||
let state = State::get().await?;
|
||||
let (instance_path, game_dir_override) =
|
||||
resolve_instance_path(instance_id, &state).await?;
|
||||
let instance_root = state
|
||||
.directories
|
||||
.resolve_game_dir(&instance_path, game_dir_override.as_deref());
|
||||
let candidates =
|
||||
collect_candidates(&instance_root, &state.directories).await?;
|
||||
let selected = select_run_candidates(candidates);
|
||||
let sources = read_sources(selected).await;
|
||||
let credentials = Credentials::get_all(&state.pool)
|
||||
.await?
|
||||
.into_iter()
|
||||
.map(|credential| credential.1)
|
||||
.collect::<Vec<_>>();
|
||||
Ok(CrashContext {
|
||||
sources,
|
||||
credentials,
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn collect_crash_logs(
|
||||
instance_id: &str,
|
||||
) -> crate::Result<CollectedCrashLogs> {
|
||||
let CrashContext {
|
||||
sources,
|
||||
credentials,
|
||||
..
|
||||
} = collect_crash_context(instance_id).await?;
|
||||
let combined_log =
|
||||
CensoredString::censor(build_combined_log(&sources), &credentials);
|
||||
let sources = sources
|
||||
.into_iter()
|
||||
.map(|source| CollectedCrashLog {
|
||||
name: source.upload_name,
|
||||
content: CensoredString::censor(source.content, &credentials),
|
||||
})
|
||||
.collect();
|
||||
Ok(CollectedCrashLogs {
|
||||
combined_log,
|
||||
sources,
|
||||
})
|
||||
}
|
||||
|
||||
fn isolated_minecraft_root(instance_root: &Path) -> Option<PathBuf> {
|
||||
let versions_dir = instance_root.parent()?;
|
||||
if versions_dir
|
||||
@@ -1320,6 +1391,7 @@ async fn read_sources(candidates: Vec<SourceCandidate>) -> Vec<SourceText> {
|
||||
};
|
||||
sources.push(SourceText {
|
||||
filename: candidate.filename,
|
||||
upload_name: candidate.upload_name,
|
||||
source_type: candidate.source_type,
|
||||
modified: candidate.modified,
|
||||
content: String::from_utf8_lossy(bytes).into_owned(),
|
||||
@@ -1779,6 +1851,7 @@ mod tests {
|
||||
fn source(filename: &str, content: &str) -> SourceText {
|
||||
SourceText {
|
||||
filename: filename.to_string(),
|
||||
upload_name: filename.to_string(),
|
||||
source_type: "minecraft_log",
|
||||
modified: SystemTime::now(),
|
||||
content: content.to_string(),
|
||||
@@ -1802,6 +1875,7 @@ mod tests {
|
||||
let candidates = vec![SourceCandidate {
|
||||
path: PathBuf::from("launcher_log.txt"),
|
||||
filename: "launcher_log.txt".to_string(),
|
||||
upload_name: "launcher_log.txt".to_string(),
|
||||
source_type: "minecraft_log",
|
||||
modified: SystemTime::now() - Duration::from_secs(181),
|
||||
}];
|
||||
|
||||
@@ -0,0 +1,622 @@
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use futures::StreamExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::crash_analysis::collect_crash_logs;
|
||||
use crate::State;
|
||||
use crate::emit_logshare_ai_event;
|
||||
|
||||
const LOGSHARE_BASE_URL: &str = "https://api.logshare.cn";
|
||||
const LOGSHARE_AI_READ_TIMEOUT_SECS: u64 = 300;
|
||||
const LOGSHARE_SOURCE_PREFIX: &str = "starlight";
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct LogShareSettings {
|
||||
pub share_provider: String,
|
||||
pub ai_source: String,
|
||||
pub auto_upload: bool,
|
||||
pub multi_file: bool,
|
||||
pub no_storage: bool,
|
||||
pub show_progress: bool,
|
||||
}
|
||||
|
||||
impl Default for LogShareSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
share_provider: "logshare".to_string(),
|
||||
ai_source: "logshare".to_string(),
|
||||
auto_upload: true,
|
||||
multi_file: true,
|
||||
no_storage: false,
|
||||
show_progress: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct SharedLog {
|
||||
pub id: String,
|
||||
pub url: String,
|
||||
pub raw: String,
|
||||
pub token: String,
|
||||
pub provider: String,
|
||||
pub instance_id: Option<String>,
|
||||
pub instance_name: Option<String>,
|
||||
pub truncated: bool,
|
||||
pub created_at: i64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct LogShareUploadResponse {
|
||||
pub success: bool,
|
||||
pub id: String,
|
||||
pub url: String,
|
||||
pub raw: String,
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct LogShareDeleteResponse {
|
||||
pub success: bool,
|
||||
pub deleted: Vec<String>,
|
||||
pub failed: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
struct UploadFile {
|
||||
name: String,
|
||||
content: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
struct UploadBody {
|
||||
content: String,
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
files: Vec<UploadFile>,
|
||||
source: String,
|
||||
}
|
||||
|
||||
pub async fn get_log_share_settings() -> crate::Result<LogShareSettings> {
|
||||
let state = State::get().await?;
|
||||
let row = sqlx::query_as::<_, (String, String, i64, i64, i64, i64)>(
|
||||
"SELECT share_provider, ai_source, auto_upload, multi_file, no_storage, show_progress FROM log_share_settings WHERE id = 0",
|
||||
)
|
||||
.fetch_one(&state.pool)
|
||||
.await?;
|
||||
Ok(LogShareSettings {
|
||||
share_provider: row.0,
|
||||
ai_source: row.1,
|
||||
auto_upload: row.2 != 0,
|
||||
multi_file: row.3 != 0,
|
||||
no_storage: row.4 != 0,
|
||||
show_progress: row.5 != 0,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn update_log_share_settings(
|
||||
settings: LogShareSettings,
|
||||
) -> crate::Result<()> {
|
||||
let settings = normalize_settings(settings);
|
||||
let state = State::get().await?;
|
||||
sqlx::query(
|
||||
"UPDATE log_share_settings SET share_provider = ?, ai_source = ?, auto_upload = ?, multi_file = ?, no_storage = ?, show_progress = ? WHERE id = 0",
|
||||
)
|
||||
.bind(&settings.share_provider)
|
||||
.bind(&settings.ai_source)
|
||||
.bind(settings.auto_upload)
|
||||
.bind(settings.multi_file)
|
||||
.bind(settings.no_storage)
|
||||
.bind(settings.show_progress)
|
||||
.execute(&state.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn normalize_settings(mut settings: LogShareSettings) -> LogShareSettings {
|
||||
if settings.share_provider != "logshare" {
|
||||
settings.share_provider = "mclogs".to_string();
|
||||
}
|
||||
if settings.ai_source != "logshare" {
|
||||
settings.ai_source = "custom".to_string();
|
||||
}
|
||||
settings
|
||||
}
|
||||
|
||||
pub async fn list_shared_logs() -> crate::Result<Vec<SharedLog>> {
|
||||
let state = State::get().await?;
|
||||
let rows = sqlx::query_as::<_, (String, String, String, String, String, Option<String>, Option<String>, i64, i64)>(
|
||||
"SELECT id, url, raw, token, provider, instance_id, instance_name, truncated, created_at FROM shared_logs ORDER BY created_at DESC",
|
||||
)
|
||||
.fetch_all(&state.pool)
|
||||
.await?;
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|row| SharedLog {
|
||||
id: row.0,
|
||||
url: row.1,
|
||||
raw: row.2,
|
||||
token: row.3,
|
||||
provider: row.4,
|
||||
instance_id: row.5,
|
||||
instance_name: row.6,
|
||||
truncated: row.7 != 0,
|
||||
created_at: row.8,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub async fn record_shared_log(log: SharedLog) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
let created_at = log.created_at.max(now_seconds());
|
||||
sqlx::query(
|
||||
"INSERT INTO shared_logs (id, url, raw, token, provider, instance_id, instance_name, truncated, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(id) DO UPDATE SET url = excluded.url, raw = excluded.raw, token = excluded.token, provider = excluded.provider, instance_id = excluded.instance_id, instance_name = excluded.instance_name, truncated = excluded.truncated",
|
||||
)
|
||||
.bind(&log.id)
|
||||
.bind(&log.url)
|
||||
.bind(&log.raw)
|
||||
.bind(&log.token)
|
||||
.bind(&log.provider)
|
||||
.bind(&log.instance_id)
|
||||
.bind(&log.instance_name)
|
||||
.bind(log.truncated)
|
||||
.bind(created_at)
|
||||
.execute(&state.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn remove_shared_log_record(id: &str) -> crate::Result<()> {
|
||||
let state = State::get().await?;
|
||||
sqlx::query("DELETE FROM shared_logs WHERE id = ?")
|
||||
.bind(id)
|
||||
.execute(&state.pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_shared_log(id: String, token: String) -> crate::Result<()> {
|
||||
let remote_result = delete_log(&id, &token).await;
|
||||
if let Err(error) = remote_result {
|
||||
tracing::warn!(
|
||||
"Remote LogShare deletion failed for {id}; removing the local record anyway: {error}"
|
||||
);
|
||||
}
|
||||
remove_shared_log_record(&id).await
|
||||
}
|
||||
|
||||
fn now_seconds() -> i64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs() as i64
|
||||
}
|
||||
|
||||
fn source_identifier() -> String {
|
||||
format!("{LOGSHARE_SOURCE_PREFIX}/{}", env!("CARGO_PKG_VERSION"))
|
||||
}
|
||||
|
||||
async fn prepare_upload(instance_id: &str) -> crate::Result<UploadBody> {
|
||||
let settings = get_log_share_settings().await?;
|
||||
let logs = collect_crash_logs(instance_id).await?;
|
||||
|
||||
let combined = logs.combined_log.as_str().to_string();
|
||||
let files = if settings.multi_file {
|
||||
logs.sources
|
||||
.iter()
|
||||
.map(|source| UploadFile {
|
||||
name: source.name.clone(),
|
||||
content: source.content.as_str().to_string(),
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
Ok(UploadBody {
|
||||
content: combined,
|
||||
files,
|
||||
source: source_identifier(),
|
||||
})
|
||||
}
|
||||
|
||||
async fn request_client() -> crate::Result<reqwest::Client> {
|
||||
let state = State::get().await?;
|
||||
let proxy = state.proxy_config().await?;
|
||||
let builder = reqwest::Client::builder()
|
||||
.connect_timeout(Duration::from_secs(30))
|
||||
.read_timeout(Duration::from_secs(LOGSHARE_AI_READ_TIMEOUT_SECS))
|
||||
.user_agent(crate::launcher_user_agent());
|
||||
proxy.apply(builder)?.build().map_err(Into::into)
|
||||
}
|
||||
|
||||
pub async fn upload_crash(
|
||||
instance_id: &str,
|
||||
) -> crate::Result<LogShareUploadResponse> {
|
||||
let prepared = prepare_upload(instance_id).await?;
|
||||
let client = request_client().await?;
|
||||
let body_value = serde_json::to_value(&prepared)?;
|
||||
let request = client
|
||||
.post(format!("{LOGSHARE_BASE_URL}/v1/log"))
|
||||
.header("Accept", "application/json")
|
||||
.header("Accept-Encoding", "br, gzip");
|
||||
|
||||
let response = request.json(&body_value).send().await?;
|
||||
let status = response.status();
|
||||
let text = response.text().await?;
|
||||
if !status.is_success() {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogShare upload failed with HTTP {status}: {}",
|
||||
text.chars().take(500).collect::<String>()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
let value: Value = serde_json::from_str(&text).map_err(|_| {
|
||||
crate::ErrorKind::OtherError(
|
||||
"LogShare returned invalid JSON".to_string(),
|
||||
)
|
||||
})?;
|
||||
if value.get("success").and_then(Value::as_bool) != Some(true) {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogShare upload failed: {}",
|
||||
value
|
||||
.get("error")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("unknown error")
|
||||
))
|
||||
.into());
|
||||
}
|
||||
Ok(LogShareUploadResponse {
|
||||
success: true,
|
||||
id: value
|
||||
.get("id")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
url: value
|
||||
.get("url")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
raw: value
|
||||
.get("raw")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
token: value
|
||||
.get("token")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn get_insights(id: &str) -> crate::Result<Value> {
|
||||
let client = request_client().await?;
|
||||
let response = client
|
||||
.get(format!("{LOGSHARE_BASE_URL}/v1/insights/{id}"))
|
||||
.header("Accept", "application/json")
|
||||
.header("Accept-Encoding", "br, gzip")
|
||||
.send()
|
||||
.await?;
|
||||
let status = response.status();
|
||||
let text = response.text().await?;
|
||||
if !status.is_success() {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogShare analysis failed with HTTP {status}: {}",
|
||||
text.chars().take(500).collect::<String>()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
serde_json::from_str(&text).map_err(|_| {
|
||||
crate::ErrorKind::OtherError(
|
||||
"LogShare returned invalid insights JSON".to_string(),
|
||||
)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn analyse_crash_direct(instance_id: &str) -> crate::Result<Value> {
|
||||
let prepared = prepare_upload(instance_id).await?;
|
||||
let client = request_client().await?;
|
||||
let response = client
|
||||
.post(format!("{LOGSHARE_BASE_URL}/v1/analyse"))
|
||||
.header("Accept", "application/json")
|
||||
.header("Accept-Encoding", "br, gzip")
|
||||
.json(&prepared)
|
||||
.send()
|
||||
.await?;
|
||||
let status = response.status();
|
||||
let text = response.text().await?;
|
||||
if !status.is_success() {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogShare analysis failed with HTTP {status}: {}",
|
||||
text.chars().take(500).collect::<String>()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
serde_json::from_str(&text).map_err(|_| {
|
||||
crate::ErrorKind::OtherError(
|
||||
"LogShare returned invalid analysis JSON".to_string(),
|
||||
)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn delete_log(
|
||||
id: &str,
|
||||
token: &str,
|
||||
) -> crate::Result<LogShareDeleteResponse> {
|
||||
let client = request_client().await?;
|
||||
let response = client
|
||||
.delete(format!("{LOGSHARE_BASE_URL}/v1/log/{id}"))
|
||||
.bearer_auth(token)
|
||||
.header("Accept", "application/json")
|
||||
.header("Accept-Encoding", "br, gzip")
|
||||
.send()
|
||||
.await?;
|
||||
let status = response.status();
|
||||
let text = response.text().await?;
|
||||
if !status.is_success() {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogShare deletion failed with HTTP {status}: {}",
|
||||
text.chars().take(500).collect::<String>()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
serde_json::from_str(&text).map_err(|_| {
|
||||
crate::ErrorKind::OtherError(
|
||||
"LogShare returned invalid deletion JSON".to_string(),
|
||||
)
|
||||
.into()
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn ai_analyze_stored(
|
||||
instance_id: &str,
|
||||
id: &str,
|
||||
) -> crate::Result<String> {
|
||||
let url = format!("{LOGSHARE_BASE_URL}/v1/ai/{id}");
|
||||
stream_ai(instance_id, url, None).await
|
||||
}
|
||||
|
||||
pub async fn ai_analyze_direct(instance_id: &str) -> crate::Result<String> {
|
||||
let prepared = prepare_upload(instance_id).await?;
|
||||
let url = format!("{LOGSHARE_BASE_URL}/v1/ai/analyse");
|
||||
let body = serde_json::to_value(&prepared)?;
|
||||
stream_ai(instance_id, url, Some(body)).await
|
||||
}
|
||||
|
||||
async fn stream_ai(
|
||||
instance_id: &str,
|
||||
url: String,
|
||||
body: Option<Value>,
|
||||
) -> crate::Result<String> {
|
||||
let settings = get_log_share_settings().await?;
|
||||
let show_progress = settings.show_progress;
|
||||
let client = request_client().await?;
|
||||
let mut request = client
|
||||
.request(
|
||||
if body.is_some() {
|
||||
reqwest::Method::POST
|
||||
} else {
|
||||
reqwest::Method::GET
|
||||
},
|
||||
url.as_str(),
|
||||
)
|
||||
.header("Accept", "text/event-stream")
|
||||
.header("Accept-Encoding", "br, gzip");
|
||||
if let Some(payload) = body {
|
||||
request = request.json(&payload);
|
||||
}
|
||||
|
||||
let response = request.send().await?;
|
||||
let status = response.status();
|
||||
if !status.is_success() {
|
||||
if status == reqwest::StatusCode::TOO_MANY_REQUESTS {
|
||||
return Err(crate::ErrorKind::OtherError(
|
||||
"LogAgent queue is full, please retry later".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let text = response.text().await?;
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogAgent analysis failed with HTTP {status}: {}",
|
||||
text.chars().take(500).collect::<String>()
|
||||
))
|
||||
.into());
|
||||
}
|
||||
|
||||
let mut stream = response.bytes_stream();
|
||||
let mut parser = SseParser::new();
|
||||
let mut output = String::new();
|
||||
|
||||
loop {
|
||||
let maybe = tokio::time::timeout(
|
||||
Duration::from_secs(LOGSHARE_AI_READ_TIMEOUT_SECS),
|
||||
stream.next(),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| {
|
||||
crate::ErrorKind::OtherError(
|
||||
"LogAgent analysis timed out".to_string(),
|
||||
)
|
||||
})?;
|
||||
let Some(chunk) = maybe else {
|
||||
break;
|
||||
};
|
||||
let chunk = chunk?;
|
||||
for event in parser.feed(&chunk) {
|
||||
if let Some(delta) = event.content {
|
||||
output.push_str(&delta);
|
||||
if show_progress {
|
||||
emit_logshare_ai_event(
|
||||
instance_id,
|
||||
"delta",
|
||||
json!({ "content": delta }),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
if let Some(status_event) = event.status_event {
|
||||
if show_progress || status_event.event_type == "queued" {
|
||||
emit_logshare_ai_event(
|
||||
instance_id,
|
||||
&status_event.event_type,
|
||||
status_event.data,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
if let Some(message) = event.error {
|
||||
return Err(crate::ErrorKind::OtherError(format!(
|
||||
"LogAgent analysis failed: {message}"
|
||||
))
|
||||
.into());
|
||||
}
|
||||
if event.done {
|
||||
return Ok(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A stream that ended without `event: done` is acceptable as long as text
|
||||
// was produced; otherwise it is a protocol error worth surfacing.
|
||||
if output.is_empty() {
|
||||
return Err(crate::ErrorKind::OtherError(
|
||||
"LogAgent analysis ended without output".to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
struct ParsedEvent {
|
||||
content: Option<String>,
|
||||
status_event: Option<ParsedStatusEvent>,
|
||||
done: bool,
|
||||
error: Option<String>,
|
||||
}
|
||||
|
||||
struct ParsedStatusEvent {
|
||||
event_type: String,
|
||||
data: Value,
|
||||
}
|
||||
|
||||
struct SseParser {
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl SseParser {
|
||||
fn new() -> Self {
|
||||
Self { buffer: Vec::new() }
|
||||
}
|
||||
|
||||
fn feed(&mut self, chunk: &[u8]) -> Vec<ParsedEvent> {
|
||||
self.buffer.extend_from_slice(chunk);
|
||||
let mut events = Vec::new();
|
||||
loop {
|
||||
let lf_pos = find_bytes(&self.buffer, b"\n\n");
|
||||
let crlf_pos = find_bytes(&self.buffer, b"\r\n\r\n");
|
||||
let (pos, separator_len) = match (lf_pos, crlf_pos) {
|
||||
(Some(lf_pos), Some(crlf_pos)) if crlf_pos < lf_pos => {
|
||||
(crlf_pos, 4)
|
||||
}
|
||||
(Some(lf_pos), _) => (lf_pos, 2),
|
||||
(None, Some(crlf_pos)) => (crlf_pos, 4),
|
||||
(None, None) => break,
|
||||
};
|
||||
let block =
|
||||
String::from_utf8_lossy(&self.buffer[..pos]).into_owned();
|
||||
self.buffer.drain(..pos + separator_len);
|
||||
if let Some(event) = parse_sse_block(&block) {
|
||||
events.push(event);
|
||||
}
|
||||
}
|
||||
events
|
||||
}
|
||||
}
|
||||
|
||||
fn find_bytes(haystack: &[u8], needle: &[u8]) -> Option<usize> {
|
||||
haystack.windows(needle.len()).position(|w| w == needle)
|
||||
}
|
||||
|
||||
fn parse_sse_block(block: &str) -> Option<ParsedEvent> {
|
||||
let mut event_name: Option<String> = None;
|
||||
let mut data_lines = Vec::new();
|
||||
|
||||
for line in block.lines() {
|
||||
if let Some(rest) = line.strip_prefix("event:") {
|
||||
event_name = Some(rest.trim().to_string());
|
||||
} else if let Some(rest) = line.strip_prefix("data:") {
|
||||
data_lines.push(rest.trim_start().to_string());
|
||||
}
|
||||
}
|
||||
if event_name.is_none() && data_lines.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let data_text = data_lines.join("\n");
|
||||
let event_name = event_name.as_deref().unwrap_or("message");
|
||||
|
||||
match event_name {
|
||||
"done" => Some(ParsedEvent {
|
||||
content: None,
|
||||
status_event: None,
|
||||
done: true,
|
||||
error: None,
|
||||
}),
|
||||
"error" => Some(ParsedEvent {
|
||||
content: None,
|
||||
status_event: None,
|
||||
done: false,
|
||||
error: Some(
|
||||
serde_json::from_str::<Value>(&data_text)
|
||||
.ok()
|
||||
.and_then(|value| {
|
||||
value
|
||||
.get("error")
|
||||
.and_then(Value::as_str)
|
||||
.map(str::to_string)
|
||||
})
|
||||
.unwrap_or_else(|| data_text.clone()),
|
||||
),
|
||||
}),
|
||||
"status" => {
|
||||
let Ok(value) = serde_json::from_str::<Value>(&data_text) else {
|
||||
return None;
|
||||
};
|
||||
let event_type = value
|
||||
.get("type")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("status")
|
||||
.to_string();
|
||||
Some(ParsedEvent {
|
||||
content: None,
|
||||
status_event: Some(ParsedStatusEvent {
|
||||
event_type,
|
||||
data: value,
|
||||
}),
|
||||
done: false,
|
||||
error: None,
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
let Ok(value) = serde_json::from_str::<Value>(&data_text) else {
|
||||
return None;
|
||||
};
|
||||
let content = value
|
||||
.pointer("/choices/0/delta/content")
|
||||
.and_then(Value::as_str)
|
||||
.map(str::to_string);
|
||||
Some(ParsedEvent {
|
||||
content,
|
||||
status_event: None,
|
||||
done: false,
|
||||
error: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ use tokio::{
|
||||
sync::{Mutex, OwnedMutexGuard},
|
||||
};
|
||||
|
||||
const API: &str = "https://skin.starlight.cool/starlight/mod/packs";
|
||||
const API: &str = "https://download.starlight.cool:20443/starlight/mod/packs";
|
||||
const STARLIGHT_YGGDRASIL_API_ROOT: &str =
|
||||
"https://skin.starlight.cool/yggdrasil";
|
||||
const ACCOUNT_REQUIRED_MESSAGE: &str = "您需要登录正版或皮肤站账号后才能操作";
|
||||
|
||||
@@ -612,3 +612,25 @@ where
|
||||
})
|
||||
.await
|
||||
}
|
||||
pub async fn emit_logshare_ai_event(
|
||||
instance_id: &str,
|
||||
event_type: &str,
|
||||
data: Value,
|
||||
) -> crate::Result<()> {
|
||||
#[cfg(feature = "tauri")]
|
||||
{
|
||||
let event_state = crate::EventState::get()?;
|
||||
event_state
|
||||
.app
|
||||
.emit(
|
||||
"logshare_ai",
|
||||
crate::event::LogShareAiEventPayload {
|
||||
instance_id: instance_id.to_string(),
|
||||
event_type: event_type.to_string(),
|
||||
data,
|
||||
},
|
||||
)
|
||||
.map_err(EventError::from)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -472,6 +472,14 @@ mod log_types {
|
||||
#[serde(flatten)]
|
||||
pub event: LogEvent,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct LogShareAiEventPayload {
|
||||
pub instance_id: String,
|
||||
pub event_type: String,
|
||||
pub data: serde_json::Value,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
||||
@@ -26,20 +26,20 @@ pub use api::*;
|
||||
pub use error::*;
|
||||
pub use event::{
|
||||
EventState, LoadingBar, LoadingBarType, emit::emit_loading,
|
||||
emit::init_loading,
|
||||
emit::emit_logshare_ai_event, emit::init_loading,
|
||||
};
|
||||
pub use logger::filter_log_contents;
|
||||
pub use logger::start_logger;
|
||||
pub use state::db::{
|
||||
backup_current_app_db_for_update, beta_database_exists,
|
||||
copy_database_between_channels, copy_release_database_to_beta,
|
||||
current_app_database_path,
|
||||
current_app_database_path, default_update_channel,
|
||||
};
|
||||
pub use state::{DirectoryInfo, State};
|
||||
pub use storage::*;
|
||||
pub use util::fetch::build_proxied_client;
|
||||
pub use util::file_lock::{LockingProcess, get_locking_processes};
|
||||
pub use util::platform::is_process_elevated;
|
||||
pub use util::platform::{default_game_dir_root, is_process_elevated};
|
||||
pub use util::proxy::{ProxyConfig, ProxyMode, ProxyTestResult};
|
||||
pub use util::symlink::SymlinkCapability;
|
||||
|
||||
|
||||
@@ -304,6 +304,18 @@ async fn app_db_path(settings_dir: &Path) -> crate::Result<PathBuf> {
|
||||
Ok(settings_dir.join(channel).join(LEGACY_APP_DB_FILE))
|
||||
}
|
||||
|
||||
/// The update channel a fresh install should default to. Beta builds carry a
|
||||
/// pre-release version (e.g. `1.0.2-beta7`), so their installers should start
|
||||
/// on the Beta channel instead of silently falling back to Release.
|
||||
pub fn default_update_channel() -> &'static str {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
if version.contains('-') {
|
||||
"beta"
|
||||
} else {
|
||||
"release"
|
||||
}
|
||||
}
|
||||
|
||||
async fn read_update_channel(
|
||||
settings_dir: &Path,
|
||||
) -> crate::Result<&'static str> {
|
||||
@@ -311,7 +323,7 @@ async fn read_update_channel(
|
||||
let contents = match tokio::fs::read_to_string(&path).await {
|
||||
Ok(contents) => contents,
|
||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
|
||||
return Ok("release");
|
||||
return Ok(default_update_channel());
|
||||
}
|
||||
Err(error) => return Err(error.into()),
|
||||
};
|
||||
|
||||
@@ -713,16 +713,37 @@ impl Process {
|
||||
|
||||
pending.push_str(&String::from_utf8_lossy(&chunk[..read]));
|
||||
|
||||
// Drain every complete frame currently buffered.
|
||||
while let Some(frame) = take_next_log4j_frame(&mut pending) {
|
||||
Self::handle_log4j_frame(
|
||||
instance_id,
|
||||
instance_name,
|
||||
process_id,
|
||||
log_path.as_ref(),
|
||||
&frame,
|
||||
)
|
||||
.await;
|
||||
// Mods can write plain text to either pipe even when the
|
||||
// launcher selected XML logging. Forward it as soon as a line
|
||||
// is complete instead of retaining it until the game exits.
|
||||
while let Some(output) = take_next_log_output(&mut pending) {
|
||||
match output {
|
||||
LogOutput::Xml(frame) => {
|
||||
Self::handle_log4j_frame(
|
||||
instance_id,
|
||||
instance_name,
|
||||
process_id,
|
||||
log_path.as_ref(),
|
||||
&frame,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
LogOutput::Legacy(text) => {
|
||||
if let Err(e) =
|
||||
Self::append_to_log_file(&log_path, &text)
|
||||
{
|
||||
tracing::warn!(
|
||||
"Failed to write to log file: {e}"
|
||||
);
|
||||
}
|
||||
if !text.trim_end().is_empty() {
|
||||
Self::emit_legacy_log(
|
||||
instance_id,
|
||||
text.trim_end(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Guard against a runaway buffer if no frame delimiters ever
|
||||
@@ -1360,32 +1381,119 @@ impl Process {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
/// Cuts the next complete `<log4j:Event …>…</log4j:Event>` frame out of the
|
||||
/// live buffer and returns it as an owned string, leaving any trailing partial
|
||||
/// frame in place.
|
||||
///
|
||||
/// Returns `None` when the buffer does not yet contain a full frame. This is a
|
||||
/// plain string operation on purpose: it never poisons any parser state, so a
|
||||
/// split or malformed frame on the live pipe cannot stop log forwarding.
|
||||
fn take_next_log4j_frame(buffer: &mut String) -> Option<String> {
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
enum LogOutput {
|
||||
Xml(String),
|
||||
Legacy(String),
|
||||
}
|
||||
|
||||
/// Drains complete XML frames or plain text in stream order. Partial frames
|
||||
/// and plain text lines remain buffered until their next chunk arrives.
|
||||
fn take_next_log_output(buffer: &mut String) -> Option<LogOutput> {
|
||||
const OPEN: &str = "<log4j:Event";
|
||||
const CLOSE: &str = "</log4j:Event>";
|
||||
|
||||
let start = buffer.find(OPEN)?;
|
||||
// Discard anything before the frame (raw text, XML prolog, …).
|
||||
if start > 0 {
|
||||
buffer.drain(..start);
|
||||
match buffer.find(OPEN) {
|
||||
Some(0) => {
|
||||
let close = buffer.find(CLOSE)?;
|
||||
let end = close + CLOSE.len();
|
||||
Some(LogOutput::Xml(buffer.drain(..end).collect()))
|
||||
}
|
||||
Some(start) => Some(LogOutput::Legacy(buffer.drain(..start).collect())),
|
||||
None => {
|
||||
let end = buffer.find('\n')? + 1;
|
||||
Some(LogOutput::Legacy(buffer.drain(..end).collect()))
|
||||
}
|
||||
}
|
||||
let close = buffer.find(CLOSE)?;
|
||||
let end = close + CLOSE.len();
|
||||
let frame = buffer[..end].to_string();
|
||||
buffer.drain(..end);
|
||||
Some(frame)
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod post_upgrade_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn mixed_log_output_keeps_partial_xml_and_multiline_messages() {
|
||||
let mut pending = "raw\n<log4j:Ev".to_string();
|
||||
assert_eq!(
|
||||
take_next_log_output(&mut pending),
|
||||
Some(LogOutput::Legacy("raw\n".into()))
|
||||
);
|
||||
assert_eq!(take_next_log_output(&mut pending), None);
|
||||
pending.push_str("ent><log4j:Message><![CDATA[first\nsecond");
|
||||
assert_eq!(take_next_log_output(&mut pending), None);
|
||||
pending.push_str("]]></log4j:Message></log4j:Event>\nafter\n");
|
||||
assert_eq!(take_next_log_output(&mut pending), Some(LogOutput::Xml("<log4j:Event><log4j:Message><![CDATA[first\nsecond]]></log4j:Message></log4j:Event>".into())));
|
||||
assert_eq!(
|
||||
take_next_log_output(&mut pending),
|
||||
Some(LogOutput::Legacy("\n".into()))
|
||||
);
|
||||
assert_eq!(
|
||||
take_next_log_output(&mut pending),
|
||||
Some(LogOutput::Legacy("after\n".into()))
|
||||
);
|
||||
assert!(pending.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn xml_logging_forwards_plain_text_before_pipe_closes() {
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
let instance_id = Uuid::new_v4().to_string();
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let log_path = directory.path().join("live.log");
|
||||
let (mut writer, reader) = tokio::io::duplex(1024);
|
||||
let output = Process::process_output(
|
||||
&instance_id,
|
||||
"instance",
|
||||
"Instance",
|
||||
"process",
|
||||
reader,
|
||||
&log_path,
|
||||
true,
|
||||
);
|
||||
tokio::pin!(output);
|
||||
writer.write_all(b"mod output\n").await.unwrap();
|
||||
let forwarded = async {
|
||||
loop {
|
||||
if get_log_buffer(&instance_id) == ["mod output"] {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(5)).await;
|
||||
}
|
||||
};
|
||||
tokio::select! {
|
||||
_ = &mut output => panic!("reader ended while writer is still open"),
|
||||
result = tokio::time::timeout(std::time::Duration::from_secs(1), forwarded) => {
|
||||
result.expect("plain text was buffered until EOF");
|
||||
}
|
||||
}
|
||||
assert_eq!(std::fs::read_to_string(&log_path).unwrap(), "mod output\n");
|
||||
drop(writer);
|
||||
output.await;
|
||||
remove_log_buffer(&instance_id);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn xml_logging_preserves_plain_text_before_xml_frames() {
|
||||
let instance_id = Uuid::new_v4().to_string();
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let log_path = directory.path().join("mixed.log");
|
||||
let input = "mod output\n<log4j:Event level=\"INFO\"><log4j:Message><![CDATA[xml output]]></log4j:Message></log4j:Event>\n";
|
||||
Process::process_output(
|
||||
&instance_id,
|
||||
"instance",
|
||||
"Instance",
|
||||
"process",
|
||||
std::io::Cursor::new(input),
|
||||
&log_path,
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
let lines = get_log_buffer(&instance_id);
|
||||
assert_eq!(lines.first().map(String::as_str), Some("mod output"));
|
||||
assert!(lines.iter().any(|line| line.contains("xml output")));
|
||||
remove_log_buffer(&instance_id);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_log_snapshot_sequences_batches_and_preserves_position_after_clear()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Platform-related code
|
||||
use daedalus::minecraft::{Os, OsRule};
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// (e.g. "Run as administrator" on Windows).
|
||||
#[cfg(target_os = "windows")]
|
||||
@@ -143,3 +144,31 @@ pub fn classpath_separator(java_arch: &str) -> &'static str {
|
||||
Os::Windows | Os::WindowsArm64 => ";",
|
||||
}
|
||||
}
|
||||
|
||||
/// Root directory used as the default for one-click StarLight instance
|
||||
/// installs. Portable builds live next to their executable, which is a fine
|
||||
/// place for game data. System installs (e.g. a Linux `.deb` under `/usr/bin`)
|
||||
/// do not, so fall back to the user's home directory there.
|
||||
pub fn default_game_dir_root() -> Option<PathBuf> {
|
||||
let exe_dir = std::env::current_exe().ok()?.parent()?.to_path_buf();
|
||||
if cfg!(target_os = "linux") && is_system_install_dir(&exe_dir) {
|
||||
return dirs::home_dir();
|
||||
}
|
||||
Some(exe_dir)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn is_system_install_dir(path: &std::path::Path) -> bool {
|
||||
const SYSTEM_PREFIXES: &[&str] = &[
|
||||
"/usr/", "/opt/", "/snap/", "/bin/", "/sbin/", "/lib/", "/lib64/",
|
||||
];
|
||||
let display = path.to_string_lossy();
|
||||
SYSTEM_PREFIXES
|
||||
.iter()
|
||||
.any(|prefix| display.starts_with(prefix))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn is_system_install_dir(_path: &std::path::Path) -> bool {
|
||||
false
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<span class="inline-flex flex-wrap items-center gap-1">
|
||||
<kbd
|
||||
v-for="(part, index) in parts"
|
||||
:key="`${index}-${part}`"
|
||||
aria-hidden="true"
|
||||
class="rounded-md border border-solid border-surface-4 bg-surface-3 px-2 py-0.5 font-mono text-sm text-[var(--color-text-primary)]"
|
||||
>
|
||||
{{ part }}
|
||||
</kbd>
|
||||
<span class="sr-only">{{ text }}</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useBindingParts, useBindingText } from '../../composables/use-keybinding-labels'
|
||||
import type { KeyBinding } from '../../utils/keybinding'
|
||||
|
||||
const props = defineProps<{ binding: KeyBinding }>()
|
||||
|
||||
const parts = useBindingParts(() => props.binding)
|
||||
const text = useBindingText(() => props.binding)
|
||||
</script>
|
||||
@@ -7,6 +7,8 @@ import type { ButtonProps } from './types'
|
||||
const props = withDefaults(defineProps<ButtonProps>(), {
|
||||
type: 'base',
|
||||
size: 'md',
|
||||
iconOnly: false,
|
||||
circular: false,
|
||||
nativeType: 'button',
|
||||
disabled: false,
|
||||
loading: false,
|
||||
@@ -26,8 +28,11 @@ defineExpose({ element })
|
||||
:color="props.color"
|
||||
:size="props.size"
|
||||
:interaction="props.interaction"
|
||||
:icon-only="props.iconOnly"
|
||||
:circular="props.circular"
|
||||
:native-type="props.nativeType"
|
||||
:disabled="props.disabled || props.loading"
|
||||
:aria-label="props.iconOnly ? props.label : undefined"
|
||||
:aria-busy="props.loading || undefined"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -13,7 +13,10 @@ import type {
|
||||
const baseClasses = [
|
||||
// Base
|
||||
'relative inline-flex min-w-0 shrink-0 items-center justify-center',
|
||||
'whitespace-nowrap border-0 no-underline',
|
||||
// The transparent border is load-bearing, not decorative: it participates in
|
||||
// layout, so an auto-width button is 2px wider than it would be without it.
|
||||
// The ring participates in layout; dropping it would silently narrow every text button.
|
||||
'whitespace-nowrap border border-solid border-transparent no-underline',
|
||||
// Interactions
|
||||
'touch-manipulation cursor-pointer select-none transition-[background-color,color,box-shadow,filter,opacity,transform] duration-150 ease-out',
|
||||
'enabled:active:scale-[0.97]',
|
||||
@@ -26,6 +29,8 @@ const baseClasses = [
|
||||
].join(' ')
|
||||
|
||||
const sizeClasses: Record<ButtonSize, string> = {
|
||||
'2xs':
|
||||
'h-6 gap-1 rounded-lg px-1.5 text-sm font-semibold leading-5 [&>svg]:size-4 [&>svg]:min-h-4 [&>svg]:min-w-4 [&>svg]:shrink-0',
|
||||
xs: 'h-7 gap-1 rounded-lg px-1.5 text-sm font-semibold leading-5 [&>svg]:size-4 [&>svg]:min-h-4 [&>svg]:min-w-4 [&>svg]:shrink-0',
|
||||
sm: 'h-8 gap-1 rounded-[10px] px-1.5 text-sm font-semibold leading-5 [&>svg]:size-4 [&>svg]:min-h-4 [&>svg]:min-w-4 [&>svg]:shrink-0',
|
||||
md: 'h-9 gap-1.5 rounded-xl px-2.5 text-base font-semibold leading-5 [&>svg]:size-5 [&>svg]:min-h-5 [&>svg]:min-w-5 [&>svg]:shrink-0',
|
||||
@@ -34,6 +39,7 @@ const sizeClasses: Record<ButtonSize, string> = {
|
||||
}
|
||||
|
||||
const iconOnlySizeClasses: Record<ButtonSize, string> = {
|
||||
'2xs': 'min-w-6 w-6 !px-0',
|
||||
xs: 'min-w-7 w-7 !px-0',
|
||||
sm: 'min-w-8 w-8 !px-0',
|
||||
md: 'min-w-9 w-9 !px-0',
|
||||
@@ -42,14 +48,23 @@ const iconOnlySizeClasses: Record<ButtonSize, string> = {
|
||||
}
|
||||
|
||||
const typeClasses: Record<ButtonType, string> = {
|
||||
base: 'button-frame--base bg-surface-4 text-contrast [&>svg]:text-primary',
|
||||
base: 'button-frame--base bg-surface-4 text-[var(--color-text-primary)] [&>svg]:text-[var(--color-text-default)]',
|
||||
colored:
|
||||
'button-frame--colored bg-[--button-color] text-[var(--color-accent-contrast)] [&>svg]:text-inherit',
|
||||
'colored-text':
|
||||
'button-frame--colored-text bg-surface-4 text-[--button-color] [&>svg]:text-inherit',
|
||||
outlined:
|
||||
'button-frame--outlined bg-transparent text-[var(--button-color,var(--color-contrast))] [&>svg]:text-[var(--button-color,var(--color-base))]',
|
||||
'button-frame--outlined bg-transparent text-[var(--button-color,var(--color-text-primary))] [&>svg]:text-[var(--button-color,var(--color-text-default))]',
|
||||
quiet: 'button-frame--quiet bg-transparent [&>svg]:text-inherit',
|
||||
// A 25% tint of the accent colour. All three read the same tint; they differ
|
||||
// in label colour and whether they carry the raised shadow. Without a colour
|
||||
// the tint variable is unset and the fill falls back to the raised surface,
|
||||
// which is what the legacy uncoloured chip rendered as.
|
||||
chip: 'button-frame--chip bg-[--button-highlight,var(--surface-4)] text-[var(--button-color,var(--color-text-default))] [&>svg]:text-inherit',
|
||||
'chip-text':
|
||||
'button-frame--chip-text bg-[--button-highlight,var(--surface-4)] text-[var(--button-color,var(--color-text-default))] [&>svg]:text-inherit',
|
||||
highlight:
|
||||
'button-frame--highlight bg-[--button-highlight,var(--surface-4)] text-[var(--color-text-primary)] [&>svg]:text-inherit',
|
||||
}
|
||||
|
||||
const interactionClasses: Record<ButtonInteraction, string> = {
|
||||
@@ -67,7 +82,17 @@ const colorVariables: Record<ButtonColor, string> = {
|
||||
green: 'var(--color-green)',
|
||||
blue: 'var(--color-blue)',
|
||||
purple: 'var(--color-purple)',
|
||||
medal_promotion: 'var(--medal-promotion-text-orange, var(--color-orange))',
|
||||
}
|
||||
|
||||
// The 25%-opacity tint behind `chip`/`highlight`. Each accent has its own
|
||||
// token, so the tint must be looked up rather than derived.
|
||||
const highlightVariables: Record<ButtonColor, string> = {
|
||||
brand: 'var(--color-brand-highlight)',
|
||||
red: 'var(--color-red-highlight)',
|
||||
orange: 'var(--color-orange-highlight)',
|
||||
green: 'var(--color-green-highlight)',
|
||||
blue: 'var(--color-blue-highlight)',
|
||||
purple: 'var(--color-purple-highlight)',
|
||||
}
|
||||
|
||||
const props = withDefaults(
|
||||
@@ -101,7 +126,20 @@ const classes = computed(() => [
|
||||
props.circular ? '!rounded-full' : '',
|
||||
])
|
||||
const style = computed((): CSSProperties | undefined => {
|
||||
// `outlined` and `quiet` deliberately publish nothing without an explicit
|
||||
// colour, so their own `var(--button-color, <default>)` fallbacks apply —
|
||||
// that is what reproduces the legacy default ring and text colours.
|
||||
if ((props.type === 'outlined' || props.type === 'quiet') && !props.color) return undefined
|
||||
if (props.type === 'chip' || props.type === 'chip-text' || props.type === 'highlight') {
|
||||
// Without an accent these fall back to the page surface and the default
|
||||
// label, matching the legacy behaviour for an uncoloured chip.
|
||||
const accent = props.color
|
||||
if (!accent) return undefined
|
||||
return {
|
||||
'--button-color': colorVariables[accent],
|
||||
'--button-highlight': highlightVariables[accent],
|
||||
} as CSSProperties
|
||||
}
|
||||
if (
|
||||
props.type !== 'colored' &&
|
||||
props.type !== 'colored-text' &&
|
||||
@@ -163,11 +201,24 @@ defineExpose({ element })
|
||||
mask-composite: exclude;
|
||||
}
|
||||
|
||||
/* The ring is a real border so it participates in layout. Set here rather
|
||||
* than as a utility because it has to beat the transparent border colour in
|
||||
* `baseClasses`. */
|
||||
.button-frame--outlined {
|
||||
box-shadow: inset 0 0 0 1px var(--button-color, var(--surface-5));
|
||||
border-color: var(--button-color, var(--surface-5));
|
||||
}
|
||||
|
||||
.button-frame--quiet {
|
||||
color: var(--button-color, var(--color-base));
|
||||
color: var(--button-color, var(--color-text-default));
|
||||
}
|
||||
|
||||
/* `chip` and `highlight` are tinted fills rather than transparent ones, so they
|
||||
* keep the raised-button shadow. `chip-text` is the same tint without it --
|
||||
* the legacy `highlight-colored-text`, which never had a shadow. */
|
||||
.button-frame--chip,
|
||||
.button-frame--highlight {
|
||||
box-shadow:
|
||||
inset 0 0 0 1px var(--surface-5),
|
||||
0 1px 1px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
</style>
|
||||
@@ -1,56 +1,74 @@
|
||||
export type ButtonType = 'base' | 'colored' | 'colored-text' | 'outlined' | 'quiet'
|
||||
export type ButtonType =
|
||||
'base' | 'colored' | 'colored-text' | 'outlined' | 'quiet' | 'chip' | 'chip-text' | 'highlight'
|
||||
|
||||
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
||||
export type ButtonSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
||||
|
||||
export type ButtonInteraction = 'surface' | 'filled' | 'none'
|
||||
|
||||
// TODO: Standardized color string enum props across @modrinth/ui
|
||||
export type ButtonColor =
|
||||
| 'brand'
|
||||
| 'red'
|
||||
| 'orange'
|
||||
| 'green'
|
||||
| 'blue'
|
||||
| 'purple'
|
||||
| 'medal_promotion'
|
||||
export type ButtonColor = 'brand' | 'red' | 'orange' | 'green' | 'blue' | 'purple'
|
||||
|
||||
export type ButtonVisualProps = {
|
||||
type ButtonVisualBase = {
|
||||
size?: ButtonSize
|
||||
interaction?: ButtonInteraction
|
||||
} & (
|
||||
}
|
||||
|
||||
type ButtonVisualWithoutInteraction =
|
||||
| {
|
||||
type?: 'base'
|
||||
color?: never
|
||||
interaction?: never
|
||||
}
|
||||
| {
|
||||
type: 'outlined'
|
||||
type: Exclude<ButtonType, 'base' | 'quiet'>
|
||||
color?: ButtonColor
|
||||
interaction?: never
|
||||
}
|
||||
| {
|
||||
type: 'colored'
|
||||
color?: ButtonColor
|
||||
}
|
||||
| {
|
||||
type: 'colored-text'
|
||||
color?: ButtonColor
|
||||
}
|
||||
| {
|
||||
type: 'quiet'
|
||||
color?: ButtonColor
|
||||
}
|
||||
)
|
||||
|
||||
/**
|
||||
* Public visual combinations supported by the current button frame.
|
||||
*
|
||||
* `interaction` only changes quiet buttons, so exposing it on any other type
|
||||
* would accept a prop that has no effect. Keeping that restriction here makes
|
||||
* Button and ButtonLink share one truthful visual contract.
|
||||
*/
|
||||
export type ButtonVisualProps = ButtonVisualBase &
|
||||
(
|
||||
| ButtonVisualWithoutInteraction
|
||||
| {
|
||||
type: 'quiet'
|
||||
color?: ButtonColor
|
||||
interaction?: ButtonInteraction
|
||||
}
|
||||
)
|
||||
|
||||
export type ButtonNativeType = 'button' | 'submit' | 'reset'
|
||||
|
||||
export interface ButtonProps {
|
||||
type?: ButtonType
|
||||
color?: ButtonColor
|
||||
size?: ButtonSize
|
||||
interaction?: ButtonInteraction
|
||||
nativeType?: ButtonNativeType
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
}
|
||||
/** Icon-only controls need a name because their slot has no visible label. */
|
||||
export type ButtonContentProps =
|
||||
| {
|
||||
iconOnly: true
|
||||
label: string
|
||||
}
|
||||
| {
|
||||
iconOnly?: false
|
||||
label?: never
|
||||
}
|
||||
|
||||
export type ButtonProps = ButtonVisualProps &
|
||||
ButtonContentProps & {
|
||||
circular?: boolean
|
||||
nativeType?: ButtonNativeType
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
export type ButtonLinkProps = ButtonVisualProps &
|
||||
ButtonContentProps & {
|
||||
as?: string | import('vue').Component
|
||||
href?: string
|
||||
disabled?: boolean
|
||||
circular?: boolean
|
||||
}
|
||||
|
||||
export interface ButtonElementHandle {
|
||||
element: HTMLElement | null
|
||||
|
||||
@@ -118,3 +118,4 @@ export { default as TimeFramePicker } from './TimeFramePicker.vue'
|
||||
export { default as Timeline } from './Timeline.vue'
|
||||
export { default as Toggle } from './Toggle.vue'
|
||||
export { default as UnsavedChangesPopup } from './UnsavedChangesPopup.vue'
|
||||
export { default as KeybindingChips } from './KeybindingChips.vue'
|
||||
Loaded 100 of 114 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user