hejianhao
2026-04-02 0940d56748a73525790c350c393a5be960aab62c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!-- 项目 -->
 
<template>
  <div class="project-info" v-if="project">
    <!-- 项目名称 -->
    <div class="custom-card custom-input">
      <span>{{ project?.name || "未知项目" }}</span>
      <div v-if="showEdit" class="icon" @click="$emit('edit')">
        <el-icon><Edit /></el-icon>
      </div>
    </div>
 
    <!-- 项目方法信息 -->
    <div class="custom-card custom-info">
      <div
        class="info-circle"
        :style="{ backgroundColor: currentMethodConfig?.color || '#409EFF' }"
      >
        {{ currentMethodConfig?.icon || "📊" }}
      </div>
      <div class="info-cont">
        <div class="title">
          {{
            currentMethodConfig?.title ||
            project?.instance?.title ||
            "深度学习项目"
          }}
        </div>
        <div class="text">
          {{
            currentMethodConfig?.description ||
            project?.instance?.description ||
            "暂无描述信息"
          }}
        </div>
      </div>
      <div v-if="showMore" class="more" @click="$emit('more')">
        <el-icon><More /></el-icon>
      </div>
    </div>
 
    <!-- 项目详细信息 -->
    <div v-if="showDetails" class="custom-card project-details">
      <div class="custom-item">
        <div class="label">项目文件:</div>
        <div
          class="text clickable-path"
          @click="handleOpenFolder(project?.path)"
          :title="'点击打开文件夹: ' + project?.path"
        >
          {{ project?.path }}
        </div>
      </div>
      <div class="custom-item">
        <div class="label">标签类别:</div>
        <!-- 显示统计数据中的类别 -->
        <div class="text">
          {{
            formatCategories(project?.statistics?.categories) || "暂无标签类别"
          }}
        </div>
      </div>
      <div class="custom-item">
        <div class="label">标签实例/图像:</div>
        <div class="text">
          {{ project?.statistics?.totalAnnotations || 0 }}/{{
            project?.statistics?.totalImages || 0
          }}
        </div>
      </div>
      <div class="custom-item">
        <div class="label">创建时间/修改时间:</div>
        <div class="text">
          {{ formatDate(project?.createdAt) }}/{{
            formatDate(project?.updatedAt)
          }}
        </div>
      </div>
      <div class="custom-item">
        <div class="label">程序版本/文件版本:</div>
        <div class="text">
          {{ project?.version?.program }}/{{ project?.version?.file }}
        </div>
      </div>
    </div>
  </div>
</template>
 
<script setup>
import { onMounted } from "vue";
import { useMethodConfig } from "../../utils/config/methodConfig";
import { formatDate } from "../../utils/system/dateFormatter";
 
const props = defineProps({
  project: {
    type: Object,
    default: () => null,
  },
  showEdit: {
    type: Boolean,
    default: false,
  },
  showMore: {
    type: Boolean,
    default: false,
  },
  showDetails: {
    type: Boolean,
    default: false,
  },
});
 
const emit = defineEmits(["edit", "more"]);
 
// 使用公共方法配置工具
const { currentMethodConfig, loadMethods } = useMethodConfig(props.project);
 
// 格式化类别显示
const formatCategories = (categories) => {
  if (!categories || !Array.isArray(categories) || categories.length === 0) {
    return "暂无标签类别";
  }
  // 类别名称现在使用了序号格式(如"类别 00001"),已经是唯一的,直接显示即可
  return categories.join(", ");
};
 
// 打开文件夹
const handleOpenFolder = async (folderPath) => {
  if (!folderPath) {
    alert("项目路径不存在");
    return;
  }
 
  try {
    if (window.electronAPI?.openFolder) {
      const result = await window.electronAPI.openFolder(folderPath);
      if (!result.success) {
        alert("打开文件夹失败: " + result.error);
      }
    } else {
      alert("系统API不可用");
    }
  } catch (error) {
    console.error("打开文件夹失败:", error);
    alert("打开文件夹失败: " + error.message);
  }
};
 
// 初始化时加载方法配置
onMounted(() => {
  loadMethods();
});
</script>
 
<style scoped lang="scss">
.project-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
 
  .custom-card {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.6) 0%,
      rgba(255, 255, 255, 0.4) 100%
    );
    border-radius: 6px;
    border: 2px solid #ffffff;
    padding: 0;
  }
 
  .custom-input {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    gap: 10px;
 
    span {
      font-size: 14px;
      min-height: 20px;
      color: #222;
      font-weight: 600;
      flex: 1;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
 
    .icon {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 4px;
      border-radius: 4px;
      transition: background-color 0.2s;
 
      &:hover {
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
  }
 
  .custom-info {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 80px;
    padding: 0 15px;
    position: relative;
 
    .info-circle {
      width: 35px;
      height: 35px;
      border-radius: 50%;
      background: #409eff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 18px;
      color: white;
      text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
      flex-shrink: 0;
    }
 
    .info-cont {
      flex: 1;
 
      .title {
        font-size: 14px;
        color: #333;
        margin-bottom: 4px;
        font-weight: 500;
      }
 
      .text {
        font-size: 12px;
        color: #666;
        line-height: 1.4;
      }
    }
 
    .more {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 4px;
      border-radius: 4px;
      transition: background-color 0.2s;
 
      &:hover {
        background-color: rgba(0, 0, 0, 0.1);
      }
    }
  }
 
  .project-details {
    padding: 14px;
 
    .custom-item {
      margin-bottom: 15px;
      display: flex;
      flex-direction: column;
      gap: 3px;
 
      &:last-child {
        margin-bottom: 0;
      }
 
      .label {
        font-size: 14px;
        color: #333;
        font-weight: 500;
      }
 
      .text {
        font-size: 12px;
        color: #606266;
        white-space: wrap;
        word-break: break-all;
 
        &.clickable-path {
          cursor: pointer;
          color: #409eff;
          text-decoration: underline;
          transition: color 0.2s;
 
          &:hover {
            color: #66b1ff;
          }
        }
      }
    }
  }
}
</style>