进行了一些小修复
This commit is contained in:
+10
-36
@@ -19,21 +19,20 @@ 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 {
|
||||
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 {
|
||||
$runtime_uri = $base_uri . '/assets';
|
||||
$runtime_loader_path = get_template_directory() . '/assets/js/runtime/loader.js';
|
||||
$runtime_main_path = get_template_directory() . '/assets/js/runtime/main.min.js';
|
||||
$runtime_loader_version = file_exists($runtime_loader_path) ? (string) filemtime($runtime_loader_path) : $version;
|
||||
$runtime_version = file_exists($runtime_main_path) ? (string) filemtime($runtime_main_path) : $version;
|
||||
$public_runtime_path = get_template_directory() . '/assets/js/build/public.js';
|
||||
wp_enqueue_script(
|
||||
'loader_js',
|
||||
$runtime_uri . '/js/runtime/loader.js',
|
||||
['jquery', 'bootstrap'],
|
||||
$runtime_loader_version,
|
||||
'aksrt-runtime',
|
||||
$base_uri . '/assets/js/build/public.js',
|
||||
['jquery'],
|
||||
file_exists($public_runtime_path) ? (string) filemtime($public_runtime_path) : $version,
|
||||
true
|
||||
);
|
||||
wp_localize_script(
|
||||
'loader_js',
|
||||
'aksrt-runtime',
|
||||
'_win',
|
||||
[
|
||||
'views' => '',
|
||||
@@ -82,16 +81,6 @@ trait ScriptsPart1c {
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$public_runtime_path = get_template_directory() . '/assets/js/build/public.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-runtime',
|
||||
$base_uri . '/assets/js/build/public.js',
|
||||
['loader_js'],
|
||||
file_exists($public_runtime_path) ? (string) filemtime($public_runtime_path) : $version,
|
||||
true
|
||||
);
|
||||
|
||||
// AJAX 调试(WP_DEBUG 或 ?aksrt_ajax_debug=1):记录所有失败的
|
||||
// jQuery ajax / fetch 请求,用于定位 vendor main.min.js 的 400 "0" 来源。
|
||||
if (function_exists('aksrt_ajax_debug_enabled') && aksrt_ajax_debug_enabled()) {
|
||||
@@ -133,18 +122,6 @@ trait ScriptsPart1c {
|
||||
);
|
||||
}
|
||||
|
||||
// Instant page prefetch (hover to preload)
|
||||
$instant_page_js = get_template_directory() . '/assets/js/instant-page.js';
|
||||
if (file_exists($instant_page_js)) {
|
||||
wp_enqueue_script(
|
||||
'aksrt-instant-page',
|
||||
$base_uri . '/assets/js/instant-page.js',
|
||||
[],
|
||||
(string) filemtime($instant_page_js),
|
||||
false // load in <head> for early prefetch capability
|
||||
);
|
||||
}
|
||||
|
||||
// Section navs: article TOC / scrollspy
|
||||
$section_navs_js = get_template_directory() . '/assets/js/section-navs.js';
|
||||
if (is_singular() && file_exists($section_navs_js)) {
|
||||
@@ -321,7 +298,7 @@ trait ScriptsPart1c {
|
||||
wp_enqueue_script(
|
||||
'aksrt-weixin-share',
|
||||
$base_uri . '/assets/js/weixin-share.js',
|
||||
['loader_js'],
|
||||
['aksrt-runtime'],
|
||||
(string) filemtime($weixin_share_path),
|
||||
true
|
||||
);
|
||||
@@ -332,7 +309,7 @@ trait ScriptsPart1c {
|
||||
wp_enqueue_script(
|
||||
'aksrt-post-share',
|
||||
$base_uri . '/assets/js/post-share.js',
|
||||
['loader_js', 'aksrt-weixin-share', 'aksrt-share-data'],
|
||||
['aksrt-runtime', 'aksrt-weixin-share', 'aksrt-share-data'],
|
||||
(string) filemtime($post_share_path),
|
||||
true
|
||||
);
|
||||
@@ -348,10 +325,7 @@ trait ScriptsPart1c {
|
||||
// 数据注入 - 全站统一消费 window.aksrtData
|
||||
// Attach to aksrt-runtime (loaded before all core modules) so ajaxUrl/nonce
|
||||
// exist before pagination/search/article handlers run.
|
||||
$aksrt_data_handle = wp_script_is('aksrt-runtime', 'registered') || wp_script_is('aksrt-runtime', 'enqueued')
|
||||
? 'aksrt-runtime'
|
||||
: 'loader_js';
|
||||
wp_localize_script($aksrt_data_handle, 'aksrtData', [
|
||||
wp_localize_script('aksrt-runtime', 'aksrtData', [
|
||||
'ajaxUrl' => admin_url('admin-ajax.php'),
|
||||
'nonce' => wp_create_nonce('aksrt_public_nonce'),
|
||||
'restNonce' => wp_create_nonce('wp_rest'),
|
||||
|
||||
Reference in New Issue
Block a user