DiagnosticsView.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <Section :title="t('diagnostics.get-support')">
  3. <p>{{ t('diagnostics.get-support-description') }}
  4. </p>
  5. <ul>
  6. <li>
  7. <a href = "https://docs.olivetin.app/troubleshooting/wheretofindhelp.html" target="_blank">{{ t('diagnostics.where-to-find-help') }}</a>
  8. </li>
  9. </ul>
  10. </Section>
  11. <Section :title="t('diagnostics.ssh')">
  12. <dl>
  13. <dt>{{ t('diagnostics.found-key') }}</dt>
  14. <dd>{{ diagnostics.sshFoundKey || '?' }}</dd>
  15. <dt>{{ t('diagnostics.found-config') }}</dt>
  16. <dd>{{ diagnostics.sshFoundConfig || '?' }}</dd>
  17. </dl>
  18. </Section>
  19. <Section :title="t('diagnostics.sos-report')">
  20. <p>{{ t('diagnostics.sos-report-description') }}</p>
  21. <p>
  22. <a href="https://docs.olivetin.app/troubleshooting/sosreport.html" target="_blank">{{ t('diagnostics.sos-report-docs') }}</a>
  23. </p>
  24. <div role="toolbar">
  25. <button @click="generateSosReport" :disabled="loading" class = "good">{{ t('diagnostics.generate-sos-report') }}</button>
  26. <button @click="copySosReport" :disabled="!sosReport || loading" :class="sosReportCopied ? 'good' : ''">{{ sosReportCopied ? t('diagnostics.copied') : t('diagnostics.copy-to-clipboard') }}</button>
  27. </div>
  28. <textarea v-model="sosReport" readonly style="flex: 1; min-height: 200px; resize: vertical; width: 100%; box-sizing: border-box;"></textarea>
  29. </Section>
  30. <Section :title="t('diagnostics.browser-info')">
  31. <p>{{ t('diagnostics.browser-info-description') }}</p>
  32. <div role="toolbar">
  33. <button @click="generateBrowserInfo" :disabled="loading" class = "good">{{ t('diagnostics.generate-browser-info') }}</button>
  34. <button @click="copyBrowserInfo" :disabled="!browserInfo || loading" :class="browserInfoCopied ? 'good' : ''">{{ browserInfoCopied ? t('diagnostics.copied') : t('diagnostics.copy-to-clipboard') }}</button>
  35. </div>
  36. <textarea v-model="browserInfo" readonly style="flex: 1; min-height: 200px; resize: vertical; width: 100%; box-sizing: border-box;"></textarea>
  37. </Section>
  38. </template>
  39. <script setup>
  40. import { ref, onMounted } from 'vue'
  41. import Section from 'picocrank/vue/components/Section.vue'
  42. import { useI18n } from 'vue-i18n'
  43. const { t, locale } = useI18n()
  44. const diagnostics = ref({})
  45. const loading = ref(false)
  46. const sosReport = ref('')
  47. const browserInfo = ref('')
  48. const sosReportCopied = ref(false)
  49. const browserInfoCopied = ref(false)
  50. async function fetchDiagnostics() {
  51. loading.value = true
  52. try {
  53. const response = await window.client.getDiagnostics();
  54. diagnostics.value = {
  55. sshFoundKey: response.SshFoundKey,
  56. sshFoundConfig: response.SshFoundConfig
  57. };
  58. } catch (err) {
  59. console.error('Failed to fetch diagnostics:', err);
  60. diagnostics.value = {
  61. sshFoundKey: t('diagnostics.unknown'),
  62. sshFoundConfig: t('diagnostics.unknown')
  63. }
  64. }
  65. loading.value = false
  66. }
  67. function formatKey(key) {
  68. return key
  69. .replace(/([A-Z])/g, ' $1')
  70. .replace(/^./, str => str.toUpperCase())
  71. .trim()
  72. }
  73. async function generateSosReport() {
  74. const response = await window.client.sosReport()
  75. console.log("response", response)
  76. sosReport.value = `\`\`\`\n${response.alert}\n\`\`\`\n`
  77. }
  78. async function copySosReport() {
  79. try {
  80. await navigator.clipboard.writeText(sosReport.value)
  81. sosReportCopied.value = true
  82. setTimeout(() => {
  83. sosReportCopied.value = false
  84. }, 2000)
  85. } catch (err) {
  86. console.error('Failed to copy SOS report to clipboard:', err)
  87. }
  88. }
  89. async function generateBrowserInfo() {
  90. loading.value = true
  91. try {
  92. let userAgentData = 'N/A'
  93. if (navigator.userAgentData) {
  94. try {
  95. const uaData = await navigator.userAgentData.getHighEntropyValues([
  96. 'platform',
  97. 'platformVersion',
  98. 'architecture',
  99. 'model',
  100. 'uaFullVersion',
  101. 'bitness',
  102. 'fullVersionList'
  103. ])
  104. userAgentData = JSON.stringify(uaData, null, 2)
  105. } catch (err) {
  106. userAgentData = `${t('diagnostics.useragent-data-error')}: ${err.message}`
  107. }
  108. }
  109. const info = {
  110. userAgent: navigator.userAgent,
  111. platform: navigator.platform,
  112. language: navigator.language,
  113. languages: navigator.languages?.join(', ') || 'N/A',
  114. cookieEnabled: navigator.cookieEnabled,
  115. onLine: navigator.onLine,
  116. screenWidth: screen.width,
  117. screenHeight: screen.height,
  118. screenColorDepth: screen.colorDepth,
  119. screenPixelDepth: screen.pixelDepth,
  120. viewportWidth: window.innerWidth,
  121. viewportHeight: window.innerHeight,
  122. devicePixelRatio: window.devicePixelRatio || 'N/A',
  123. timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
  124. timezoneOffset: new Date().getTimezoneOffset(),
  125. localStorageEnabled: (() => {
  126. try {
  127. localStorage.setItem('test', 'test')
  128. localStorage.removeItem('test')
  129. return true
  130. } catch {
  131. return false
  132. }
  133. })(),
  134. sessionStorageEnabled: (() => {
  135. try {
  136. sessionStorage.setItem('test', 'test')
  137. sessionStorage.removeItem('test')
  138. return true
  139. } catch {
  140. return false
  141. }
  142. })(),
  143. hardwareConcurrency: navigator.hardwareConcurrency || 'N/A',
  144. maxTouchPoints: navigator.maxTouchPoints || 'N/A',
  145. userAgentData: userAgentData
  146. }
  147. const olivetinVersion = window.initResponse?.currentVersion || t('diagnostics.unknown')
  148. const currentLanguage = locale.value || t('diagnostics.unknown')
  149. let output = '';
  150. output += `\`\`\`\n`
  151. output += '### BROWSER INFO START (copy all text to BROWSER INFO END)\n'
  152. output += `# OliveTin Information\n`
  153. output += `olivetinVersion: ${olivetinVersion}\n`
  154. output += `currentLanguage: ${currentLanguage}\n`
  155. output += `\n# Browser Information\n`
  156. output += `userAgent: ${info.userAgent}\n`
  157. output += `platform: ${info.platform}\n`
  158. output += `language: ${info.language}\n`
  159. output += `languages: ${info.languages}\n`
  160. output += `\n# User Agent Data\n`
  161. output += `userAgentData:\n${info.userAgentData}\n`
  162. output += `\n# Display Information\n`
  163. output += `screenWidth: ${info.screenWidth}\n`
  164. output += `screenHeight: ${info.screenHeight}\n`
  165. output += `screenColorDepth: ${info.screenColorDepth}\n`
  166. output += `screenPixelDepth: ${info.screenPixelDepth}\n`
  167. output += `viewportWidth: ${info.viewportWidth}\n`
  168. output += `viewportHeight: ${info.viewportHeight}\n`
  169. output += `devicePixelRatio: ${info.devicePixelRatio}\n`
  170. output += `\n# Feature Support\n`
  171. output += `cookieEnabled: ${info.cookieEnabled}\n`
  172. output += `localStorageEnabled: ${info.localStorageEnabled}\n`
  173. output += `sessionStorageEnabled: ${info.sessionStorageEnabled}\n`
  174. output += `onLine: ${info.onLine}\n`
  175. output += `hardwareConcurrency: ${info.hardwareConcurrency}\n`
  176. output += `maxTouchPoints: ${info.maxTouchPoints}\n`
  177. output += `\n# Location & Time\n`
  178. output += `timezone: ${info.timezone}\n`
  179. output += `timezoneOffset: ${info.timezoneOffset}\n`
  180. output += `\n### BROWSER INFO END (copy all text from BROWSER INFO START)`
  181. output += `\n\`\`\`\n`
  182. browserInfo.value = output
  183. } finally {
  184. loading.value = false
  185. }
  186. }
  187. async function copyBrowserInfo() {
  188. try {
  189. await navigator.clipboard.writeText(browserInfo.value)
  190. browserInfoCopied.value = true
  191. setTimeout(() => {
  192. browserInfoCopied.value = false
  193. }, 2000)
  194. } catch (err) {
  195. console.error('Failed to copy browser info to clipboard:', err)
  196. }
  197. }
  198. onMounted(() => {
  199. fetchDiagnostics()
  200. })
  201. </script>
  202. <style scoped>
  203. .diagnostics-view {
  204. padding: 1rem;
  205. }
  206. .diagnostics-content {
  207. max-width: 800px;
  208. margin: 0 auto;
  209. }
  210. .note {
  211. background: #f8f9fa;
  212. border-left: 4px solid #007bff;
  213. padding: 1rem;
  214. margin-bottom: 1rem;
  215. border-radius: 0 4px 4px 0;
  216. font-size: 0.875rem;
  217. color: #495057;
  218. }
  219. .note a {
  220. color: #007bff;
  221. text-decoration: none;
  222. }
  223. .note a:hover {
  224. text-decoration: underline;
  225. }
  226. .diagnostics-table {
  227. width: 100%;
  228. border-collapse: collapse;
  229. }
  230. .diagnostics-table td {
  231. padding: 0.75rem 1rem;
  232. border-bottom: 1px solid #f1f3f4;
  233. }
  234. .diagnostics-table td:first-child {
  235. font-weight: 500;
  236. color: #495057;
  237. background: #f8f9fa;
  238. }
  239. .diagnostics-table tr:last-child td {
  240. border-bottom: none;
  241. }
  242. .error-list {
  243. padding: 1rem;
  244. }
  245. .error-item {
  246. background: #f8d7da;
  247. color: #721c24;
  248. padding: 0.75rem;
  249. margin-bottom: 0.5rem;
  250. border-radius: 4px;
  251. border-left: 4px solid #dc3545;
  252. font-family: monospace;
  253. font-size: 0.875rem;
  254. }
  255. .error-item:last-child {
  256. margin-bottom: 0;
  257. }
  258. .flex-col {
  259. display: flex;
  260. flex-direction: column;
  261. }
  262. .section-content {
  263. display: flex;
  264. flex-direction: column;
  265. gap: 1em;
  266. }
  267. </style>