|
@@ -1,37 +1,57 @@
|
|
|
import type { SpecialTag, Track } from "@/types";
|
|
|
|
|
|
export default function useTrackColor() {
|
|
|
- const colors = ["red", "blue", "green"];
|
|
|
- const colorMap: Record<number, string> = {};
|
|
|
-
|
|
|
function addTrackColorAttr(tList: Track[]): Track[] {
|
|
|
- let userIds: (number | undefined)[] = tList
|
|
|
+ let markerIds: (number | undefined)[] = tList
|
|
|
.map((v) => v.userId)
|
|
|
.filter((x) => !!x);
|
|
|
- userIds = Array.from(new Set(userIds));
|
|
|
- const isByMultMark = userIds.length > 1;
|
|
|
-
|
|
|
- tList = tList.map((item) => {
|
|
|
- const uid = item.userId;
|
|
|
- if (item.headerMarkScore) {
|
|
|
- item.color = "green";
|
|
|
- } else {
|
|
|
- if (!colorMap[uid]) {
|
|
|
- colorMap[uid] = colors[Object.keys(colorMap).length] || "green";
|
|
|
- }
|
|
|
- item.color = colorMap[uid];
|
|
|
+ markerIds = Array.from(new Set(markerIds));
|
|
|
+ // markerIds.sort();
|
|
|
+ const colorMap: ColorMap = {};
|
|
|
+ for (let i = 0; i < markerIds.length; i++) {
|
|
|
+ const mId: any = markerIds[i];
|
|
|
+ if (i == 0) {
|
|
|
+ colorMap[mId + ""] = "red";
|
|
|
+ } else if (i == 1) {
|
|
|
+ colorMap[mId + ""] = "blue";
|
|
|
+ } else if (i > 1) {
|
|
|
+ colorMap[mId + ""] = "gray";
|
|
|
}
|
|
|
- item.isByMultMark = isByMultMark;
|
|
|
+ }
|
|
|
+ // if (Object.keys(colorMap).length > 1) {
|
|
|
+ // emit("getIsMultComments", true);
|
|
|
+ // }
|
|
|
+ tList = tList.map((item: Track) => {
|
|
|
+ item.color = colorMap[item.userId + ""] || "red";
|
|
|
+ item.isByMultMark = markerIds.length > 1;
|
|
|
return item;
|
|
|
});
|
|
|
return tList;
|
|
|
}
|
|
|
|
|
|
- function addSpecialTrackColorAttr(tList: SpecialTag[]): SpecialTag[] {
|
|
|
- return tList.map((item) => {
|
|
|
- item.color = colorMap[item.markerId] || "green";
|
|
|
+ function addTagColorAttr(tList: SpecialTag[]): SpecialTag[] {
|
|
|
+ let markerIds: (number | undefined)[] = tList
|
|
|
+ .map((v) => v.userId)
|
|
|
+ .filter((x) => !!x);
|
|
|
+ markerIds = Array.from(new Set(markerIds));
|
|
|
+ // markerIds.sort();
|
|
|
+ const colorMap: ColorMap = {};
|
|
|
+ for (let i = 0; i < markerIds.length; i++) {
|
|
|
+ const mId: any = markerIds[i];
|
|
|
+ if (i == 0) {
|
|
|
+ colorMap[mId + ""] = "red";
|
|
|
+ } else if (i == 1) {
|
|
|
+ colorMap[mId + ""] = "blue";
|
|
|
+ } else if (i > 1) {
|
|
|
+ colorMap[mId + ""] = "gray";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tList = tList.map((item: SpecialTag) => {
|
|
|
+ item.color = colorMap[item.userId + ""] || "red";
|
|
|
+ item.isByMultMark = markerIds.length > 1;
|
|
|
return item;
|
|
|
});
|
|
|
+ return tList;
|
|
|
}
|
|
|
|
|
|
function addHeaderTrackColorAttr(headerTrackList: any): any {
|
|
@@ -43,7 +63,7 @@ export default function useTrackColor() {
|
|
|
|
|
|
return {
|
|
|
addTrackColorAttr,
|
|
|
- addSpecialTrackColorAttr,
|
|
|
+ addTagColorAttr,
|
|
|
addHeaderTrackColorAttr,
|
|
|
};
|
|
|
}
|