|
1 | 1 | <script setup lang="ts"> |
2 | 2 | useHead({ title: '账号 · NSUK' }) |
| 3 | +
|
| 4 | +const { user, configured, joinUrl, needsJoin, roleLabel, login } = useAuth() |
| 5 | +const route = useRoute() |
| 6 | +
|
| 7 | +/** 回调失败时会带 ?error= 回来 */ |
| 8 | +const loginError = computed(() => { |
| 9 | + const e = route.query.error |
| 10 | + return typeof e === 'string' ? e : '' |
| 11 | +}) |
| 12 | +
|
| 13 | +const ERROR_TEXT: Record<string, string> = { |
| 14 | + invalid_state: '登录状态已过期,请重新登录。', |
| 15 | + missing_code: '授权未完成。', |
| 16 | + login_failed: '登录失败,请稍后重试。', |
| 17 | + access_denied: '你取消了授权。', |
| 18 | +} |
3 | 19 | </script> |
4 | 20 |
|
5 | 21 | <template> |
6 | 22 | <div class="mx-auto max-w-3xl px-6 py-12"> |
7 | 23 | <h1 class="text-2xl font-bold">账号</h1> |
8 | | - <p class="mt-2 text-sm text-(--ui-text-muted)"> |
9 | | - 本站账号由 Prism 提供,模组令牌与设备绑定也在这里管理。 |
10 | | - </p> |
11 | | - |
12 | | - <div |
13 | | - class="mt-8 rounded-(--ui-radius) border border-dashed border-(--ui-border) p-8 text-sm text-(--ui-text-dimmed)" |
14 | | - > |
15 | | - 登录链路开发中(M1,等待 Prism 侧适配完成)。 |
16 | | - </div> |
| 24 | + |
| 25 | + <UAlert |
| 26 | + v-if="loginError" |
| 27 | + class="mt-6" |
| 28 | + color="error" |
| 29 | + variant="subtle" |
| 30 | + :description="ERROR_TEXT[loginError] ?? `登录失败:${loginError}`" |
| 31 | + /> |
| 32 | + |
| 33 | + <!-- 未登录 --> |
| 34 | + <template v-if="!user"> |
| 35 | + <p class="mt-2 text-sm text-(--ui-text-muted)"> |
| 36 | + 本站账号由 Prism 提供,模组令牌与设备绑定也在这里管理。 |
| 37 | + </p> |
| 38 | + <UButton v-if="configured" class="mt-6" @click="login('/account')">使用 Prism 登录</UButton> |
| 39 | + <div |
| 40 | + v-else |
| 41 | + class="mt-6 rounded-(--ui-radius) border border-dashed border-(--ui-border) p-8 text-sm text-(--ui-text-dimmed)" |
| 42 | + > |
| 43 | + 登录尚未配置(等待 Prism 侧提供应用凭据)。 |
| 44 | + </div> |
| 45 | + </template> |
| 46 | + |
| 47 | + <!-- 已登录 --> |
| 48 | + <template v-else> |
| 49 | + <div class="mt-6 flex items-center gap-3"> |
| 50 | + <span class="text-lg">{{ user.displayName }}</span> |
| 51 | + <UBadge variant="subtle">{{ roleLabel }}</UBadge> |
| 52 | + </div> |
| 53 | + <p class="mt-1 text-sm text-(--ui-text-dimmed)">@{{ user.username }}</p> |
| 54 | + |
| 55 | + <!-- |
| 56 | + 已登录但没有任何身份组:说明还没通过 NSUK 通道加入团队。 |
| 57 | + 引导去邀请链接注册页,带 continue 回跳。 |
| 58 | + --> |
| 59 | + <UAlert |
| 60 | + v-if="needsJoin" |
| 61 | + class="mt-6" |
| 62 | + color="warning" |
| 63 | + variant="subtle" |
| 64 | + title="尚未加入 NSUK" |
| 65 | + description="你的 Prism 账号还不属于 NSUK 团队,暂时只能浏览公开内容。" |
| 66 | + > |
| 67 | + <template #actions> |
| 68 | + <UButton v-if="joinUrl" :to="joinUrl" external size="sm">前往加入</UButton> |
| 69 | + </template> |
| 70 | + </UAlert> |
| 71 | + |
| 72 | + <section class="mt-10"> |
| 73 | + <h2 class="text-lg font-semibold">模组授权</h2> |
| 74 | + <p class="mt-1 text-sm text-(--ui-text-muted)"> |
| 75 | + 赞助者及以上可生成令牌,填入模组后即可使用。一个账号同时只能绑定一台设备。 |
| 76 | + </p> |
| 77 | + <div |
| 78 | + class="mt-4 rounded-(--ui-radius) border border-dashed border-(--ui-border) p-8 text-sm text-(--ui-text-dimmed)" |
| 79 | + > |
| 80 | + 开发中(M4)。 |
| 81 | + </div> |
| 82 | + </section> |
| 83 | + </template> |
17 | 84 | </div> |
18 | 85 | </template> |
0 commit comments