vue-layout-gitcode 1.12.43 → 1.12.44

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a3, $, a1, U, V, X, a6, a8, a0, Y, Z, Q, S, W, a2, P, C, a9, a5, a7, a4 } from "./index-M2ZGt9xA.js";
1
+ import { a3, $, a1, U, V, X, a6, a8, a0, Y, Z, Q, S, W, a2, P, C, a9, a5, a7, a4 } from "./index-DiN4g4by.js";
2
2
  export {
3
3
  a3 as AsideFooterTools,
4
4
  $ as AtomCodeLauncher,
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, createBlock, openBlock, unref, isRef, withCtx, createElementVNode, normalizeClass, createVNode, createTextVNode } from "vue";
2
- import { i as isPhone, u as useModel, _ as _export_sfc } from "./index-M2ZGt9xA.js";
2
+ import { i as isPhone, u as useModel, _ as _export_sfc } from "./index-DiN4g4by.js";
3
3
  import { Notification } from "vue-devui-lal/notification";
4
4
  import { Button } from "vue-devui-lal/button";
5
5
  import "vue-devui-lal/notification/style.css";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-layout-gitcode",
3
- "version": "1.12.43",
3
+ "version": "1.12.44",
4
4
  "description": "用于 gitcode 站点生产环境使用",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
@@ -1,6 +1,6 @@
1
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-M2ZGt9xA.js";
3
- import { t as transWebUrl } from "./transWebUrl-DJX4eAMa.js";
2
+ import { d as transferNumber, G as GIcon, _ as _export_sfc, s as setLoginTriggerSource, e as useRequestReport, r as reqCatch, h as headRequest, a as i18n, T as TOPIC_TYPE, f as useTimeFormat, g as useCookie, j as usePageResize, L as LANG_ZH, k as isGstarRepo, m as _sfc_main$b, o as isIncubationRepo, p as highlightWords, t as transformUrl, q as _frEventTrack, E as EVENT_NAME, w as REPO_TYPE, x as extractRepoInfoWithURL, y as LANG_KEY } from "./index-DiN4g4by.js";
3
+ import { t as transWebUrl } from "./transWebUrl-DPYJWnMX.js";
4
4
  import { useRouter } from "vue-router";
5
5
  import { Row, Col } from "vue-devui-lal/grid";
6
6
  import { Skeleton, SkeletonItem } from "vue-devui-lal/skeleton";
@@ -543,6 +543,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
543
543
  hover: { type: Boolean, default: false },
544
544
  hideTopicTags: { type: Boolean, default: false },
545
545
  urlParams: { default: () => ({}) },
546
+ preserveUrlOrigin: { type: Boolean, default: false },
546
547
  hideStarBtn: { type: Boolean, default: false },
547
548
  hideFooter: { type: Boolean, default: false },
548
549
  hideDescription: { type: Boolean, default: false }
@@ -557,7 +558,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
557
558
  const { widthType } = usePageResize();
558
559
  const { t: $t } = i18n.global;
559
560
  const handleClick = () => {
560
- window.open(transWebUrl(transformUrl(props.info.web_url), props.urlParams), "_blank");
561
+ window.open(transWebUrl(transformUrl(props.info.web_url), props.urlParams, {
562
+ preserveOrigin: props.preserveUrlOrigin
563
+ }), "_blank");
561
564
  emits("report");
562
565
  _frEventTrack(EVENT_NAME.CLICK_SEARCH_RESULT);
563
566
  };
@@ -832,8 +835,75 @@ const useReportRepo = (reportParams, viewReport) => {
832
835
  triggerReport
833
836
  };
834
837
  };
838
+ const normalizeOrigin = (origin) => {
839
+ const value = origin.trim().replace(/\/+$/, "");
840
+ if (!value) return "";
841
+ try {
842
+ const url = new URL(/^[a-z][a-z\d+.-]*:\/\//i.test(value) ? value : `https://${value}`);
843
+ return url.origin;
844
+ } catch {
845
+ return value;
846
+ }
847
+ };
848
+ const getStringValue = (value) => typeof value === "string" ? value : "";
849
+ const normalizeProjectUrlForMainSite = (value, projectOrigin, currentOrigin) => {
850
+ const urlValue = getStringValue(value).trim();
851
+ if (!urlValue) return urlValue;
852
+ const mainOrigin = normalizeOrigin(projectOrigin) || normalizeOrigin(currentOrigin);
853
+ if (!mainOrigin) return urlValue;
854
+ try {
855
+ const mainSiteUrl = new URL(mainOrigin);
856
+ const projectUrl = new URL(urlValue, `${mainSiteUrl.origin}/`);
857
+ if (projectUrl.protocol !== "http:" && projectUrl.protocol !== "https:") return urlValue;
858
+ projectUrl.protocol = mainSiteUrl.protocol;
859
+ projectUrl.host = mainSiteUrl.host;
860
+ projectUrl.username = "";
861
+ projectUrl.password = "";
862
+ return projectUrl.toString();
863
+ } catch {
864
+ return urlValue;
865
+ }
866
+ };
867
+ const isProjectSuggestionType = (repoType) => {
868
+ if (repoType === void 0 || repoType === null || repoType === "") return true;
869
+ const normalizedType = String(repoType).trim().toLowerCase();
870
+ return !normalizedType || ["repo", "repository", "project", "0"].includes(normalizedType);
871
+ };
872
+ const convertDataList = ({ dataList, searchType, origin }) => {
873
+ if (!Array.isArray(dataList)) {
874
+ return { items: [] };
875
+ }
876
+ const baseOrigin = normalizeOrigin(origin);
877
+ const items = dataList.slice(0, 3).filter((item) => Boolean(item) && typeof item === "object" && !Array.isArray(item)).map((item) => {
878
+ const isGitcodeRepo = REPO_TYPE.GITCODE === item.is_mirrors;
879
+ const importUrl = getStringValue(item.import_url);
880
+ const importedRepoName = importUrl ? extractRepoInfoWithURL(importUrl) : "";
881
+ const nameWithNamespace = getStringValue(item.name_with_namespace);
882
+ const pathWithNamespace = getStringValue(item.path_with_namespace);
883
+ const repoName = (isGitcodeRepo ? nameWithNamespace : importedRepoName) || nameWithNamespace || pathWithNamespace;
884
+ const displayName = formatNameSpace(repoName).join("/");
885
+ const path = `${baseOrigin}/${pathWithNamespace}`;
886
+ return {
887
+ ...item,
888
+ searchType,
889
+ path,
890
+ displayName,
891
+ web_url: path
892
+ };
893
+ });
894
+ return { items };
895
+ };
896
+ const mergeSearchSuggestions = ({ response = {}, origin, projectOrigin }) => ({
897
+ items: [
898
+ ...convertDataList({ dataList: response.recommend_project, searchType: "repo", origin: projectOrigin || origin }).items,
899
+ ...convertDataList({ dataList: response.recommend_model, searchType: "model", origin }).items,
900
+ ...convertDataList({ dataList: response.recommend_dataset, searchType: "dataset", origin }).items
901
+ ]
902
+ });
835
903
  export {
836
904
  SearchRepoCard as S,
837
- formatNameSpace as f,
905
+ isProjectSuggestionType as i,
906
+ mergeSearchSuggestions as m,
907
+ normalizeProjectUrlForMainSite as n,
838
908
  useReportRepo as u
839
909
  };