feat(navigation): hard-switch to Zibll navigation and Font Awesome 5

This commit is contained in:
2026-08-18 20:46:21 +08:00
parent 3c3ddac8be
commit a0b84977a2
630 changed files with 101647 additions and 11293 deletions
+89 -181
View File
@@ -20,100 +20,86 @@ trait ScriptsPart1c {
* Fonts / FA / global JS stack / aksrtData (split from enqueue_public).
*/
private function enqueue_public_fonts_js_and_data($base_uri, $core_dep, $deps, $is_fixed_homepage, $is_home_or_archive, $is_single_post, $is_single_resource, $version): void {
// ===== 5. 字体 =====
// 5a. 拉丁字体 - Inter (UI) + Source Serif 4 (正文)
wp_enqueue_style(
'aksrt-fonts',
'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700;1,8..60,400&display=swap',
[],
null
);
// 5b. 中文字体 - jsDelivr CDN (思源黑体 / 思源宋体)
// 仅 regular 字重,避免拖慢首屏;其它字重通过 system fallback (PingFang/微软雅黑)
// Fontsource v5 已按 unicode-range 自动分包,浏览器只会下载用到的简中子集
wp_enqueue_style(
'aksrt-fonts-cn',
'https://cdn.jsdelivr.net/npm/@fontsource/noto-sans-sc@5.2.9/400.css',
[],
null
);
wp_enqueue_style(
'aksrt-fonts-cn-serif',
'https://cdn.jsdelivr.net/npm/@fontsource/noto-serif-sc@5.2.9/400.css',
[],
null
);
// ===== 6. 图标系统 =====
// Font Awesome 5 全站加载(评论回复、单篇互动栏、profile 联系方式等
// 多处模板使用 fa-* 类名,作为全主题图标包统一使用)
wp_enqueue_style(
'aksrt-font-awesome-5',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css',
[],
'5.15.4'
);
// FA4 class aliases (fa-diamond, fa-file-text-o, ...) used by zibll-style markup.
wp_enqueue_style(
'aksrt-font-awesome-5-v4-shims',
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/v4-shims.min.css',
['aksrt-font-awesome-5'],
'5.15.4'
);
$notyf_css = get_template_directory() . '/assets/css/frontend/notyf.css';
wp_enqueue_style(
'aksrt-notyf',
$base_uri . '/assets/css/frontend/notyf.css',
[$core_dep, 'aksrt-font-awesome-5-v4-shims'],
file_exists($notyf_css) ? (string) filemtime($notyf_css) : $version
);
$notyf_css = get_template_directory() . '/assets/css/frontend/notyf.css';
wp_enqueue_style(
'aksrt-notyf',
$base_uri . '/assets/css/frontend/notyf.css',
[$core_dep, '_fontawesome'],
file_exists($notyf_css) ? (string) filemtime($notyf_css) : $version
);
// ===== 7. JS =====
// Swiper.js(文章列表媒体及单篇资源页加载)
$needs_post_list_media = wp_style_is('aksrt-post-card', 'enqueued');
$needs_swiper = $needs_post_list_media || $is_home_or_archive || $is_single_post || $is_single_resource;
if ($needs_swiper) {
wp_enqueue_style(
'aksrt-swiper',
$base_uri . '/assets/css/frontend/swiper-bundle.min.css',
[],
'11.2.10'
);
wp_enqueue_script(
'aksrt-swiper',
$base_uri . '/assets/js/swiper-bundle.min.js',
[],
'11.2.10',
true
);
}
wp_enqueue_script(
'aksrt-qrcode',
'https://cdn.jsdelivr.net/npm/kjua@0.9.0/dist/kjua.min.js',
[],
'0.9.0',
true
);
$zibll_uri = $base_uri . '/assets/vendor/zibll';
wp_enqueue_script(
'loader_js',
$zibll_uri . '/js/loader.js',
['jquery', 'bootstrap'],
$version,
true
);
wp_localize_script(
'loader_js',
'_win',
[
'views' => '',
'www' => home_url('/'),
'uri' => $zibll_uri,
'ver' => $version,
'pay_mark' => '¥',
'pay_currency_unit' => __('元', 'aksrt'),
'imgbox' => false,
'imgbox_type' => 'group',
'imgbox_thumbs' => false,
'imgbox_zoom' => false,
'imgbox_full' => false,
'imgbox_play' => false,
'imgbox_down' => false,
'sign_type' => 'page',
'signin_url' => wp_login_url(home_url('/' . ltrim((string) ($GLOBALS['wp']->request ?? ''), '/'))),
'signup_url' => wp_registration_url(),
'ajax_url' => admin_url('admin-ajax.php'),
'ajaxpager' => '',
'ajax_trigger' => __('加载更多', 'aksrt'),
'ajax_nomore' => __('没有更多了', 'aksrt'),
'qj_loading' => __('加载中...', 'aksrt'),
'highlight_kg' => false,
'highlight_hh' => false,
'highlight_btn' => false,
'highlight_zt' => 'enlighter',
'highlight_white_zt' => 'enlighter',
'highlight_dark_zt' => 'dracula',
'upload_img_size' => 3,
'img_upload_multiple' => 6,
'upload_video_size' => 30,
'upload_file_size' => 30,
'upload_ext' => implode('|', array_keys(get_allowed_mime_types())),
'user_upload_nonce' => wp_create_nonce('user_upload'),
'post_action_nonce' => wp_create_nonce('post_action'),
'is_split_upload' => false,
'split_minimum_size' => 10,
'comment_upload_img' => false,
'translate_config' => [],
'qrcode_signin' => ['url' => false, 'state' => false],
'i18n' => [
'load_more' => __('加载更多', 'aksrt'),
'processing' => __('处理中...', 'aksrt'),
'please_wait' => __('请稍候', 'aksrt'),
'done' => __('操作完成', 'aksrt'),
'confirm_clear_search' => __('确认清空搜索记录?', 'aksrt'),
'search_loading' => __('搜索中...', 'aksrt'),
'search_min_chars' => __('至少输入 %s 个字符', 'aksrt'),
],
]
);
// Zibll lazySizes is the only media lazy-loading runtime.
$lazysizes_js = get_template_directory() . '/assets/js/lazysizes.js';
wp_enqueue_script(
'aksrt-lazysizes',
$base_uri . '/assets/js/lazysizes.js',
[],
file_exists($lazysizes_js) ? (string) filemtime($lazysizes_js) : $version,
true
);
// Rehydrate system — must load before aksrt-script so AksrtFrontend is available
wp_enqueue_script(
'aksrt-rehydrate',
$base_uri . '/assets/js/rehydrate.js',
['aksrt-lazysizes'],
// AKSRT-only modules register after the Zibll loader; navigation is owned by main.min.js.
wp_enqueue_script(
'aksrt-rehydrate',
$base_uri . '/assets/js/rehydrate.js',
['loader_js'],
file_exists(get_template_directory() . '/assets/js/rehydrate.js')
? (string) filemtime(get_template_directory() . '/assets/js/rehydrate.js')
: $version,
@@ -153,13 +139,7 @@ trait ScriptsPart1c {
}
// Core modules (split from main.js) — register with AksrtFrontend
$core_modules = [
'aksrt-core-theme' => 'theme.js',
'aksrt-core-nav' => 'nav.js',
'aksrt-core-search' => 'search.js',
'aksrt-core-dropdown' => 'dropdown.js',
'aksrt-core-scroll' => 'scroll.js',
'aksrt-core-slider' => 'slider.js',
$core_modules = [
'aksrt-core-article' => 'article.js',
'aksrt-core-comments' => 'comments.js',
'aksrt-core-comment-fixed' => 'comment-fixed-input.js',
@@ -183,9 +163,7 @@ trait ScriptsPart1c {
if (file_exists($path)) {
// Depend on aksrt-runtime so window.aksrtData (localized below) is available.
$deps = ['aksrt-rehydrate', 'aksrt-runtime'];
if ($handle === 'aksrt-core-slider') {
$deps = array_merge($deps, $needs_swiper ? ['aksrt-swiper'] : []);
} elseif ($handle === 'aksrt-core-misc' && $needs_post_list_media) {
if ($handle === 'aksrt-core-misc' && $needs_post_list_media) {
$deps[] = 'aksrt-grade';
} elseif ($handle === 'aksrt-core-modal-runtime') {
$deps = array_merge($deps, [
@@ -208,54 +186,6 @@ trait ScriptsPart1c {
}
}
wp_enqueue_script(
'aksrt-script',
$base_uri . '/assets/js/main.js',
array_merge(
['jquery', 'bootstrap5', 'aksrt-rehydrate', 'aksrt-runtime'],
$core_handles
),
file_exists(get_template_directory() . '/assets/js/main.js')
? (string) filemtime(get_template_directory() . '/assets/js/main.js')
: $version,
true
);
// SVG icon data + helper (must load before other scripts that use icons)
$svg_icon_js = get_template_directory() . '/assets/js/svg-icon.js';
if (file_exists($svg_icon_js)) {
wp_enqueue_script(
'aksrt-svg-icon',
$base_uri . '/assets/js/svg-icon.js',
['jquery'],
(string) filemtime($svg_icon_js),
true // load after <body> exists
);
}
$svg_helper_js = get_template_directory() . '/assets/js/svg-icon-helper.js';
if (file_exists($svg_helper_js)) {
wp_enqueue_script(
'aksrt-svg-icon-helper',
$base_uri . '/assets/js/svg-icon-helper.js',
['aksrt-svg-icon'],
(string) filemtime($svg_helper_js),
true
);
}
// Page loading indicator (top progress bar)
$loader_js = get_template_directory() . '/assets/js/loader.js';
if (file_exists($loader_js)) {
wp_enqueue_script(
'aksrt-loader',
$base_uri . '/assets/js/loader.js',
[],
(string) filemtime($loader_js),
true
);
}
// Code block enhancements (copy button + language label)
$precode_js = get_template_directory() . '/assets/js/precode.js';
if (file_exists($precode_js)) {
@@ -292,18 +222,6 @@ trait ScriptsPart1c {
);
}
// Touch gesture support (swipe, pull-to-dismiss)
$mini_touch_js = get_template_directory() . '/assets/js/mini-touch.js';
if (file_exists($mini_touch_js)) {
wp_enqueue_script(
'aksrt-mini-touch',
$base_uri . '/assets/js/mini-touch.js',
[],
(string) filemtime($mini_touch_js),
true
);
}
// Section navs: article TOC / scrollspy
$section_navs_js = get_template_directory() . '/assets/js/section-navs.js';
if (file_exists($section_navs_js)) {
@@ -356,7 +274,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-enhancements',
$base_uri . '/assets/js/enhancements.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($enhancements_js),
true
);
@@ -367,7 +285,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-enhancements2',
$base_uri . '/assets/js/enhancements2.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($enhancements2_js),
true
);
@@ -379,7 +297,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-reward',
$base_uri . '/assets/js/reward.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($reward_js),
true
);
@@ -391,7 +309,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-effects',
$base_uri . '/assets/js/effects.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($effects_js),
true
);
@@ -450,7 +368,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-modal-auth',
$base_uri . '/assets/js/modal-auth.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($modal_auth_js),
true
);
@@ -462,7 +380,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-homepage-fixed',
$base_uri . '/assets/js/homepage-fixed.js',
['aksrt-script'],
['loader_js'],
file_exists($homepage_js_path) ? (string) filemtime($homepage_js_path) : $version,
true
);
@@ -476,7 +394,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-comment-tools',
$base_uri . '/assets/js/comment-tools.js',
['aksrt-script', 'aksrt-core-comment-fixed', 'aksrt-core-comment-move'],
['loader_js', 'aksrt-core-comment-fixed', 'aksrt-core-comment-move'],
file_exists($comment_tools_path) ? (string) filemtime($comment_tools_path) : $version,
true
);
@@ -499,7 +417,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-comment-ajax',
$base_uri . '/assets/js/comment-ajax.js',
['aksrt-script', 'aksrt-core-comments'],
['loader_js', 'aksrt-core-comments'],
(string) filemtime($comment_ajax_path),
true
);
@@ -512,7 +430,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-page-template',
$base_uri . '/assets/js/page-template.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($page_template_path),
true
);
@@ -526,7 +444,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-weixin-share',
$base_uri . '/assets/js/weixin-share.js',
['aksrt-script'],
['loader_js'],
(string) filemtime($weixin_share_path),
true
);
@@ -537,7 +455,7 @@ trait ScriptsPart1c {
wp_enqueue_script(
'aksrt-post-share',
$base_uri . '/assets/js/post-share.js',
['aksrt-script', 'aksrt-weixin-share', 'aksrt-share-data'],
['loader_js', 'aksrt-weixin-share', 'aksrt-share-data'],
(string) filemtime($post_share_path),
true
);
@@ -557,7 +475,7 @@ trait ScriptsPart1c {
// exist before pagination/search/article handlers run.
$aksrt_data_handle = wp_script_is('aksrt-runtime', 'registered') || wp_script_is('aksrt-runtime', 'enqueued')
? 'aksrt-runtime'
: 'aksrt-script';
: 'loader_js';
wp_localize_script($aksrt_data_handle, 'aksrtData', [
'ajaxUrl' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('aksrt_public_nonce'),
@@ -578,7 +496,7 @@ trait ScriptsPart1c {
'homeListSortEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_list_sort_enabled(),
'homeListSortDropdown' => class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::home_list_sort_dropdown(),
// AJAX 翻页文案
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fa-angle-right"></i>加载更多',
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fas fa-angle-right"></i>加载更多',
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'aksrt'),
'ajaxLoading' => __('正在加载...', 'aksrt'),
'iasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
@@ -602,16 +520,6 @@ trait ScriptsPart1c {
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
'search' => [
'mode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_mode() : 'default',
'placeholder' => function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索...', 'aksrt'),
'historyEnabled' => function_exists('aksrt_search_history_enabled') ? aksrt_search_history_enabled() : true,
'suggestionsEnabled' => function_exists('aksrt_search_suggestions_enabled') ? aksrt_search_suggestions_enabled() : false,
'hotKeywords' => function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [],
'popularTitle' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_popular_title() : __('热门搜索', 'aksrt'),
'contentTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_search_content_types()['types'] : ['post', 'category', 'tag'],
'defaultType' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_search_content_types()['default'] : 'post',
],
// 用户状态
'isLoggedIn' => is_user_logged_in(),
'userId' => get_current_user_id(),