Preferences.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { message } from "@/utils/message";
  4. import { deviceDetection } from "@pureadmin/utils";
  5. defineOptions({
  6. name: "Preferences"
  7. });
  8. const list = ref([
  9. {
  10. title: "账户密码",
  11. illustrate: "其他用户的消息将以站内信的形式通知",
  12. checked: true
  13. },
  14. {
  15. title: "系统消息",
  16. illustrate: "系统消息将以站内信的形式通知",
  17. checked: true
  18. },
  19. {
  20. title: "待办任务",
  21. illustrate: "待办任务将以站内信的形式通知",
  22. checked: true
  23. }
  24. ]);
  25. function onChange(val, item) {
  26. console.log("onChange", val);
  27. message(`${item.title}设置成功`, { type: "success" });
  28. }
  29. </script>
  30. <template>
  31. <div
  32. :class="[
  33. 'min-w-[180px]',
  34. deviceDetection() ? 'max-w-[100%]' : 'max-w-[70%]'
  35. ]"
  36. >
  37. <h3 class="my-8!">偏好设置</h3>
  38. <div v-for="(item, index) in list" :key="index">
  39. <div class="flex items-center">
  40. <div class="flex-1">
  41. <p>{{ item.title }}</p>
  42. <p class="wp-4">
  43. <el-text class="mx-1" type="info">
  44. {{ item.illustrate }}
  45. </el-text>
  46. </p>
  47. </div>
  48. <el-switch
  49. v-model="item.checked"
  50. inline-prompt
  51. active-text="是"
  52. inactive-text="否"
  53. @change="val => onChange(val, item)"
  54. />
  55. </div>
  56. <el-divider />
  57. </div>
  58. </div>
  59. </template>
  60. <style lang="scss" scoped>
  61. .el-divider--horizontal {
  62. border-top: 0.1px var(--el-border-color) var(--el-border-style);
  63. }
  64. </style>