vue-layout-gitcode 1.3.24 → 1.3.26

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.
@@ -1,94 +0,0 @@
1
- import { inject, ref, watch, onMounted, createElementBlock, createCommentVNode, openBlock, createElementVNode, toDisplayString, unref, Fragment, renderList, createBlock } from "vue";
2
- import "vue-devui-lal/icon";
3
- import "vue-devui-lal/icon/style.css";
4
- import { a as i18n, h as headRequest, R as REPO_MODULE, b as REPO_TYPE, e as extractRepoInfoWithURL, c as REPO_EVENT } from "./index-DC9YPjPv.js";
5
- import { u as useReportRepo, S as SearchRepoCard, f as formatNameSpace } from "./index-243BN_SR.js";
6
- const _hoisted_1 = {
7
- key: 0,
8
- class: "px-[8px] history-list-project pl-[8px]"
9
- };
10
- const _hoisted_2 = { class: "history-list-project-globartitle mb-[4px] mt-[16px]" };
11
- const _sfc_main = {
12
- __name: "GloabarSearch",
13
- props: ["searchStr"],
14
- setup(__props) {
15
- const { t: $t } = i18n.global;
16
- const API = headRequest(inject("request"));
17
- const useReport = inject("useReport");
18
- const { triggerReport } = useReportRepo({ moduleName: REPO_MODULE.SEARCH_SUGGESTION_CARD }, API.viewReport);
19
- const searchFileList = ref([]);
20
- const origin = window.location.origin;
21
- const props = __props;
22
- let timer = null;
23
- const handleReport = (item) => {
24
- useReport(REPO_EVENT.CLICK, { module_name: REPO_MODULE.SEARCH_SUGGESTION_CARD, repo_id: item.id });
25
- };
26
- const getData = async () => {
27
- if (!props.searchStr) {
28
- return;
29
- }
30
- try {
31
- useReport("search-project", {});
32
- const res = await API.getGloabarSearchKeyLink({ q: props.searchStr });
33
- const { recommend_project = [] } = res.data || {};
34
- searchFileList.value = recommend_project.slice(0, 5).map((item) => {
35
- const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
36
- const repoName = (!isGitcodeRepo ? extractRepoInfoWithURL(item.import_url) : item.name_with_namespace) || item.name_with_namespace;
37
- const displayName = formatNameSpace(repoName).join("/");
38
- return {
39
- ...item,
40
- path: `${origin}/${item.path_with_namespace}`,
41
- displayName,
42
- web_url: `${origin}/${item.path_with_namespace}`
43
- };
44
- });
45
- searchFileList.value.forEach((item, index) => {
46
- triggerReport("expo", { ...item, index });
47
- });
48
- } catch (error) {
49
- console.error("Failed to fetch search results:", error);
50
- searchFileList.value = [];
51
- }
52
- };
53
- if (props.searchStr) {
54
- getData();
55
- }
56
- watch(
57
- () => props.searchStr,
58
- () => {
59
- if (timer) {
60
- clearTimeout(timer);
61
- }
62
- timer = setTimeout(() => {
63
- getData();
64
- }, 300);
65
- }
66
- );
67
- onMounted(() => {
68
- console.log("GloabarSearch");
69
- });
70
- return (_ctx, _cache) => {
71
- return searchFileList.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
72
- createElementVNode("p", _hoisted_2, toDisplayString(unref($t)("gitCodeLayout.header.repo")), 1),
73
- (openBlock(true), createElementBlock(Fragment, null, renderList(searchFileList.value, (item, index) => {
74
- return openBlock(), createBlock(SearchRepoCard, {
75
- key: item.id,
76
- class: "mb-[8px]",
77
- info: { ...item, index },
78
- keyword: __props.searchStr,
79
- hover: "",
80
- hideTopicTags: "",
81
- hideStarBtn: "",
82
- hideFooter: "",
83
- onReport: (evt) => handleReport(item),
84
- cardType: "repo",
85
- "url-params": { source_module: "search_project" }
86
- }, null, 8, ["info", "keyword", "onReport"]);
87
- }), 128))
88
- ])) : createCommentVNode("", true);
89
- };
90
- }
91
- };
92
- export {
93
- _sfc_main as default
94
- };