cread.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. <template>
  2. <div class="CalligraphyMaster-cread">
  3. <Header />
  4. <div class="bg_main">
  5. <div class="main">
  6. <div class="main-top">
  7. <div class="left">
  8. <span>画布设置:</span>
  9. <div>
  10. <span>长度</span>
  11. <el-input
  12. :readonly="true"
  13. v-model="form.heightText"
  14. style="width: 60px"
  15. ></el-input>
  16. <div class="add_remove">
  17. <img
  18. @click="addCanvasWH('H')"
  19. src="../../assets/teacherdev/sfds-canvas-add.png"
  20. alt=""
  21. />
  22. <img
  23. @click="removeCanvasWH('H')"
  24. src="../../assets/teacherdev/sfds-canvas-remove.png"
  25. alt=""
  26. />
  27. </div>
  28. </div>
  29. <div>
  30. <img src="../../assets/teacherdev/sfds-canvas-line.png" alt="" />
  31. <span>宽度</span>
  32. <el-input
  33. :readonly="true"
  34. v-model="form.widthText"
  35. style="width: 60px"
  36. ></el-input>
  37. <div class="add_remove">
  38. <img
  39. @click="addCanvasWH('W')"
  40. src="../../assets/teacherdev/sfds-canvas-add.png"
  41. alt=""
  42. />
  43. <img
  44. @click="removeCanvasWH('W')"
  45. src="../../assets/teacherdev/sfds-canvas-remove.png"
  46. alt=""
  47. />
  48. </div>
  49. </div>
  50. <div>
  51. <span>背景颜色</span>
  52. <el-color-picker v-model="form.bg_color"></el-color-picker>
  53. </div>
  54. </div>
  55. <div class="right">
  56. <div>
  57. <img src="../../assets/teacherdev/word-save.png" alt="" />
  58. 保存
  59. </div>
  60. <div>
  61. <img src="../../assets/teacherdev/sfds-fb.png" alt="" />
  62. 发布
  63. </div>
  64. <div>
  65. <img src="../../assets/teacherdev/word-download.png" alt="" />
  66. 下载
  67. </div>
  68. </div>
  69. </div>
  70. <div
  71. class="operation"
  72. v-if="changeType == 'text' || changeType == 'luminance'"
  73. >
  74. <template v-if="changeType == 'text'">
  75. <div class="text-operation">
  76. <div class="font_sele">
  77. <div
  78. class="font_sele_input"
  79. @click="FontFamilySele = !FontFamilySele"
  80. >
  81. <span>{{ fontForm.fontFamily }}</span>
  82. <img
  83. src="../../assets/teacherdev/font-sele-down.png"
  84. alt=""
  85. />
  86. </div>
  87. <div v-show="FontFamilySele" class="fontFamily_list">
  88. <div class="Boutque_font">
  89. <span class="one">精品字体</span>
  90. <span
  91. v-for="(item, index) in BoutiqueFontList"
  92. :key="index + 'BoutiqueFon'"
  93. >{{ item }}</span
  94. >
  95. <span class="more">更多...</span>
  96. </div>
  97. <div
  98. class="fontFamily_one"
  99. v-for="(item, index) in fontList"
  100. :key="index + 'font'"
  101. :value="item.fontFamily"
  102. >
  103. <div class="use" v-if="item.RecentUse">
  104. <span>最近使用</span>
  105. </div>
  106. <div class="fontFamily">{{ item.fontFamily }}</div>
  107. <div class="content">
  108. <span>{{ item.content }}</span>
  109. <img
  110. v-if="item.collect"
  111. src="../../assets/teacherdev/font-collect-sele.png"
  112. alt=""
  113. />
  114. <img
  115. v-else
  116. src="../../assets/teacherdev/font-collect.png"
  117. alt=""
  118. />
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <el-select
  124. v-model="fontForm.fontSize"
  125. style="width: 60px; margin-left: 8px"
  126. >
  127. <el-option
  128. v-for="(item, i) in fontSizeList"
  129. :key="i + 'fontsize'"
  130. :value="item.value"
  131. :label="item.name"
  132. >
  133. </el-option>
  134. </el-select>
  135. <el-select
  136. v-model="fontForm.percent"
  137. style="width: 68px; height: 32px; margin-left: 8px"
  138. >
  139. <el-option
  140. v-for="i in 100"
  141. :key="i + 'fontsize'"
  142. :value="i"
  143. :label="i + '%'"
  144. >
  145. </el-option>
  146. </el-select>
  147. <div class="img_dv">
  148. <img src="../../assets/teacherdev/font-add.png" alt="" />
  149. <img src="../../assets/teacherdev/font-remove.png" alt="" />
  150. <img src="../../assets/teacherdev/font-blod.png" alt="" />
  151. <img src="../../assets/teacherdev/font-red.png" alt="" />
  152. </div>
  153. <el-color-picker
  154. v-model="fontForm.fontColor"
  155. style="margin-left: 8px; width: 60px"
  156. ></el-color-picker>
  157. <div class="img_dv" style="margin-left: 8px">
  158. <img src="../../assets/teacherdev/font-left.png" alt="" />
  159. <img src="../../assets/teacherdev/font-center.png" alt="" />
  160. <img src="../../assets/teacherdev/font-right.png" alt="" />
  161. </div>
  162. <div class="img_dv" style="margin-left: 8px">
  163. <img
  164. src="../../assets/teacherdev/font-line-left-right.png"
  165. alt=""
  166. />
  167. <img
  168. src="../../assets/teacherdev/font-line-top-bottom.png"
  169. alt=""
  170. />
  171. </div>
  172. <div class="img_dv" style="margin-left: 8px">
  173. <img src="../../assets/teacherdev/font-italic.png" alt="" />
  174. <img src="../../assets/teacherdev/font-blod2.png" alt="" />
  175. </div>
  176. </div>
  177. </template>
  178. <template v-else-if="changeType == 'luminance'">
  179. <div class="luminance-operation">
  180. <img
  181. :style="{ filter: `brightness(${changeluminanceNumber()})` }"
  182. src="../../assets/teacherdev/sun.png"
  183. alt=""
  184. />
  185. <div class="line-text">
  186. <div class="DragLine">
  187. <DragLine :min="-100" :max="100" v-model="luminanceNumber" />
  188. </div>
  189. <div class="text">
  190. <span>-100</span>
  191. <span>0</span>
  192. <span>+100</span>
  193. </div>
  194. </div>
  195. </div>
  196. </template>
  197. </div>
  198. <div
  199. class="canvas"
  200. :style="{
  201. marginTop:
  202. changeType == 'text' || changeType == 'luminance' ? 0 : '32px',
  203. }"
  204. >
  205. <div
  206. id="imgCanvas"
  207. ref="imgCanvas"
  208. :style="{
  209. width: form.width + 'px',
  210. height: form.height + 'px',
  211. background: form.bg_color,
  212. }"
  213. ></div>
  214. </div>
  215. <div class="bottom">
  216. <div @click="changeSize">
  217. <img src="../../assets/teacherdev/sfds-tailoring.png" alt="" />
  218. </div>
  219. <!-- <el-upload
  220. :accept="'.png,.jpg'"
  221. class="upload-demo"
  222. :show-file-list="false"
  223. :action="url"
  224. :on-preview="handlePreview"
  225. :on-remove="handleRemove"
  226. :multiple="true"
  227. :on-exceed="handleExceed"
  228. :on-success="handleSuccess"
  229. :file-list="fileList"
  230. :before-remove="beforeRemove"
  231. :limit="1"
  232. :before-upload="handlebeforeUplaod"
  233. >
  234. <div>
  235. <img src="../../assets/teacherdev/sfds-image.png" alt="" />
  236. </div>
  237. </el-upload> -->
  238. <div @click="addText">
  239. <img src="../../assets/teacherdev/sfds-text.png" alt="" />
  240. </div>
  241. <div @click="deleteImage">
  242. <img src="../../assets/teacherdev/sfds-delete.png" alt="" />
  243. </div>
  244. <div @click="changeluminance">
  245. <img src="../../assets/teacherdev/sfds-sun.png" alt="" />
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </template>
  252. <script>
  253. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  254. //例如:import 《组件名称》from ‘《组件路径》';
  255. import Header from "@/components/Header";
  256. import DragLine from "@/components/DragLine";
  257. import { getToken, removeToken } from "@/utils/auth";
  258. import { WebFileDownload } from "@/api/api";
  259. import "tui-image-editor/dist/tui-image-editor.css";
  260. import "tui-color-picker/dist/tui-color-picker.css";
  261. import ImageEditor from "tui-image-editor";
  262. const locale_zh = {
  263. ZoomIn: "放大",
  264. ZoomOut: "缩小",
  265. Hand: "手掌",
  266. History: "历史",
  267. Resize: "调整宽高",
  268. Crop: "裁剪",
  269. DeleteAll: "全部删除",
  270. Delete: "删除",
  271. Undo: "撤销",
  272. Redo: "反撤销",
  273. Reset: "重置",
  274. Flip: "镜像",
  275. Rotate: "旋转",
  276. Draw: "画",
  277. Shape: "形状标注",
  278. Icon: "图标标注",
  279. Text: "文字标注",
  280. Mask: "遮罩",
  281. Filter: "滤镜",
  282. Bold: "加粗",
  283. Italic: "斜体",
  284. Underline: "下划线",
  285. Left: "左对齐",
  286. Center: "居中",
  287. Right: "右对齐",
  288. Color: "颜色",
  289. "Text size": "字体大小",
  290. Custom: "自定义",
  291. Square: "正方形",
  292. Apply: "应用",
  293. Cancel: "取消",
  294. "Flip X": "X 轴",
  295. "Flip Y": "Y 轴",
  296. Range: "区间",
  297. Stroke: "描边",
  298. Fill: "填充",
  299. Circle: "圆",
  300. Triangle: "三角",
  301. Rectangle: "矩形",
  302. Free: "曲线",
  303. Straight: "直线",
  304. Arrow: "箭头",
  305. "Arrow-2": "箭头2",
  306. "Arrow-3": "箭头3",
  307. "Star-1": "星星1",
  308. "Star-2": "星星2",
  309. Polygon: "多边形",
  310. Location: "定位",
  311. Heart: "心形",
  312. Bubble: "气泡",
  313. "Custom icon": "自定义图标",
  314. "Load Mask Image": "加载蒙层图片",
  315. Grayscale: "灰度",
  316. Blur: "模糊",
  317. Sharpen: "锐化",
  318. Emboss: "浮雕",
  319. "Remove White": "除去白色",
  320. Distance: "距离",
  321. Brightness: "亮度",
  322. Noise: "噪音",
  323. "Color Filter": "彩色滤镜",
  324. Sepia: "棕色",
  325. Sepia2: "棕色2",
  326. Invert: "负片",
  327. Pixelate: "像素化",
  328. Threshold: "阈值",
  329. Tint: "色调",
  330. Multiply: "正片叠底",
  331. Blend: "混合色",
  332. Width: "宽度",
  333. Height: "高度",
  334. "Lock Aspect Ratio": "锁定宽高比例",
  335. };
  336. const customTheme = {
  337. "common.bi.image": "", // 左上角logo图片
  338. "common.bisize.width": "0px",
  339. "common.bisize.height": "0px",
  340. "common.backgroundImage": "none",
  341. "common.backgroundColor": "#f3f4f6",
  342. "common.border": "1px solid #333",
  343. // header
  344. "header.backgroundImage": "none",
  345. "header.backgroundColor": "#f3f4f6",
  346. "header.border": "0px",
  347. // load button
  348. "loadButton.backgroundColor": "#fff",
  349. "loadButton.border": "1px solid #ddd",
  350. "loadButton.color": "#222",
  351. "loadButton.fontFamily": "NotoSans, sans-serif",
  352. "loadButton.fontSize": "12px",
  353. "loadButton.display": "none", // 隐藏
  354. // download button
  355. "downloadButton.backgroundColor": "#fdba3b",
  356. "downloadButton.border": "1px solid #fdba3b",
  357. "downloadButton.color": "#fff",
  358. "downloadButton.fontFamily": "NotoSans, sans-serif",
  359. "downloadButton.fontSize": "12px",
  360. "downloadButton.display": "none", // 隐藏
  361. // icons default
  362. "menu.normalIcon.color": "#8a8a8a",
  363. "menu.activeIcon.color": "#555555",
  364. "menu.disabledIcon.color": "#ccc",
  365. "menu.hoverIcon.color": "#e9e9e9",
  366. "submenu.normalIcon.color": "#8a8a8a",
  367. "submenu.activeIcon.color": "#e9e9e9",
  368. "menu.iconSize.width": "24px",
  369. "menu.iconSize.height": "24px",
  370. "submenu.iconSize.width": "32px",
  371. "submenu.iconSize.height": "32px",
  372. // submenu primary color
  373. "submenu.backgroundColor": "#1e1e1e",
  374. "submenu.partition.color": "#858585",
  375. // submenu labels
  376. "submenu.normalLabel.color": "#858585",
  377. "submenu.normalLabel.fontWeight": "lighter",
  378. "submenu.activeLabel.color": "#fff",
  379. "submenu.activeLabel.fontWeight": "lighter",
  380. // checkbox style
  381. "checkbox.border": "1px solid #ccc",
  382. "checkbox.backgroundColor": "#fff",
  383. // rango style
  384. "range.pointer.color": "#fff",
  385. "range.bar.color": "#666",
  386. "range.subbar.color": "#d1d1d1",
  387. "range.disabledPointer.color": "#414141",
  388. "range.disabledBar.color": "#282828",
  389. "range.disabledSubbar.color": "#414141",
  390. "range.value.color": "#fff",
  391. "range.value.fontWeight": "lighter",
  392. "range.value.fontSize": "11px",
  393. "range.value.border": "1px solid #353535",
  394. "range.value.backgroundColor": "#151515",
  395. "range.title.color": "#fff",
  396. "range.title.fontWeight": "lighter",
  397. // colorpicker style
  398. "colorpicker.button.border": "1px solid #1e1e1e",
  399. "colorpicker.title.color": "#fff",
  400. };
  401. export default {
  402. //import引入的组件需要注入到对象中才能使用
  403. components: {
  404. Header,
  405. DragLine,
  406. },
  407. props: {},
  408. data() {
  409. //这里存放数据
  410. return {
  411. form: {
  412. width: 500,
  413. widthText: "500mm",
  414. height: 500,
  415. heightText: "500mm",
  416. bg_color: "#FF3F3F",
  417. },
  418. BoutiqueFontList: [
  419. "水墨字体",
  420. "古风字体",
  421. "中国风字体",
  422. "书协专家字体",
  423. "电影海报字体",
  424. "国潮字体",
  425. ],
  426. fontSizeList: [
  427. {
  428. name: "5号",
  429. value: 5,
  430. },
  431. ],
  432. fontList: [
  433. {
  434. fontFamily: "方正颜真卿楷书",
  435. content: "忽如一夜春风来",
  436. collect: true,
  437. RecentUse: true,
  438. },
  439. {
  440. fontFamily: "方正颜真卿楷书",
  441. content: "忽如一夜春风来",
  442. collect: false,
  443. RecentUse: false,
  444. },
  445. {
  446. fontFamily: "方正颜真卿楷书",
  447. content: "忽如一夜春风来",
  448. collect: true,
  449. RecentUse: true,
  450. },
  451. {
  452. fontFamily: "方正颜真卿楷书",
  453. content: "忽如一夜春风来",
  454. collect: false,
  455. RecentUse: false,
  456. },
  457. {
  458. fontFamily: "方正颜真卿楷书",
  459. content: "忽如一夜春风来",
  460. collect: true,
  461. RecentUse: true,
  462. },
  463. {
  464. fontFamily: "方正颜真卿楷书",
  465. content: "忽如一夜春风来",
  466. collect: false,
  467. RecentUse: false,
  468. },
  469. {
  470. fontFamily: "方正颜真卿楷书",
  471. content: "忽如一夜春风来",
  472. collect: true,
  473. RecentUse: true,
  474. },
  475. {
  476. fontFamily: "方正颜真卿楷书",
  477. content: "忽如一夜春风来",
  478. collect: false,
  479. RecentUse: false,
  480. },
  481. {
  482. fontFamily: "方正颜真卿楷书",
  483. content: "忽如一夜春风来",
  484. collect: true,
  485. RecentUse: true,
  486. },
  487. {
  488. fontFamily: "方正颜真卿楷书",
  489. content: "忽如一夜春风来",
  490. collect: false,
  491. RecentUse: false,
  492. },
  493. ],
  494. luminanceNumber: 0,
  495. changeType: "",
  496. fontForm: {
  497. fontFamily: "方正颜真卿楷书",
  498. fontSize: 5,
  499. percent: 100,
  500. fontColor: "#FFFFFF",
  501. },
  502. FontFamilySele: false,
  503. loading: false,
  504. fileList: [],
  505. imgCtx: null,
  506. TUI_selectedItem: null,
  507. TUI_selectedFont: "",
  508. instance: null,
  509. };
  510. },
  511. //计算属性 类似于data概念
  512. computed: {
  513. url() {
  514. let userInfor = JSON.parse(getToken());
  515. let UserCode = "",
  516. UserType = "",
  517. SessionID = "";
  518. if (userInfor) {
  519. UserCode = userInfor.user_code;
  520. UserType = userInfor.user_type;
  521. SessionID = userInfor.session_id;
  522. }
  523. return (
  524. process.env.VUE_APP_BASE_API +
  525. `/GCLSFileServer/WebFileUpload?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}&SecurityLevel=Mid"`
  526. );
  527. },
  528. },
  529. //监控data中数据变化
  530. watch: {},
  531. //方法集合
  532. methods: {
  533. // 增加画布宽或高
  534. addCanvasWH(type) {
  535. if (type == "W") {
  536. if (this.form.width == 500) {
  537. this.$message.warning("已达到上限");
  538. return;
  539. }
  540. this.form.width++;
  541. this.form.widthText = this.form.width + "mm";
  542. } else {
  543. if (this.form.height == 500) {
  544. this.$message.warning("已达到上限");
  545. return;
  546. }
  547. this.form.height++;
  548. this.form.heightText = this.form.height + "mm";
  549. }
  550. },
  551. // 减少画布宽或高
  552. removeCanvasWH(type) {
  553. if (type == "W") {
  554. if (this.form.width == 0) {
  555. return;
  556. }
  557. this.form.width--;
  558. this.form.widthText = this.form.width + "mm";
  559. } else {
  560. if (this.form.height == 0) {
  561. return;
  562. }
  563. this.form.height--;
  564. this.form.heightText = this.form.height + "mm";
  565. }
  566. },
  567. // 添加文字
  568. addText() {
  569. this.changeType = "text";
  570. },
  571. // 修改亮度
  572. changeluminance() {
  573. this.changeType = "luminance";
  574. },
  575. // 计算css所需亮度
  576. changeluminanceNumber() {
  577. if (this.luminanceNumber == 0) {
  578. return 1;
  579. }
  580. if (this.luminanceNumber > 0) {
  581. return 1 + (this.luminanceNumber / 100) * 2;
  582. } else {
  583. return Math.abs(Math.abs(this.luminanceNumber) - 100) / 100;
  584. }
  585. },
  586. // 裁剪
  587. changeSize() {
  588. this.instance.ui._actions.crop.cancel();
  589. },
  590. initCanvasImage() {
  591. this.loading = this.$loading({
  592. lock: true,
  593. text: "Loading",
  594. spinner: "el-icon-loading",
  595. background: "rgba(0, 0, 0, 0.7)",
  596. });
  597. // const objectUrl = window.URL.createObjectURL("");
  598. this.instance = new ImageEditor(document.querySelector("#imgCanvas"), {
  599. includeUI: {
  600. loadImage: {
  601. path: "https://img2.baidu.com/it/u=1395980100,2999837177&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=675",
  602. name: "image",
  603. },
  604. menu: [
  605. "resize",
  606. "crop",
  607. "rotate",
  608. "draw",
  609. "shape",
  610. "icon",
  611. "text",
  612. "filter",
  613. ], // 底部菜单按钮列表 隐藏镜像flip和遮罩mask
  614. initMenu: "crop", // 默认打开的菜单项
  615. menuBarPosition: "bottom", // 菜单所在的位置
  616. locale: locale_zh, // 本地化语言为中文
  617. theme: customTheme, // 自定义样式
  618. },
  619. cssMaxWidth: this.form.width, // canvas 最大宽度
  620. cssMaxHeight: this.form.heigt, // canvas 最大高度
  621. });
  622. let fontArray = [
  623. "Arial",
  624. "Arial Black",
  625. "Caveat",
  626. "Comic Sans MS",
  627. "Courier New",
  628. "Georgia1",
  629. "Impact",
  630. "Lobster Two",
  631. "Lucida Console",
  632. "Luckiest Guy",
  633. "Open Sans",
  634. "Pacifico",
  635. "Palatino Linotype",
  636. "Press Start 2P",
  637. "Roboto",
  638. "Tahoma",
  639. "Tangerine",
  640. "Times New Roman",
  641. "Tourney",
  642. "Ultra",
  643. "Verdana",
  644. "Symbol",
  645. "Webdings",
  646. "Wingdings",
  647. ];
  648. let fontSelectHTML =
  649. '<select #fontselect class="form-select font-selector">';
  650. for (let i = 0; i < fontArray.length; i++) {
  651. let selected = "";
  652. if (i == 0) {
  653. selected = "selected";
  654. }
  655. fontSelectHTML +=
  656. '<option style="font-family:' +
  657. fontArray[i] +
  658. ' !important;" value="' +
  659. fontArray[i] +
  660. '" ' +
  661. selected +
  662. ">" +
  663. fontArray[i] +
  664. "</option>";
  665. }
  666. fontSelectHTML += "</select>";
  667. let textMenuAlign = document.querySelector(
  668. ".tui-image-editor-menu-text .tie-text-align-button"
  669. );
  670. textMenuAlign.insertAdjacentHTML("afterbegin", fontSelectHTML);
  671. document
  672. .querySelector(".font-selector")
  673. .addEventListener("change", () =>
  674. this.TUI_updateFontOnText($(".font-selector option:selected").val())
  675. );
  676. this.instance.on("objectActivated", (props) => {
  677. this.TUI_selectedItem = props;
  678. this.TUI_updateFontSelected(props);
  679. console.log("TUI_selectedItem", props);
  680. });
  681. this.loading.close();
  682. },
  683. TUI_updateFontOnText(font) {
  684. console.log("TUI_updateFontOnText", font, this.TUI_selectedItem.id);
  685. if (font) {
  686. this.TUI_selectedFont = font;
  687. }
  688. if (font && this.TUI_selectedItem) {
  689. this.instance.changeTextStyle(this.TUI_selectedItem.id, {
  690. fontFamily: font,
  691. });
  692. }
  693. },
  694. TUI_updateFontSelected(layer) {
  695. console.log("TUI_updateFontSelected", layer);
  696. if (layer.fontFamily) {
  697. document.querySelector(".font-selector").value = layer.fontFamily;
  698. this.TUI_selectedFont = layer.fontFamily;
  699. }
  700. },
  701. // 删除上传的图片
  702. deleteImage() {
  703. this.fileList = [];
  704. },
  705. handlebeforeUplaod(file) {
  706. if (file.size > 20 * 1024 * 1024) {
  707. this.$message.warning("上传文件大小不能超过20M");
  708. return false; //必须返回false
  709. }
  710. this.loading = this.$loading({
  711. lock: true,
  712. text: "Loading",
  713. spinner: "el-icon-loading",
  714. background: "rgba(0, 0, 0, 0.7)",
  715. });
  716. },
  717. handleSuccess(response, file, fileList) {
  718. if (response.status == 1) {
  719. this.fileList = response.file_info_list;
  720. this.loading.close();
  721. this.initCanvasImage();
  722. } else if (response.status == -1) {
  723. this.loading.close();
  724. removeToken();
  725. this.$message.warning(response.error);
  726. this.$router.push("/login");
  727. } else {
  728. this.loading.close();
  729. }
  730. },
  731. handleRemove(file, fileList) {},
  732. handlePreview(file) {},
  733. handleExceed(files, fileList) {
  734. this.$message.warning(
  735. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  736. files.length + fileList.length
  737. } 个文件`
  738. );
  739. },
  740. beforeRemove(file, filleList) {},
  741. },
  742. //生命周期 - 创建完成(可以访问当前this实例)
  743. created() {},
  744. //生命周期 - 挂载完成(可以访问DOM元素)
  745. mounted() {
  746. this.initCanvasImage();
  747. },
  748. //生命周期-创建之前
  749. beforeCreated() {},
  750. //生命周期-挂载之前
  751. beforeMount() {},
  752. //生命周期-更新之前
  753. beforUpdate() {},
  754. //生命周期-更新之后
  755. updated() {},
  756. //生命周期-销毁之前
  757. beforeDestory() {},
  758. //生命周期-销毁完成
  759. destoryed() {},
  760. //如果页面有keep-alive缓存功能,这个函数会触发
  761. activated() {},
  762. };
  763. </script>
  764. <style lang="scss" scoped>
  765. /* @import url(); 引入css类 */
  766. .CalligraphyMaster-cread {
  767. height: 100%;
  768. position: relative;
  769. .bg_main {
  770. background: #f7f7f7;
  771. min-height: 100%;
  772. padding-top: 24px;
  773. padding-bottom: 70px;
  774. .main {
  775. width: 1168px;
  776. margin: 0 auto;
  777. padding: 16px;
  778. background: #ffffff;
  779. .main-top {
  780. display: flex;
  781. justify-content: space-between;
  782. .left {
  783. display: flex;
  784. align-items: center;
  785. font-weight: 400;
  786. font-size: 14px;
  787. color: #000000;
  788. > div {
  789. display: flex;
  790. align-items: center;
  791. margin-right: 8px;
  792. > img {
  793. width: 16px;
  794. height: 16px;
  795. margin-right: 8px;
  796. }
  797. .add_remove {
  798. display: flex;
  799. flex-wrap: wrap;
  800. align-items: center;
  801. width: 10px;
  802. margin-left: 8px;
  803. img {
  804. width: 10px;
  805. height: 10px;
  806. cursor: pointer;
  807. }
  808. > :nth-child(1) {
  809. margin-bottom: 1px;
  810. }
  811. }
  812. }
  813. span {
  814. margin-right: 8px;
  815. }
  816. }
  817. .right {
  818. display: flex;
  819. div {
  820. margin-left: 16px;
  821. width: 96px;
  822. height: 40px;
  823. background: #ffffff;
  824. border: 1px solid rgba(0, 0, 0, 0.08);
  825. border-radius: 4px;
  826. display: flex;
  827. align-items: center;
  828. justify-content: center;
  829. cursor: pointer;
  830. img {
  831. width: 24px;
  832. height: 24px;
  833. margin-right: 8px;
  834. }
  835. }
  836. }
  837. }
  838. .operation {
  839. margin-top: 33px;
  840. }
  841. .text-operation {
  842. height: 48px;
  843. border: 1px solid rgba(0, 0, 0, 0.08);
  844. border-radius: 8px 8px 0px 0px;
  845. border-bottom: none;
  846. display: flex;
  847. align-items: center;
  848. padding: 0 16px;
  849. .font_sele {
  850. position: relative;
  851. .font_sele_input {
  852. width: 193px;
  853. height: 32px;
  854. padding: 0 6px;
  855. background: #ffffff;
  856. border: 1px solid rgba(0, 0, 0, 0.08);
  857. border-radius: 4px;
  858. display: flex;
  859. align-items: center;
  860. justify-content: space-between;
  861. cursor: pointer;
  862. > span {
  863. font-weight: 400;
  864. font-size: 14px;
  865. line-height: 20px;
  866. color: #000000;
  867. }
  868. > img {
  869. width: 16px;
  870. height: 16px;
  871. }
  872. }
  873. .fontFamily_list {
  874. position: absolute;
  875. top: 39px;
  876. left: 0;
  877. width: 468px;
  878. background: #ffffff;
  879. border-width: 0px 1px 1px 1px;
  880. border-style: solid;
  881. border-color: #dbdbdb;
  882. height: 520px;
  883. overflow: auto;
  884. .fontFamily_one {
  885. padding: 12px 24px 16px 32px;
  886. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  887. position: relative;
  888. .use {
  889. width: 80px;
  890. height: 80px;
  891. background: url("../../assets/teacherdev/font-use.png");
  892. background-size: cover;
  893. position: absolute;
  894. left: -20px;
  895. top: -20px;
  896. -webkit-transform: scale(0.5);
  897. span {
  898. color: #ffffff;
  899. font-weight: 400;
  900. font-size: 16px;
  901. position: absolute;
  902. transform: translateX(-3px) translateY(20px) rotate(-45deg);
  903. }
  904. }
  905. .fontFamily {
  906. font-weight: 400;
  907. font-size: 14px;
  908. line-height: 20px;
  909. color: rgba(0, 0, 0, 0.5);
  910. }
  911. .content {
  912. margin-top: 8px;
  913. display: flex;
  914. justify-content: space-between;
  915. span {
  916. font-weight: 400;
  917. font-size: 32px;
  918. line-height: 150%;
  919. color: #000000;
  920. }
  921. img {
  922. width: 24px;
  923. height: 24px;
  924. cursor: pointer;
  925. }
  926. }
  927. }
  928. }
  929. }
  930. .Boutque_font {
  931. padding: 16px 12px 0 12px;
  932. background: #f0f0f0;
  933. font-weight: 400;
  934. font-size: 14px;
  935. line-height: 20px;
  936. color: rgba(0, 0, 0, 0.6);
  937. cursor: default;
  938. span {
  939. display: inline-block;
  940. margin: 0 12px 12px 12px;
  941. }
  942. .one {
  943. color: #000000;
  944. }
  945. .more {
  946. color: rgba(0, 0, 0, 0.35);
  947. cursor: pointer;
  948. }
  949. }
  950. .img_dv {
  951. img {
  952. width: 26px;
  953. height: 26px;
  954. cursor: pointer;
  955. margin-left: 8px;
  956. }
  957. }
  958. }
  959. .luminance-operation {
  960. width: 440px;
  961. margin: 0 auto;
  962. display: flex;
  963. > img {
  964. width: 24px;
  965. height: 24px;
  966. }
  967. .line-text {
  968. margin-left: 17px;
  969. .DragLine {
  970. margin-top: 7px;
  971. }
  972. .text {
  973. margin-top: 8px;
  974. display: flex;
  975. justify-content: space-between;
  976. font-weight: 400;
  977. font-size: 12px;
  978. line-height: 20px;
  979. color: #919c9e;
  980. }
  981. }
  982. }
  983. .canvas {
  984. height: 500px;
  985. border: 1px solid rgba(0, 0, 0, 0.1);
  986. display: flex;
  987. justify-content: center;
  988. align-items: center;
  989. }
  990. .bottom {
  991. margin-top: 40px;
  992. display: flex;
  993. justify-content: center;
  994. div {
  995. width: 48px;
  996. height: 40px;
  997. background: #ffffff;
  998. border: 1px solid rgba(0, 0, 0, 0.08);
  999. border-radius: 4px;
  1000. display: flex;
  1001. align-items: center;
  1002. justify-content: center;
  1003. cursor: pointer;
  1004. margin: 0 16px;
  1005. img {
  1006. width: 32px;
  1007. height: 32px;
  1008. }
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. </style>
  1015. <style lang="scss">
  1016. .CalligraphyMaster-cread {
  1017. // 图片编辑器操作栏
  1018. .tui-image-editor-controls {
  1019. display: none;
  1020. }
  1021. .tui-image-editor-container .tui-image-editor-main-container {
  1022. height: 100%;
  1023. }
  1024. .main-top {
  1025. .left {
  1026. .el-input__inner {
  1027. padding: 0 5px;
  1028. }
  1029. .el-color-picker__color {
  1030. border: none;
  1031. }
  1032. .el-icon-close:before {
  1033. content: "";
  1034. }
  1035. .el-icon-arrow-down:before {
  1036. content: "";
  1037. }
  1038. .el-color-picker__color-inner {
  1039. position: absolute;
  1040. left: 3px;
  1041. top: 3px;
  1042. right: 0;
  1043. bottom: 0;
  1044. width: 24px;
  1045. height: 24px;
  1046. }
  1047. }
  1048. }
  1049. .text-operation {
  1050. .el-color-picker__trigger {
  1051. width: 60px;
  1052. height: 32px;
  1053. }
  1054. .el-color-picker__empty,
  1055. .el-color-picker__icon {
  1056. left: 72%;
  1057. }
  1058. .el-color-picker__color {
  1059. width: 28px;
  1060. }
  1061. .el-icon-close:before,
  1062. .el-icon-arrow-down:before {
  1063. color: gray;
  1064. }
  1065. .el-color-picker__color-inner {
  1066. position: absolute;
  1067. left: -1px;
  1068. top: -1px;
  1069. right: 0;
  1070. bottom: 0;
  1071. width: 100%;
  1072. height: 100%;
  1073. border: 1px solid rgba(0, 0, 0, 0.08);
  1074. border-radius: 2px;
  1075. }
  1076. .el-input__inner {
  1077. padding: 0 8px;
  1078. }
  1079. .el-input__inner,
  1080. .el-input__suffix {
  1081. height: 32px;
  1082. }
  1083. .el-input__icon {
  1084. line-height: 32px;
  1085. }
  1086. }
  1087. }
  1088. </style>