index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <script setup lang="ts">
  2. import { Plus } from '@element-plus/icons-vue'
  3. import { ElButton, ElDialog, ElEmpty, ElInput, ElMessage, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
  4. import { selectGlobalPrompt, updateGlobalPrompt } from '@/api/modules/model'
  5. import { toast } from 'vue-sonner'
  6. import LangSelector from '@/components/LangSelector.vue'
  7. const loading = ref(false)
  8. const input = ref<string>('')
  9. const lang = ref<string>('zh_CN')
  10. async function fetchData() {
  11. loading.value = true
  12. const {code, data} = await selectGlobalPrompt({i18nKey: lang.value})
  13. if(code === 0){
  14. input.value = data
  15. }
  16. loading.value = false
  17. }
  18. async function handleSave () {
  19. const {code, data} = await updateGlobalPrompt({i18nKey: lang.value, text: input.value})
  20. if(code === 0){
  21. toast.success('保存成功')
  22. }
  23. }
  24. onMounted(async () => {
  25. await fetchData()
  26. })
  27. </script>
  28. <template>
  29. <div class="absolute-container">
  30. <FaPageHeader title="全局提示词" />
  31. <FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto gap-4">
  32. <LangSelector v-model="lang"></LangSelector>
  33. <el-input
  34. v-model="input"
  35. style="width: 100%;"
  36. :autosize="{ minRows: 4, maxRows: 10 }"
  37. type="textarea"
  38. placeholder="Please input"
  39. class="mb-4"
  40. />
  41. <ElSpace>
  42. <ElButton type="primary" @click="handleSave">保存</ElButton>
  43. </ElSpace>
  44. </FaPageMain>
  45. </div>
  46. </template>
  47. <style scoped>
  48. .absolute-container {
  49. position: absolute;
  50. display: flex;
  51. flex-direction: column;
  52. width: 100%;
  53. height: 100%;
  54. }
  55. </style>