|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useITStorage, useQueryParam } from '@/composable/queryParams'; |
| 3 | +
|
| 4 | +const command = useQueryParam({ tool: 'explainshell', name: 'command', defaultValue: '' }); |
| 5 | +const explainshellUrl = useITStorage('explainchain:url', 'https://explainshell.com'); |
| 6 | +
|
| 7 | +const iframeUrl = ref(''); |
| 8 | +function openExplain() { |
| 9 | + const encoded = encodeURIComponent(command.value.trim()); |
| 10 | + iframeUrl.value = `${explainshellUrl.value}/explain?cmd=${encoded}`; |
| 11 | +} |
| 12 | +</script> |
| 13 | + |
| 14 | +<template> |
| 15 | + <div> |
| 16 | + <details mb-1> |
| 17 | + <summary>Explain Shell Configuration</summary> |
| 18 | + <n-card> |
| 19 | + <c-input-text |
| 20 | + v-model:value="explainshellUrl" |
| 21 | + label="Custom Explain Shell Url:" |
| 22 | + label-position="left" |
| 23 | + placeholder="Put your custom explainshell url here..." |
| 24 | + mb-1 |
| 25 | + /> |
| 26 | + <n-p> |
| 27 | + You can self host Explain Shell, to get total privacy. See: |
| 28 | + <c-link href="https://github.com/idank/explainshell?tab=readme-ov-file#running-explainshell-locally" target="_blank"> |
| 29 | + Local Explain Shell docker install |
| 30 | + </c-link> |
| 31 | + </n-p> |
| 32 | + </n-card> |
| 33 | + </details> |
| 34 | + <n-form-item label="Shell command:" label-placement="left"> |
| 35 | + <n-input |
| 36 | + v-model:value="command" |
| 37 | + placeholder="Shell command to explain" |
| 38 | + clearable |
| 39 | + mr-1 |
| 40 | + /> |
| 41 | + </n-form-item> |
| 42 | + |
| 43 | + <n-space justify="center"> |
| 44 | + <n-button |
| 45 | + type="primary" |
| 46 | + :disabled="!command" |
| 47 | + @click="openExplain" |
| 48 | + > |
| 49 | + Explain |
| 50 | + </n-button> |
| 51 | + </n-space> |
| 52 | + |
| 53 | + <n-divider /> |
| 54 | + |
| 55 | + <div style="height: 70vh; border: 1px solid #ddd; border-radius: 6px; overflow: hidden;"> |
| 56 | + <iframe |
| 57 | + v-if="iframeUrl" |
| 58 | + :src="iframeUrl" |
| 59 | + style="width: 100%; height: 100%; border: none;" |
| 60 | + /> |
| 61 | + <div v-else style="padding: 1rem; text-align: center; color: #888;"> |
| 62 | + Enter a shell command to explain |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | +</template> |
0 commit comments