vue-layout-gitcode 1.12.15-beta.47 → 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.
@@ -1,4 +1,4 @@
1
- import { z as useLayoutConfig } from "./index-DoYP7NyR.js";
1
+ import { y as useLayoutConfig } from "./index-D27sLwSF.js";
2
2
  const layoutConfig = useLayoutConfig();
3
3
  const transWebUrl = (url, params) => {
4
4
  if (!url) return url;
@@ -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-DoYP7NyR.js";
3
- import { u as useReportRepo, S as SearchRepoCard, f as formatNameSpace } from "./useReportRepo-BAoT7ILs.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: {
10
- type: Array,
11
- default: () => []
12
- },
13
- searchStr: {
14
- type: String,
15
- default: ""
16
- },
17
- type: {
18
- type: String,
19
- default: ""
20
- }
21
- },
22
- setup(__props) {
23
- const API = headRequest(inject("request"));
24
- const { triggerReport } = useReportRepo({ moduleName: REPO_MODULE.SEARCH_SUGGESTION_CARD }, API.viewReport);
25
- const useReport = inject("useReport");
26
- const handleReport = (item) => {
27
- useReport(REPO_EVENT.CLICK, { module_name: REPO_MODULE.SEARCH_SUGGESTION_CARD, repo_id: item.id });
28
- };
29
- return (_ctx, _cache) => {
30
- return openBlock(true), createElementBlock(Fragment, null, renderList(__props.dataList, (item, index) => {
31
- return withDirectives((openBlock(), createBlock(SearchRepoCard, {
32
- key: `${item.searchType || __props.type}-${item.id}`,
33
- class: "search-repo-list-card",
34
- info: { ...item, index },
35
- keyword: __props.searchStr,
36
- hover: "",
37
- hideTopicTags: "",
38
- hideStarBtn: "",
39
- hideFooter: "",
40
- hideDescription: "",
41
- onReport: () => handleReport(item),
42
- cardType: item.searchType || __props.type,
43
- "url-params": { source_module: "search_project" }
44
- }, null, 8, ["info", "keyword", "onReport", "cardType"])), [
45
- [unref(vElementExposure), { trigger: (type) => unref(triggerReport)(type, item) }]
46
- ]);
47
- }), 128);
48
- };
49
- }
50
- });
51
- const SearchRepoCardList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-vue-layout-gitcode"]]);
52
- const normalizeOrigin = (origin) => origin.replace(/\/+$/, "");
53
- const convertDataList = (dataList, searchType, origin) => {
54
- if (!Array.isArray(dataList)) {
55
- return [];
56
- }
57
- const baseOrigin = normalizeOrigin(origin);
58
- return dataList.slice(0, 3).filter((item) => Boolean(item) && typeof item === "object").map((item) => {
59
- const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
60
- const importedRepoName = item.import_url ? extractRepoInfoWithURL(item.import_url) : "";
61
- const repoName = (isGitcodeRepo ? item.name_with_namespace : importedRepoName) || item.name_with_namespace || item.path_with_namespace || "";
62
- const displayName = formatNameSpace(repoName).join("/");
63
- const path = `${baseOrigin}/${item.path_with_namespace || ""}`;
64
- return {
65
- ...item,
66
- searchType,
67
- path,
68
- displayName,
69
- web_url: path
70
- };
71
- });
72
- };
73
- const mergeSearchSuggestions = (response = {}, origin) => [
74
- ...convertDataList(response.recommend_project, "repo", origin),
75
- ...convertDataList(response.recommend_model, "model", origin),
76
- ...convertDataList(response.recommend_dataset, "dataset", origin)
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(res.data || {}, origin);
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
- };