.tmp-showdoc-1.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width,viewport-fit=cover, initial-scale=1.0"
  8. />
  9. <meta name="renderer" content="webkit" />
  10. <meta http-equiv="X-UA-Compatible" content="edge" />
  11. <meta http-equiv="Expires" content="0" />
  12. <meta http-equiv="Pragma" content="no-cache" />
  13. <meta
  14. http-equiv="Cache-control"
  15. content="no-cache, no-store, must-revalidate"
  16. />
  17. <meta http-equiv="Cache" content="no-cache" />
  18. <link rel="apple-touch-icon" href="https://showdoc-server.cdn.dfyun.com.cn/logo/w_64.png" />
  19. <link rel="apple-touch-icon-precomposed" href="https://showdoc-server.cdn.dfyun.com.cn/logo/w_64.png" />
  20. <link rel="icon" href="https://showdoc-server.cdn.dfyun.com.cn/favicon.ico" />
  21. <title>ShowDoc</title>
  22. <meta name="keywords" content="在线API文档 技术文档 数据字典 在线手册" />
  23. <meta
  24. name="description"
  25. content="一个非常适合IT团队的在线API文档、技术文档工具。你可以使用Showdoc来编写在线API文档、技术文档、数据字典、在线手册"
  26. />
  27. <script src="https://showdoc-server.cdn.dfyun.com.cn/server-cdn-status.js?v=3"></script>
  28. <script src="https://showdoc.cdn.dfyun.com.cn/cdn-status.js?v=2"></script>
  29. <script type="text/javascript">
  30. // ========================================
  31. // 环境检测(优先执行)
  32. // ========================================
  33. var host = window.location.host
  34. var port = window.location.port
  35. // 开发环境:Vite dev server(端口 8081)
  36. var isDevEnv = (host.indexOf('localhost') > -1 || host.indexOf('127.0.0.1') > -1) && port === '8081'
  37. // 测试环境:构建后的代码 + 测试域名(不使用 CDN)
  38. var isTestEnv = !isDevEnv && (
  39. host.indexOf('wu.com') > -1 ||
  40. host.indexOf('gaoyixia.com') > -1 ||
  41. host.indexOf('test.showdoc') > -1 ||
  42. host.indexOf('local.showdoc') > -1 ||
  43. host.indexOf('sd.gaoyixia.com') > -1 ||
  44. host.indexOf('127.0.0.1') > -1 ||
  45. host.indexOf('192.168.') > -1 ||
  46. host.indexOf('localhost') > -1
  47. )
  48. // ========================================
  49. // 全局配置
  50. // ========================================
  51. if (isDevEnv) {
  52. // 开发环境
  53. window.DocConfig = {
  54. server: '/server/index.php?s=',
  55. originalServer: '/server/index.php?s=',
  56. lang: 'zh-cn',
  57. staticPath: '/'
  58. }
  59. } else if (isTestEnv) {
  60. // 测试环境:使用本地资源(根目录)
  61. window.DocConfig = {
  62. server: '/server/index.php?s=',
  63. originalServer: '/server/index.php?s=',
  64. lang: 'zh-cn',
  65. staticPath: '/'
  66. }
  67. } else {
  68. // 生产环境(默认使用 CDN)
  69. window.DocConfig = {
  70. server: 'https://showdoc-server.cdn.dfyun.com.cn/server/index.php?s=',
  71. originalServer: '/server/index.php?s=',
  72. lang: 'zh-cn',
  73. staticPath: 'https://showdoc.cdn.dfyun.com.cn/'
  74. }
  75. // 生产环境 CDN 容灾
  76. // Server CDN 容灾
  77. if (typeof window.SHOWDOC_SERVER_CDN_STASTUS == 'undefined') {
  78. window.DocConfig.server = '/server/index.php?s='
  79. }
  80. // 静态资源 CDN 容灾
  81. if (typeof window.SHOWDOC_CDN_STASTUS == 'undefined') {
  82. window.DocConfig.staticPath = '/'
  83. }
  84. }
  85. </script>
  86. <script type="module" crossorigin src="https://showdoc.cdn.dfyun.com.cn/assets/index-bf750cc3.js"></script>
  87. <link rel="modulepreload" crossorigin href="https://showdoc.cdn.dfyun.com.cn/assets/vendor-775275a9.js">
  88. <link rel="modulepreload" crossorigin href="https://showdoc.cdn.dfyun.com.cn/assets/vendor-vue-dc600416.js">
  89. <link rel="modulepreload" crossorigin href="https://showdoc.cdn.dfyun.com.cn/assets/components-79c21c71.js">
  90. <link rel="modulepreload" crossorigin href="https://showdoc.cdn.dfyun.com.cn/assets/core-9aca1148.js">
  91. <link rel="modulepreload" crossorigin href="https://showdoc.cdn.dfyun.com.cn/assets/assets-7d25f5ec.js">
  92. <link rel="stylesheet" href="https://showdoc.cdn.dfyun.com.cn/assets/vendor-49dc2278.css">
  93. <link rel="stylesheet" href="https://showdoc.cdn.dfyun.com.cn/assets/vendor-vue-e0182f4b.css">
  94. <link rel="stylesheet" href="https://showdoc.cdn.dfyun.com.cn/assets/components-2a251b15.css">
  95. <link rel="stylesheet" href="https://showdoc.cdn.dfyun.com.cn/assets/assets-c462eb69.css">
  96. <link rel="stylesheet" href="https://showdoc.cdn.dfyun.com.cn/assets/index-726c1082.css">
  97. </head>
  98. <body class="grey-bg">
  99. <div class="index-item-block">
  100. <div>INDEX_HTML</div>
  101. <div>ITEM_HTML</div>
  102. </div>
  103. <div id="app"></div>
  104. <!-- CDN 容灾脚本 -->
  105. <script>
  106. // CDN 容灾:如果 CDN 不可用,替换所有资源为本地路径
  107. if (typeof window.SHOWDOC_CDN_STASTUS == 'undefined') {
  108. // 把全局变量中的静态资源路径改为本地
  109. window.DocConfig.staticPath = '/'
  110. changeCDNToRoot()
  111. setTimeout(() => {
  112. changeCDNToRoot()
  113. }, 500)
  114. }
  115. // 修改资源路径从 CDN 到本地,并重新加载
  116. function changeCDNToRoot() {
  117. const loadScript = src => {
  118. return new Promise((resolve, reject) => {
  119. const scriptTag = document.createElement('script')
  120. scriptTag.src = src
  121. scriptTag.type = 'module'
  122. scriptTag.crossOrigin = 'anonymous'
  123. scriptTag.onload = resolve
  124. scriptTag.onerror = reject
  125. document.head.appendChild(scriptTag)
  126. })
  127. }
  128. const loadStylesheet = href => {
  129. return new Promise((resolve, reject) => {
  130. const linkTag = document.createElement('link')
  131. linkTag.href = href
  132. linkTag.rel = 'stylesheet'
  133. linkTag.onload = resolve
  134. linkTag.onerror = reject
  135. document.head.appendChild(linkTag)
  136. })
  137. }
  138. const updateLinkTags = async () => {
  139. // 转换为数组,避免 HTMLCollection live 更新问题
  140. const links = Array.from(document.getElementsByTagName('link'))
  141. for (const linkTag of links) {
  142. const href = linkTag.getAttribute('href')
  143. if (href && href.includes('dfyun')) {
  144. const newHref = href.replace('https://showdoc.cdn.dfyun.com.cn/', '/')
  145. await loadStylesheet(newHref)
  146. // 检查 parentNode 是否存在
  147. if (linkTag.parentNode) {
  148. linkTag.parentNode.removeChild(linkTag)
  149. }
  150. }
  151. }
  152. }
  153. const updateScriptTags = async () => {
  154. // 转换为数组,避免 HTMLCollection live 更新问题
  155. const scripts = Array.from(document.getElementsByTagName('script'))
  156. for (const scriptTag of scripts) {
  157. const src = scriptTag.getAttribute('src')
  158. if (src && src.includes('dfyun') && !src.includes('showdoc-server')) {
  159. const newSrc = src.replace('https://showdoc.cdn.dfyun.com.cn/', '/')
  160. await loadScript(newSrc)
  161. // 检查 parentNode 是否存在
  162. if (scriptTag.parentNode) {
  163. scriptTag.parentNode.removeChild(scriptTag)
  164. }
  165. }
  166. }
  167. }
  168. const updateImgTags = () => {
  169. const imgs = Array.from(document.getElementsByTagName('img'))
  170. for (const imgTag of imgs) {
  171. let src = imgTag.getAttribute('src')
  172. if (src && src.includes('dfyun')) {
  173. src = src.replace('https://showdoc.cdn.dfyun.com.cn/', '/')
  174. imgTag.setAttribute('src', src)
  175. }
  176. }
  177. }
  178. updateLinkTags()
  179. .then(() => {
  180. return updateScriptTags()
  181. })
  182. .then(() => {
  183. console.log('[CDN] 已切换到本地资源')
  184. updateImgTags()
  185. })
  186. .catch(error => {
  187. console.error('[CDN] 切换失败:', error)
  188. })
  189. }
  190. </script>
  191. <!-- 防止被镜像站 -->
  192. <script language="JavaScript">
  193. var host = window.location.host
  194. if (
  195. host.indexOf('localhost') === -1 &&
  196. host.indexOf('wu') === -1 &&
  197. host.indexOf('showdoc') === -1 &&
  198. host.indexOf('star7th.com') === -1 &&
  199. host.indexOf('192.168.') === -1 &&
  200. host.indexOf('gaoyixia.com') === -1 &&
  201. host.indexOf('dongjingyu.cn') === -1 &&
  202. host.indexOf('127.0.0.1') === -1
  203. ) {
  204. var href = window.location.href
  205. var j = href.replace(new RegExp(host, 'g'), 'www.showdoc.com.cn')
  206. window.location.href = j
  207. }
  208. </script>
  209. <!-- 百度统计 -->
  210. <script>
  211. if (window.location.host == 'www.showdoc.com.cn') {
  212. var _hmt = _hmt || []
  213. ;(function() {
  214. var hm = document.createElement('script')
  215. hm.src = 'https://hm.baidu.com/hm.js?84e82fa31c8ca8671f6b6f972b7e54fb'
  216. var s = document.getElementsByTagName('script')[0]
  217. s.parentNode.insertBefore(hm, s)
  218. })()
  219. }
  220. </script>
  221. <!-- 主应用入口 -->
  222. </body>
  223. </html>