sensitive.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import Mint from "mint-filter";
  4. defineOptions({
  5. name: "Sensitive"
  6. });
  7. // 自定义敏感词字典
  8. const words = ["脑残", "废物", "白痴", "三八", "智障"];
  9. const modelValue = ref();
  10. const mint = new Mint(words);
  11. function onInput() {
  12. modelValue.value = mint.filter(modelValue.value).text;
  13. }
  14. </script>
  15. <template>
  16. <el-card shadow="never">
  17. <template #header>
  18. <div class="card-header">
  19. <p class="font-medium">敏感词过滤</p>
  20. <el-link
  21. class="mt-2"
  22. href="https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/able/sensitive.vue"
  23. target="_blank"
  24. >
  25. 代码位置 src/views/able/sensitive.vue
  26. </el-link>
  27. </div>
  28. </template>
  29. <div class="flex flex-wrap gap-2 my-2">
  30. <span>自定义敏感词</span>
  31. <el-tag
  32. v-for="(word, index) in words"
  33. :key="index"
  34. type="warning"
  35. class="mx-1"
  36. effect="dark"
  37. round
  38. >
  39. {{ word }}
  40. </el-tag>
  41. </div>
  42. <el-input v-model="modelValue" @input="onInput" />
  43. <p class="mt-2!">{{ modelValue }}</p>
  44. </el-card>
  45. </template>