1
0

index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE HTML>
  2. <html lang="zh-CN" class="fh-jf">
  3. <head>
  4. <title>JSON格式化查看工具</title>
  5. <meta charset="UTF-8">
  6. <link rel="stylesheet" href="index.css" />
  7. <script type="text/javascript" src="../static/vendor/evalCore.min.js"></script>
  8. <script type="text/javascript" src="../static/vendor/vue/vue.js"></script>
  9. </head>
  10. <body class="theme-default">
  11. <div class="wrapper wp-json" id="pageContainer">
  12. <div class="panel panel-default" style="margin-bottom: 0px;">
  13. <div class="panel-heading">
  14. <h3 class="panel-title">
  15. <a href="https://www.baidufe.com/fehelper/index/index.html" target="_blank" class="x-a-high">
  16. <img src="../static/img/fe-16.png" alt="fehelper"/> FeHelper</a>:JSON格式化
  17. <span class="x-xdemo" ref="demoLink1" @click="setDemo">示例1:JSON片段</span>
  18. <a class="x-xdemo" href="http://t.weather.sojson.com/api/weather/city/101030100" target="_blank">示例2:在线JSON</a>
  19. <a class="x-xdemo" href="/options/index.html?query=数据Mock工具" target="_blank" class="fh-tip-link">获取更多Mock数据</a>
  20. <span id="layoutBar">
  21. <button id="btnLeftRight" ref="btnLeftRight" class="selected" @click="changeLayout('left-right')">左右布局</button><button id="btnUpDown" ref="btnUpDown" @click="changeLayout('up-down')">上下布局</button>
  22. </span>
  23. <a class="x-other-tools" v-if="!isInUSAFlag" @click="openOptionsPage($event)"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
  24. <span class="x-donate-link" v-if="!isInUSAFlag" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>
  25. </h3>
  26. </div>
  27. </div>
  28. <div class="x-toolbar x-inpage">
  29. <button id="btnFormat" class="btn btn-primary btn-xs ui-mr-10" @click="format">格式化</button>
  30. <button id="btnCompress" class="btn btn-success btn-xs" @click="compress">压缩</button>
  31. <span class="x-split">|</span>
  32. <input type="checkbox" v-model="jsonLintSwitch" id="jsonLint" @click="lintOn"><label for="jsonLint">JSONLint</label>
  33. <span class="x-split">|</span>
  34. <input type="checkbox" v-model="autoDecode" id="endecode" @click="autoDecodeFn"><label for="endecode">自动解码</label>
  35. <span class="x-split">|</span>
  36. <input type="checkbox" v-model="overrideJson" id="jsonOvrd" @click="setCache"><label for="jsonOvrd">节点编辑</label>
  37. <span class="x-split">|</span>
  38. <input type="checkbox" v-model="autoUnpackJsonString" id="autoUnpackJsonString" @click="autoUnpackJsonStringFn"><label for="autoUnpackJsonString">支持嵌套解析</label>
  39. <span class="x-split">|</span>
  40. <span class="x-sort">
  41. <span class="x-stitle">排序:</span>
  42. <label for="sort_null">默认</label>
  43. <input type="radio" name="jsonsort" id="sort_null" value="0" checked @click="format">
  44. <label for="sort_asc">升序</label>
  45. <input type="radio" name="jsonsort" id="sort_asc" value="1" @click="format">
  46. <label for="sort_desc">降序</label>
  47. <input type="radio" name="jsonsort" id="sort_desc" value="-1" @click="format">
  48. </span>
  49. <span class="x-split">|</span>
  50. <span class="x-endecode">
  51. <button class="xjf-btn xjf-btn-left" @click="uniEncode">Uni编码</button><button class="xjf-btn xjf-btn-mid" @click="uniDecode">Uni解码</button><button class="xjf-btn xjf-btn-right" @click="urlDecode">URL解码</button>
  52. </span>
  53. <span class="x-split">|</span>
  54. <button class="xjf-btn" @click="openJsonPathModal">JSONPath查询</button>
  55. <span id="optionBar"></span>
  56. </div>
  57. <div class="panel-body mod-json">
  58. <div class="row panel-txt">
  59. <textarea class="form-control mod-textarea" id="jsonSource" placeholder="在这里粘贴您需要进行格式化的JSON代码" ref="jsonBox"></textarea>
  60. </div>
  61. <div class="row rst-item" id="modJsonResult">
  62. <div id="formattingMsg"><span class="x-loading"></span>格式化中...</div>
  63. <div id="jfCallbackName_start" class="callback-name" v-html="jfCallbackName_start"></div>
  64. <div id="jfContent" v-html="placeHolder"></div>
  65. <pre id="jfContent_pre"></pre>
  66. <div id="jfCallbackName_end" class="callback-name" v-html="jfCallbackName_end"></div>
  67. </div>
  68. </div>
  69. <!-- JSONPath查询模态框 -->
  70. <div id="jsonPathModal" class="jsonpath-modal" v-show="showJsonPathModal" @click="closeJsonPathModal">
  71. <div class="jsonpath-modal-content" @click.stop>
  72. <div class="jsonpath-modal-header">
  73. <h3>JSONPath查询</h3>
  74. <div class="jsonpath-header-controls">
  75. <input type="text" class="xjf-input jsonpath-header-input" v-model="jsonPathQuery"
  76. placeholder="JSONPath表达式 (如: $.data.items[*].name)"
  77. @keyup.enter="executeJsonPath">
  78. <button class="xjf-btn jsonpath-header-btn" @click="executeJsonPath" :disabled="!jsonPathQuery.trim()">查询</button>
  79. <button class="xjf-btn xjf-btn-examples jsonpath-header-btn" @click="showJsonPathExamples">示例</button>
  80. </div>
  81. <span class="jsonpath-modal-close" @click="closeJsonPathModal">&times;</span>
  82. </div>
  83. <div class="jsonpath-modal-body">
  84. <!-- 查询结果区域 -->
  85. <div class="jsonpath-results-section" v-if="jsonPathQuery && (jsonPathResults.length > 0 || jsonPathError)">
  86. <div class="jsonpath-query-info">
  87. <strong>查询表达式:</strong> <code>{{jsonPathQuery}}</code>
  88. <span class="jsonpath-result-count" v-if="!jsonPathError">找到 {{jsonPathResults.length}} 个结果</span>
  89. </div>
  90. <div class="jsonpath-result-actions" v-if="jsonPathResults.length > 0">
  91. <button class="xjf-btn"
  92. :class="{
  93. 'xjf-btn-copying': copyButtonState === 'copying',
  94. 'xjf-btn-success': copyButtonState === 'success',
  95. 'xjf-btn-error': copyButtonState === 'error'
  96. }"
  97. @click="copyJsonPathResults"
  98. :disabled="copyButtonState === 'copying'">
  99. <span v-if="copyButtonState === 'normal'">复制结果</span>
  100. <span v-if="copyButtonState === 'copying'">复制中...</span>
  101. <span v-if="copyButtonState === 'success'">✓ 复制成功</span>
  102. <span v-if="copyButtonState === 'error'">✗ 复制失败</span>
  103. </button>
  104. <button class="xjf-btn" @click="downloadJsonPathResults">下载结果</button>
  105. </div>
  106. <div class="jsonpath-results" v-if="jsonPathResults.length > 0">
  107. <div class="jsonpath-result-item" v-for="(result, index) in jsonPathResults" :key="index">
  108. <div class="jsonpath-result-path">路径: <code>{{result.path}}</code></div>
  109. <pre class="jsonpath-result-value">{{formatJsonPathResult(result.value)}}</pre>
  110. </div>
  111. </div>
  112. <div class="jsonpath-no-results" v-if="jsonPathResults.length === 0 && !jsonPathError">
  113. <p>未找到匹配的结果</p>
  114. </div>
  115. <div class="jsonpath-error" v-if="jsonPathError">
  116. <p class="error-msg">{{jsonPathError}}</p>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <!-- JSONPath示例模态框 -->
  123. <div id="jsonPathExamplesModal" class="jsonpath-modal v-cloak" v-show="showJsonPathExamplesModal" @click="closeJsonPathExamplesModal">
  124. <div class="jsonpath-modal-content" @click.stop>
  125. <div class="jsonpath-modal-header">
  126. <h3>JSONPath查询示例</h3>
  127. <span class="jsonpath-modal-close" @click="closeJsonPathExamplesModal">&times;</span>
  128. </div>
  129. <div class="jsonpath-modal-body">
  130. <div class="jsonpath-examples">
  131. <div class="jsonpath-example-item" v-for="example in jsonPathExamples" :key="example.path" @click="useJsonPathExample(example.path)">
  132. <div class="jsonpath-example-path"><code>{{example.path}}</code></div>
  133. <div class="jsonpath-example-desc">{{example.description}}</div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <script src="../static/vendor/jquery/jquery-3.3.1.min.js"></script>
  141. <script src="../static/vendor/codemirror/codemirror.js"></script>
  142. <script src="../static/vendor/codemirror/javascript.js"></script>
  143. <script src="../static/vendor/codemirror/active-line.js"></script>
  144. <script src="../static/vendor/codemirror/matchbrackets.js"></script>
  145. <script src="../static/vendor/codemirror/placeholder.js"></script>
  146. <script src="json-lint.js"></script>
  147. <script src="json-bigint.js"></script>
  148. <script src="format-lib.js"></script>
  149. <script src="json-abc.js"></script>
  150. <script src="json-decode.js"></script>
  151. <script src="../static/js/dark-mode.js"></script>
  152. <script src="index.js" type="module"></script>
  153. </body>
  154. </html>