vue-layout-gitcode 1.3.22 → 1.3.24

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,216 +0,0 @@
1
- import { defineComponent, inject, createElementBlock, openBlock, Fragment, createElementVNode, toDisplayString, createVNode, unref, renderList, withDirectives, createBlock, ref, watch, onMounted, createCommentVNode } from "vue";
2
- import "vue-devui-lal/icon";
3
- import "vue-devui-lal/icon/style.css";
4
- import { h as headRequest, R as REPO_MODULE, a as i18n, G as GIcon, b as REPO_EVENT, _ as _export_sfc, c as REPO_TYPE, e as extractRepoInfoWithURL } from "./index-CqAiepjz.js";
5
- import { u as useReportRepo, S as SearchRepoCard, f as formatNameSpace } from "./index-CHIT0RIe.js";
6
- import "vue-devui-lal/tooltip";
7
- import "vue-devui-lal/tooltip/style.css";
8
- import "vue-router";
9
- import "vue-devui-lal/grid";
10
- import "vue-devui-lal/skeleton";
11
- import "vue-devui-lal/grid/style.css";
12
- import "vue-devui-lal/skeleton/style.css";
13
- import "@vueuse/core";
14
- const vElementExposure = {
15
- mounted(el, binding) {
16
- let observer = new IntersectionObserver(function(entries, observer2) {
17
- entries.forEach(function(entry) {
18
- var _a;
19
- if (entry.isIntersecting) {
20
- (_a = binding.value) == null ? void 0 : _a.trigger("expo");
21
- observer2.unobserve(entry.target);
22
- }
23
- });
24
- }, { threshold: 0 });
25
- observer.observe(el);
26
- },
27
- beforeUnmount() {
28
- }
29
- };
30
- const _hoisted_1$1 = { class: "mb-[4px] mt-[16px] flex justify-between" };
31
- const _hoisted_2$1 = { class: "title" };
32
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
33
- __name: "SearchRepoCardList",
34
- props: {
35
- dataList: {
36
- type: Array,
37
- default: () => []
38
- },
39
- searchStr: {
40
- type: String,
41
- default: ""
42
- },
43
- type: {
44
- type: String,
45
- default: ""
46
- },
47
- name: {
48
- type: String,
49
- default: ""
50
- }
51
- },
52
- emits: ["report"],
53
- setup(__props, { emit: __emit }) {
54
- const API = headRequest(inject("request"));
55
- const { triggerReport } = useReportRepo({ moduleName: REPO_MODULE.SEARCH_SUGGESTION_CARD }, API.viewReport);
56
- const { t: $t } = i18n.global;
57
- const useReport = inject("useReport");
58
- const emits = __emit;
59
- const handleReport = (item) => {
60
- useReport(REPO_EVENT.CLICK, { module_name: REPO_MODULE.SEARCH_SUGGESTION_CARD, repo_id: item.id });
61
- };
62
- const handleMore = () => {
63
- emits("more");
64
- };
65
- return (_ctx, _cache) => {
66
- return openBlock(), createElementBlock(Fragment, null, [
67
- createElementVNode("div", _hoisted_1$1, [
68
- createElementVNode("p", _hoisted_2$1, toDisplayString(__props.name), 1),
69
- createElementVNode("a", {
70
- class: "more-btn",
71
- onClick: handleMore
72
- }, [
73
- createElementVNode("span", null, toDisplayString(unref($t)("gitCodeLayout.common.more")), 1),
74
- createVNode(GIcon, {
75
- name: "gt-line-right",
76
- color: "var(--theme-placeholder)"
77
- })
78
- ])
79
- ]),
80
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.dataList, (item, index) => {
81
- return withDirectives((openBlock(), createBlock(SearchRepoCard, {
82
- key: item.id,
83
- class: "mb-[8px]",
84
- info: { ...item, index },
85
- keyword: __props.searchStr,
86
- hover: "",
87
- hideTopicTags: "",
88
- hideStarBtn: "",
89
- hideFooter: "",
90
- hideDescription: "",
91
- onReport: () => handleReport(item),
92
- cardType: __props.type,
93
- "url-params": { source_module: "search_project" }
94
- }, null, 8, ["info", "keyword", "onReport", "cardType"])), [
95
- [unref(vElementExposure), { trigger: (type) => unref(triggerReport)(type, item) }]
96
- ]);
97
- }), 128))
98
- ], 64);
99
- };
100
- }
101
- });
102
- const SearchRepoCardList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-gitcode-layout-lib"]]);
103
- const _hoisted_1 = {
104
- key: 0,
105
- class: "px-[8px] history-list-project pl-[8px]"
106
- };
107
- const _hoisted_2 = {
108
- key: 1,
109
- class: "px-[8px] history-list-project pl-[8px]"
110
- };
111
- const _hoisted_3 = {
112
- key: 2,
113
- class: "px-[8px] history-list-project pl-[8px]"
114
- };
115
- const _sfc_main = {
116
- __name: "GloabarSearch",
117
- props: ["searchStr"],
118
- emits: ["searchMore"],
119
- setup(__props, { emit: __emit }) {
120
- const emits = __emit;
121
- const { t: $t } = i18n.global;
122
- const API = headRequest(inject("request"));
123
- const useReport = inject("useReport");
124
- const projectList = ref([]);
125
- const datasetList = ref([]);
126
- const modelList = ref([]);
127
- const origin = window.location.origin;
128
- const props = __props;
129
- let timer = null;
130
- const convertDataList = (dataList) => {
131
- return dataList == null ? void 0 : dataList.slice(0, 5).map((item) => {
132
- const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
133
- const repoName = (!isGitcodeRepo ? extractRepoInfoWithURL(item.import_url) : item.name_with_namespace) || item.name_with_namespace;
134
- const displayName = formatNameSpace(repoName).join("/");
135
- return {
136
- ...item,
137
- path: `${origin}/${item.path_with_namespace}`,
138
- displayName,
139
- web_url: `${origin}/${item.path_with_namespace}`
140
- };
141
- });
142
- };
143
- const handleMore = (type) => {
144
- emits("searchMore", type);
145
- };
146
- const getData = async () => {
147
- if (!props.searchStr) {
148
- return;
149
- }
150
- try {
151
- useReport("search-project", {});
152
- const res = await API.getGloabarSearchKeyLink({ q: props.searchStr });
153
- const { recommend_project = [], recommend_model = [], recommend_dataset = [] } = res.data || {};
154
- projectList.value = convertDataList(recommend_project);
155
- modelList.value = convertDataList(recommend_model);
156
- datasetList.value = convertDataList(recommend_dataset);
157
- } catch (error) {
158
- console.error("Failed to fetch search results:", error);
159
- projectList.value = [];
160
- modelList.value = [];
161
- datasetList.value = [];
162
- }
163
- };
164
- if (props.searchStr) {
165
- getData();
166
- }
167
- watch(
168
- () => props.searchStr,
169
- () => {
170
- if (timer) {
171
- clearTimeout(timer);
172
- }
173
- timer = setTimeout(() => {
174
- getData();
175
- }, 300);
176
- }
177
- );
178
- onMounted(() => {
179
- console.log("GloabarSearch");
180
- });
181
- return (_ctx, _cache) => {
182
- return openBlock(), createElementBlock(Fragment, null, [
183
- projectList.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
184
- createVNode(SearchRepoCardList, {
185
- "data-list": projectList.value,
186
- "search-str": __props.searchStr,
187
- name: unref($t)("gitCodeLayout.header.repo"),
188
- type: "repo",
189
- onMore: _cache[0] || (_cache[0] = () => handleMore("repo"))
190
- }, null, 8, ["data-list", "search-str", "name"])
191
- ])) : createCommentVNode("", true),
192
- modelList.value.length ? (openBlock(), createElementBlock("div", _hoisted_2, [
193
- createVNode(SearchRepoCardList, {
194
- "data-list": modelList.value,
195
- "search-str": __props.searchStr,
196
- name: unref($t)("gitCodeLayout.aihub.model"),
197
- type: "model",
198
- onMore: _cache[1] || (_cache[1] = () => handleMore("model"))
199
- }, null, 8, ["data-list", "search-str", "name"])
200
- ])) : createCommentVNode("", true),
201
- datasetList.value.length ? (openBlock(), createElementBlock("div", _hoisted_3, [
202
- createVNode(SearchRepoCardList, {
203
- "data-list": datasetList.value,
204
- "search-str": __props.searchStr,
205
- name: unref($t)("gitCodeLayout.aihub.dataSet"),
206
- type: "dataset",
207
- onMore: _cache[2] || (_cache[2] = () => handleMore("dataset"))
208
- }, null, 8, ["data-list", "search-str", "name"])
209
- ])) : createCommentVNode("", true)
210
- ], 64);
211
- };
212
- }
213
- };
214
- export {
215
- _sfc_main as default
216
- };