fix: 修正管理面板权限组、公告发布人与问卷选项显示
- 用户列表新增权限组列,展示权限标签 - 公告发布人由 UUID 解析为用户名 - 问卷选择题作答由选项 ID 解析为选项文字 - 维基默认打开首页,内部链接标题不再被替换下划线
This commit is contained in:
1 parent
52b3606062
commit
227af685d4
7 files changed
+78
-7
No files matched your search
@@ -101,7 +101,7 @@ function onBugCreated(id: number) {
|
||||
@open="openBug"
|
||||
/>
|
||||
<SkinSiteAdminView v-else-if="view === 'admin'" @back="view = 'home'" />
|
||||
<WikiView v-else-if="view === 'wiki'" />
|
||||
<WikiView v-else-if="view === 'wiki'" initial-title="The Land Of StarLight" />
|
||||
|
||||
<SkinSiteBugDetailView
|
||||
v-else-if="view === 'bug-detail' && selectedBugId !== null"
|
||||
|
||||
@@ -4,8 +4,10 @@ import { defineMessages, injectNotificationManager, useVIntl } from '@modrinth/u
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
import {
|
||||
type SkinSiteAdminUser,
|
||||
type SkinSiteBroadcast,
|
||||
type SkinSiteBroadcastInput,
|
||||
skinSiteAdminUserList,
|
||||
skinSiteBroadcasts,
|
||||
skinSiteCreateBroadcast,
|
||||
skinSiteDeleteBroadcast,
|
||||
@@ -44,6 +46,7 @@ const messages = defineMessages({
|
||||
})
|
||||
|
||||
const items = ref<SkinSiteBroadcast[]>([])
|
||||
const uploaderNames = ref<Record<string, string>>({})
|
||||
const loading = ref(true)
|
||||
const failed = ref(false)
|
||||
const saving = ref(false)
|
||||
@@ -154,11 +157,28 @@ const canSave = computed(
|
||||
() => form.value.title.trim().length > 0 && form.value.content.length > 0 && !saving.value,
|
||||
)
|
||||
|
||||
function uploaderName(uuid: string): string {
|
||||
return uploaderNames.value[uuid] ?? uuid
|
||||
}
|
||||
|
||||
async function loadUploaderNames() {
|
||||
try {
|
||||
const res = await skinSiteAdminUserList({ limit: 200, offset: 0 })
|
||||
if (!res.success) return
|
||||
const users: SkinSiteAdminUser[] = res.payload ?? []
|
||||
const map: Record<string, string> = {}
|
||||
for (const u of users) map[u.uuid] = u.username
|
||||
uploaderNames.value = map
|
||||
} catch {
|
||||
// 名称映射失败不影响公告列表展示
|
||||
}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
failed.value = false
|
||||
try {
|
||||
const result = await skinSiteBroadcasts()
|
||||
const [result] = await Promise.all([skinSiteBroadcasts(), loadUploaderNames()])
|
||||
if (!result.success) throw new Error(result.errorMessage)
|
||||
items.value = result.payload ?? []
|
||||
} catch (error) {
|
||||
@@ -248,7 +268,7 @@ onMounted(() => void load())
|
||||
</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 }) }}
|
||||
{{ formatMessage(messages.uploader, { name: uploaderName(item.uploader) }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -270,9 +270,18 @@ function questionFor(submission: SkinSiteReviewSubmission, questionId: string) {
|
||||
return submission.paper?.questions?.find((q) => q.id === questionId)
|
||||
}
|
||||
|
||||
function answerText(answer: SkinSiteReviewAnswer): string {
|
||||
function answerText(
|
||||
submission: SkinSiteReviewSubmission,
|
||||
answer: SkinSiteReviewAnswer,
|
||||
): string {
|
||||
if (answer.text) return answer.text
|
||||
if (Array.isArray(answer.values) && answer.values.length) return answer.values.join(', ')
|
||||
if (Array.isArray(answer.values) && answer.values.length) {
|
||||
const question = answer.questionId ? questionFor(submission, answer.questionId) : undefined
|
||||
const options = question?.options ?? []
|
||||
return answer.values
|
||||
.map((value) => options.find((o) => o.id === value)?.description ?? value)
|
||||
.join(', ')
|
||||
}
|
||||
return '—'
|
||||
}
|
||||
|
||||
@@ -1046,7 +1055,7 @@ onMounted(() => void load())
|
||||
<span
|
||||
class="mt-1 rounded-lg bg-bg px-3 py-2 text-sm break-words whitespace-pre-wrap text-contrast"
|
||||
>
|
||||
{{ answerText(answer) }}
|
||||
{{ answerText(detailSubmission, answer) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="answer.awardedScore !== null && answer.awardedScore !== undefined"
|
||||
|
||||
@@ -57,6 +57,10 @@ const messages = defineMessages({
|
||||
},
|
||||
banned: { id: 'app.skin-site.admin.users.banned', defaultMessage: 'Banned' },
|
||||
permissions: { id: 'app.skin-site.admin.users.permissions', defaultMessage: 'Permissions' },
|
||||
permissionGroups: {
|
||||
id: 'app.skin-site.admin.users.permission-groups',
|
||||
defaultMessage: 'Groups',
|
||||
},
|
||||
permissionsHint: {
|
||||
id: 'app.skin-site.admin.users.permissions-hint',
|
||||
defaultMessage: 'Comma separated, e.g. WEB_ADMIN, SERVER_ADMIN.',
|
||||
@@ -514,6 +518,21 @@ async function nextPage() {
|
||||
await load()
|
||||
}
|
||||
|
||||
const PERMISSION_META: Record<string, { label: string; color: string }> = {
|
||||
GUEST: { label: '游客', color: 'bg-button-bg text-secondary' },
|
||||
EXTERNAL_MEMBER: { label: 'Mod服玩家', color: 'bg-blue text-contrast' },
|
||||
INTERNAL_MEMBER: { label: '原版服玩家', color: 'bg-orange text-contrast' },
|
||||
SENIOR_MEMBER: { label: '老资历', color: 'bg-purple text-contrast' },
|
||||
SPONSOR: { label: '捐赠者', color: 'bg-yellow text-contrast' },
|
||||
SERVER_ADMIN: { label: '服务器管理', color: 'bg-green text-contrast' },
|
||||
WEB_ADMIN: { label: 'Web 管理', color: 'bg-brand text-contrast' },
|
||||
DEVELOPER: { label: '开发者', color: 'bg-red text-contrast' },
|
||||
}
|
||||
|
||||
function permissionMeta(perm: string) {
|
||||
return PERMISSION_META[perm] ?? { label: perm, color: 'bg-button-bg text-secondary' }
|
||||
}
|
||||
|
||||
function startEdit(user: SkinSiteAdminUser) {
|
||||
editingUuid.value = user.uuid
|
||||
editForm.value = {
|
||||
@@ -676,6 +695,9 @@ onMounted(() => void load())
|
||||
<th class="px-3 py-2 font-semibold">{{ formatMessage(messages.email) }}</th>
|
||||
<th class="px-3 py-2 font-semibold">{{ formatMessage(messages.qq) }}</th>
|
||||
<th class="px-3 py-2 font-semibold">{{ formatMessage(messages.status) }}</th>
|
||||
<th class="px-3 py-2 font-semibold">
|
||||
{{ formatMessage(messages.permissionGroups) }}
|
||||
</th>
|
||||
<th class="px-3 py-2 font-semibold">{{ formatMessage(messages.registeredAt) }}</th>
|
||||
<th class="px-3 py-2 font-semibold">{{ formatMessage(messages.actions) }}</th>
|
||||
</tr>
|
||||
@@ -704,6 +726,24 @@ onMounted(() => void load())
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-3 py-2">
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<span
|
||||
v-for="perm in user.permissions ?? []"
|
||||
:key="perm"
|
||||
class="rounded-full px-2 py-0.5 text-[10px] font-semibold"
|
||||
:class="permissionMeta(perm).color"
|
||||
>
|
||||
{{ permissionMeta(perm).label }}
|
||||
</span>
|
||||
<span
|
||||
v-if="!user.permissions?.length"
|
||||
class="text-[11px] text-secondary"
|
||||
>
|
||||
—
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 text-xs text-secondary">
|
||||
{{ formatDateTime(user.registerTime) }}
|
||||
</td>
|
||||
|
||||
@@ -13,7 +13,7 @@ function headingTag(level?: number | null): string {
|
||||
}
|
||||
|
||||
function navigate(title?: string | null) {
|
||||
emit('navigate', (title ?? '').replaceAll('_', ' '))
|
||||
emit('navigate', title ?? '')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -12724,6 +12724,7 @@
|
||||
"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.users.permission-groups": { "message": "Groups" },
|
||||
"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" },
|
||||
|
||||
@@ -13045,6 +13045,7 @@
|
||||
"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.users.permission-groups": { "message": "权限组" },
|
||||
"app.skin-site.admin.mods.upload": { "message": "上传" },
|
||||
"app.skin-site.admin.mods.select-mode": { "message": "选择多个" },
|
||||
"app.skin-site.admin.mods.exit-select": { "message": "完成选择" },
|
||||
|
||||
Reference in new issue
Block a user