default.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. import { useIntl } from "react-intl";
  2. export interface ISettingItemOption {
  3. label: string;
  4. key: string;
  5. }
  6. export interface ISetting {
  7. key: string;
  8. label: string;
  9. description: string;
  10. defaultValue: string | number | boolean;
  11. value?: string | number | boolean;
  12. widget?: "input" | "select" | "radio" | "radio-button";
  13. options?: ISettingItemOption[];
  14. max?: number;
  15. min?: number;
  16. }
  17. export const SettingFind = (key: string): ISetting | undefined => {
  18. return Settings().find((element) => element.key === key);
  19. };
  20. export const Settings = (): ISetting[] => {
  21. const intl = useIntl();
  22. const defaultSetting: ISetting[] = [
  23. {
  24. /**
  25. * 是否显示巴利原文
  26. */
  27. key: "setting.display.original",
  28. label: intl.formatMessage({ id: "setting.display.original.label" }),
  29. description: intl.formatMessage({
  30. id: "setting.display.original.description",
  31. }),
  32. defaultValue: true,
  33. },
  34. {
  35. /**
  36. * 排版方向
  37. */
  38. key: "setting.layout.direction",
  39. label: intl.formatMessage({ id: "setting.layout.direction.label" }),
  40. description: intl.formatMessage({
  41. id: "setting.layout.direction.description",
  42. }),
  43. defaultValue: "column",
  44. options: [
  45. {
  46. key: "column",
  47. label: intl.formatMessage({
  48. id: "setting.layout.direction.col.label",
  49. }),
  50. },
  51. {
  52. key: "row",
  53. label: intl.formatMessage({
  54. id: "setting.layout.direction.row.label",
  55. }),
  56. },
  57. ],
  58. widget: "radio-button",
  59. },
  60. {
  61. /**
  62. * 段落或者逐句对读
  63. */
  64. key: "setting.layout.paragraph",
  65. label: intl.formatMessage({ id: "setting.layout.paragraph.label" }),
  66. description: intl.formatMessage({
  67. id: "setting.layout.paragraph.description",
  68. }),
  69. defaultValue: "sentence",
  70. options: [
  71. {
  72. key: "sentence",
  73. label: intl.formatMessage({
  74. id: "setting.layout.paragraph.sentence.label",
  75. }),
  76. },
  77. {
  78. key: "paragraph",
  79. label: intl.formatMessage({
  80. id: "setting.layout.paragraph.paragraph.label",
  81. }),
  82. },
  83. ],
  84. widget: "radio-button",
  85. },
  86. {
  87. /**
  88. * 第一巴利脚本
  89. */
  90. key: "setting.pali.script1",
  91. label: intl.formatMessage({ id: "setting.pali.script1.label" }),
  92. description: intl.formatMessage({
  93. id: "setting.pali.script1.description",
  94. }),
  95. defaultValue: "rome",
  96. options: [
  97. {
  98. key: "rome",
  99. label: intl.formatMessage({
  100. id: "setting.pali.script.rome.label",
  101. }),
  102. },
  103. {
  104. key: "my",
  105. label: intl.formatMessage({
  106. id: "setting.pali.script.my.label",
  107. }),
  108. },
  109. {
  110. key: "si",
  111. label: intl.formatMessage({
  112. id: "setting.pali.script.si.label",
  113. }),
  114. },
  115. ],
  116. },
  117. {
  118. /**
  119. * 第一巴利脚本
  120. */
  121. key: "setting.pali.script2",
  122. label: intl.formatMessage({ id: "setting.pali.script2.label" }),
  123. description: intl.formatMessage({
  124. id: "setting.pali.script2.description",
  125. }),
  126. defaultValue: "none",
  127. options: [
  128. {
  129. key: "none",
  130. label: intl.formatMessage({
  131. id: "setting.pali.script.none.label",
  132. }),
  133. },
  134. {
  135. key: "rome",
  136. label: intl.formatMessage({
  137. id: "setting.pali.script.rome.label",
  138. }),
  139. },
  140. {
  141. key: "my",
  142. label: intl.formatMessage({
  143. id: "setting.pali.script.my.label",
  144. }),
  145. },
  146. {
  147. key: "si",
  148. label: intl.formatMessage({
  149. id: "setting.pali.script.si.label",
  150. }),
  151. },
  152. ],
  153. },
  154. ];
  155. return defaultSetting;
  156. };