vue-layout-gitcode 1.12.15-beta.48 → 1.12.15-beta.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GloabarSearch-CLYtierP.js +202 -0
- package/{MenuItem-Dp65SK91.js → MenuItem-BYzU-MFz.js} +2 -2
- package/{ProjectMenuList-BxRlYnoF.js → ProjectMenuList-BUdSeYzS.js} +3 -3
- package/{ProjectMenuListV2-DQsGq4m0.js → ProjectMenuListV2-DUXR22kj.js} +3 -3
- package/{ProjectSearch-CaIZni-C.js → ProjectSearch-ZPemd9C2.js} +2 -2
- package/{SearchHistoryList-IdXbhtN1.js → SearchHistoryList-MOAZW-ce.js} +5 -11
- package/{SearchRecommed-DTQt1DB4.js → SearchRecommed-Bx_0qPG9.js} +5 -4
- package/{SearchScopeList-Dvh7ngu5.js → SearchScopeList-COb6DGCL.js} +2 -2
- package/{UserSearch-DBU5DMOj.js → UserSearch-DS5CbYZ0.js} +2 -2
- package/{index-BhGgHG6v.js → index-BTaTpv7I.js} +2 -2
- package/{useReportRepo-NVskwkzo.js → index-Bv4s4B-r.js} +72 -72
- package/{index-CNYp05iL.js → index-C2hNaYFz.js} +2 -2
- package/{index-oglgxmFJ.js → index-D27sLwSF.js} +650 -1351
- package/index.d.ts +0 -3
- package/index.js +19 -19
- package/{notice-srYZBv1G.js → notice-DO9c145B.js} +2 -2
- package/package.json +1 -1
- package/style.css +1 -1
- package/{transWebUrl-C4rUAe6a.js → transWebUrl-DFYqL_Qw.js} +1 -1
- package/GloabarSearch-BLFm4iwc.js +0 -150
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { defineComponent, inject, openBlock, createElementBlock, Fragment, renderList, withDirectives, createBlock, unref, ref, watch, createElementVNode, createVNode, toDisplayString, createCommentVNode } from "vue";
|
|
2
|
-
import { h as headRequest, R as REPO_MODULE, v as vElementExposure, b as REPO_EVENT, _ as _export_sfc, c as REPO_TYPE, e as extractRepoInfoWithURL, a as i18n, G as GIcon } from "./index-oglgxmFJ.js";
|
|
3
|
-
import { u as useReportRepo, S as SearchRepoCard, f as formatNameSpace } from "./useReportRepo-NVskwkzo.js";
|
|
4
|
-
import "vue-devui-lal/icon";
|
|
5
|
-
import "vue-devui-lal/icon/style.css";
|
|
6
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
7
|
-
__name: "SearchRepoCardList",
|
|
8
|
-
props: {
|
|
9
|
-
dataList: { default: () => [] },
|
|
10
|
-
searchStr: { default: "" },
|
|
11
|
-
type: { default: "" }
|
|
12
|
-
},
|
|
13
|
-
setup(__props) {
|
|
14
|
-
const props = __props;
|
|
15
|
-
const API = headRequest(inject("request"));
|
|
16
|
-
const { triggerReport } = useReportRepo({ moduleName: REPO_MODULE.SEARCH_SUGGESTION_CARD }, API.viewReport);
|
|
17
|
-
const useReport = inject("useReport");
|
|
18
|
-
const handleReport = (item) => {
|
|
19
|
-
useReport(REPO_EVENT.CLICK, { module_name: REPO_MODULE.SEARCH_SUGGESTION_CARD, repo_id: item.id });
|
|
20
|
-
};
|
|
21
|
-
return (_ctx, _cache) => {
|
|
22
|
-
return openBlock(true), createElementBlock(Fragment, null, renderList(props.dataList, (item, index) => {
|
|
23
|
-
return withDirectives((openBlock(), createBlock(SearchRepoCard, {
|
|
24
|
-
key: `${item.searchType || props.type}-${item.id}`,
|
|
25
|
-
class: "search-repo-list-card",
|
|
26
|
-
info: { ...item, index },
|
|
27
|
-
keyword: props.searchStr,
|
|
28
|
-
hover: "",
|
|
29
|
-
noborder: false,
|
|
30
|
-
hideTopicTags: "",
|
|
31
|
-
hideStarBtn: "",
|
|
32
|
-
hideFooter: "",
|
|
33
|
-
hideDescription: "",
|
|
34
|
-
onReport: () => handleReport(item),
|
|
35
|
-
cardType: item.searchType || props.type,
|
|
36
|
-
"url-params": { source_module: "search_project" }
|
|
37
|
-
}, null, 8, ["info", "keyword", "onReport", "cardType"])), [
|
|
38
|
-
[unref(vElementExposure), { trigger: (type) => unref(triggerReport)(type, item) }]
|
|
39
|
-
]);
|
|
40
|
-
}), 128);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
const SearchRepoCardList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-vue-layout-gitcode"]]);
|
|
45
|
-
const normalizeOrigin = (origin) => origin.replace(/\/+$/, "");
|
|
46
|
-
const getStringValue = (value) => typeof value === "string" ? value : "";
|
|
47
|
-
const convertDataList = ({ dataList, searchType, origin }) => {
|
|
48
|
-
if (!Array.isArray(dataList)) {
|
|
49
|
-
return { items: [] };
|
|
50
|
-
}
|
|
51
|
-
const baseOrigin = normalizeOrigin(origin);
|
|
52
|
-
const items = dataList.slice(0, 3).filter((item) => Boolean(item) && typeof item === "object" && !Array.isArray(item)).map((item) => {
|
|
53
|
-
const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
|
|
54
|
-
const importUrl = getStringValue(item.import_url);
|
|
55
|
-
const importedRepoName = importUrl ? extractRepoInfoWithURL(importUrl) : "";
|
|
56
|
-
const nameWithNamespace = getStringValue(item.name_with_namespace);
|
|
57
|
-
const pathWithNamespace = getStringValue(item.path_with_namespace);
|
|
58
|
-
const repoName = (isGitcodeRepo ? nameWithNamespace : importedRepoName) || nameWithNamespace || pathWithNamespace;
|
|
59
|
-
const displayName = formatNameSpace(repoName).join("/");
|
|
60
|
-
const path = `${baseOrigin}/${pathWithNamespace}`;
|
|
61
|
-
return {
|
|
62
|
-
...item,
|
|
63
|
-
searchType,
|
|
64
|
-
path,
|
|
65
|
-
displayName,
|
|
66
|
-
web_url: path
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
return { items };
|
|
70
|
-
};
|
|
71
|
-
const mergeSearchSuggestions = ({ response = {}, origin }) => ({
|
|
72
|
-
items: [
|
|
73
|
-
...convertDataList({ dataList: response.recommend_project, searchType: "repo", origin }).items,
|
|
74
|
-
...convertDataList({ dataList: response.recommend_model, searchType: "model", origin }).items,
|
|
75
|
-
...convertDataList({ dataList: response.recommend_dataset, searchType: "dataset", origin }).items
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
const _hoisted_1 = {
|
|
79
|
-
key: 0,
|
|
80
|
-
class: "history-list-project history-list-project--padded"
|
|
81
|
-
};
|
|
82
|
-
const _sfc_main = {
|
|
83
|
-
__name: "GloabarSearch",
|
|
84
|
-
props: ["searchStr"],
|
|
85
|
-
emits: ["searchMore"],
|
|
86
|
-
setup(__props, { emit: __emit }) {
|
|
87
|
-
const emits = __emit;
|
|
88
|
-
const { t: $t } = i18n.global;
|
|
89
|
-
const API = headRequest(inject("request"));
|
|
90
|
-
const useReport = inject("useReport");
|
|
91
|
-
const searchSuggestionList = ref([]);
|
|
92
|
-
const origin = window.location.origin;
|
|
93
|
-
const props = __props;
|
|
94
|
-
let timer = null;
|
|
95
|
-
const handleSearchAll = () => {
|
|
96
|
-
emits("searchMore", "all");
|
|
97
|
-
};
|
|
98
|
-
const getData = async () => {
|
|
99
|
-
if (!props.searchStr) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
try {
|
|
103
|
-
useReport("search-project", {});
|
|
104
|
-
const res = await API.getGloabarSearchKeyLink({ q: props.searchStr });
|
|
105
|
-
searchSuggestionList.value = mergeSearchSuggestions({ response: res.data || {}, origin }).items;
|
|
106
|
-
} catch (error) {
|
|
107
|
-
console.error("Failed to fetch search results:", error);
|
|
108
|
-
searchSuggestionList.value = [];
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
if (props.searchStr) {
|
|
112
|
-
getData();
|
|
113
|
-
}
|
|
114
|
-
watch(
|
|
115
|
-
() => props.searchStr,
|
|
116
|
-
() => {
|
|
117
|
-
if (timer) {
|
|
118
|
-
clearTimeout(timer);
|
|
119
|
-
}
|
|
120
|
-
timer = setTimeout(() => {
|
|
121
|
-
getData();
|
|
122
|
-
}, 300);
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
return (_ctx, _cache) => {
|
|
126
|
-
return openBlock(), createElementBlock(Fragment, null, [
|
|
127
|
-
createElementVNode("button", {
|
|
128
|
-
type: "button",
|
|
129
|
-
class: "global-search-all",
|
|
130
|
-
onClick: handleSearchAll
|
|
131
|
-
}, [
|
|
132
|
-
createVNode(GIcon, {
|
|
133
|
-
name: "gt-search",
|
|
134
|
-
color: "var(--theme-placeholder)"
|
|
135
|
-
}),
|
|
136
|
-
createElementVNode("span", null, toDisplayString(unref($t)("gitCodeLayout.header.searchAll", { keyword: __props.searchStr })), 1)
|
|
137
|
-
]),
|
|
138
|
-
searchSuggestionList.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
139
|
-
createVNode(SearchRepoCardList, {
|
|
140
|
-
"data-list": searchSuggestionList.value,
|
|
141
|
-
"search-str": __props.searchStr
|
|
142
|
-
}, null, 8, ["data-list", "search-str"])
|
|
143
|
-
])) : createCommentVNode("", true)
|
|
144
|
-
], 64);
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
export {
|
|
149
|
-
_sfc_main as default
|
|
150
|
-
};
|