vue-layout-gitcode 1.5.39 → 1.5.40

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,156 +0,0 @@
1
- import { defineComponent, inject, useSlots, ref, computed, createBlock, openBlock, unref, withCtx, createElementVNode, normalizeClass, createElementBlock, createTextVNode, createCommentVNode, toDisplayString, renderSlot } from "vue";
2
- import { q as useLayoutConfig, w as ThemeType, x as currentTheme, g as LANG_ZH, y as LANG_EN, z as getLocaleLang, G as GIcon, A as emitEvent, B as isHttps, b as REPO_EVENT, _ as _export_sfc } from "./index-BoBr_WCM.js";
3
- import { useRouter } from "vue-router";
4
- import { Popover } from "vue-devui-lal/popover";
5
- import "vue-devui-lal/popover/style.css";
6
- const _hoisted_1 = ["src"];
7
- const _hoisted_2 = { class: "relative" };
8
- const _sfc_main = /* @__PURE__ */ defineComponent({
9
- __name: "MenuItem",
10
- props: {
11
- item: {
12
- type: Object,
13
- default: () => {
14
- }
15
- },
16
- active: {
17
- type: Boolean,
18
- default: false
19
- },
20
- isLogin: {
21
- type: Boolean,
22
- default: false
23
- },
24
- slotKeys: {
25
- type: Array,
26
- default: () => []
27
- }
28
- },
29
- setup(__props) {
30
- const layoutConfig = useLayoutConfig();
31
- const asideSetShow = inject("asideSetShow");
32
- const slots = useSlots();
33
- const useReport = inject("useReport");
34
- const independence = inject("independence");
35
- const router = useRouter();
36
- const props = __props;
37
- const isHover = ref(false);
38
- const isSelected = computed(() => {
39
- return props.active || isHover.value;
40
- });
41
- const currentImg = computed(() => {
42
- const imgMap = {
43
- [ThemeType.WHITE]: {
44
- selected: props.item.left_menu_logo_hover,
45
- unselected: props.item.left_menu_logo
46
- },
47
- [ThemeType.BLACK]: {
48
- selected: props.item.left_menu_logo_hover_black,
49
- unselected: props.item.left_menu_logo_black
50
- }
51
- };
52
- if (isSelected.value) {
53
- return imgMap[currentTheme.value].selected;
54
- } else {
55
- return imgMap[currentTheme.value].unselected;
56
- }
57
- });
58
- const currentName = computed(() => {
59
- const nameMap = {
60
- [LANG_EN]: props.item.left_menu_name_en,
61
- [LANG_ZH]: props.item.left_menu_name_cn
62
- };
63
- return nameMap[getLocaleLang()] || props.item.left_menu_name_cn;
64
- });
65
- const isShowPopover = computed(() => {
66
- return props.item.is_show_popup && props.slotKeys.includes(props.item.popup_key) && slots[props.item.popup_key] && asideSetShow.value;
67
- });
68
- const handleMouseEnter = () => {
69
- isHover.value = true;
70
- };
71
- const handleMouseLeave = () => {
72
- isHover.value = false;
73
- };
74
- const clickMenuReport = () => {
75
- if (!useReport) {
76
- return;
77
- }
78
- const reportName = props.item.left_menu_name_cn;
79
- if (reportName) {
80
- useReport(REPO_EVENT.CLICK, { module_name: `侧边栏_${reportName}` });
81
- }
82
- };
83
- const handleMenuClick = () => {
84
- const currentHref = window.location.href;
85
- if (props.item.left_menu_url === currentHref) {
86
- return;
87
- }
88
- if (props.item.is_need_login && !props.isLogin) {
89
- emitEvent("login", { loginTriggerSource: `aside_${props.item.left_menu_url}` });
90
- return;
91
- }
92
- if (props.item.is_open_new_tab) {
93
- window.open(props.item.left_menu_url, "_blank");
94
- } else if (isHttps(props.item.left_menu_url)) {
95
- window.open(props.item.left_menu_url, "_self");
96
- } else {
97
- if (independence) {
98
- window.open(layoutConfig.VITE_HOST + props.item.left_menu_url, "_self");
99
- return;
100
- }
101
- router.push({
102
- path: props.item.left_menu_url
103
- });
104
- }
105
- clickMenuReport();
106
- };
107
- return (_ctx, _cache) => {
108
- return openBlock(), createBlock(unref(Popover), {
109
- class: "menu-item-popover",
110
- trigger: "hover",
111
- position: ["right-start"],
112
- disabled: !isShowPopover.value
113
- }, {
114
- content: withCtx(() => [
115
- renderSlot(_ctx.$slots, __props.item.popup_key, {}, void 0, true)
116
- ]),
117
- default: withCtx(() => [
118
- createElementVNode("div", {
119
- class: normalizeClass(["menu-item", { "menu-item__selected": isSelected.value }]),
120
- onMouseenter: handleMouseEnter,
121
- onMouseleave: handleMouseLeave,
122
- onClick: handleMenuClick
123
- }, [
124
- props.item.isIcon ? (openBlock(), createBlock(GIcon, {
125
- key: 0,
126
- name: currentImg.value,
127
- class: "default-icon",
128
- size: "16",
129
- color: "var(--theme-menu-icon-fill)"
130
- }, null, 8, ["name"])) : (openBlock(), createElementBlock("img", {
131
- key: 1,
132
- class: "menu-item__icon",
133
- src: currentImg.value,
134
- alt: ""
135
- }, null, 8, _hoisted_1)),
136
- createElementVNode("span", _hoisted_2, [
137
- createTextVNode(toDisplayString(currentName.value) + " ", 1),
138
- isShowPopover.value ? (openBlock(), createBlock(GIcon, {
139
- key: 0,
140
- class: "side-bar-icon",
141
- size: "12",
142
- name: "gt-line-right-tianqi",
143
- color: "var(--theme-text)"
144
- })) : createCommentVNode("", true)
145
- ])
146
- ], 34)
147
- ]),
148
- _: 3
149
- }, 8, ["disabled"]);
150
- };
151
- }
152
- });
153
- const MenuItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-gitcode-layout-lib"]]);
154
- export {
155
- MenuItem as default
156
- };
@@ -1,389 +0,0 @@
1
- import { defineComponent, inject, ref, reactive, watch, computed, createElementBlock, openBlock, createCommentVNode, createBlock, withDirectives, Fragment, createElementVNode, createVNode, toDisplayString, unref, withModifiers, normalizeClass, withCtx, renderList, createTextVNode, vShow } from "vue";
2
- import { a as i18n, G as GIcon, C as _sfc_main$1, D as loadAsideData, s as setLoginTriggerSource, d as useRequestReport, F as asideRequest, _ as _export_sfc } from "./index-BoBr_WCM.js";
3
- import { useRouter } from "vue-router";
4
- import { t as transWebUrl } from "./transWebUrl-BGhTRg9b.js";
5
- import { Select, Option } from "vue-devui-lal/select";
6
- import { Input } from "vue-devui-lal/input";
7
- import { Skeleton } from "vue-devui-lal/skeleton";
8
- import { MenuItem } from "vue-devui-lal/menu";
9
- import { Button } from "vue-devui-lal/button";
10
- import "vue-devui-lal/select/style.css";
11
- import "vue-devui-lal/input/style.css";
12
- import "vue-devui-lal/skeleton/style.css";
13
- import "vue-devui-lal/menu/style.css";
14
- import "vue-devui-lal/button/style.css";
15
- const _hoisted_1 = { class: "devui-submenu layer_2 my-work-platform submenu-item relative" };
16
- const _hoisted_2 = {
17
- class: "devui-submenu-title layer_2",
18
- style: { "padding": "0px 24px" }
19
- };
20
- const _hoisted_3 = { class: "devui-submenu-title-content cursor-auto" };
21
- const _hoisted_4 = {
22
- class: "devui-submenu-title layer_2",
23
- style: { "padding": "0px 24px" }
24
- };
25
- const _hoisted_5 = { class: "devui-submenu-title-content cursor-auto" };
26
- const _hoisted_6 = { key: 0 };
27
- const _hoisted_7 = { class: "project-label" };
28
- const _hoisted_8 = { class: "project-label flex-1 min-w-0 ellipsis" };
29
- const _hoisted_9 = {
30
- key: 1,
31
- class: "project-label"
32
- };
33
- const _sfc_main = /* @__PURE__ */ defineComponent({
34
- __name: "ProjectMenuList",
35
- props: {
36
- type: { default: "project" },
37
- buttonText: { default: "" },
38
- subShow: { type: Boolean, default: false },
39
- query: { default: {} },
40
- defaultData: { default: {} },
41
- isLogin: { type: Boolean, default: false },
42
- defaultOrg: { default: {} },
43
- username: { default: "" }
44
- },
45
- setup(__props) {
46
- const { t } = i18n.global;
47
- const request = inject("request");
48
- const API = asideRequest(request);
49
- const globalStore = inject("globalStore");
50
- const { useReport } = useRequestReport(request, globalStore);
51
- const props = __props;
52
- const projectList = ref([]);
53
- const loading = ref(false);
54
- const pageQuery = reactive({
55
- page: 1,
56
- size: 10
57
- });
58
- const firstLoading = ref(false);
59
- const showSearch = ref(false);
60
- const extendQuery = {};
61
- const searchKey = ref("");
62
- const nameSpace = ref(0);
63
- let storeData = [];
64
- const totalNum = ref(0);
65
- const router = useRouter();
66
- const inputIng = ref(false);
67
- const projectRoute = {
68
- name: "newRepo",
69
- query: { position: "nav_top" }
70
- };
71
- const teamRoute = {
72
- name: "newOrg"
73
- };
74
- let scTimer = null;
75
- let loadMoreTotal = 0;
76
- watch(
77
- () => props.defaultData,
78
- () => {
79
- firstLoading.value = !!props.defaultData.loading;
80
- if (props.defaultData && props.defaultData.list) {
81
- projectList.value = [...props.defaultData.list];
82
- if (props.defaultData.storeData) {
83
- storeData = [...props.defaultData.storeData];
84
- }
85
- totalNum.value = props.defaultData.totalNum || 0;
86
- }
87
- },
88
- { immediate: true, deep: true }
89
- );
90
- const customRequest = (params, type) => {
91
- if (type === "project" && params.namespace_id === "my-repo") {
92
- const temp = { ...params };
93
- delete temp.namespace_id;
94
- return {
95
- params: {
96
- ...temp,
97
- repo_query_type: "created",
98
- repo_type: "0,1,2"
99
- },
100
- requestFn: (params2) => API.getMyCreatedProjects(params2)
101
- };
102
- }
103
- return {
104
- params,
105
- requestFn: type === "project" ? (params2) => API.getMyProjects(params2) : (params2) => API.getMyGroups(params2)
106
- };
107
- };
108
- const loadMoreData = (loadType) => {
109
- const data = [...storeData];
110
- if (totalNum.value > pageQuery.size * pageQuery.page || loadType === "search") {
111
- pageQuery.page = pageQuery.page + 1;
112
- loading.value = true;
113
- const params = {
114
- page: pageQuery.page,
115
- per_page: pageQuery.size,
116
- ...props.query,
117
- ...extendQuery
118
- };
119
- const { params: newParams, requestFn } = customRequest(params, props.type);
120
- loadAsideData(requestFn, newParams, props.type).then(
121
- (res) => {
122
- if (params.search !== searchKey.value && loadType === "search") {
123
- return;
124
- }
125
- if (res.list) {
126
- data.push(...res.list);
127
- }
128
- if (loadType === "search" && res.storeData) {
129
- storeData = [...res.storeData];
130
- }
131
- totalNum.value = res.totalNum || 0;
132
- projectList.value.push(...data);
133
- loading.value = false;
134
- }
135
- );
136
- } else {
137
- projectList.value.push(...data);
138
- }
139
- storeData = [];
140
- };
141
- const selectQuery = {
142
- page: 1,
143
- size: 10
144
- };
145
- const moreOrgData = ref([]);
146
- const DEFAULT_ORG_FILTER_OPTIONS = [{ id: 0, label: t("gitCodeLayout.common.all") }, { id: "my-repo", label: props.username || t("gitCodeLayout.common.iCreated") }];
147
- const teamList = computed(() => {
148
- var _a;
149
- if (props.defaultOrg.list) {
150
- loadMoreTotal = props.defaultOrg.totalNum;
151
- const propStoreData = ((_a = props.defaultOrg) == null ? void 0 : _a.storeData) || [];
152
- return [...DEFAULT_ORG_FILTER_OPTIONS, ...props.defaultOrg.list, ...propStoreData, ...moreOrgData.value];
153
- }
154
- return [...DEFAULT_ORG_FILTER_OPTIONS, ...moreOrgData.value];
155
- });
156
- const fastToLink = (type) => {
157
- if (type === "project") {
158
- router.push({ name: "userRepos", params: { namespace: props.username } });
159
- } else {
160
- router.push({ name: "settingOrganization" });
161
- }
162
- };
163
- const loadMoreTeams = () => {
164
- loadAsideData(
165
- (params) => API.getMyProjects(params),
166
- {
167
- page: selectQuery.page,
168
- per_page: selectQuery.size
169
- },
170
- "team"
171
- ).then((res) => {
172
- loadMoreTotal = res.totalNum || 0;
173
- if (res.list) {
174
- moreOrgData.value.push(...res.list, ...res.storeData || []);
175
- }
176
- });
177
- };
178
- const loadTeam = () => {
179
- if (loadMoreTotal > selectQuery.size * selectQuery.page) {
180
- selectQuery.page++;
181
- loadMoreTeams();
182
- }
183
- };
184
- const searchProject = () => {
185
- extendQuery.search = searchKey.value;
186
- extendQuery.namespace_id = nameSpace.value !== 0 ? nameSpace.value : void 0;
187
- pageQuery.page = 0;
188
- projectList.value = [];
189
- storeData = [];
190
- loadMoreData("search");
191
- };
192
- const searchTeam = () => {
193
- extendQuery.search = searchKey.value;
194
- pageQuery.page = 0;
195
- projectList.value = [];
196
- storeData = [];
197
- loadMoreData("search");
198
- };
199
- const valChange = () => {
200
- if (inputIng.value) {
201
- return;
202
- }
203
- if (scTimer) clearTimeout(scTimer);
204
- scTimer = setTimeout(() => {
205
- if (props.type === "project") {
206
- searchProject();
207
- } else {
208
- searchTeam();
209
- }
210
- }, 200);
211
- };
212
- const createRepoOrOrg = () => {
213
- if (!props.isLogin) {
214
- setLoginTriggerSource(props.type === "project" ? "aside_createRepo" : "aside_createOrg");
215
- useReport("login_exposure", { source: props.type === "project" ? "aside_createRepo" : "aside_createOrg" });
216
- }
217
- router.push(props.type === "project" ? projectRoute : teamRoute);
218
- };
219
- return (_ctx, _cache) => {
220
- return openBlock(), createElementBlock("ul", _hoisted_1, [
221
- _ctx.type === "project" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
222
- createElementVNode("div", _hoisted_2, [
223
- _cache[13] || (_cache[13] = createElementVNode("span", { class: "devui-menu-icon" }, null, -1)),
224
- createElementVNode("span", _hoisted_3, [
225
- createElementVNode("div", {
226
- class: "fast-click-button",
227
- onClick: _cache[0] || (_cache[0] = ($event) => fastToLink("project"))
228
- }, toDisplayString(unref(t)("gitCodeLayout.org.project")), 1)
229
- ])
230
- ]),
231
- createVNode(GIcon, {
232
- class: "my-work-platform-searchicon",
233
- color: "var(--theme-menu-icon-fill)",
234
- name: "gt-search",
235
- onClick: _cache[1] || (_cache[1] = withModifiers(($event) => showSearch.value = !showSearch.value, ["stop"]))
236
- }),
237
- createElementVNode("div", {
238
- class: normalizeClass(["flex flex-col pl-[0] my-work-platform-inputbox", showSearch.value ? "" : "my-work-platform-hideInputBox"]),
239
- onClick: _cache[6] || (_cache[6] = withModifiers(() => {
240
- }, ["stop"]))
241
- }, [
242
- createVNode(unref(Select), {
243
- "menu-class": "my-work-platform-select",
244
- modelValue: nameSpace.value,
245
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => nameSpace.value = $event),
246
- class: "mb-[8px]",
247
- placeholder: "",
248
- filter: true,
249
- onLoadMore: loadTeam,
250
- onValueChange: searchProject
251
- }, {
252
- default: withCtx(() => [
253
- (openBlock(true), createElementBlock(Fragment, null, renderList(teamList.value, (item, index) => {
254
- return openBlock(), createBlock(unref(Option), {
255
- key: index,
256
- value: item.id,
257
- name: item.label,
258
- title: item.label
259
- }, null, 8, ["value", "name", "title"]);
260
- }), 128))
261
- ]),
262
- _: 1
263
- }, 8, ["modelValue"]),
264
- createVNode(unref(Input), {
265
- modelValue: searchKey.value,
266
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => searchKey.value = $event),
267
- placeholder: unref(t)("gitCodeLayout.common.search"),
268
- onInput: valChange,
269
- onCompositionstart: _cache[4] || (_cache[4] = ($event) => inputIng.value = true),
270
- onCompositionend: _cache[5] || (_cache[5] = ($event) => inputIng.value = false)
271
- }, {
272
- prefix: withCtx(() => [
273
- createVNode(GIcon, {
274
- name: "gt-search",
275
- color: "var(--theme-menu-icon-fill)"
276
- })
277
- ]),
278
- _: 1
279
- }, 8, ["modelValue", "placeholder"])
280
- ], 2)
281
- ], 64)) : createCommentVNode("", true),
282
- _ctx.type === "team" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
283
- createElementVNode("div", _hoisted_4, [
284
- _cache[14] || (_cache[14] = createElementVNode("span", { class: "devui-menu-icon" }, null, -1)),
285
- createElementVNode("span", _hoisted_5, [
286
- createElementVNode("div", {
287
- class: "fast-click-button",
288
- onClick: _cache[7] || (_cache[7] = ($event) => fastToLink("team"))
289
- }, toDisplayString(unref(t)("gitCodeLayout.common.organize")), 1)
290
- ])
291
- ]),
292
- createVNode(GIcon, {
293
- class: "my-work-platform-searchicon",
294
- name: "gt-search",
295
- onClick: _cache[8] || (_cache[8] = withModifiers(($event) => showSearch.value = !showSearch.value, ["stop"])),
296
- color: "var(--theme-menu-icon-fill)"
297
- }),
298
- createElementVNode("div", {
299
- class: normalizeClass(["flex flex-col pl-[0] my-work-platform-inputbox", showSearch.value ? "" : "my-work-platform-hideInputBox"]),
300
- onClick: _cache[12] || (_cache[12] = withModifiers(() => {
301
- }, ["stop"]))
302
- }, [
303
- createVNode(unref(Input), {
304
- modelValue: searchKey.value,
305
- "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => searchKey.value = $event),
306
- placeholder: unref(t)("gitCodeLayout.common.search"),
307
- onInput: valChange,
308
- onCompositionstart: _cache[10] || (_cache[10] = ($event) => inputIng.value = true),
309
- onCompositionend: _cache[11] || (_cache[11] = ($event) => inputIng.value = false)
310
- }, {
311
- prefix: withCtx(() => [
312
- createVNode(GIcon, {
313
- name: "gt-search",
314
- color: "var(--theme-menu-icon-fill)"
315
- })
316
- ]),
317
- _: 1
318
- }, 8, ["modelValue", "placeholder"])
319
- ], 2)
320
- ], 64)) : createCommentVNode("", true),
321
- firstLoading.value ? (openBlock(), createBlock(unref(Skeleton), {
322
- key: 2,
323
- rows: 1
324
- })) : createCommentVNode("", true),
325
- (openBlock(true), createElementBlock(Fragment, null, renderList(projectList.value, (item) => {
326
- return openBlock(), createBlock(unref(MenuItem), {
327
- key: item.key,
328
- "data-openBlank": true,
329
- "data-href": unref(transWebUrl)(item.web_url),
330
- class: "text",
331
- title: _ctx.type === "project" ? `${item.namespace}/${item.label}` : item.label
332
- }, {
333
- icon: withCtx(() => [
334
- _ctx.type === "project" ? (openBlock(), createBlock(GIcon, {
335
- key: 0,
336
- name: "gt-line-project",
337
- color: "var(--theme-menu-icon-fill)",
338
- size: "16"
339
- })) : (openBlock(), createBlock(_sfc_main$1, {
340
- key: 1,
341
- src: item.avatar,
342
- name: item.key,
343
- width: 16,
344
- height: 16,
345
- class: normalizeClass(!item.avatar ? "avatar" : "avatar1")
346
- }, null, 8, ["src", "name", "class"]))
347
- ]),
348
- default: withCtx(() => [
349
- _ctx.type === "project" ? (openBlock(), createElementBlock("span", _hoisted_6, [
350
- createElementVNode("span", _hoisted_7, toDisplayString((item.namespace || "").slice(0, 10)) + toDisplayString((item.namespace || "").length > 10 ? "..." : ""), 1),
351
- createElementVNode("span", _hoisted_8, "/" + toDisplayString(item.label), 1)
352
- ])) : (openBlock(), createElementBlock("span", _hoisted_9, toDisplayString(item.label), 1))
353
- ]),
354
- _: 2
355
- }, 1032, ["data-href", "title"]);
356
- }), 128)),
357
- !totalNum.value && !firstLoading.value ? (openBlock(), createBlock(unref(Button), {
358
- key: 3,
359
- variant: "text",
360
- class: "more-btn",
361
- onClick: withModifiers(createRepoOrOrg, ["stop"])
362
- }, {
363
- default: withCtx(() => [
364
- createTextVNode(toDisplayString(_ctx.buttonText), 1)
365
- ]),
366
- _: 1
367
- })) : createCommentVNode("", true),
368
- withDirectives(createVNode(unref(Button), {
369
- variant: "text",
370
- class: "more-btn",
371
- onClick: withModifiers(loadMoreData, ["stop"]),
372
- loading: loading.value,
373
- disabled: loading.value
374
- }, {
375
- default: withCtx(() => [
376
- createTextVNode(toDisplayString(unref(t)("gitCodeLayout.org.expand_more")), 1)
377
- ]),
378
- _: 1
379
- }, 8, ["loading", "disabled"]), [
380
- [vShow, (totalNum.value > pageQuery.size * pageQuery.page || unref(storeData).length) && props.subShow]
381
- ])
382
- ]);
383
- };
384
- }
385
- });
386
- const ProjectMenuList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-gitcode-layout-lib"]]);
387
- export {
388
- ProjectMenuList as default
389
- };