可信代码库-搜索列表页面优化

This commit is contained in:
付民康
2025-03-13 16:09:33 +08:00
parent 7cebe8fc00
commit 39fa8b40c5
10 changed files with 927 additions and 251 deletions

View File

@@ -21,6 +21,7 @@ import dInput from 'vue-devui/input';
import { FormOperation } from 'vue-devui/form';
import { Option } from 'vue-devui/select';
import { BreadcrumbItem } from 'vue-devui/breadcrumb';
import { CheckboxGroup as DCheckboxGroup, Checkbox as DCheckbox } from 'vue-devui/checkbox';
import { useReport } from '@/utils/hooks/useReport';
import { savePageRef } from '@/utils';
import qs from 'qs';
@@ -40,73 +41,73 @@ declare global {
/**
* micro-app 微前端
*/
import microApp from '@micro-zoe/micro-app';
microApp.start({
'disable-memory-router': true, // 关闭虚拟路由系统
'disable-patch-request': true, // 关闭对子应用请求的拦截
lifeCycles: {
created() {
// console.log('created');
},
beforemount() {
// console.log('beforemount');
},
mounted() {
console.log('fst', performance.now().toFixed()); // 首屏时间
// console.log('mounted');
},
unmount() {
console.log('unmount');
},
error(e) {
Sentry.captureException(new Error('主站Error:生命周期错误'), {
level: 'error',
extra: {
...e
}
});
}
}
});
microApp.router.setBaseAppRouter(router);
microApp.router.beforeEach({
'micoro-app-homeweb-app': (to, from) => {
const toQuery = qs.parse(to.search, { ignoreQueryPrefix: true });
const fromQuery = qs.parse(from.search, { ignoreQueryPrefix: true });
if (
toQuery.type !== fromQuery.type ||
(from.pathname === '/search' && fromQuery.threadId && !toQuery.threadId && toQuery.type === 'chat')
) {
// 设置全局ref
savePageRef(to.fullPath);
} else if (to.pathname === '/search' && toQuery.type === 'chat' && toQuery.threadId) {
const BASE_URL = (import.meta as any).env.VITE_HOST;
sessionStorage.setItem('ref', BASE_URL + to.fullPath);
} else {
savePageRef(to.fullPath);
}
}
});
microApp.router.afterEach({
'micoro-app-homeweb-app': (to, from) => {
const names = {
'/': '首页',
'/search': '搜索',
'/g-star': 'g-star',
'/g-star/apply': 'g-star 申请',
'/explore': '搜索开源'
};
const toQuery = qs.parse(to.search, { ignoreQueryPrefix: true });
if (to.pathname === '/search' && toQuery.type !== 'repo') {
// 对话有threadid后上报
if (toQuery.threadId) useReport('pageview', {}, { 'homeweb-page-title': names[to.pathname] });
} else {
useReport('pageview', {}, { 'homeweb-page-title': names[to.pathname] });
}
}
});
// import microApp from '@micro-zoe/micro-app';
// microApp.start({
// 'disable-memory-router': true, // 关闭虚拟路由系统
// 'disable-patch-request': true, // 关闭对子应用请求的拦截
// lifeCycles: {
// created() {
// // console.log('created');
// },
// beforemount() {
// // console.log('beforemount');
// },
// mounted() {
// console.log('fst', performance.now().toFixed()); // 首屏时间
// // console.log('mounted');
// },
// unmount() {
// console.log('unmount');
// },
// error(e) {
// Sentry.captureException(new Error('主站Error:生命周期错误'), {
// level: 'error',
// extra: {
// ...e
// }
// });
// }
// }
// });
// microApp.router.setBaseAppRouter(router);
//
// microApp.router.beforeEach({
// 'micoro-app-homeweb-app': (to, from) => {
// const toQuery = qs.parse(to.search, { ignoreQueryPrefix: true });
// const fromQuery = qs.parse(from.search, { ignoreQueryPrefix: true });
//
// if (
// toQuery.type !== fromQuery.type ||
// (from.pathname === '/search' && fromQuery.threadId && !toQuery.threadId && toQuery.type === 'chat')
// ) {
// // 设置全局ref
// savePageRef(to.fullPath);
// } else if (to.pathname === '/search' && toQuery.type === 'chat' && toQuery.threadId) {
// const BASE_URL = (import.meta as any).env.VITE_HOST;
// sessionStorage.setItem('ref', BASE_URL + to.fullPath);
// } else {
// savePageRef(to.fullPath);
// }
// }
// });
// microApp.router.afterEach({
// 'micoro-app-homeweb-app': (to, from) => {
// const names = {
// '/': '首页',
// '/search': '搜索',
// '/g-star': 'g-star',
// '/g-star/apply': 'g-star 申请',
// '/explore': '搜索开源'
// };
// const toQuery = qs.parse(to.search, { ignoreQueryPrefix: true });
// if (to.pathname === '/search' && toQuery.type !== 'repo') {
// // 对话有threadid后上报
// if (toQuery.threadId) useReport('pageview', {}, { 'homeweb-page-title': names[to.pathname] });
// } else {
// useReport('pageview', {}, { 'homeweb-page-title': names[to.pathname] });
// }
// }
// });
storageService.setInstanceName('gitcode');
// 缓存策略表
@@ -183,6 +184,8 @@ Sentry.init({
app.use(Icon);
app.use(dInput);
app.component('gc-checkbox-group', DCheckboxGroup);
app.component('gc-checkbox', DCheckbox);
app.component('gc-option', Option);
app.component('gc-skeleton-item', SkeletonItem);
app.component('gc-modal-header', ModalHeader);