StandAloneImg.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <svg class="stand-alone-img" viewBox="0 0 1570 1070" version="1.1" xmlns="http://www.w3.org/2000/svg"
  3. xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" :width="svgWidth" :height="svgHeight">
  4. <defs>
  5. <!-- 变桨 -->
  6. <path class="stand-alone-img-path" id="pitch" fill="#BA3237" opacity="0.6" stroke="#05BB4C" stroke-width="6"
  7. d="M27.62,60.304l160.03,48.361l3.518,29.016L3,84.044c0,0,2.227-9.026,8.605-15.174C17.522,63.166,27.62,60.304,27.62,60.304z" />
  8. <!-- 机舱 -->
  9. <path class="stand-alone-img-path" id="engine-room" fill="#BA3237" opacity="0.6" stroke="#05BB4C"
  10. stroke-width="6"
  11. d="M295.172,87.062c-3.13-13.486-14.851-16.73-14.851-16.73L-468.878-79.698l-16.143-12.344l-63.62-24.688l-11.395,5.697l-126.291-47.478c0,0-35.843,9.664-58.729,35.366c-35.833,40.244-64.713,103.269-64.713,103.269l-0.949,24.688L79.016,185.228c0,0,12.043,3.038,24.665,4.067c10.436,0.853,21.862-0.27,21.862-0.27l167.122-65.519C292.665,123.507,298.214,100.157,295.172,87.062z" />
  12. <!-- 齿轮箱 -->
  13. <path class="stand-alone-img-path" id="gear-box" fill="#BA3237" opacity="0.6" stroke="#05BB4C"
  14. stroke-width="6"
  15. d="M177.396,18.822L86.052,2.504L11.984,177.197l88.787,16.317l43.275-98.657l31.637,6.959l4.997-19.08l-27.789-6.13L177.396,18.822z" />
  16. <!-- 发电机 -->
  17. <path class="stand-alone-img-path" id="alternator" fill="#BA3237" opacity="0.6" stroke="#05BB4C"
  18. stroke-width="6"
  19. d="M14.016,175.068L118.433,198.6l30.883-99.516l18.095-54.753l12.79-13.878L39.996,2.021L22.838,55.454L14.016,175.068z" />
  20. <!-- 偏航 -->
  21. <path class="stand-alone-img-path" id="yaw" fill="#BA3237" opacity="0.6" stroke="#05BB4C" stroke-width="6"
  22. d="M210.152,130.465l-68.025-12.017c0,0-75.83,0.199-135.799-12.484c-67.41-14.257-97.892-41.659-97.892-41.659s-11.844,12.318,2.256,25.502c20.491,19.159,98.496,43.978,176.047,51.625c97.358,9.599,181.853,1.301,181.853,1.301l1.241-10.201L210.152,130.465z" />
  23. <!-- 液压 -->
  24. <path class="stand-alone-img-path" id="hydraulic-pressure" fill="#BA3237" opacity="0.6" stroke="#05BB4C"
  25. stroke-width="6"
  26. d="M82.965,111.483l7.241-72.311l-56.954-8.682L3,181.489l44.656,0.79c0.946,1.133,82.424,16.771,82.424,16.771l7.024-83.744L82.965,111.483z" />
  27. <!-- 圆圈圈 -->
  28. <g id="stand-alone-circle-bj">
  29. <circle :class="{
  30. 'stand-alone-circle1': StandAloneCircle1 && hover == 3,
  31. }" cx="0" cy="0" r="10" fill="#edbf03" />
  32. <circle :class="{
  33. 'stand-alone-circle2': StandAloneCircle2 && hover == 3,
  34. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  35. <circle :class="{
  36. 'stand-alone-circle3': StandAloneCircle3 && hover == 3,
  37. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  38. <circle :class="{
  39. 'stand-alone-circle4': StandAloneCircle4 && hover == 3,
  40. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  41. </g>
  42. <g id="stand-alone-circle-jc">
  43. <circle :class="{
  44. 'stand-alone-circle1': StandAloneCircle1 && hover == 6,
  45. }" cx="0" cy="0" r="10" fill="#edbf03" />
  46. <circle :class="{
  47. 'stand-alone-circle2': StandAloneCircle2 && hover == 6,
  48. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  49. <circle :class="{
  50. 'stand-alone-circle3': StandAloneCircle3 && hover == 6,
  51. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  52. <circle :class="{
  53. 'stand-alone-circle4': StandAloneCircle4 && hover == 6,
  54. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  55. </g>
  56. <g id="stand-alone-circle-clx">
  57. <circle :class="{
  58. 'stand-alone-circle1': StandAloneCircle1 && hover == 2,
  59. }" cx="0" cy="0" r="10" fill="#edbf03" />
  60. <circle :class="{
  61. 'stand-alone-circle2': StandAloneCircle2 && hover == 2,
  62. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  63. <circle :class="{
  64. 'stand-alone-circle3': StandAloneCircle3 && hover == 2,
  65. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  66. <circle :class="{
  67. 'stand-alone-circle4': StandAloneCircle4 && hover == 2,
  68. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  69. </g>
  70. <g id="stand-alone-circle-fdj">
  71. <circle :class="{
  72. 'stand-alone-circle1': StandAloneCircle1 && hover == 1,
  73. }" cx="0" cy="0" r="10" fill="#edbf03" />
  74. <circle :class="{
  75. 'stand-alone-circle2': StandAloneCircle2 && hover == 1,
  76. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  77. <circle :class="{
  78. 'stand-alone-circle3': StandAloneCircle3 && hover == 1,
  79. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  80. <circle :class="{
  81. 'stand-alone-circle4': StandAloneCircle4 && hover == 1,
  82. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  83. </g>
  84. <g id="stand-alone-circle-ph">
  85. <circle :class="{
  86. 'stand-alone-circle1': StandAloneCircle1 && hover == 4,
  87. }" cx="0" cy="0" r="10" fill="#edbf03" />
  88. <circle :class="{
  89. 'stand-alone-circle2': StandAloneCircle2 && hover == 4,
  90. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  91. <circle :class="{
  92. 'stand-alone-circle3': StandAloneCircle3 && hover == 4,
  93. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  94. <circle :class="{
  95. 'stand-alone-circle4': StandAloneCircle4 && hover == 4,
  96. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  97. </g>
  98. <g id="stand-alone-circle-yy">
  99. <circle :class="{
  100. 'stand-alone-circle1': StandAloneCircle1 && hover == 5,
  101. }" cx="0" cy="0" r="10" fill="#edbf03" />
  102. <circle :class="{
  103. 'stand-alone-circle2': StandAloneCircle2 && hover == 5,
  104. }" cx="0" cy="0" r="20" fill="none" stroke="#edbf03" stroke-width="2" />
  105. <circle :class="{
  106. 'stand-alone-circle3': StandAloneCircle3 && hover == 5,
  107. }" cx="0" cy="0" r="30" fill="none" stroke="#edbf03" stroke-width="1" />
  108. <circle :class="{
  109. 'stand-alone-circle4': StandAloneCircle4 && hover == 5,
  110. }" cx="0" cy="0" r="45" fill="none" stroke="#edbf03" stroke-width="1" />
  111. </g>
  112. </defs>
  113. <!-- 背景图片 -->
  114. <image x="0" y="90" height="787" width="1570" v-show='$store.state.themeName === "dark"' href="./standAloneImg-green.png" />
  115. <image x="0" y="90" height="787" width="1570" v-show='$store.state.themeName === "light"' href="./standAloneImg-white.png" />
  116. <!-- 变桨 -->
  117. <g class="stand-alone-img-g" :class="{ active: activeIndex == 3 }" @mouseover="mouseover(3)"
  118. @mouseout="mouseout" @click="click(3)">
  119. <use class="stand-alone-img-item" xlink:href="#pitch" x="214" y="110"
  120. transform="translate(110, 190) scale(0.7)" />
  121. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-bj" x="320" y="330" />
  122. <line :class="{ 'stand-alone-line': line && hover == 3 }" x1="320" y1="330" x2="620" y2="30"
  123. stroke="#edbf03" stroke-width="2" />
  124. <circle :class="{ 'stand-alone-circle': circle && hover == 3 }" cx="620" cy="30" r="5" fill="#edbf03" />
  125. <text :class="{ 'stand-alone-text': text && hover == 3 }" x="630" y="30" fill="#36348e" font-size="24">
  126. 变桨
  127. </text>
  128. </g>
  129. <!-- 机舱 -->
  130. <g class="stand-alone-img-g" :class="{ active: activeIndex == 6 }" @mouseover="mouseover(6)"
  131. @mouseout="mouseout" @click="click(6)">
  132. <use class="stand-alone-img-item" xlink:href="#engine-room" x="1270" y="395" />
  133. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-jc" x="750" y="380" />
  134. <line :class="{ 'stand-alone-line': line && hover == 6 }" x1="750" y1="380" x2="1050" y2="80"
  135. stroke="#edbf03" stroke-width="2" />
  136. <circle :class="{ 'stand-alone-circle': circle && hover == 6 }" cx="1050" cy="80" r="5" fill="#edbf03" />
  137. <text :class="{ 'stand-alone-text': text && hover == 6 }" x="1060" y="80" fill="#36348e" font-size="24">
  138. 机舱
  139. </text>
  140. </g>
  141. <!-- 齿轮箱 -->
  142. <g class="stand-alone-img-g" :class="{ active: activeIndex == 2 }" @mouseover="mouseover(2)"
  143. @mouseout="mouseout" @click="click(2)">
  144. <use class="stand-alone-img-item" xlink:href="#gear-box" x="730" y="335"
  145. transform="translate(220, 280) scale(0.7)" />
  146. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-clx" x="800" y="550" />
  147. <line :class="{ 'stand-alone-line': line && hover == 2 }" x1="800" y1="550" x2="1100" y2="250"
  148. stroke="#edbf03" stroke-width="2" />
  149. <circle :class="{ 'stand-alone-circle': circle && hover == 2 }" cx="1100" cy="250" r="5" fill="#edbf03" />
  150. <text :class="{ 'stand-alone-text': text && hover == 2 }" x="1110" y="250" fill="#36348e" font-size="24">
  151. 齿轮箱
  152. </text>
  153. </g>
  154. <!-- 发电机 -->
  155. <g class="stand-alone-img-g" :class="{ active: activeIndex == 1 }" @mouseover="mouseover(1)"
  156. @mouseout="mouseout" @click="click(1)">
  157. <use class="stand-alone-img-item" xlink:href="#alternator" x="900" y="385"
  158. transform="translate(300, 260) scale(0.7)" />
  159. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-fdj" x="990" y="580" />
  160. <line :class="{ 'stand-alone-line': line && hover == 1 }" x1="990" y1="580" x2="1290" y2="880"
  161. stroke="#edbf03" stroke-width="2" />
  162. <circle :class="{ 'stand-alone-circle': circle && hover == 1 }" cx="1290" cy="880" r="5" fill="#edbf03" />
  163. <text :class="{ 'stand-alone-text': text && hover == 1 }" x="1300" y="920" fill="#36348e" font-size="24">
  164. 发电机
  165. </text>
  166. </g>
  167. <!-- 偏航 -->
  168. <g class="stand-alone-img-g" :class="{ active: activeIndex == 4 }" @mouseover="mouseover(4)"
  169. @mouseout="mouseout" @click="click(4)">
  170. <use class="stand-alone-img-item" xlink:href="#yaw" x="675" y="645" />
  171. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-ph" x="650" y="750" />
  172. <line :class="{ 'stand-alone-line': line && hover == 4 }" x1="650" y1="750" x2="950" y2="1050"
  173. stroke="#edbf03" stroke-width="2" />
  174. <circle :class="{ 'stand-alone-circle': circle && hover == 4 }" cx="950" cy="1050" r="5" fill="#edbf03" />
  175. <text :class="{ 'stand-alone-text': text && hover == 4 }" x="960" y="1050" fill="#36348e" font-size="24">
  176. 偏航
  177. </text>
  178. </g>
  179. <!-- 液压 -->
  180. <g class="stand-alone-img-g" :class="{ active: activeIndex == 5 }" @mouseover="mouseover(5)"
  181. @mouseout="mouseout" @click="click(5)">
  182. <use class="stand-alone-img-item" xlink:href="#hydraulic-pressure" x="775" y="455"
  183. transform="translate(260, 310) scale(0.7)" />
  184. <use class="stand-alone-img-item-circle" xlink:href="#stand-alone-circle-yy" x="850" y="730" />
  185. <line :class="{ 'stand-alone-line': line && hover == 5 }" x1="850" y1="730" x2="1150" y2="1030"
  186. stroke="#edbf03" stroke-width="2" />
  187. <circle :class="{ 'stand-alone-circle': circle && hover == 5 }" cx="1150" cy="1030" r="5" fill="#edbf03" />
  188. <text :class="{ 'stand-alone-text': text && hover == 5 }" x="1160" y="1030" fill="#36348e" font-size="24">
  189. 液压
  190. </text>
  191. </g>
  192. </svg>
  193. </template>
  194. <script>
  195. export default {
  196. // 名称
  197. name: "StandAloneImg",
  198. // 使用组件
  199. components: {},
  200. // 数据
  201. data() {
  202. return {
  203. StandAloneCircle1: false,
  204. StandAloneCircle2: false,
  205. StandAloneCircle3: false,
  206. StandAloneCircle4: false,
  207. line: false,
  208. circle: false,
  209. text: false,
  210. hover: 0,
  211. svgWidth: 157,
  212. svgHeight: 107,
  213. };
  214. },
  215. props: {
  216. activeIndex: {
  217. type: Number,
  218. default: 0,
  219. },
  220. },
  221. emits: {
  222. // 选中事件
  223. selectSvg: null,
  224. },
  225. // 函数
  226. methods: {
  227. mouseover: function(hIndex) {
  228. this.StandAloneCircle1 = false;
  229. this.StandAloneCircle2 = false;
  230. this.StandAloneCircle3 = false;
  231. this.StandAloneCircle4 = false;
  232. this.line = false;
  233. this.circle = false;
  234. this.text = false;
  235. this.StandAloneCircle1 = true;
  236. this.StandAloneCircle2 = true;
  237. this.StandAloneCircle3 = true;
  238. this.StandAloneCircle4 = true;
  239. this.line = true;
  240. this.circle = true;
  241. this.text = true;
  242. // this.hover = hIndex;
  243. this.hover = this.activeIndex;
  244. },
  245. mouseout: function() {
  246. this.StandAloneCircle1 = false;
  247. this.StandAloneCircle2 = false;
  248. this.StandAloneCircle3 = false;
  249. this.StandAloneCircle4 = false;
  250. this.line = false;
  251. this.circle = false;
  252. this.text = false;
  253. this.hover = 0;
  254. },
  255. click: function(index) {
  256. this.$emit("selectSvg", index);
  257. },
  258. },
  259. // 生命周期钩子
  260. beforeCreate() {
  261. // 创建前
  262. },
  263. created() {
  264. // 创建后
  265. },
  266. beforeMount() {
  267. // 渲染前
  268. },
  269. mounted() {
  270. // 渲染后
  271. let isShow = setInterval(() => {
  272. if (this.$el.style.display != 'none') {
  273. if (this.$el.scrollWidth == this.svgWidth) {
  274. let height = (this.$el.scrollHeight).toFixed(0);
  275. let width = (height / this.svgHeight * this.svgWidth).toFixed(0);
  276. this.svgWidth = width;
  277. this.svgHeight = height;
  278. clearInterval(isShow);
  279. } else {
  280. let width = (this.$el.scrollWidth).toFixed(0);
  281. let height = (width / this.svgWidth * this.svgHeight).toFixed(0);
  282. this.svgWidth = width;
  283. this.svgHeight = height;
  284. clearInterval(isShow);
  285. }
  286. }
  287. }, 200);
  288. },
  289. beforeUpdate() {
  290. // 数据更新前
  291. },
  292. updated() {
  293. // 数据更新后
  294. },
  295. watch: {
  296. },
  297. };
  298. </script>
  299. <style lang="less" scoped>
  300. .stand-alone-img {
  301. .stand-alone-img-path {
  302. -webkit-filter: drop-shadow(0 0 5px @green);
  303. }
  304. .stand-alone-img-g {
  305. .stand-alone-img-item {
  306. opacity: 0;
  307. cursor: pointer;
  308. transition: all 0.3s;
  309. }
  310. .stand-alone-img-item-circle,
  311. line,
  312. circle,
  313. text {
  314. opacity: 0;
  315. }
  316. text {
  317. display: none;
  318. }
  319. &:hover,
  320. &.active {
  321. .stand-alone-img-item,
  322. .stand-alone-img-item-circle,
  323. line,
  324. circle,
  325. text {
  326. opacity: 1;
  327. }
  328. text {
  329. display: block;
  330. }
  331. }
  332. }
  333. .stand-alone-circle1 {
  334. animation: StandAloneCircle1 0.1s linear;
  335. }
  336. .stand-alone-circle2 {
  337. animation: StandAloneCircle2 0.2s linear;
  338. }
  339. .stand-alone-circle3 {
  340. animation: StandAloneCircle3 0.3s linear;
  341. }
  342. .stand-alone-circle4 {
  343. animation: StandAloneCircle4 0.45s linear;
  344. }
  345. .stand-alone-line {
  346. stroke-dasharray: 430, 450;
  347. animation: line 0.45s linear;
  348. }
  349. .stand-alone-circle {
  350. animation: circle 0.5s linear;
  351. }
  352. .stand-alone-text {
  353. animation: text 0.5s linear;
  354. }
  355. }
  356. @keyframes line {
  357. from {
  358. stroke-dashoffset: 430;
  359. }
  360. to {
  361. stroke-dashoffset: 0;
  362. }
  363. }
  364. @keyframes circle {
  365. 0% {
  366. r: 0;
  367. }
  368. 90% {
  369. r: 0;
  370. }
  371. 100% {
  372. r: 5;
  373. }
  374. }
  375. @keyframes text {
  376. 0% {
  377. opacity: 0;
  378. }
  379. 90% {
  380. opacity: 0;
  381. }
  382. 100% {
  383. opacity: 1;
  384. }
  385. }
  386. @keyframes StandAloneCircle1 {
  387. from {
  388. r: 0;
  389. }
  390. to {
  391. r: 10;
  392. }
  393. }
  394. @keyframes StandAloneCircle2 {
  395. from {
  396. r: 0;
  397. }
  398. to {
  399. r: 20;
  400. }
  401. }
  402. @keyframes StandAloneCircle3 {
  403. from {
  404. r: 0;
  405. }
  406. to {
  407. r: 30;
  408. }
  409. }
  410. @keyframes StandAloneCircle4 {
  411. from {
  412. r: 0;
  413. }
  414. to {
  415. r: 45;
  416. }
  417. }
  418. </style>