fix(badges): complete full-chain badge circuit and preset icons

Close the full circuit break in the badge/medal system and replace
empty default icons with preset SVG assets so badges render out of
the box:

- Add aksrt_get_worn_medal_icon() helper that renders the worn medal
  image inline (with settings fallback when the Badges class is
  unavailable).
- Profile header (UC) now shows the worn medal icon beside the name,
  matching zibll's name row order (display_name → VIP → Medal → Level → Verify).
- Add .medal-icon / .aksrt-identity-medal vertical-align rules in UC shell.css.
- Extract SchemaUsers::default_medal_args() and preset 6 badges (rookie,
  checkin-30, writer, popular, annual-star, vip-member) with real icon
  URLs from assets/img/medal/ (medal-1/2/5/9/12/15.svg).
- Vue badge.js: add MEDAL_BASE helper + preset icons matching PHP defaults.
This commit is contained in:
2026-08-04 10:36:50 +08:00
parent 8318e02f77
commit e991f1a0c6
5 changed files with 215 additions and 39 deletions
+76 -36
View File
@@ -27,6 +27,81 @@ class SchemaUsers {
];
}
/**
* Default medal catalog with preset icons from assets/img/medal.
*
* @return array<int,array{cat_name:string,items:array<int,array{slug:string,name:string,desc:string,icon:string,get_type:string,get_val:int}>}>
*/
private static function default_medal_args(): array {
$medal = static function (int $n): string {
$path = sprintf('/assets/img/medal/medal-%d.svg', $n);
if (file_exists(get_theme_file_path($path))) {
return get_theme_file_uri($path);
}
return '';
};
return [
[
'cat_name' => '成长',
'items' => [
[
'slug' => 'rookie',
'name' => '初出茅庐',
'desc' => '注册时间超过30天',
'icon' => $medal(1),
'get_type' => 'registration_time',
'get_val' => 30,
],
[
'slug' => 'checkin-30',
'name' => '签到达人',
'desc' => '累计签到30天',
'icon' => $medal(2),
'get_type' => 'checkin_all_day',
'get_val' => 30,
],
[
'slug' => 'writer',
'name' => '创作先锋',
'desc' => '发布10篇文章',
'icon' => $medal(5),
'get_type' => 'new_post',
'get_val' => 10,
],
[
'slug' => 'popular',
'name' => '人气之星',
'desc' => '累计获得100次点赞',
'icon' => $medal(9),
'get_type' => 'like',
'get_val' => 100,
],
],
],
[
'cat_name' => '限定',
'items' => [
[
'slug' => 'annual-star',
'name' => '年度人气达人',
'desc' => '活动限定徽章',
'icon' => $medal(12),
'get_type' => 'manually_add',
'get_val' => 0,
],
[
'slug' => 'vip-member',
'name' => '尊贵会员',
'desc' => '给予 VIP 用户的特殊徽章',
'icon' => $medal(15),
'get_type' => 'manually_add',
'get_val' => 0,
],
],
],
];
}
public static function build(): array {
return [
'domain' => 'users',
@@ -681,42 +756,7 @@ class SchemaUsers {
'key' => 'user_medal_args',
'label' => '分类与条目',
'type' => 'json',
'default' => [
[
'cat_name' => '成长',
'items' => [
[
'slug' => 'rookie',
'name' => '初出茅庐',
'desc' => '注册时间超过30天',
'icon' => '',
'get_type' => 'registration_time',
'get_val' => 30,
],
[
'slug' => 'checkin-30',
'name' => '签到达人',
'desc' => '累计签到30天',
'icon' => '',
'get_type' => 'checkin_all_day',
'get_val' => 30,
],
],
],
[
'cat_name' => '限定',
'items' => [
[
'slug' => 'annual-star',
'name' => '年度人气达人',
'desc' => '活动限定徽章',
'icon' => '',
'get_type' => 'manually_add',
'get_val' => 0,
],
],
],
],
'default' => self::default_medal_args(),
'help' => '结构化目录:分类 → 条目(slug/name/desc/icon/get_type/get_val)。由 SPA UsersBadge 编辑。',
],
]],