fix(single): align article code blocks with the reference theme

The article body ran two highlighting pipelines at once: the runtime
EnlighterJS pass (same one the comment area uses) plus a bespoke
precode.js enhancer, and a hand-rolled .code-block skin. The two
disagreed, so rendered blocks carried a dark #282c34 card with 15px
padding, 14px text, a border and a second copy button stacked on top of
the EnlighterJS toolbar.

Drop the parallel path and let one pipeline own code blocks:
- delete precode.js, single-post/code-blocks.css and the unused
  assets/js/enlighter copy that only precode.js referenced
- drop the now-dead has_code requirement (PHP scan + feature enqueue)
- render pre exactly as the reference does: bootstrap's pre box
  (9.5px padding / 13px / radius 4) plus main.css's muted background,
  with the EnlighterJS theme supplying the skin

Also scope the inline-code skin to :not(pre code) so it stops painting
the block background pink, and remap the toolbar copy glyph: \f0ea is
the clipboard in FA4 but "paste" in FA5; the clipboard is \f328.

Verified against the reference at 1440px both themes: pre 13px/18.57,
9.5px padding, radius 4, muted background; EnlighterJS block heights
151.31 / 60.38 match exactly.
This commit is contained in:
kate522 committed 2026-11-03 23:31:28 +08:00
1 parent ba32e0ef9c
commit 8ad5ef9aff
19 files changed
+112 -430

No files matched your search

-5
View File
@@ -120,11 +120,6 @@
}
function syncCodeHighlightTheme(isDark) {
if (typeof window.JioPrecodeApplyTheme === "function") {
window.JioPrecodeApplyTheme(isDark);
return;
}
var settings = (window.jioData && window.jioData.codeHighlight) || {};
var theme = isDark ? (settings.darkTheme || "monokai") : (settings.lightTheme || "enlighter");
document.querySelectorAll(".enlighter-default").forEach(function (el) {
-1
View File
@@ -1 +0,0 @@
/*! EnlighterJS Syntax Highlighter 3.0.0 | Mozilla Public License 2.0 | https://enlighterjs.org */.enlighter-tooltip{z-index:100}.enlighter-default{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px;line-height:1.4;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;margin:0 0 20px 0;padding:0;position:relative;text-align:left;direction:ltr;border-radius:8px}.enlighter-default .enlighter-special:hover{background-color:#f4f8fc}.enlighter-default .enlighter-raw{display:none;white-space:pre-wrap;word-wrap:break-word;box-shadow:none;padding:0 17px!important;color:inherit}.enlighter-toolbar{opacity:0;position:absolute;right:10px;top:8px;z-index:10;transition:.2s}.enlighter-default:hover .enlighter-toolbar{opacity:1}.enlighter-default .enlighter-btn{font:normal normal 900 14px/1 "Font Awesome 5 Free";border-radius:4px;display:inline-block;transition:.15s;padding:.3em .6em;background:rgba(235,237,239,.8);color:#666;font-size:14px;margin-left:6px;cursor:pointer}.enlighter-default .enlighter-btn:hover{color:#157ff9}.enlighter-t-atomic .enlighter-btn,.enlighter-t-dracula .enlighter-btn,.enlighter-t-monokai .enlighter-btn{background:rgba(57,60,66,.87)}.enlighter-default .enlighter-toolbar .enlighter-btn-raw::after{content:"\f121"}.enlighter-default .enlighter-toolbar .enlighter-btn-copy::after{content:"\f0ea"}.enlighter-default .enlighter-toolbar .enlighter-btn-window::after{content:"\f1b2"}.enlighter-origin{display:none!important}.enlighter-clipboard{position:absolute;left:0;bottom:0;width:1px;height:1px;overflow:hidden}.enlighter-v-inline{display:inline-block;overflow:inherit;margin:0}.enlighter-v-standard{display:block}.enlighter-v-codegroup{display:block}.enlighter-v-codegroup .enlighter-codegroup-wrapper{position:relative}div.enlighter{width:100%;border-collapse:collapse;border-spacing:0;padding:12px 0;empty-cells:show;min-width:100%;font-size:10px;margin:0;text-indent:0;-webkit-overflow-scrolling:touch;counter-reset:enlighter 0}div.enlighter>div{margin:0;border:solid 0 #fff;list-style:none;font-size:inherit;line-height:1.4;min-height:14px}div.enlighter>div>div{display:table-cell;width:100%;padding-left:10px}div.enlighter>div>div::before{content:" "}span.enlighter{display:inline-block;padding:3px 5px 1px 5px;margin:0 2px 0 2px}.enlighter span{margin:0;padding:0;line-height:inherit;font-size:13px;font-family:inherit}.enlighter-linenumbers div.enlighter>div::before{white-space:nowrap;display:block;display:table-cell;width:45px;min-width:45px;counter-increment:enlighter;content:counter(enlighter,decimal) ".";text-align:right;padding-right:8px}.enlighter-overflow-scroll.enlighter-v-standard .enlighter{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-codegroup-wrapper{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter>div>div,.enlighter-overflow-scroll.enlighter-v-standard .enlighter>div>div{white-space:pre!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-raw,.enlighter-overflow-scroll.enlighter-v-standard .enlighter-raw{white-space:pre!important}.enlighter-show-rawcode .enlighter-raw{padding:12px 16px!important;display:block}.enlighter-show-rawcode .enlighter{display:none!important}.enlighter-t-enlighter{color:#555;background:#f8f9fa}.enlighter-t-enlighter.enlighter-hover div.enlighter>div:hover{color:#444;background-color:#fffcd3}.enlighter-t-enlighter div.enlighter>div{color:#aaa}.enlighter-t-enlighter div.enlighter>div.enlighter-special{background-color:#fdf5f0}.enlighter-t-enlighter.enlighter-linenumbers div.enlighter>div::before{border-right:solid 1px #e8e8e8}.enlighter-t-enlighter .enlighter-text{color:#555}.enlighter-t-enlighter .enlighter-c0{color:#99a}.enlighter-t-enlighter .enlighter-c1{color:#99a}.enlighter-t-enlighter .enlighter-c2{color:#99a}.enlighter-t-enlighter .enlighter-c9{color:#9baa8f}.enlighter-t-enlighter .enlighter-k0{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k1{color:#4573f7;font-weight:700}.enlighter-t-enlighter .enlighter-k2{color:#458;font-weight:700}.enlighter-t-enlighter .enlighter-k3{color:#4da0d2;background-color:#f0f0f0}.enlighter-t-enlighter .enlighter-k4{color:#4a9141;font-weight:700}.enlighter-t-enlighter .enlighter-k5{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k6{color:#286491;font-style:italic}.enlighter-t-enlighter .enlighter-k7{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k8{color:#4da0d2}.enlighter-t-enlighter .enlighter-k9{color:#990073;font-weight:700}.enlighter-t-enlighter .enlighter-k10{color:#4a9141;font-style:italic}.enlighter-t-enlighter .enlighter-e0{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e1{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e2{color:#009926}.enlighter-t-enlighter .enlighter-e3{color:#286491}.enlighter-t-enlighter .enlighter-e4{color:#ff8c00;font-style:italic}.enlighter-t-enlighter .enlighter-s0{color:Line truncated
-2
View File
@@ -1,2 +0,0 @@
var EnlighterJS=function(e){"use strict";function t(e,t,r,n,s){return{text:e,type:t,index:n||0,end:e.length+n,filter:r||null,priority:s||0}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var i=Object.getPrototypeOf(e);return null===i?void 0:s(i,t,r)}if("value"in n)return n.value;var o=n.get;return void 0!==o?o.call(r):void 0}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(){r(this,a),this.rules=[],this.setupLanguage()}function g(){return r(this,g),o(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}function l(){return r(this,l),o(this,(l.__proto__||Object.getPrototypeOf(l)).apply(this,arguments))}function p(){return r(this,p),o(this,(p.__proto__||Object.getPrototypeOf(p)).apply(this,arguments))}function u(){return r(this,u),o(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments))}function c(e,r,n){for(var s=[],i=0,o=void 0;null!=(o=r.exec(e.text));){i<o.index&&s.push(t(e.text.substring(i,o.index),e.type,null,i));for(var a=n(o,e.type)||[],g=0;g<a.length;g++)s.push(a[g]);i=o.index+o[0].length,r.lastIndex=i}return 0==s.length?[e]:(i<e.text.length&&s.push(t(e.text.substring(i),e.type,null,i)),s)}function y(){return r(this,y),o(this,(y.__proto__||Object.getPrototypeOf(y)).apply(this,arguments))}function b(){return r(this,b),o(this,(b.__proto__||Object.getPrototypeOf(b)).apply(this,arguments))}function f(){return r(this,f),o(this,(f.__proto__||Object.getPrototypeOf(f)).apply(this,arguments))}function h(){return r(this,h),o(this,(h.__proto__||Object.getPrototypeOf(h)).apply(this,arguments))}function d(){return r(this,d),o(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}function x(){return r(this,x),o(this,(x.__proto__||Object.getPrototypeOf(x)).apply(this,arguments))}function m(){return r(this,m),o(this,(m.__proto__||Object.getPrototypeOf(m)).apply(this,arguments))}function k(){return r(this,k),o(this,(k.__proto__||Object.getPrototypeOf(k)).apply(this,arguments))}function _(){return r(this,_),o(this,(_.__proto__||Object.getPrototypeOf(_)).apply(this,arguments))}function w(){return r(this,w),o(this,(w.__proto__||Object.getPrototypeOf(w)).apply(this,arguments))}function v(){return r(this,v),o(this,(v.__proto__||Object.getPrototypeOf(v)).apply(this,arguments))}function C(){return r(this,C),o(this,(C.__proto__||Object.getPrototypeOf(C)).apply(this,arguments))}function O(){return r(this,O),o(this,(O.__proto__||Object.getPrototypeOf(O)).apply(this,arguments))}function S(){return r(this,S),o(this,(S.__proto__||Object.getPrototypeOf(S)).apply(this,arguments))}function A(){return r(this,A),o(this,(A.__proto__||Object.getPrototypeOf(A)).apply(this,arguments))}function L(){return r(this,L),o(this,(L.__proto__||Object.getPrototypeOf(L)).apply(this,arguments))}function j(){return r(this,j),o(this,(j.__proto__||Object.getPrototypeOf(j)).apply(this,arguments))}function q(){return r(this,q),o(this,(q.__proto__||Object.getPrototypeOf(q)).apply(this,arguments))}function E(){return r(this,E),o(this,(E.__proto__||Object.getPrototypeOf(E)).apply(this,arguments))}function P(){return r(this,P),o(this,(P.__proto__||Object.getPrototypeOf(P)).apply(this,arguments))}function W(){return r(this,W),o(this,(W.__proto__||Object.getPrototypeOf(W)).apply(this,arguments))}function $(){return r(this,$),o(this,($.__proto__||Object.getPrototypeOf($)).apply(this,arguments))}function I(){return r(this,I),o(this,(I.__proto__||Object.getPrototypeOf(I)).apply(this,arguments))}function N(){return r(this,N),o(this,(N.__proto__||Object.getPrototypeOf(N)).apply(this,arguments))}function F(){return r(this,F),o(this,(F.__proto__||Object.getPrototypeOf(F)).apply(this,arguments))}function D(){return r(this,D),o(this,(D.__proto__||Object.getPrototypeOf(D)).apply(this,arguments))}function T(){return r(this,T),o(this,(T.__proto__||Object.getPrototypeOf(T)).apply(this,arguments))}function R(){return r(this,R),o(this,(R.__proto__||Object.getPrototypeOf(R)).apply(this,arguments))}function Z(){return r(this,Z),o(this,(Z.__proto__||Object.getPrototypeOf(Z)).apply(this,arguments))}function z(){return r(this,z),o(this,(z.__proto__||Object.getPrototypeOf(z)).apply(this,arguments))}function B(){return r(this,B),o(this,(B.__proto__||Object.getPrototypeOf(B)).apply(this,argumentLine truncated
regex:/\b(Data|Do|DynamicParam|Exit|Filter|From|Function|In|InlineScript|Hidden|Parallel|Param|Process|Return|Sequence|Trap|Workflow)\b/gi,type:"k0"},{regex:/\b([A-Z]\w+(?:-\w+)+)\b/g,type:"m0"},{regex:/<#[\S\s]+?#>/gi,type:"c1"},ve.poundComments,{regex:/\$[A-Z_][\w]*/gim,type:"k7"},ve.mCalls,ve.fCalls,ve.int,ve.floats,ve.brackets]}}]),W),Xe=(i($,Se),Ce($,[{key:"setupLanguage",value:function(){this.rules=[{regex:/(%.*)$/gm,type:"c0"},ve.blockComments,ve.dqStrings,ve.sqStrings,{regex:/^(\w+)(?:\(.*?\))?\s*(?::-|\.)/gm,type:"k9"},{regex:/\b(true|false|Yes|No|not|fail)\b/gi,type:"e0"},{regex:/\b(catch|throw|repeat)\b/g,type:"k1"},{regex:/^(\?-)/g,type:"k9"},{regex:/\b(is)\b/g,type:"k3"},{regex:/[A-Z_][\w]*/g,type:"k7"},ve.brackets,ve.floats,ve.int,ve.fCalls]}}]),$),Ke=(i(I,Se),Ce(I,[{key:"setupLanguage",value:function(){this.rules=[ve.dqStrings,ve.prop,{regex:/\b([A-Z]\w+)\b/g,type:"k5"},{regex:/^(import)(\s+[\w.]+)/gm,type:["k0","k5"]},{regex:/\b(bool|char|double|float|int|long|short|void|string)\b/g,type:"k5"},ve.mCalls,ve.null,ve.boolean,ve.slashComments,ve.blockComments,ve.int,ve.floats,ve.brackets]}}]),I),et=(i(N,Se),Ce(N,[{key:"setupLanguage",value:function(){this.rules=[{regex:/^(.*?)$/g,type:"text"}]}}]),N),tt=(i(F,Se),Ce(F,[{key:"setupLanguage",value:function(){function e(e){return e.text.match(/^%r/)?e.type="e2":e.text.match(/^%x/)&&(e.type="e4"),[e]}this.rules=[ve.dqStrings,ve.sqStrings,ve.heredoc,{regex:/(`(?:[^`\\]|\\.)*`)/g,type:"e4"},ve.boolean,{regex:/\b(nil)\b/gi,type:"e1"},ve.fCalls,ve.prop,{regex:/@{1,2}[A-Za-z_]\w*\W/g,type:"k7"},{regex:/[^:](:[\w]+)\b/g,type:"k6"},{regex:/(\$[a-z0-9_-]+|\$.)\W/gi,type:"k9"},{regex:/\b(begin|break|case|do|else|elsif|end|ensure|for|if|in|next|redo|rescue|retry|then|unless|until|when|while)\b/gi,type:"k1"},{regex:/\b((?:__)?[A-Z][A-Z0-9_]+)\b/g,type:"e3"},{regex:/\b(alias|class|defined\?|undef|def|module|return|self|super|yield)\W/gi,type:"k0"},{regex:/\b(and|not|or)\b/gi,type:"k3"},ve.poundComments,{regex:/^=begin[\S\s]*?^=end/gim,type:"c2"},{regex:/(%[iqrswx](\W)(?:[^\2\n\\]|\\.)*\2[iomx]*)/gim,type:"s2",filter:e},{regex:/(%[iqrswx]?(\{(?:[^}\\]|\\.)*}|\[(?:[^}\\]|\\.)*]|\((?:[^)\\]|\\.)*\))[iomx]*)/gim,type:"s2",filter:e},{regex:/\W(\/(?:[^/\\]|\\.)*\/\w*)\W/g,type:"e2"},{regex:/\W\?(?:\w|\\M|\\C)(?:-\w|-\\M|-\\C)*\b/g,type:"n1"},{regex:/[\b\W](-?\d[\d_]+?)(?!\.)\b/g,type:"n1"},{regex:/[\b\W](-?0x[A-F0-9][A-F0-9_]+)\b/gi,type:"n2"},{regex:/[\b\W](-?0b[01][01_]+)\b/gi,type:"n3"},{regex:/[\b\W](-?[\d_]+(?:\.[\d_]+)?(?:e[+-]?\d+)?[ji]?)\b/gi,type:"n0"},ve.brackets]}}]),F),rt=(i(D,Se),Ce(D,[{key:"setupLanguage",value:function(){this.rules=[ve.char,{regex:/r((#+)".*?"\2)/gm,type:"s0"},{regex:/("(?:\\.|\\\s*\n|\\s*\r\n|[^\\"])*")/g,type:"s0"},{regex:/^\s*#.*$/gm,type:"k4"},{regex:/fn\s+([\w]+)\s*(<\w+\s*>)?\(/gm,type:"k0"},{regex:/\b\.?([\w]+)\s*(\(|::)/gm,type:"k1"},{regex:/\b([\w]+)!/gm,type:"k9"},{regex:/\bself\b/gi,type:"k9"},ve.boolean,{regex:/\b(while|loop|in|for|if|else|do|continue|break)\b/g,type:"k1"},{regex:/\b(type|struct|let|enum)\b/g,type:"k2"},{regex:/\b(const)\b/g,type:"k8"},{regex:/\b(yield|where|virtual|use|unsized|unsafe|trait|super|static|return|ref|pure|pub|proc|priv|override|offsetof|mut|move|mod|match|macro|impl|fn|final|extern|crate|box|become|as|alignof|abstract)\b/g,type:"k0"},{regex:/\b(sizeof|typeof)\b/g,type:"k3"},{regex:/\b([0-9_]+\.?[0-9_]+?(e\+[0-9_]+)?)(?:f32|f64)?\b/gim,type:"n0"},{regex:/\b([0-9_]+|0o[0-9_]+|0x[A-F0-9_]+|0b[0-1_]+)(?:u8|i8|u16|i16|u32|i32|u64|i64|isize|usize)?\b/gim,type:"n1"},ve.slashComments,ve.blockComments,{regex:/(?:^|[^\\])\/\/[/!].*$/gm,type:"c2"},{regex:/\/\*[*!][\s\S]*?\*\//gm,type:"c2"},ve.brackets,{regex:/\W(&)\w/g,type:"k3"}]}}]),D),nt=(i(T,Se),Ce(T,[{key:"setupLanguage",value:function(){this.rules=[ve.dqStrings,ve.char,{regex:/s"(?:[^"\\]|\\.)*"/g,type:"s2"},{regex:/`(?:[^`\\]|\\.)*`/g,type:"k7"},{regex:/@[\W\w_][\w]+/g,type:"s9"},{regex:/\b([A-Z]\w*)\b/g,type:"k5"},{regex:/\b(while|try|catch|else|throw|break|if|do|goto|switch|for|match)\b/g,type:"k1"},{regex:/(package|import)(\s+[\w.]+)/gm,type:["k0","k10"]},{regex:/[\b\w\s)](_|:|@|#|<-|←|<:|<%|=|=>|⇒|>:)[\b\w\s]/g,type:"k3"},{regex:/\b(abstract|class|case|extends|final|finally|forSome|implicit|lazy|object|override|private|protected|return|sealed|trait|with|yield)\b/g,type:"k0"},{regex:/\b(def)\s+(\w+)\b/gm,type:["k2","m0"]},{regex:/\b(type)\s+(\w+)\b/gm,type:["k2","k5"]},{regex:/\b(val)\s+(\w+)\b/gm,type:["k2","k7"]},{regex:/\b(var)\s+(\w+)\b/gm,type:["k2","k7"]},{regex:/\b(this|super)\b/g,type:"k9"},{regex:/\b(new)\b/g,type:"k3"},ve.mCalls,ve.fCalls,ve.null,ve.boolean,ve.slashComments,ve.blockComments,ve.docComments,ve.int,ve.floats,ve.bin,ve.brackets]}}]),T),st=(i(R,Pe),Ce(R,[{key:"setupLanguage",value:function(){s(R.prototype.__proto__||Object.getPrototypeOf(R.prototype),"setupLanguage",this).call(this);var e=[ve.slashComments,{regex:/\b([\w-]+)\s*\(/gm,type:"m0"},{regex:/\$[\w-]+\b/g,type:"k7"},{regex:/@[\w-]+\b/g,type:"k9"},{regex:/&/gi,Line truncated
-222
View File
@@ -1,222 +0,0 @@
/**
* Jio Code Block Enhancements
*
* Integrates EnlighterJS for syntax highlighting and adds
* copy-to-clipboard buttons and language labels to code blocks.
* No jQuery dependency — pure vanilla JS.
*
* @package Jio
*/
(function () {
'use strict';
var BASE_URI = (window.jioData && window.jioData.themeUri) || '';
var STYLE_ID = 'jio-enlighter-css';
var ENLIGHTER_LOADED = false;
function getHighlightSettings() {
return (window.jioData && window.jioData.codeHighlight) || {};
}
function isDarkTheme(value) {
if (typeof value === 'boolean') return value;
return document.documentElement.classList.contains('dark') ||
document.documentElement.getAttribute('data-theme') === 'dark';
}
function getThemeName(isDark) {
var settings = getHighlightSettings();
return isDarkTheme(isDark) ? (settings.darkTheme || 'monokai') : (settings.lightTheme || 'enlighter');
}
function applyEnlighterTheme(isDark) {
var settings = getHighlightSettings();
if (settings.enabled === false) return;
var theme = getThemeName(isDark);
document.querySelectorAll('.enlighter-default').forEach(function (el) {
el.className = el.className.replace(/\benlighter-t-[\w-]+\b/g, '').replace(/\s+/g, ' ').trim();
el.classList.add('enlighter-t-' + theme);
});
}
window.JioPrecodeApplyTheme = applyEnlighterTheme;
// ── Copy Button Styles ──
var COPY_STYLE_ID = 'jio-precode-style';
function injectCopyStyle() {
if (document.getElementById(COPY_STYLE_ID)) return;
var style = document.createElement('style');
style.id = COPY_STYLE_ID;
style.textContent =
'.jio-code-copy{position:absolute;top:6px;right:8px;border:none;background:rgba(255,255,255,0.08);color:#a6adc8;cursor:pointer;padding:3px 10px;border-radius:6px;font-size:12px;z-index:10;transition:all 0.2s;backdrop-filter:blur(4px);}' +
'.jio-code-copy:hover{background:rgba(255,255,255,0.15);color:#cdd6f4;}' +
'.jio-code-copy.is-copied{color:#a6e3a1;}' +
'.enlighter-default{position:relative;}' +
'.enlighter-default .jio-code-copy{top:4px;right:4px;}' +
'pre{position:relative;}' +
'pre .jio-code-copy{top:8px;right:8px;}';
document.head.appendChild(style);
}
// ── EnlighterJS CSS Injection ──
function injectEnlighterCSS() {
if (document.getElementById(STYLE_ID)) return;
var link = document.createElement('link');
link.id = STYLE_ID;
link.rel = 'stylesheet';
link.href = BASE_URI + '/assets/js/enlighter/enlighterjs.min.css';
document.head.appendChild(link);
}
// ── EnlighterJS Loader ──
function loadEnlighterJS(callback) {
if (ENLIGHTER_LOADED && window.EnlighterJS) {
callback();
return;
}
injectEnlighterCSS();
var script = document.createElement('script');
script.src = BASE_URI + '/assets/js/enlighter/enlighterjs.min.js';
script.onload = function () {
ENLIGHTER_LOADED = true;
callback();
};
script.onerror = function () {
// Fallback: just add copy buttons without highlighting
addCopyButtonsPlain();
};
document.head.appendChild(script);
}
// ── Copy to Clipboard ──
function copyToClipboard(text, btn) {
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(text).then(function () {
showCopied(btn);
});
} else {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.cssText = 'position:fixed;left:-9999px;';
document.body.appendChild(ta);
ta.select();
try { document.execCommand('copy'); showCopied(btn); } catch (e) { /* ignore */ }
document.body.removeChild(ta);
}
}
function showCopied(btn) {
btn.textContent = '已复制';
btn.classList.add('is-copied');
setTimeout(function () {
btn.textContent = '复制';
btn.classList.remove('is-copied');
}, 1500);
}
function createCopyButton(text) {
var btn = document.createElement('button');
btn.className = 'jio-code-copy';
btn.textContent = '复制';
btn.type = 'button';
btn.addEventListener('click', function () {
copyToClipboard(text, btn);
});
return btn;
}
// ── EnlighterJS Integration ──
function initEnlighter() {
if (!window.EnlighterJS) return;
// Get settings from jioData or use defaults
var settings = getHighlightSettings();
if (settings.enabled === false) return; // 后台关闭代码高亮
var lineNumbers = settings.lineNumbers === true;
var showButtons = settings.showButtons !== false;
var maxHeight = settings.maxHeight || 400;
var currentTheme = getThemeName();
// Find all code blocks that haven't been processed
var blocks = document.querySelectorAll('pre > code:not(.enlighter-origin)');
if (blocks.length === 0) return;
// Process each block
blocks.forEach(function (code) {
var pre = code.parentElement;
if (!pre || pre.dataset.jioEnhanced) return;
// Get raw text before EnlighterJS processes it
var rawText = code.textContent;
// Apply EnlighterJS
try {
EnlighterJS.enlight(code, {
theme: currentTheme,
linenumbers: lineNumbers,
indent: 2,
textOverflow: 'scroll',
rawcodeDbclick: true,
rawButton: showButtons,
infoButton: showButtons,
windowButton: showButtons
});
} catch (e) {
// If EnlighterJS fails, keep the plain block
}
// Add copy button after EnlighterJS processing
var container = pre.querySelector('.enlighter-default') || pre;
container.appendChild(createCopyButton(rawText));
pre.dataset.jioEnhanced = '1';
// Apply max-height
if (maxHeight > 0) {
pre.style.maxHeight = maxHeight + 'px';
pre.style.overflow = 'auto';
}
});
applyEnlighterTheme();
}
// ── Fallback: Plain code blocks with copy buttons ──
function addCopyButtonsPlain() {
var blocks = document.querySelectorAll('pre > code');
blocks.forEach(function (code) {
var pre = code.parentElement;
if (!pre || pre.dataset.jioEnhanced) return;
pre.style.position = 'relative';
pre.appendChild(createCopyButton(code.textContent));
pre.dataset.jioEnhanced = '1';
});
}
// ── Main Init ──
function init() {
injectCopyStyle();
// Check if there are any code blocks on the page
var blocks = document.querySelectorAll('pre > code');
if (blocks.length === 0) return;
// Load EnlighterJS and initialize
loadEnlighterJS(initEnlighter);
}
jQuery(document).off('auto_fun.jio-precode').on('auto_fun.jio-precode', function () { init(document); });
})();
+3 -1
View File
@@ -67,12 +67,14 @@
background: rgba(57, 60, 66, 0.87)
}
/* 字形码位随 FA5 重新映射:旧版 \f0ea 在 FA4 是剪贴板,FA5 里同码位变成
* 粘贴,剪贴板移到 \f328。其余两个码位在 FA5 中保持同名。 */
.enlighter-default .enlighter-toolbar .enlighter-btn-raw::after {
content: "\f121"
}
.enlighter-default .enlighter-toolbar .enlighter-btn-copy::after {
content: "\f0ea"
content: "\f328"
}
.enlighter-default .enlighter-toolbar .enlighter-btn-window::after {
+1 -1
View File
@@ -1 +1 @@
/*! EnlighterJS Syntax Highlighter 3.0.0 | Mozilla Public License 2.0 | https://enlighterjs.org */.enlighter-tooltip{z-index:100}.enlighter-default{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px;line-height:1.4;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;margin:0 0 20px 0;padding:0;position:relative;text-align:left;direction:ltr;border-radius:8px}.enlighter-default .enlighter-special:hover{background-color:#f4f8fc}.enlighter-default .enlighter-raw{display:none;white-space:pre-wrap;word-wrap:break-word;box-shadow:none;padding:0 17px!important;color:inherit}.enlighter-toolbar{opacity:0;position:absolute;right:10px;top:8px;z-index:10;transition:.2s}.enlighter-default:hover .enlighter-toolbar{opacity:1}.enlighter-default .enlighter-btn{font: normal normal 900 14px/1 "Font Awesome 5 Free";border-radius:4px;display:inline-block;transition:.15s;padding:.3em .6em;background:rgba(235,237,239,.8);color:#666;font-size:14px;margin-left:6px;cursor:pointer}.enlighter-default .enlighter-btn:hover{color:#157ff9}.enlighter-t-atomic .enlighter-btn,.enlighter-t-dracula .enlighter-btn,.enlighter-t-monokai .enlighter-btn{background:rgba(57,60,66,.87)}.enlighter-default .enlighter-toolbar .enlighter-btn-raw::after{content:"\f121"}.enlighter-default .enlighter-toolbar .enlighter-btn-copy::after{content:"\f0ea"}.enlighter-default .enlighter-toolbar .enlighter-btn-window::after{content:"\f1b2"}.enlighter-origin{display:none!important}.enlighter-clipboard{position:absolute;left:0;bottom:0;width:1px;height:1px;overflow:hidden}.enlighter-v-inline{display:inline-block;overflow:inherit;margin:0}.enlighter-v-standard{display:block}.enlighter-v-codegroup{display:block}.enlighter-v-codegroup .enlighter-codegroup-wrapper{position:relative}div.enlighter{width:100%;border-collapse:collapse;border-spacing:0;padding:12px 0;empty-cells:show;min-width:100%;font-size:10px;margin:0;text-indent:0;-webkit-overflow-scrolling:touch;counter-reset:enlighter 0}div.enlighter>div{margin:0;border:solid 0 #fff;list-style:none;font-size:inherit;line-height:1.4;min-height:14px}div.enlighter>div>div{display:table-cell;width:100%;padding-left:10px}div.enlighter>div>div::before{content:" "}span.enlighter{display:inline-block;padding:3px 5px 1px 5px;margin:0 2px 0 2px}.enlighter span{margin:0;padding:0;line-height:inherit;font-size:13px;font-family:inherit}.enlighter-linenumbers div.enlighter>div::before{white-space:nowrap;display:block;display:table-cell;width:45px;min-width:45px;counter-increment:enlighter;content:counter(enlighter,decimal) ".";text-align:right;padding-right:8px}.enlighter-overflow-scroll.enlighter-v-standard .enlighter{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-codegroup-wrapper{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter>div>div,.enlighter-overflow-scroll.enlighter-v-standard .enlighter>div>div{white-space:pre!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-raw,.enlighter-overflow-scroll.enlighter-v-standard .enlighter-raw{white-space:pre!important}.enlighter-show-rawcode .enlighter-raw{padding:12px 16px!important;display:block}.enlighter-show-rawcode .enlighter{display:none!important}.enlighter-t-enlighter{color:#555;background:#f8f9fa}.enlighter-t-enlighter.enlighter-hover div.enlighter>div:hover{color:#444;background-color:#fffcd3}.enlighter-t-enlighter div.enlighter>div{color:#aaa}.enlighter-t-enlighter div.enlighter>div.enlighter-special{background-color:#fdf5f0}.enlighter-t-enlighter.enlighter-linenumbers div.enlighter>div::before{border-right:solid 1px #e8e8e8}.enlighter-t-enlighter .enlighter-text{color:#555}.enlighter-t-enlighter .enlighter-c0{color:#99a}.enlighter-t-enlighter .enlighter-c1{color:#99a}.enlighter-t-enlighter .enlighter-c2{color:#99a}.enlighter-t-enlighter .enlighter-c9{color:#9baa8f}.enlighter-t-enlighter .enlighter-k0{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k1{color:#4573f7;font-weight:700}.enlighter-t-enlighter .enlighter-k2{color:#458;font-weight:700}.enlighter-t-enlighter .enlighter-k3{color:#4da0d2;background-color:#f0f0f0}.enlighter-t-enlighter .enlighter-k4{color:#4a9141;font-weight:700}.enlighter-t-enlighter .enlighter-k5{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k6{color:#286491;font-style:italic}.enlighter-t-enlighter .enlighter-k7{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k8{color:#4da0d2}.enlighter-t-enlighter .enlighter-k9{color:#990073;font-weight:700}.enlighter-t-enlighter .enlighter-k10{color:#4a9141;font-style:italic}.enlighter-t-enlighter .enlighter-e0{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e1{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e2{color:#009926}.enlighter-t-enlighter .enlighter-e3{color:#286491}.enlighter-t-enlighter .enlighter-e4{color:#ff8c00;font-style:italic}.enlighter-t-enlighter .enlighter-s0{colorLine truncated
/*! EnlighterJS Syntax Highlighter 3.0.0 | Mozilla Public License 2.0 | https://enlighterjs.org */.enlighter-tooltip{z-index:100}.enlighter-default{font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px;line-height:1.4;overflow:hidden;white-space:pre-wrap;word-wrap:break-word;margin:0 0 20px 0;padding:0;position:relative;text-align:left;direction:ltr;border-radius:8px}.enlighter-default .enlighter-special:hover{background-color:#f4f8fc}.enlighter-default .enlighter-raw{display:none;white-space:pre-wrap;word-wrap:break-word;box-shadow:none;padding:0 17px!important;color:inherit}.enlighter-toolbar{opacity:0;position:absolute;right:10px;top:8px;z-index:10;transition:.2s}.enlighter-default:hover .enlighter-toolbar{opacity:1}.enlighter-default .enlighter-btn{font: normal normal 900 14px/1 "Font Awesome 5 Free";border-radius:4px;display:inline-block;transition:.15s;padding:.3em .6em;background:rgba(235,237,239,.8);color:#666;font-size:14px;margin-left:6px;cursor:pointer}.enlighter-default .enlighter-btn:hover{color:#157ff9}.enlighter-t-atomic .enlighter-btn,.enlighter-t-dracula .enlighter-btn,.enlighter-t-monokai .enlighter-btn{background:rgba(57,60,66,.87)}.enlighter-default .enlighter-toolbar .enlighter-btn-raw::after{content:"\f121"}.enlighter-default .enlighter-toolbar .enlighter-btn-copy::after{content:"\f328"}.enlighter-default .enlighter-toolbar .enlighter-btn-window::after{content:"\f1b2"}.enlighter-origin{display:none!important}.enlighter-clipboard{position:absolute;left:0;bottom:0;width:1px;height:1px;overflow:hidden}.enlighter-v-inline{display:inline-block;overflow:inherit;margin:0}.enlighter-v-standard{display:block}.enlighter-v-codegroup{display:block}.enlighter-v-codegroup .enlighter-codegroup-wrapper{position:relative}div.enlighter{width:100%;border-collapse:collapse;border-spacing:0;padding:12px 0;empty-cells:show;min-width:100%;font-size:10px;margin:0;text-indent:0;-webkit-overflow-scrolling:touch;counter-reset:enlighter 0}div.enlighter>div{margin:0;border:solid 0 #fff;list-style:none;font-size:inherit;line-height:1.4;min-height:14px}div.enlighter>div>div{display:table-cell;width:100%;padding-left:10px}div.enlighter>div>div::before{content:" "}span.enlighter{display:inline-block;padding:3px 5px 1px 5px;margin:0 2px 0 2px}.enlighter span{margin:0;padding:0;line-height:inherit;font-size:13px;font-family:inherit}.enlighter-linenumbers div.enlighter>div::before{white-space:nowrap;display:block;display:table-cell;width:45px;min-width:45px;counter-increment:enlighter;content:counter(enlighter,decimal) ".";text-align:right;padding-right:8px}.enlighter-overflow-scroll.enlighter-v-standard .enlighter{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-codegroup-wrapper{overflow-x:auto;word-wrap:normal!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter>div>div,.enlighter-overflow-scroll.enlighter-v-standard .enlighter>div>div{white-space:pre!important}.enlighter-overflow-scroll.enlighter-v-codegroup .enlighter-raw,.enlighter-overflow-scroll.enlighter-v-standard .enlighter-raw{white-space:pre!important}.enlighter-show-rawcode .enlighter-raw{padding:12px 16px!important;display:block}.enlighter-show-rawcode .enlighter{display:none!important}.enlighter-t-enlighter{color:#555;background:#f8f9fa}.enlighter-t-enlighter.enlighter-hover div.enlighter>div:hover{color:#444;background-color:#fffcd3}.enlighter-t-enlighter div.enlighter>div{color:#aaa}.enlighter-t-enlighter div.enlighter>div.enlighter-special{background-color:#fdf5f0}.enlighter-t-enlighter.enlighter-linenumbers div.enlighter>div::before{border-right:solid 1px #e8e8e8}.enlighter-t-enlighter .enlighter-text{color:#555}.enlighter-t-enlighter .enlighter-c0{color:#99a}.enlighter-t-enlighter .enlighter-c1{color:#99a}.enlighter-t-enlighter .enlighter-c2{color:#99a}.enlighter-t-enlighter .enlighter-c9{color:#9baa8f}.enlighter-t-enlighter .enlighter-k0{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k1{color:#4573f7;font-weight:700}.enlighter-t-enlighter .enlighter-k2{color:#458;font-weight:700}.enlighter-t-enlighter .enlighter-k3{color:#4da0d2;background-color:#f0f0f0}.enlighter-t-enlighter .enlighter-k4{color:#4a9141;font-weight:700}.enlighter-t-enlighter .enlighter-k5{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k6{color:#286491;font-style:italic}.enlighter-t-enlighter .enlighter-k7{color:#286491;font-weight:700}.enlighter-t-enlighter .enlighter-k8{color:#4da0d2}.enlighter-t-enlighter .enlighter-k9{color:#990073;font-weight:700}.enlighter-t-enlighter .enlighter-k10{color:#4a9141;font-style:italic}.enlighter-t-enlighter .enlighter-e0{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e1{color:#34068a;font-weight:700}.enlighter-t-enlighter .enlighter-e2{color:#009926}.enlighter-t-enlighter .enlighter-e3{color:#286491}.enlighter-t-enlighter .enlighter-e4{color:#ff8c00;font-style:italic}.enlighter-t-enlighter .enlighter-s0{colorLine truncated
+1 -1
View File
@@ -1 +1 @@
(function($,window2,document2){"use strict";function closeNotyf($element){$element.addClass("notyn-out"),window2.setTimeout(function(){$element.remove()},1e3)}function notyf2(message,type,time,id){var $body=jQuery(document2.body);jQuery(".notyn").length||$body.append('<div class="notyn"></div>'),type=type||"success",type==="error"&&(type="danger"),time=time||5e3,time=time<100?time*1e3:time;var idAttribute=id?' id="'+id+'"':"",$notification=jQuery('<div class="noty1"'+idAttribute+'><div class="notyf '+type+'">'+message+"</div></div>"),shouldClose=!id;id&&jQuery("#"+id).length?(jQuery("#"+id).find(".notyf").removeClass().addClass("notyf "+type).html(message),$notification=jQuery("#"+id),shouldClose=!0):jQuery(".notyn").append($notification),shouldClose&&window2.setTimeout(function(){closeNotyf($notification)},time)}jQuery(document2.body).on("click",".noty1",function(){closeNotyf(jQuery(this))}),window2.notyf=notyf2})(jQuery,window,document),(function(window2){"use strict";var allowedKinds={identity:!0,badges:!0,orders:!0,vip:!0},allowedEvents={click:!0,shell:!0,"first-content":!0,ready:!0,"action-start":!0,"action-end":!0,unauthorized:!0,error:!0},sessions=Object.create(null),sequence=0,maxSessions=100;function normalize(value,fallback){var normalized=String(value||fallback||"").toLowerCase().replace(/[^a-z0-9-]/g,"");return normalized||fallback}function now(){return window2.performance&&typeof window2.performance.now=="function"?window2.performance.now():0}function markName(session,event){return"jio-modal-"+session.kind+"-"+session.id+"-"+event}function emit(session,event){if(!(!window2.performance||typeof window2.performance.mark!="function")){var name=markName(session,event);if(window2.performance.mark(name),session.marks[event]=name,typeof window2.performance.measure=="function"&&session.marks.click&&event!=="click")try{window2.performance.measure("jio-modal-"+session.kind+"-"+session.id+"-click-to-"+event,session.marks.click,name)}catch{}}}function start(kind){var safeKind=normalize(kind,"unknown");allowedKinds[safeKind]||(safeKind="unknown"),sequence+=1;var id=String(sequence),session={id,kind:safeKind,startedAt:now(),marks:Object.create(null)};sessions[id]=session,emit(session,"click");for(var ids=Object.keys(sessions);ids.length>maxSessions;)delete sessions[ids.shift()];return id}function mark(id,event){var session=sessions[String(id||"")],safeEvent=normalize(event,"error");!session||!allowedEvents[safeEvent]||emit(session,safeEvent)}function finish(id){mark(id,"ready")}function fail(id){mark(id,"error")}window2.JioModalTelemetry={start,mark,finish,error:fail}})(window),(function(window2){"use strict";function data(){return window2.jioData||window2.jio||{}}function createIdempotencyKey(){if(window2.crypto&&typeof window2.crypto.randomUUID=="function")return window2.crypto.randomUUID();if(!window2.crypto||typeof window2.crypto.getRandomValues!="function")throw new Error("当前浏览器无法生成安全的操作标识");var bytes=new Uint8Array(16);window2.crypto.getRandomValues(bytes),bytes[6]=bytes[6]&15|64,bytes[8]=bytes[8]&63|128;var hex=Array.prototype.map.call(bytes,function(value){return value.toString(16).padStart(2,"0")}).join("");return hex.slice(0,8)+"-"+hex.slice(8,12)+"-"+hex.slice(12,16)+"-"+hex.slice(16,20)+"-"+hex.slice(20)}function restBase(){var config=data(),raw=config.restUrl||config.apiUrl||config.rest_url||"",siteUrl=config.siteUrl||config.homeUrl||window2.location.origin+"/";return window2.location.protocol==="https:"&&siteUrl.substring(0,5)==="http:"&&(siteUrl="https:"+siteUrl.substring(5)),raw?String(raw).replace(/\/$/,""):String(siteUrl).replace(/\/$/,"")+"/index.php?rest_route=/jio/v1"}function appendQuery(url2,query){if(!query)return url2;var parts=[];return typeof query=="string"?parts=query.replace(/^\?/,"").split("&").filter(Boolean):typeof query=="object"&&Object.keys(query).forEach(function(key){query[key]===void 0||query[key]===null||parts.push(encodeURIComponent(key)+"="+encodeURIComponent(String(query[key])))}),parts.length?url2+(url2.indexOf("?")>=0?"&":"?")+parts.join("&"):url2}function url(path,query){path=String(path||"");var inlineQuery="",queryIndex=path.indexOf("?");if(queryIndex>=0&&(inlineQuery=path.slice(queryIndex+1),path=path.slice(0,queryIndex)),/^https?:\/\//i.test(path))return appendQuery(path,query||inlineQuery);path.charAt(0)!=="/"&&(path="/"+path);var base=restBase(),result=(base.indexOf("rest_route=")>=0,base+path);return appendQuery(result,query||inlineQuery)}function headers(options){var config=data(),source=options&&options.headers||{},result={},nonce=config.restNonce||config.nonce||"";return Object.keys(source).forEach(function(key){result[key]=source[key]}),result.Accept||(result.Accept="application/json, text/html;q=0.9, */*;q=0.8"),nonce&&!result["X-WP-Nonce"]&&(result["X-WP-Nonce"]=nonce),options&&options.body!==void 0&&options.body!==null&&!(window2.FormData&&options.body instanceof window2.FormData)&&!result["Content-Type"]&&(result["CoLine truncated
(function($,window2,document2){"use strict";function closeNotyf($element){$element.addClass("notyn-out"),window2.setTimeout(function(){$element.remove()},1e3)}function notyf2(message,type,time,id){var $body=jQuery(document2.body);jQuery(".notyn").length||$body.append('<div class="notyn"></div>'),type=type||"success",type==="error"&&(type="danger"),time=time||5e3,time=time<100?time*1e3:time;var idAttribute=id?' id="'+id+'"':"",$notification=jQuery('<div class="noty1"'+idAttribute+'><div class="notyf '+type+'">'+message+"</div></div>"),shouldClose=!id;id&&jQuery("#"+id).length?(jQuery("#"+id).find(".notyf").removeClass().addClass("notyf "+type).html(message),$notification=jQuery("#"+id),shouldClose=!0):jQuery(".notyn").append($notification),shouldClose&&window2.setTimeout(function(){closeNotyf($notification)},time)}jQuery(document2.body).on("click",".noty1",function(){closeNotyf(jQuery(this))}),window2.notyf=notyf2})(jQuery,window,document),(function(window2){"use strict";var allowedKinds={identity:!0,badges:!0,orders:!0,vip:!0},allowedEvents={click:!0,shell:!0,"first-content":!0,ready:!0,"action-start":!0,"action-end":!0,unauthorized:!0,error:!0},sessions=Object.create(null),sequence=0,maxSessions=100;function normalize(value,fallback){var normalized=String(value||fallback||"").toLowerCase().replace(/[^a-z0-9-]/g,"");return normalized||fallback}function now(){return window2.performance&&typeof window2.performance.now=="function"?window2.performance.now():0}function markName(session,event){return"jio-modal-"+session.kind+"-"+session.id+"-"+event}function emit(session,event){if(!(!window2.performance||typeof window2.performance.mark!="function")){var name=markName(session,event);if(window2.performance.mark(name),session.marks[event]=name,typeof window2.performance.measure=="function"&&session.marks.click&&event!=="click")try{window2.performance.measure("jio-modal-"+session.kind+"-"+session.id+"-click-to-"+event,session.marks.click,name)}catch{}}}function start(kind){var safeKind=normalize(kind,"unknown");allowedKinds[safeKind]||(safeKind="unknown"),sequence+=1;var id=String(sequence),session={id,kind:safeKind,startedAt:now(),marks:Object.create(null)};sessions[id]=session,emit(session,"click");for(var ids=Object.keys(sessions);ids.length>maxSessions;)delete sessions[ids.shift()];return id}function mark(id,event){var session=sessions[String(id||"")],safeEvent=normalize(event,"error");!session||!allowedEvents[safeEvent]||emit(session,safeEvent)}function finish(id){mark(id,"ready")}function fail(id){mark(id,"error")}window2.JioModalTelemetry={start,mark,finish,error:fail}})(window),(function(window2){"use strict";function data(){return window2.jioData||window2.jio||{}}function createIdempotencyKey(){if(window2.crypto&&typeof window2.crypto.randomUUID=="function")return window2.crypto.randomUUID();if(!window2.crypto||typeof window2.crypto.getRandomValues!="function")throw new Error("当前浏览器无法生成安全的操作标识");var bytes=new Uint8Array(16);window2.crypto.getRandomValues(bytes),bytes[6]=bytes[6]&15|64,bytes[8]=bytes[8]&63|128;var hex=Array.prototype.map.call(bytes,function(value){return value.toString(16).padStart(2,"0")}).join("");return hex.slice(0,8)+"-"+hex.slice(8,12)+"-"+hex.slice(12,16)+"-"+hex.slice(16,20)+"-"+hex.slice(20)}function restBase(){var config=data(),raw=config.restUrl||config.apiUrl||config.rest_url||"",siteUrl=config.siteUrl||config.homeUrl||window2.location.origin+"/";return window2.location.protocol==="https:"&&siteUrl.substring(0,5)==="http:"&&(siteUrl="https:"+siteUrl.substring(5)),raw?String(raw).replace(/\/$/,""):String(siteUrl).replace(/\/$/,"")+"/index.php?rest_route=/jio/v1"}function appendQuery(url2,query){if(!query)return url2;var parts=[];return typeof query=="string"?parts=query.replace(/^\?/,"").split("&").filter(Boolean):typeof query=="object"&&Object.keys(query).forEach(function(key){query[key]===void 0||query[key]===null||parts.push(encodeURIComponent(key)+"="+encodeURIComponent(String(query[key])))}),parts.length?url2+(url2.indexOf("?")>=0?"&":"?")+parts.join("&"):url2}function url(path,query){path=String(path||"");var inlineQuery="",queryIndex=path.indexOf("?");if(queryIndex>=0&&(inlineQuery=path.slice(queryIndex+1),path=path.slice(0,queryIndex)),/^https?:\/\//i.test(path))return appendQuery(path,query||inlineQuery);path.charAt(0)!=="/"&&(path="/"+path);var base=restBase(),result=(base.indexOf("rest_route=")>=0,base+path);return appendQuery(result,query||inlineQuery)}function headers(options){var config=data(),source=options&&options.headers||{},result={},nonce=config.restNonce||config.nonce||"";return Object.keys(source).forEach(function(key){result[key]=source[key]}),result.Accept||(result.Accept="application/json, text/html;q=0.9, */*;q=0.8"),nonce&&!result["X-WP-Nonce"]&&(result["X-WP-Nonce"]=nonce),options&&options.body!==void 0&&options.body!==null&&!(window2.FormData&&options.body instanceof window2.FormData)&&!result["Content-Type"]&&(result["CoLine truncated