Common.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-01-18 09:41:14
  4. * @LastEditTime: 2022-01-20 14:26:41
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: \vue3-element-admin\src\components\Common.vue
  8. -->
  9. <template>
  10. <div class="ve_404">
  11. <!-- partial:index.partial.html -->
  12. <div class="moon"></div>
  13. <div class="moon__crater moon__crater1"></div>
  14. <div class="moon__crater moon__crater2"></div>
  15. <div class="moon__crater moon__crater3"></div>
  16. <div class="star star1">⭐</div>
  17. <div class="star star2">⭐</div>
  18. <div class="star star3">⭐</div>
  19. <div class="star star4">⭐</div>
  20. <div class="star star5">⭐</div>
  21. <slot>
  22. <div class="error">
  23. <div class="error__title">404</div>
  24. <div class="error__subtitle">🐱🐱🐱(⓿_⓿)🐱🐱🐱</div>
  25. <div class="error__description">看来你是迷路了......</div>
  26. <router-link to="/">
  27. <button class="error__button error__button--active">
  28. 回到首页
  29. </button>
  30. </router-link>
  31. <!-- <button class="error__button">CONTACT</button> -->
  32. </div>
  33. </slot>
  34. <div class="astronaut" v-resize="{ resize: draw3dAstronaut }">
  35. <canvas ref="cav"></canvas>
  36. </div>
  37. </div>
  38. </template>
  39. <script setup>
  40. import Zdog from "zdog";
  41. import { ref, onUnmounted, onMounted } from "vue";
  42. const cav = ref(null);
  43. let timer = null;
  44. onMounted(() => {
  45. draw3dAstronaut();
  46. });
  47. /**
  48. * @description: 画3d太空人
  49. * @param {*}
  50. * @return {*}
  51. */
  52. const draw3dAstronaut = () => {
  53. cav.value.width = cav.value.parentNode.clientWidth;
  54. cav.value.height = cav.value.parentNode.clientHeight;
  55. // colours
  56. let dark_navy = "#131e38";
  57. let orange = "#fe9642";
  58. let cream = "#FFF8E7";
  59. let light_purple = "#7f3f98";
  60. let dark_purple = "#563795";
  61. let cheese = "#fbc715";
  62. // create illo
  63. let illo = new Zdog.Illustration({
  64. // set canvas with selector
  65. element: cav.value,
  66. dragRotate: true,
  67. zoom: 0.65,
  68. });
  69. /** Body **/
  70. // Body
  71. let body = new Zdog.RoundedRect({
  72. addTo: illo,
  73. width: 200,
  74. height: 220,
  75. color: "white",
  76. fill: true,
  77. cornerRadius: 16,
  78. stroke: 60,
  79. });
  80. // Backpack
  81. new Zdog.RoundedRect({
  82. addTo: body,
  83. width: 180,
  84. height: 310,
  85. color: orange,
  86. fill: true,
  87. cornerRadius: 24,
  88. stroke: 120,
  89. translate: { z: -85, y: -60 },
  90. });
  91. /** arm **/
  92. let arm = new Zdog.RoundedRect({
  93. addTo: body,
  94. height: 30,
  95. width: 28,
  96. stroke: 60,
  97. fill: true,
  98. color: dark_purple,
  99. translate: { x: -140, y: -64 },
  100. cornerRadius: 0.05,
  101. });
  102. new Zdog.RoundedRect({
  103. addTo: arm,
  104. height: 120,
  105. width: 12,
  106. stroke: 60,
  107. fill: true,
  108. color: cream,
  109. translate: { y: 120 },
  110. cornerRadius: 0.05,
  111. });
  112. // bubble_arm
  113. let bubble_arm = new Zdog.Shape({
  114. addTo: arm,
  115. path: [{ x: -20 }, { x: 20 }],
  116. stroke: 32,
  117. color: light_purple,
  118. translate: { y: 210 },
  119. });
  120. bubble_arm.copy({
  121. color: dark_purple,
  122. translate: { y: 230 },
  123. });
  124. // hand
  125. new Zdog.RoundedRect({
  126. addTo: bubble_arm,
  127. height: 32,
  128. width: 22,
  129. translate: { x: -8, y: 60 },
  130. fill: true,
  131. color: cheese,
  132. stroke: 30,
  133. });
  134. new Zdog.RoundedRect({
  135. addTo: bubble_arm,
  136. height: 24,
  137. width: 0,
  138. translate: { x: 24, y: 50 },
  139. fill: true,
  140. color: orange,
  141. stroke: 20,
  142. });
  143. arm.copyGraph({
  144. translate: { x: 140, y: -64 },
  145. rotate: { y: Zdog.TAU / 2 },
  146. });
  147. /** Leg **/
  148. let leg = new Zdog.RoundedRect({
  149. addTo: body,
  150. height: 160,
  151. width: 28,
  152. stroke: 60,
  153. fill: true,
  154. color: cream,
  155. translate: { x: -56, y: 230 },
  156. cornerRadius: 0.05,
  157. });
  158. // bubble_leg
  159. let bubble_leg = new Zdog.Shape({
  160. addTo: leg,
  161. path: [{ x: -28 }, { x: 28 }],
  162. stroke: 32,
  163. color: light_purple,
  164. translate: { y: 100 },
  165. });
  166. bubble_leg.copy({
  167. color: dark_purple,
  168. translate: { y: 124 },
  169. });
  170. // foot
  171. new Zdog.RoundedRect({
  172. addTo: leg,
  173. width: 96,
  174. height: 24,
  175. stroke: 40,
  176. fill: true,
  177. color: cheese,
  178. translate: { x: -24, y: 170 },
  179. cornerRadius: 24,
  180. });
  181. leg.copyGraph({
  182. translate: { x: 56, y: 230 },
  183. rotate: { y: Zdog.TAU / 2 },
  184. });
  185. /** Head **/
  186. // Head
  187. let head = new Zdog.RoundedRect({
  188. addTo: body,
  189. width: 216,
  190. height: 180,
  191. depth: 40,
  192. cornerRadius: 80,
  193. stroke: 60,
  194. color: cream,
  195. fill: true,
  196. translate: { y: -300 },
  197. });
  198. //add helmet
  199. let helmet = new Zdog.RoundedRect({
  200. addTo: head,
  201. width: 210,
  202. height: 165,
  203. cornerRadius: 64,
  204. color: dark_navy,
  205. fill: true,
  206. backface: false,
  207. translate: { z: 20 },
  208. });
  209. //add refletion
  210. new Zdog.Rect({
  211. addTo: helmet,
  212. width: 48,
  213. height: 2,
  214. stroke: 10,
  215. translate: { x: 24, y: -24, z: 10 },
  216. color: "white",
  217. backface: false,
  218. });
  219. // add ear
  220. let ear = new Zdog.RoundedRect({
  221. addTo: head,
  222. width: 36,
  223. height: 72,
  224. cornerRadius: 80,
  225. stroke: 20,
  226. color: orange,
  227. fill: true,
  228. translate: { x: -140 },
  229. });
  230. ear.copy({
  231. translate: { x: 140 },
  232. });
  233. // neck
  234. let neck = new Zdog.Shape({
  235. addTo: head,
  236. path: [{ x: -110 }, { x: 110 }],
  237. translate: { y: 120 },
  238. stroke: 40,
  239. color: light_purple,
  240. });
  241. neck.copy({
  242. translate: { y: 160 },
  243. color: dark_purple,
  244. });
  245. /** extra **/
  246. let stripe_1 = new Zdog.Shape({
  247. addTo: body,
  248. path: [{ x: -20 }, { x: 20 }],
  249. stroke: 10,
  250. translate: { x: 200, z: 200 },
  251. color: cheese,
  252. });
  253. stripe_1.copy({
  254. translate: { x: 320, y: 200, z: -400 },
  255. color: cheese,
  256. });
  257. stripe_1.copy({
  258. translate: { x: -220, y: 300, z: -400 },
  259. color: "white",
  260. });
  261. stripe_1.copy({
  262. translate: { x: -100, y: 400, z: -280 },
  263. color: light_purple,
  264. });
  265. stripe_1.copy({
  266. translate: { x: 50, y: -60, z: 150 },
  267. color: orange,
  268. });
  269. stripe_1.copy({
  270. translate: { x: -250, y: 80, z: 300 },
  271. color: light_purple,
  272. });
  273. stripe_1.copy({
  274. translate: { x: -350, y: -280, z: 175 },
  275. color: dark_purple,
  276. });
  277. stripe_1.copy({
  278. translate: { x: 250, y: -380, z: -175 },
  279. color: "white",
  280. });
  281. // update & render
  282. illo.updateRenderGraph();
  283. function animate() {
  284. // rotate illo each frame
  285. illo.rotate.y += 0.005;
  286. illo.rotate.x += 0.005;
  287. illo.rotate.z += 0.005;
  288. illo.updateRenderGraph();
  289. // animate next frame
  290. timer = requestAnimationFrame(animate);
  291. }
  292. // start animation
  293. animate();
  294. };
  295. onUnmounted(() => {
  296. cancelAnimationFrame(timer);
  297. timer = null;
  298. });
  299. </script>
  300. <style lang="scss" scoped>
  301. .ve_404 {
  302. height: 100vh;
  303. width: 100vw;
  304. position: relative;
  305. overflow: hidden;
  306. background: linear-gradient(90deg, #2f3640 23%, #181b20 100%);
  307. }
  308. .moon {
  309. background: linear-gradient(90deg, #d0d0d0 48%, #919191 100%);
  310. position: absolute;
  311. top: -30vh;
  312. left: -80vh;
  313. width: 160vh;
  314. height: 160%;
  315. content: "";
  316. border-radius: 50%;
  317. box-shadow: 0px 0px 30px -4px rgba(0, 0, 0, 0.5);
  318. }
  319. .moon__crater {
  320. position: absolute;
  321. content: "";
  322. border-radius: 100%;
  323. background: linear-gradient(90deg, #7a7a7a 38%, #c3c3c3 100%);
  324. opacity: 0.6;
  325. }
  326. .moon__crater1 {
  327. top: 250px;
  328. left: 500px;
  329. width: 60px;
  330. height: 180px;
  331. }
  332. .moon__crater2 {
  333. top: 650px;
  334. left: 340px;
  335. width: 40px;
  336. height: 80px;
  337. transform: rotate(55deg);
  338. }
  339. .moon__crater3 {
  340. top: -20px;
  341. left: 40px;
  342. width: 65px;
  343. height: 120px;
  344. transform: rotate(250deg);
  345. }
  346. .star {
  347. color: grey;
  348. position: absolute;
  349. width: 10px;
  350. height: 10px;
  351. content: "";
  352. border-radius: 100%;
  353. transform: rotate(250deg);
  354. opacity: 0.4;
  355. animation-name: shimmer;
  356. animation-duration: 1.5s;
  357. animation-iteration-count: infinite;
  358. animation-direction: alternate;
  359. }
  360. @keyframes shimmer {
  361. from {
  362. opacity: 0;
  363. }
  364. to {
  365. opacity: 0.7;
  366. }
  367. }
  368. .star1 {
  369. top: 40%;
  370. left: 50%;
  371. animation-delay: 1s;
  372. }
  373. .star2 {
  374. top: 60%;
  375. left: 90%;
  376. animation-delay: 3s;
  377. }
  378. .star3 {
  379. top: 10%;
  380. left: 70%;
  381. animation-delay: 2s;
  382. }
  383. .star4 {
  384. top: 90%;
  385. left: 40%;
  386. }
  387. .star5 {
  388. top: 20%;
  389. left: 30%;
  390. animation-delay: 0.5s;
  391. }
  392. .astronaut {
  393. position: absolute;
  394. width: 60vw;
  395. height: 100vh;
  396. top: 0;
  397. right: 0;
  398. z-index: 0;
  399. }
  400. .error {
  401. position: absolute;
  402. left: 100px;
  403. top: 400px;
  404. transform: translateY(-60%);
  405. font-family: "Righteous", cursive;
  406. color: #363e49;
  407. z-index: 1;
  408. }
  409. .error__title {
  410. font-size: 10em;
  411. font-weight: bold;
  412. color: #d0d0d0;
  413. text-shadow: -5px -5px 0 rgba(0, 0, 0, 0.7);
  414. background-image: linear-gradient(90deg, #d0d0d0 48%, #919191 100%);
  415. -webkit-background-clip: text;
  416. -webkit-text-fill-color: transparent;
  417. }
  418. .error__subtitle {
  419. font-size: 2em;
  420. }
  421. .error__description {
  422. opacity: 0.5;
  423. }
  424. .error__button {
  425. min-width: 7em;
  426. margin-top: 3em;
  427. margin-right: 0.5em;
  428. padding: 0.5em 2em;
  429. outline: none;
  430. border: 2px solid #2f3640;
  431. background-color: transparent;
  432. border-radius: 8em;
  433. color: #576375;
  434. cursor: pointer;
  435. transition-duration: 0.2s;
  436. font-size: 0.75em;
  437. font-family: "Righteous", cursive;
  438. }
  439. .error__button:hover {
  440. color: #21252c;
  441. }
  442. .error__button--active {
  443. background-color: $base-color;
  444. border: 2px solid $base-color;
  445. color: white;
  446. }
  447. .error__button--active:hover {
  448. box-shadow: 0px 0px 8px 0px rgba(0, 0, 0, 0.5);
  449. color: white;
  450. }
  451. </style>