ProjectCard.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <el-card class="project" shadow="hover" @click="toProjectInfo">
  3. <template #header>
  4. <div class="project-header">
  5. <span :title="this.projectVO['name']">
  6. {{ this.projectVO["name"] }}
  7. </span>
  8. </div>
  9. </template>
  10. <div class="project-logo">
  11. <div class="project-logo-text">
  12. D
  13. </div>
  14. </div>
  15. <el-row class="projectId">
  16. {{ projectId }}
  17. </el-row>
  18. <el-row class="project-description">
  19. {{ description }}
  20. </el-row>
  21. <el-row class="project-link">
  22. <el-button type="text" style="padding: 0" @click.stop="copyLink(projectVO['gitRemoteUrl'])">复制链接</el-button>
  23. </el-row>
  24. </el-card>
  25. </template>
  26. <script>
  27. import {ElMessage} from "element-plus";
  28. import store from "@/store";
  29. import colorUtil from "@/utils/color";
  30. export default {
  31. name: "ProjectCard",
  32. props: {
  33. projectVO: Object,
  34. type: String,
  35. isPublic: undefined,
  36. },
  37. data() {
  38. return {
  39. teacher: Object,
  40. color: colorUtil.SYSTEM_THEME.developerColor,
  41. };
  42. },
  43. computed: {
  44. isLogin() {
  45. return store.state.user.token;
  46. },
  47. isTeacher() {
  48. return this.$store.getters.isTeacher;
  49. },
  50. isStudent() {
  51. return this.$store.getters.isStudent;
  52. },
  53. projectId() {
  54. return "项目ID: " + this.projectVO.id;
  55. },
  56. description() {
  57. return "描述: " + this.projectVO.description;
  58. },
  59. },
  60. methods: {
  61. async toProjectInfo() {
  62. if (!this.isLogin) {
  63. ElMessage({
  64. showClose: true,
  65. message: "请先登录",
  66. type: "warning",
  67. duration: 1000,
  68. });
  69. await this.$router.push({name: "Auth", params: {login_to: "/portal"}});
  70. } else if (this.isPublic) {
  71. const courseId = (await this.$apis.findCourseByName(this.isPublic)).data.data.id;
  72. await this.$router.push(`/course/${courseId}`);
  73. } else {
  74. if (this.projectVO.name) {
  75. window.open("https://devcloud.seec.seecoder.cn/project/" + this.projectVO.id + "/schedule?id_token=" + this.$store.state.user.token);
  76. }
  77. }
  78. },
  79. async copyLink(link) {
  80. await navigator.clipboard.writeText(link);
  81. this.$message.success("复制成功!");
  82. }
  83. }
  84. };
  85. </script>
  86. <style scoped>
  87. .project {
  88. min-height: 180px;
  89. border-radius: 8px;
  90. height: calc(100% - 14px);
  91. position: relative;
  92. border: 1px solid #cccccc;
  93. }
  94. .project:hover {
  95. cursor: pointer;
  96. border: 1px solid #999999;
  97. }
  98. .projectId {
  99. /*font-weight: bold;*/
  100. font-size: medium;
  101. color: #777777;
  102. }
  103. .project-header {
  104. width: 100%;
  105. overflow: hidden;
  106. text-overflow: ellipsis;
  107. white-space: nowrap;
  108. font-weight: bold;
  109. }
  110. .project-description {
  111. width: 100%;
  112. display: -webkit-box; /*必须结合的属性,将对象作为弹性伸缩盒子模型显示*/
  113. -webkit-line-clamp: 2; /*设置多少行*/
  114. -webkit-box-orient: vertical; /*必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式*/
  115. overflow: hidden; /*文本会被修剪,并且剩余的部分不可见*/
  116. text-overflow: ellipsis;
  117. font-size: medium;
  118. color: #777777;
  119. }
  120. .project-link {
  121. font-size: medium;
  122. }
  123. .project-logo {
  124. float: right;
  125. width: 0;
  126. height: 0;
  127. position: absolute;
  128. right: 0;
  129. bottom: 0;
  130. border-left: 30px solid transparent;
  131. border-bottom: 30px solid v-bind(color)
  132. }
  133. .project-logo-text {
  134. padding: 0 3px 0 0;
  135. position: absolute;
  136. right: 0;
  137. bottom: -32px;
  138. color: white
  139. }
  140. </style>