Text.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import Empty from "@/components/Empty";
  2. import { useEditor } from "@/modules/editor";
  3. import { DesignComp } from "@/modules/editor/objects/DesignTemp/DesignComp";
  4. import { useResource } from "@/modules/resource";
  5. import { css } from "@linaria/core";
  6. import { Loadmore } from "@queenjs/ui";
  7. import { Button } from "ant-design-vue";
  8. import { defineUI } from "queenjs";
  9. import { CompList } from "./CompList";
  10. export default defineUI({
  11. setup() {
  12. const editor = useEditor();
  13. const resource = useResource();
  14. const { sysTextListCtrl } = resource.controls;
  15. sysTextListCtrl.loadPage(1);
  16. return () => {
  17. const dataSource = sysTextListCtrl.state.list;
  18. return (
  19. <div class="pt-20px">
  20. <Button
  21. block
  22. type="primary"
  23. onClick={() => editor.actions.clickCompToDesign("Text")}
  24. >
  25. 添加文本框
  26. </Button>
  27. <div class={"pt-20px"}>
  28. <div>默认</div>
  29. <div class={[ButtonStyle, "space-y-10px mt-16px"]}>
  30. <div
  31. class={"btn_item text-16px font-600"}
  32. onClick={() => {
  33. const h2 =
  34. '<h2 style="line-height:1.5;text-align:center;">请输入标题</h2>';
  35. editor.actions.clickCompToDesign(
  36. "Text",
  37. (comp: DesignComp) => {
  38. editor.actions.updateCompData(comp, "value", h2);
  39. }
  40. );
  41. }}
  42. >
  43. 添加标题
  44. </div>
  45. <div
  46. class={"btn_item font-600"}
  47. onClick={() => {
  48. const h3 =
  49. '<h3 style="line-height:1.5;text-align:center;">请输入副标题</h3>';
  50. editor.actions.clickCompToDesign(
  51. "Text",
  52. (comp: DesignComp) => {
  53. editor.actions.updateCompData(comp, "value", h3);
  54. }
  55. );
  56. }}
  57. >
  58. 添加副标题
  59. </div>
  60. <div
  61. class={"btn_item text-12px"}
  62. onClick={() => {
  63. const text =
  64. '<p style="text-align:center;line-height:1.5;">请输入正文</p>';
  65. editor.actions.clickCompToDesign(
  66. "Text",
  67. (comp: DesignComp) => {
  68. editor.actions.updateCompData(comp, "value", text);
  69. }
  70. );
  71. }}
  72. >
  73. 添加一段正文
  74. </div>
  75. </div>
  76. </div>
  77. <div class="my-20px">组合</div>
  78. <CompList dataSource={dataSource} columns={1} isSys={true} />
  79. {dataSource.length == 0 ? (
  80. <Empty />
  81. ) : (
  82. <Loadmore
  83. class="mt-20px"
  84. loading={sysTextListCtrl.state.loading}
  85. canLoad={sysTextListCtrl.state.canLoadNext}
  86. onChange={sysTextListCtrl.loadNextPage}
  87. />
  88. )}
  89. </div>
  90. );
  91. };
  92. },
  93. });
  94. const ButtonStyle = css`
  95. .btn_item {
  96. line-height: 46px;
  97. background-color: #303030;
  98. border-radius: 4px;
  99. text-align: center;
  100. cursor: pointer;
  101. user-select: none;
  102. &:hover {
  103. background-color: rgba(48, 48, 48, 0.8);
  104. }
  105. &:active {
  106. background-color: rgba(48, 48, 48, 1);
  107. }
  108. .inficon {
  109. font-size: 30px;
  110. }
  111. }
  112. `;