|
| 1 | +import type { FC } from 'hono/jsx'; |
| 2 | + |
| 3 | +import { config } from '@/config'; |
| 4 | +import { gitHash, gitDate } from '@/utils/git-hash'; |
| 5 | +import { getDebugInfo } from '@/utils/debug-info'; |
| 6 | + |
| 7 | +const startTime = Date.now(); |
| 8 | + |
| 9 | +const Layout: FC = (props) => ( |
| 10 | + <html> |
| 11 | + <head> |
| 12 | + <title>Welcome to RSSHub!</title> |
| 13 | + <script src="https://cdn.tailwindcss.com"></script> |
| 14 | + </head> |
| 15 | + <body className="antialiased text-zinc-700">{props.children}</body> |
| 16 | + </html> |
| 17 | +); |
| 18 | + |
| 19 | +const Index: FC<{ debugQuery: string | undefined }> = ({ debugQuery }) => { |
| 20 | + const debug = getDebugInfo(); |
| 21 | + |
| 22 | + const showDebug = !config.debugInfo || config.debugInfo === 'false' ? false : config.debugInfo === 'true' || config.debugInfo === debugQuery; |
| 23 | + const { disallowRobot, nodeName } = config; |
| 24 | + |
| 25 | + const duration = Date.now() - startTime; |
| 26 | + |
| 27 | + const info = { |
| 28 | + showDebug, |
| 29 | + disallowRobot, |
| 30 | + debug: [ |
| 31 | + ...(nodeName |
| 32 | + ? [ |
| 33 | + { |
| 34 | + name: 'Node Name', |
| 35 | + value: nodeName, |
| 36 | + }, |
| 37 | + ] |
| 38 | + : []), |
| 39 | + ...(gitHash |
| 40 | + ? [ |
| 41 | + { |
| 42 | + name: 'Git Hash', |
| 43 | + value: ( |
| 44 | + <a className="underline" href={`https://github.com/DIYgod/RSSHub/commit/${gitHash}`}> |
| 45 | + {gitHash} |
| 46 | + </a> |
| 47 | + ), |
| 48 | + }, |
| 49 | + ] |
| 50 | + : []), |
| 51 | + ...(gitDate |
| 52 | + ? [ |
| 53 | + { |
| 54 | + name: 'Git Date', |
| 55 | + value: gitDate.toUTCString(), |
| 56 | + }, |
| 57 | + ] |
| 58 | + : []), |
| 59 | + { |
| 60 | + name: 'Cache Length', |
| 61 | + value: config.cache.routeExpire + 's', |
| 62 | + }, |
| 63 | + { |
| 64 | + name: 'Request Amount', |
| 65 | + value: debug.request, |
| 66 | + }, |
| 67 | + { |
| 68 | + name: 'Request Frequency', |
| 69 | + value: ((debug.request / (duration / 1000)) * 60).toFixed(3) + ' times/minute', |
| 70 | + }, |
| 71 | + { |
| 72 | + name: 'Cache Hit Ratio', |
| 73 | + value: debug.request ? ((debug.hitCache / debug.request) * 100).toFixed(2) + '%' : 0, |
| 74 | + }, |
| 75 | + { |
| 76 | + name: 'ETag Matched Ratio', |
| 77 | + value: debug.request ? ((debug.etag / debug.request) * 100).toFixed(2) + '%' : 0, |
| 78 | + }, |
| 79 | + { |
| 80 | + name: 'Health', |
| 81 | + value: debug.request ? ((1 - debug.error / debug.request) * 100).toFixed(2) + '%' : 0, |
| 82 | + }, |
| 83 | + { |
| 84 | + name: 'Run Time', |
| 85 | + value: (duration / 3_600_000).toFixed(2) + ' hour(s)', |
| 86 | + }, |
| 87 | + ], |
| 88 | + }; |
| 89 | + |
| 90 | + return ( |
| 91 | + <Layout> |
| 92 | + <div |
| 93 | + className="pointer-events-none absolute w-full h-screen" |
| 94 | + style={{ |
| 95 | + backgroundImage: `url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAzMiAzMicgd2lkdGg9JzMyJyBoZWlnaHQ9JzMyJyBmaWxsPSdub25lJyBzdHJva2U9J3JnYigxNSAyMyA0MiAvIDAuMDQpJz48cGF0aCBkPSdNMCAuNUgzMS41VjMyJy8+PC9zdmc+')`, |
| 96 | + maskImage: 'linear-gradient(transparent, black, transparent)', |
| 97 | + }} |
| 98 | + ></div> |
| 99 | + <div className="w-full h-screen flex items-center justify-center flex-col space-y-4"> |
| 100 | + <img src="/logo.png" alt="RSSHub" width="100" loading="lazy" /> |
| 101 | + <h1 className="text-4xl font-bold"> |
| 102 | + Welcome to <span className="text-[#F5712C]">RSSHub</span>! |
| 103 | + </h1> |
| 104 | + <p className="text-zinc-500">If you see this page, the RSSHub is successfully installed and working.</p> |
| 105 | + <p className="text-xl font-medium text-zinc-600">Everything is RSSible</p> |
| 106 | + <div className="font-bold space-x-4 text-sm"> |
| 107 | + <a target="_blank" href="https://docs.rsshub.app"> |
| 108 | + <button className="text-white bg-[#F5712C] py-2 px-4 rounded-full">View Docs</button> |
| 109 | + </a> |
| 110 | + <a target="_blank" href="https://github.com/DIYgod/RSSHub"> |
| 111 | + <button className="bg-zinc-200 py-2 px-4 rounded-full">View on GitHub</button> |
| 112 | + </a> |
| 113 | + <a target="_blank" href="https://docs.rsshub.app/support" className="text-[#F5712C]"> |
| 114 | + <button className="text-white bg-red-500 py-2 px-4 rounded-full">❤️ Sponsor</button> |
| 115 | + </a> |
| 116 | + </div> |
| 117 | + {info.showDebug ? ( |
| 118 | + <details className="text-xs w-96 !mt-8"> |
| 119 | + <summary className="text-sm cursor-pointer">Debug Info</summary> |
| 120 | + {info.debug.map((item) => ( |
| 121 | + <div class="debug-item my-3 pl-8"> |
| 122 | + <span class="debug-key">{item.name}: </span> |
| 123 | + <span class="debug-value">{item.value}</span> |
| 124 | + </div> |
| 125 | + ))} |
| 126 | + </details> |
| 127 | + ) : null} |
| 128 | + </div> |
| 129 | + <div className="absolute bottom-10 text-center w-full text-sm font-medium space-y-2"> |
| 130 | + <p className="space-x-4"> |
| 131 | + <a target="_blank" href="https://github.com/DIYgod/RSSHub"> |
| 132 | + <img className="inline" src="https://icons.ly/github/_/fff" alt="github" width="20" height="20" /> |
| 133 | + </a> |
| 134 | + <a target="_blank" href="https://t.me/rsshub"> |
| 135 | + <img className="inline" src="https://icons.ly/telegram" alt="telegram group" width="20" height="20" /> |
| 136 | + </a> |
| 137 | + <a target="_blank" href="https://t.me/awesomeRSSHub"> |
| 138 | + <img className="inline" src="https://icons.ly/telegram" alt="telegram channel" width="20" height="20" /> |
| 139 | + </a> |
| 140 | + <a target="_blank" href="https://twitter.com/_RSSHub" className="text-[#F5712C]"> |
| 141 | + <img className="inline" src="https://icons.ly/twitter" alt="github" width="20" height="20" /> |
| 142 | + </a> |
| 143 | + </p> |
| 144 | + <p className="!mt-6"> |
| 145 | + Please consider <a target="_blank" href="https://docs.rsshub.app/support" className="text-[#F5712C]">sponsoring</a> to help keep this open source project alive. |
| 146 | + </p> |
| 147 | + <p> |
| 148 | + Made with ❤️ by{' '} |
| 149 | + <a target="_blank" href="https://diygod.cc" className="text-[#F5712C]"> |
| 150 | + DIYgod |
| 151 | + </a>{' '} |
| 152 | + and{' '} |
| 153 | + <a target="_blank" href="https://github.com/DIYgod/RSSHub/graphs/contributors" className="text-[#F5712C]"> |
| 154 | + Contributors |
| 155 | + </a>{' '} |
| 156 | + under MIT License. |
| 157 | + </p> |
| 158 | + </div> |
| 159 | + </Layout> |
| 160 | + ); |
| 161 | +}; |
| 162 | + |
| 163 | +export default Index; |
0 commit comments