vue-layout-gitcode 1.12.35 → 1.12.36

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 { y as useLayoutConfig } from "./index-Cx67TeFL.js";
1
+ import { z as useLayoutConfig } from "./index-BOa97Aot.js";
2
2
  const layoutConfig = useLayoutConfig();
3
3
  const transWebUrl = (url, params) => {
4
4
  if (!url) return url;
@@ -1,7 +1,6 @@
1
- import { ref, watchEffect, defineComponent, toDisplayString, unref, mergeModels, useModel, watch, createElementBlock, openBlock, createVNode, withDirectives, normalizeClass, createElementVNode, vShow, inject, withModifiers, createBlock, Fragment, computed, createCommentVNode, normalizeStyle, createTextVNode, onMounted, onUnmounted, renderList, withCtx, reactive } from "vue";
2
- import debounce from "lodash/debounce";
3
- import { d as transferNumber, G as GIcon, _ as _export_sfc, s as setLoginTriggerSource, f as useRequestReport, r as reqCatch, h as headRequest, a as i18n, T as TOPIC_TYPE, g as useTimeFormat, j as useCookie, k as usePageResize, L as LANG_ZH, m as isGstarRepo, n as _sfc_main$b, o as isIncubationRepo, p as highlightWords, t as transformUrl, q as _frEventTrack, E as EVENT_NAME, c as REPO_TYPE, e as extractRepoInfoWithURL, w as LANG_KEY } from "./index-Cx67TeFL.js";
4
- import { t as transWebUrl } from "./transWebUrl-ChZBJdJ1.js";
1
+ import { defineComponent, toDisplayString, unref, mergeModels, useModel, ref, watch, createElementBlock, openBlock, createVNode, withDirectives, normalizeClass, createElementVNode, vShow, inject, withModifiers, createBlock, Fragment, computed, createCommentVNode, normalizeStyle, createTextVNode, renderList, withCtx, reactive, onMounted, watchEffect } from "vue";
2
+ import { d as transferNumber, G as GIcon, _ as _export_sfc, s as setLoginTriggerSource, f as useRequestReport, r as reqCatch, h as headRequest, a as i18n, T as TOPIC_TYPE, g as useTimeFormat, j as useCookie, k as usePageResize, L as LANG_ZH, m as isGstarRepo, o as _sfc_main$b, p as isIncubationRepo, q as highlightWords, t as transformUrl, w as _frEventTrack, E as EVENT_NAME, c as REPO_TYPE, e as extractRepoInfoWithURL, x as LANG_KEY } from "./index-BOa97Aot.js";
3
+ import { t as transWebUrl } from "./transWebUrl-BjEWcV7K.js";
5
4
  import { useRouter } from "vue-router";
6
5
  import { Row, Col } from "vue-devui-lal/grid";
7
6
  import { Skeleton, SkeletonItem } from "vue-devui-lal/skeleton";
@@ -9,74 +8,7 @@ import "vue-devui-lal/grid/style.css";
9
8
  import "vue-devui-lal/skeleton/style.css";
10
9
  import { Popover } from "vue-devui-lal/popover";
11
10
  import "vue-devui-lal/popover/style.css";
12
- const useReportRepo = (reportParams, viewReport) => {
13
- const list = ref([]);
14
- const pageRef = ref((window == null ? void 0 : window.page_ref) || "");
15
- const locationHref = ref((window == null ? void 0 : window.location.href) || "");
16
- const keyword = ref(reportParams == null ? void 0 : reportParams.keyword);
17
- const moduleName = ref(reportParams == null ? void 0 : reportParams.moduleName);
18
- const triggerReport = (type, data) => {
19
- if (type === "click") {
20
- const params = {
21
- chat_title: "",
22
- related: {
23
- list: [formatItem(data)],
24
- type: "repo"
25
- }
26
- };
27
- viewReport(pageRef.value, locationHref.value, "click", params);
28
- } else if (type === "expo") {
29
- list.value.push(data);
30
- }
31
- };
32
- const formatItem = (data) => {
33
- const channelNames = [];
34
- if (data.channelName) channelNames.push(data.channelName);
35
- if (data.subChannelName) channelNames.push(data.subChannelName);
36
- const repoId = isNaN(Number(data.id)) ? data.id : Number(data.id);
37
- return {
38
- type: "gitcode",
39
- repo_id: repoId,
40
- dest_url: data.web_url,
41
- strategy: channelNames.join("、") || "",
42
- // 官方项目
43
- repo_index: data.index,
44
- page: data.pageIndex || data.p || 0,
45
- per_page: data.pageSize || data.pp || 0,
46
- q: data.keyword || ""
47
- };
48
- };
49
- const doReport = debounce(() => {
50
- if (list.value.length >= 1) {
51
- const reportList = list.value.splice(0).map((item) => {
52
- return formatItem(item);
53
- });
54
- const params = {
55
- chat_title: "",
56
- extend_json: {
57
- key_words: keyword.value,
58
- module_name: moduleName.value
59
- },
60
- related: {
61
- list: reportList,
62
- type: "repo"
63
- }
64
- };
65
- viewReport(pageRef.value, locationHref.value, "expo", params);
66
- }
67
- }, 500, { leading: false });
68
- watchEffect(() => {
69
- if (list.value.length) {
70
- doReport();
71
- }
72
- });
73
- return {
74
- triggerReport
75
- };
76
- };
77
- const formatNameSpace = (content) => {
78
- return content.trim().replace(/\s+/g, "").replace(/^(GitHub加速计划\/|HuggingFace镜像\/)/, "").split("/").filter(Boolean);
79
- };
11
+ import debounce from "lodash/debounce";
80
12
  const _sfc_main$a = /* @__PURE__ */ defineComponent({
81
13
  __name: "index",
82
14
  props: {
@@ -290,7 +222,7 @@ const ForkTag = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-
290
222
  const _sfc_main$6 = /* @__PURE__ */ defineComponent({
291
223
  __name: "index",
292
224
  props: {
293
- tagInfo: { default: [] },
225
+ tagInfo: { default: () => [] },
294
226
  type: {}
295
227
  },
296
228
  setup(__props) {
@@ -298,15 +230,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
298
230
  const isTag = computed(() => props.type === "tag");
299
231
  const languageTag = props.tagInfo[0] || "";
300
232
  const tagColor = props.tagInfo[1] || "#00ADD8";
301
- computed(() => {
302
- if (isTag.value) {
303
- return {
304
- background: tagColor,
305
- opacity: 0.1
306
- };
307
- }
308
- return {};
309
- });
310
233
  const tagFontColor = computed(() => {
311
234
  if (isTag.value) {
312
235
  return { color: tagColor };
@@ -408,12 +331,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
408
331
  __name: "index",
409
332
  props: {
410
333
  repoInfo: {},
411
- hideTopicTags: { type: Boolean },
412
- tagInfo: {},
413
- hideUpdateTime: { type: Boolean },
414
- hideStarIncrease: { type: Boolean },
415
- hideStarCount: { type: Boolean },
416
- searchCard: { type: Boolean }
334
+ hideTopicTags: { type: Boolean, default: false },
335
+ tagInfo: { default: () => [] },
336
+ hideUpdateTime: { type: Boolean, default: false },
337
+ hideStarIncrease: { type: Boolean, default: false },
338
+ hideStarCount: { type: Boolean, default: false },
339
+ searchCard: { type: Boolean, default: false }
417
340
  },
418
341
  emits: ["topicClick"],
419
342
  setup(__props, { emit: __emit }) {
@@ -425,22 +348,12 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
425
348
  var _a;
426
349
  return ((_a = props.repoInfo.tags) == null ? void 0 : _a.filter((item) => item.type === TOPIC_TYPE.USER)) || [];
427
350
  });
428
- ref(topicNames.value);
429
- const visibleCount = ref(0);
430
- ref(false);
431
351
  const showUpdateTimeDot = computed(() => {
432
352
  return !props.hideUpdateTime && (!props.hideStarCount || props.tagInfo && props.tagInfo[0] || props.repoInfo.forks_count);
433
353
  });
434
- computed(() => {
435
- return topicNames.value.length - visibleCount.value + 1;
436
- });
437
354
  const handleTopicClick = (topic) => {
438
355
  emits("topicClick", topic);
439
356
  };
440
- onMounted(() => {
441
- });
442
- onUnmounted(() => {
443
- });
444
357
  return (_ctx, _cache) => {
445
358
  return openBlock(), createElementBlock(Fragment, null, [
446
359
  createElementVNode("div", null, [
@@ -489,6 +402,9 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
489
402
  }
490
403
  });
491
404
  const RepoCardFooter = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-vue-layout-gitcode"]]);
405
+ const formatNameSpace = (content) => {
406
+ return content.trim().replace(/\s+/g, "").replace(/^(GitHub加速计划\/|HuggingFace镜像\/)/, "").split("/").filter(Boolean);
407
+ };
492
408
  const _hoisted_1$2 = { class: "new-tag-content" };
493
409
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
494
410
  __name: "index",
@@ -623,18 +539,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
623
539
  info: {},
624
540
  keyword: {},
625
541
  cardType: {},
626
- noborder: { type: Boolean },
627
- hover: { type: Boolean },
628
- hideTopicTags: { type: Boolean },
629
- urlParams: {},
630
- hideStarBtn: { type: Boolean },
631
- hideFooter: { type: Boolean },
632
- hideDescription: { type: Boolean }
542
+ noborder: { type: Boolean, default: false },
543
+ hover: { type: Boolean, default: false },
544
+ hideTopicTags: { type: Boolean, default: false },
545
+ urlParams: { default: () => ({}) },
546
+ hideStarBtn: { type: Boolean, default: false },
547
+ hideFooter: { type: Boolean, default: false },
548
+ hideDescription: { type: Boolean, default: false }
633
549
  },
634
550
  emits: ["report"],
635
551
  setup(__props, { emit: __emit }) {
636
552
  const lang = useCookie(LANG_KEY, LANG_ZH);
637
- const API = headRequest(inject("request"));
553
+ const request = inject("request") || (() => Promise.resolve({ data: {} }));
554
+ const API = headRequest(request);
638
555
  const emits = __emit;
639
556
  const router = useRouter();
640
557
  const { widthType } = usePageResize();
@@ -648,7 +565,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
648
565
  emits("report", "starReport");
649
566
  };
650
567
  const rowSpan = reactive({ xxl: 8, xl: 12, md: 12, lg: 24, sm: 24 });
651
- const repoIcon = { repo: "gt-line-repositories", model: "gt-plane-models", dataset: "gt-line-Datasets" };
568
+ const repoIcon = { repo: "gt-line-repositories", model: "gt-line-line-Models", dataset: "gt-line-Datasets" };
652
569
  const props = __props;
653
570
  console.log("i-search-projects-card", props.info, props.cardType);
654
571
  const iconName = computed(() => {
@@ -701,7 +618,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
701
618
  name_with_namespace: nameWithSpace,
702
619
  path_with_namespace: path,
703
620
  import_url: importUrl,
704
- is_gh_mirrors: isGhMirrors,
705
621
  is_mirrors: isMirrors
706
622
  } = info || {};
707
623
  const isGitcodeRepo = REPO_TYPE.GITCODE === isMirrors;
@@ -831,7 +747,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
831
747
  ]),
832
748
  _: 1
833
749
  })) : createCommentVNode("", true)
834
- ])) : isModel.value ? (openBlock(), createBlock(ModelCardFooter, {
750
+ ])) : isModel.value && !_ctx.hideFooter ? (openBlock(), createBlock(ModelCardFooter, {
835
751
  key: 2,
836
752
  repoInfo: _ctx.info
837
753
  }, null, 8, ["repoInfo"])) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
@@ -851,6 +767,71 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
851
767
  }
852
768
  });
853
769
  const SearchRepoCard = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-vue-layout-gitcode"]]);
770
+ const useReportRepo = (reportParams, viewReport) => {
771
+ const list = ref([]);
772
+ const pageRef = ref((window == null ? void 0 : window.page_ref) || "");
773
+ const locationHref = ref((window == null ? void 0 : window.location.href) || "");
774
+ const keyword = ref(reportParams == null ? void 0 : reportParams.keyword);
775
+ const moduleName = ref(reportParams == null ? void 0 : reportParams.moduleName);
776
+ const triggerReport = (type, data) => {
777
+ if (type === "click") {
778
+ const params = {
779
+ chat_title: "",
780
+ related: {
781
+ list: [formatItem(data)],
782
+ type: "repo"
783
+ }
784
+ };
785
+ viewReport(pageRef.value, locationHref.value, "click", params);
786
+ } else if (type === "expo") {
787
+ list.value.push(data);
788
+ }
789
+ };
790
+ const formatItem = (data) => {
791
+ const channelNames = [];
792
+ if (data.channelName) channelNames.push(data.channelName);
793
+ if (data.subChannelName) channelNames.push(data.subChannelName);
794
+ const repoId = isNaN(Number(data.id)) ? data.id : Number(data.id);
795
+ return {
796
+ type: "gitcode",
797
+ repo_id: repoId,
798
+ dest_url: data.web_url,
799
+ strategy: channelNames.join("、") || "",
800
+ // 官方项目
801
+ repo_index: data.index,
802
+ page: data.pageIndex || data.p || 0,
803
+ per_page: data.pageSize || data.pp || 0,
804
+ q: data.keyword || ""
805
+ };
806
+ };
807
+ const doReport = debounce(() => {
808
+ if (list.value.length >= 1) {
809
+ const reportList = list.value.splice(0).map((item) => {
810
+ return formatItem(item);
811
+ });
812
+ const params = {
813
+ chat_title: "",
814
+ extend_json: {
815
+ key_words: keyword.value,
816
+ module_name: moduleName.value
817
+ },
818
+ related: {
819
+ list: reportList,
820
+ type: "repo"
821
+ }
822
+ };
823
+ viewReport(pageRef.value, locationHref.value, "expo", params);
824
+ }
825
+ }, 500, { leading: false });
826
+ watchEffect(() => {
827
+ if (list.value.length) {
828
+ doReport();
829
+ }
830
+ });
831
+ return {
832
+ triggerReport
833
+ };
834
+ };
854
835
  export {
855
836
  SearchRepoCard as S,
856
837
  formatNameSpace as f,
@@ -1,202 +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, v as vElementExposure, b as REPO_EVENT, _ as _export_sfc, c as REPO_TYPE, e as extractRepoInfoWithURL } from "./index-Cx67TeFL.js";
5
- import "lodash/debounce";
6
- import { u as useReportRepo, S as SearchRepoCard, f as formatNameSpace } from "./index-BsyIPSbg.js";
7
- import "./transWebUrl-ChZBJdJ1.js";
8
- import "vue-devui-lal/tooltip";
9
- import "vue-devui-lal/tooltip/style.css";
10
- import "vue-router";
11
- import "vue-devui-lal/grid";
12
- import "vue-devui-lal/skeleton";
13
- import "vue-devui-lal/grid/style.css";
14
- import "vue-devui-lal/skeleton/style.css";
15
- import "vue-devui-lal/popover";
16
- import "vue-devui-lal/popover/style.css";
17
- const _hoisted_1$1 = { class: "search-repo-list-header" };
18
- const _hoisted_2$1 = { class: "title" };
19
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
20
- __name: "SearchRepoCardList",
21
- props: {
22
- dataList: {
23
- type: Array,
24
- default: () => []
25
- },
26
- searchStr: {
27
- type: String,
28
- default: ""
29
- },
30
- type: {
31
- type: String,
32
- default: ""
33
- },
34
- name: {
35
- type: String,
36
- default: ""
37
- }
38
- },
39
- emits: ["report"],
40
- setup(__props, { emit: __emit }) {
41
- const API = headRequest(inject("request"));
42
- const { triggerReport } = useReportRepo({ moduleName: REPO_MODULE.SEARCH_SUGGESTION_CARD }, API.viewReport);
43
- const { t: $t } = i18n.global;
44
- const useReport = inject("useReport");
45
- const emits = __emit;
46
- const handleReport = (item) => {
47
- useReport(REPO_EVENT.CLICK, { module_name: REPO_MODULE.SEARCH_SUGGESTION_CARD, repo_id: item.id });
48
- };
49
- const handleMore = () => {
50
- emits("more");
51
- };
52
- return (_ctx, _cache) => {
53
- return openBlock(), createElementBlock(Fragment, null, [
54
- createElementVNode("div", _hoisted_1$1, [
55
- createElementVNode("p", _hoisted_2$1, toDisplayString(__props.name), 1),
56
- createElementVNode("a", {
57
- class: "more-btn",
58
- onClick: handleMore
59
- }, [
60
- createElementVNode("span", null, toDisplayString(unref($t)("gitCodeLayout.common.more")), 1),
61
- createVNode(GIcon, {
62
- name: "gt-line-right",
63
- color: "var(--theme-placeholder)"
64
- })
65
- ])
66
- ]),
67
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.dataList, (item, index) => {
68
- return withDirectives((openBlock(), createBlock(SearchRepoCard, {
69
- key: item.id,
70
- class: "search-repo-list-card",
71
- info: { ...item, index },
72
- keyword: __props.searchStr,
73
- hover: "",
74
- hideTopicTags: "",
75
- hideStarBtn: "",
76
- hideFooter: "",
77
- hideDescription: "",
78
- onReport: () => handleReport(item),
79
- cardType: __props.type,
80
- "url-params": { source_module: "search_project" }
81
- }, null, 8, ["info", "keyword", "onReport", "cardType"])), [
82
- [unref(vElementExposure), { trigger: (type) => unref(triggerReport)(type, item) }]
83
- ]);
84
- }), 128))
85
- ], 64);
86
- };
87
- }
88
- });
89
- const SearchRepoCardList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-vue-layout-gitcode"]]);
90
- const _hoisted_1 = {
91
- key: 0,
92
- class: "history-list-project history-list-project--padded"
93
- };
94
- const _hoisted_2 = {
95
- key: 1,
96
- class: "history-list-project history-list-project--padded"
97
- };
98
- const _hoisted_3 = {
99
- key: 2,
100
- class: "history-list-project history-list-project--padded"
101
- };
102
- const _sfc_main = {
103
- __name: "GloabarSearch",
104
- props: ["searchStr"],
105
- emits: ["searchMore"],
106
- setup(__props, { emit: __emit }) {
107
- const emits = __emit;
108
- const { t: $t } = i18n.global;
109
- const API = headRequest(inject("request"));
110
- const useReport = inject("useReport");
111
- const projectList = ref([]);
112
- const datasetList = ref([]);
113
- const modelList = ref([]);
114
- const origin = window.location.origin;
115
- const props = __props;
116
- let timer = null;
117
- const convertDataList = (dataList) => {
118
- return dataList == null ? void 0 : dataList.slice(0, 5).map((item) => {
119
- const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
120
- const repoName = (!isGitcodeRepo ? extractRepoInfoWithURL(item.import_url) : item.name_with_namespace) || item.name_with_namespace;
121
- const displayName = formatNameSpace(repoName).join("/");
122
- return {
123
- ...item,
124
- path: `${origin}/${item.path_with_namespace}`,
125
- displayName,
126
- web_url: `${origin}/${item.path_with_namespace}`
127
- };
128
- });
129
- };
130
- const handleMore = (type) => {
131
- emits("searchMore", type);
132
- };
133
- const getData = async () => {
134
- if (!props.searchStr) {
135
- return;
136
- }
137
- try {
138
- useReport("search-project", {});
139
- const res = await API.getGloabarSearchKeyLink({ q: props.searchStr });
140
- const { recommend_project = [], recommend_model = [], recommend_dataset = [] } = res.data || {};
141
- projectList.value = convertDataList(recommend_project);
142
- modelList.value = convertDataList(recommend_model);
143
- datasetList.value = convertDataList(recommend_dataset);
144
- } catch (error) {
145
- console.error("Failed to fetch search results:", error);
146
- projectList.value = [];
147
- modelList.value = [];
148
- datasetList.value = [];
149
- }
150
- };
151
- if (props.searchStr) {
152
- getData();
153
- }
154
- watch(
155
- () => props.searchStr,
156
- () => {
157
- if (timer) {
158
- clearTimeout(timer);
159
- }
160
- timer = setTimeout(() => {
161
- getData();
162
- }, 300);
163
- }
164
- );
165
- onMounted(() => {
166
- });
167
- return (_ctx, _cache) => {
168
- return openBlock(), createElementBlock(Fragment, null, [
169
- projectList.value.length ? (openBlock(), createElementBlock("div", _hoisted_1, [
170
- createVNode(SearchRepoCardList, {
171
- "data-list": projectList.value,
172
- "search-str": __props.searchStr,
173
- name: unref($t)("gitCodeLayout.header.repo"),
174
- type: "repo",
175
- onMore: _cache[0] || (_cache[0] = () => handleMore("repo"))
176
- }, null, 8, ["data-list", "search-str", "name"])
177
- ])) : createCommentVNode("", true),
178
- modelList.value.length ? (openBlock(), createElementBlock("div", _hoisted_2, [
179
- createVNode(SearchRepoCardList, {
180
- "data-list": modelList.value,
181
- "search-str": __props.searchStr,
182
- name: unref($t)("gitCodeLayout.aihub.model"),
183
- type: "model",
184
- onMore: _cache[1] || (_cache[1] = () => handleMore("model"))
185
- }, null, 8, ["data-list", "search-str", "name"])
186
- ])) : createCommentVNode("", true),
187
- datasetList.value.length ? (openBlock(), createElementBlock("div", _hoisted_3, [
188
- createVNode(SearchRepoCardList, {
189
- "data-list": datasetList.value,
190
- "search-str": __props.searchStr,
191
- name: unref($t)("gitCodeLayout.aihub.dataSet"),
192
- type: "dataset",
193
- onMore: _cache[2] || (_cache[2] = () => handleMore("dataset"))
194
- }, null, 8, ["data-list", "search-str", "name"])
195
- ])) : createCommentVNode("", true)
196
- ], 64);
197
- };
198
- }
199
- };
200
- export {
201
- _sfc_main as default
202
- };