可信代码库-可信开源代码库AI助手开源软件列表展示开发完成
This commit is contained in:
6
.env.loc
6
.env.loc
@@ -2,7 +2,7 @@
|
||||
VITE_ENV = 'loc'
|
||||
|
||||
# 主域名
|
||||
VITE_HOST = 'https://test.gitcode.net'
|
||||
VITE_HOST = 'http://124.223.71.235:8080'
|
||||
|
||||
# 接口地址
|
||||
VITE_API_HOST = 'https://test.gitcode.net'
|
||||
@@ -26,7 +26,7 @@ VITE_CSDN_URL = 'https://test.gitcode.net/oauth/login/csdn'
|
||||
VITE_ORG_COMMUNITY = 'https://test.gitcode.net'
|
||||
|
||||
# 静态资源域名
|
||||
VITE_STATIC_HOST = 'https://test.gitcode.net'
|
||||
VITE_STATIC_HOST = 'http://124.223.71.235:8080'
|
||||
|
||||
# 主页搜索子应用
|
||||
VITE_CHILD_HOMEWEB_HOST = 'https://local.gitcode.net:8001/child/homeweb-app'
|
||||
@@ -36,3 +36,5 @@ VITE_USER_CENTER_HOST = 'https://local.gitcode.net:8002'
|
||||
|
||||
# ai-copilot 子应用
|
||||
VITE_COPILOT_HOST = 'https://local.gitcode.net:8003/child/aichat-app'
|
||||
|
||||
VITE_BASE_URL=/openRepoPortal/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test",
|
||||
"build:pre": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode pre",
|
||||
"build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode production",
|
||||
"build:loc": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode loc",
|
||||
"analysis": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode analysis",
|
||||
"preview": "vite preview",
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
|
||||
|
||||
BIN
src/assets/imgs/jyh/ai/icon_generate.png
Normal file
BIN
src/assets/imgs/jyh/ai/icon_generate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 234 B |
BIN
src/assets/imgs/jyh/ai/icon_skgc.png
Normal file
BIN
src/assets/imgs/jyh/ai/icon_skgc.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 769 B |
@@ -11,7 +11,7 @@
|
||||
</d-button>
|
||||
</div>
|
||||
<div class="card-description">
|
||||
<button v-for="(question, index) in questions" :key="index" class="question-button">
|
||||
<button v-for="(question, index) in questions" :key="index" class="question-button" @click="emits('submit',question)">
|
||||
{{ question }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -21,6 +21,8 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
const emits = defineEmits(['submit']);
|
||||
|
||||
// 假设的图标 URL,你可以根据实际情况修改
|
||||
const iconUrl = 'https://example.com/icon.png';
|
||||
|
||||
|
||||
@@ -36,7 +36,10 @@ const mySwiper = ref(null);
|
||||
const slideData = [
|
||||
{ id: 1, title: '热门开源软件', description: '列出热门开源软件',icon:icon_hot },
|
||||
{ id: 2, title: '预警公告', description: '列出最近预警公告',icon:icon_yj },
|
||||
{ id: 3, title: '你可以帮我做什么', description: '了解当前AI助手可以帮忙干什么',icon:icon_jh }
|
||||
{ id: 3, title: '你可以帮我做什么', description: '了解当前AI助手可以帮忙干什么',icon:icon_jh },
|
||||
{ id: 4, title: '热门开源软件', description: '列出热门开源软件',icon:icon_hot },
|
||||
{ id: 5, title: '预警公告', description: '列出最近预警公告',icon:icon_yj },
|
||||
{ id: 6, title: '你可以帮我做什么', description: '了解当前AI助手可以帮忙干什么',icon:icon_jh }
|
||||
];
|
||||
|
||||
const onSelectItem = (item) => {
|
||||
|
||||
522
src/views/Jyh/AI/Home/components/OssList.vue
Normal file
522
src/views/Jyh/AI/Home/components/OssList.vue
Normal file
@@ -0,0 +1,522 @@
|
||||
<template>
|
||||
<div class="secret-container">
|
||||
<div class="title">开源软件列表</div>
|
||||
<div class="mt-3">
|
||||
<d-table
|
||||
:key="tableKey"
|
||||
ref="filterTableRef"
|
||||
class="jyh-table"
|
||||
v-if="tableData.length"
|
||||
:striped="false"
|
||||
:data="tableData"
|
||||
>
|
||||
<!-- <d-column type="checkable" width="40" reserve-check align="center"></d-column>-->
|
||||
<!-- 索引列 -->
|
||||
<!-- <d-column type="index" width="40"></d-column> -->
|
||||
|
||||
<!-- 动态渲染列 -->
|
||||
<template v-for="column in columns" :key="column.key">
|
||||
<d-column v-if="column.visible" :field="column.key" :header="column.label" :width="column.width||120" show-overflow-tooltip>
|
||||
<!-- 自定义列内容 -->
|
||||
<template #default="scope">
|
||||
<template v-if="column.key === 'versionName'">
|
||||
<a @click="gotoDetail(scope.row)">{{ scope.row.versionName }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'version'">
|
||||
<a @click="gotoDetail(scope.row)">{{ scope.row.version }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'securityScore'">
|
||||
<a @click="gotoDetail(scope.row)" style="
|
||||
font-weight: bold;
|
||||
color: #409EFF;
|
||||
font-size: 16px;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
">{{ scope.row.securityScore }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'releaseDate'">
|
||||
<span>{{ formatTime(scope.row.releaseDate, 'YYYY-MM-DD') }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'eolDate'">
|
||||
<span>{{ formatTime(scope.row.eolDate, 'YYYY-MM-DD') }}</span>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'softwareVersion'">
|
||||
<a @click="gotoDetail(scope.row)">{{ scope.row.softwareVersion }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'smStatus'">
|
||||
<a>{{ scope.row.smStatus }}</a>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'industryCategory'">
|
||||
<d-tag type="success">{{ getIndustryName(scope.row.industryCategory) }}</d-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'programmingLanguage'">
|
||||
<d-tag type="success">{{ scope.row.programmingLanguage }}</d-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'primaryLanguage'">
|
||||
<d-tag type="primary">{{ scope.row.primaryLanguage }}</d-tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'contributorCountries'">
|
||||
<!-- <div style="cursor: pointer" @click="openCountryModal(column)">-->
|
||||
<!-- <span class="mr-2">美国 3.57%</span>-->
|
||||
<!-- <d-tag color="gray">+3</d-tag>-->
|
||||
<!-- </div>-->
|
||||
</template>
|
||||
<template v-else-if="column.key === 'contributorOrganizations'">
|
||||
<!-- <div style="cursor: pointer" @click="openOrgModal(column)">-->
|
||||
<!-- <span class="mr-2">microsoft 3.57%</span>-->
|
||||
<!-- <d-tag color="gray">+3</d-tag>-->
|
||||
<!-- </div>-->
|
||||
</template>
|
||||
<template v-else-if="column.key === 'sourceDownloadUrl'">
|
||||
<a :href="scope.row.sourceDownloadUrl">{{ scope.row.sourceDownloadUrl }}</a>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ scope.row[column.key] }}
|
||||
</template>
|
||||
</template>
|
||||
</d-column>
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
<!-- <DataPanel v-else skeleton :card="false" :empty="true">-->
|
||||
<!-- </DataPanel>-->
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
<d-pagination
|
||||
size="md"
|
||||
:page-size-options="[10, 20, 50]"
|
||||
:total="pager.total"
|
||||
v-model:pageSize="pager.pageSize"
|
||||
v-model:pageIndex="pager.pageIndex"
|
||||
:max-items="5"
|
||||
:can-change-page-size="true"
|
||||
:can-view-total="true"
|
||||
total-item-text="总计"
|
||||
@page-index-change="getReleaseList()"
|
||||
@page-size-change="getReleaseList()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<d-button v-if="isLogin" class="output-btn" @click="exportResult">导出列表</d-button>
|
||||
<div class="bubble-bottom-operations">
|
||||
<img onclick="handleRefresh()" src="@/assets/imgs/jyh/ai/icon_generate.png" />
|
||||
<i class="icon-file" title="复制" onclick="handleFile()"></i>
|
||||
<i class="icon-like" title="点赞" onclick="handleLike()"></i>
|
||||
<i class="icon-dislike" title="踩" onclick="handleDislike()"></i>
|
||||
<i class="icon-clever-customer" title="智能客服" onclick="handleCustomerService()"></i>
|
||||
<i class="icon-more-operate" title="更多操作" onclick="handleMore()"></i>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch, nextTick } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { getOrgInfo } from '@/views/Org/hooks/orgInfo';
|
||||
import { Message } from 'vue-devui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import NoData from '@/components/NoData/NoData.vue';
|
||||
import { useAccountStore } from '@/stores/user';
|
||||
import * as XLSX from 'xlsx';
|
||||
const { formatTime } = useTimeFormat();
|
||||
import { getReleaseExport, releasePage, searchLanguageList } from '@/api/jyh';
|
||||
import { useTimeFormat } from '@/utils/hooks/useTimeFormat';
|
||||
import { useGlobalInfoStore } from '@/stores/Global';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const filterTableRef = ref();
|
||||
const { namespace } = getOrgInfo();
|
||||
const userInfo = useAccountStore();
|
||||
const { isLogin } = storeToRefs(userInfo);
|
||||
// 定义 tableKey,用于强制刷新表格
|
||||
const tableKey = ref(0);
|
||||
const countryVisible = ref(false);
|
||||
const orgVisible = ref(false);
|
||||
const allTableData = ref([]);
|
||||
const tableData = ref([]);
|
||||
const languageList = ref([]);
|
||||
const globalInfo = useGlobalInfoStore();
|
||||
const industryList = ref(globalInfo.industryList);
|
||||
const newFormData = ref({
|
||||
licenseName: '',
|
||||
searchType: 'software',
|
||||
softwareName: '',
|
||||
softwareVersion: '',
|
||||
dependentSoftware: '',
|
||||
programmingLanguage: '',
|
||||
interestTag: '',
|
||||
industry: '',
|
||||
dateRange: ['', '']
|
||||
});
|
||||
|
||||
const pager = ref({
|
||||
total: 10,
|
||||
pageIndex: 1,
|
||||
pageSize: 10
|
||||
});
|
||||
|
||||
// 定义 columns 数据
|
||||
const columns = ref([
|
||||
{ key: 'softwareName', label: '软件名称', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'softwareVersion', label: '软件版本', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'securityScore', label: '软件评分', visible: true, filterable: false, sortable: true },
|
||||
{ key: 'licenseNum', label: 'License数量', visible: true, filterable: false, sortable: false,width: 140 },
|
||||
{ key: 'industryCategory', label: '行业类型', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'primaryLanguage', label: '编程语言', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'codeLines', label: '代码量', visible: true, filterable: false, sortable: false },
|
||||
{ key: 'sourceDownloadUrl', label: '源码包下载地址', visible: true, filterable: false, sortable: false,width: 200 },
|
||||
{ key: 'releaseDate', label: '版本发布时间', visible: false, filterable: true, sortable: true,width: 160 },
|
||||
// { key: 'dependencyCount', label: '依赖软件数', visible: false, filterable: false, sortable: false },
|
||||
// { key: 'productComponentUsage', label: '产品成分使用量', visible: false, filterable: false, sortable: false,width: 160 },
|
||||
{ key: 'vulnerabilityCount', label: '漏洞数量', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'developer', label: '开发商', visible: false, filterable: true, sortable: false },
|
||||
{ key: 'contributorCountries', label: '贡献者国家/地区分布', visible: false, filterable: false, sortable: false,width: 200 },
|
||||
{ key: 'contributorOrganizations', label: '贡献者组织/公司分布', visible: false, filterable: false, sortable: false,width: 200 },
|
||||
{ key: 'communityHash', label: '社区hash值', visible: false, filterable: false, sortable: false,width: 160 },
|
||||
{ key: 'copyright', label: 'Copyright', visible: false, filterable: false, sortable: false },
|
||||
{
|
||||
key: 'externalVulnerabilitySource',
|
||||
label: '外部漏洞源的软件名称',
|
||||
visible: false,
|
||||
filterable: true,
|
||||
sortable: false,width: 200
|
||||
},
|
||||
{ key: 'versionDescription', label: '版本描述', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'compatibilityRisk', label: '兼容性风险描述', visible: false, filterable: false, sortable: false ,width: 160},
|
||||
{ key: 'eolDate', label: '社区EOL时间', visible: false, filterable: true, sortable: true,width: 160 }
|
||||
]);
|
||||
|
||||
// 获取子组件的引用
|
||||
const countryModalRef = ref(null);
|
||||
const orgModalRef = ref(null);
|
||||
|
||||
const getIndustryName = (value) => {
|
||||
const industry = industryList.value.find((item) => item.value === value);
|
||||
return industry ? industry.name : '未知行业'; // 如果找不到,返回默认值
|
||||
};
|
||||
|
||||
// 打开模态框的方法
|
||||
const openCountryModal = () => {
|
||||
if (countryModalRef.value) {
|
||||
countryModalRef.value.openModal(); // 调用子组件的方法
|
||||
}
|
||||
};
|
||||
// 打开模态框的方法
|
||||
const openOrgModal = () => {
|
||||
if (orgModalRef.value) {
|
||||
orgModalRef.value.openModal(); // 调用子组件的方法
|
||||
}
|
||||
};
|
||||
// 更新 的方法
|
||||
const updateTableKey = () => {
|
||||
tableKey.value++; // 更新 tableKey,强制刷新表格
|
||||
};
|
||||
|
||||
// 更新 的方法
|
||||
const openCountryChart = (row) => {
|
||||
// selectRow.value = row;
|
||||
countryVisible.value = true;
|
||||
};
|
||||
// 更新 的方法
|
||||
const openOrgChart = (row) => {
|
||||
// selectRow.value = row;
|
||||
orgVisible.value = true;
|
||||
};
|
||||
|
||||
// 跳转
|
||||
const gotoDetail = (row) => {
|
||||
// 后续请换成params,暂时params传参没传过去
|
||||
router.push({
|
||||
path: 'repoDetail/' + row.id
|
||||
});
|
||||
};
|
||||
|
||||
const repoFun = (arr: any) => {
|
||||
return arr ? (arr.length > 3 ? arr.slice(0, 3) : arr) : [];
|
||||
};
|
||||
|
||||
// 编辑
|
||||
const editRow = (row: any) => {
|
||||
// 后续请换成params,暂时params传参没传过去
|
||||
router.push({
|
||||
path: 'cla/edit/' + row.object_id,
|
||||
query: { cla: row.cla, pageType: 'edit' }
|
||||
});
|
||||
};
|
||||
|
||||
// 确认删除
|
||||
const confirmDelete = async (e: any) => {
|
||||
// const res = await reqCatch(deleteGroupCla, { group_id: namespace.value, cla_id: item.value.object_id });
|
||||
// if (!res.error) {
|
||||
// getGroupClaListData();
|
||||
// }
|
||||
};
|
||||
|
||||
// 去成员页
|
||||
const goMember = (row: any) => {
|
||||
// 后续请换成params,暂时params传参没传过去,注意路由有个:claID
|
||||
router.push({
|
||||
path: 'cla/claId/member',
|
||||
query: { claId: row.object_id, claName: row.cla_name, group_path: namespace.value, pageType: 'edit' }
|
||||
});
|
||||
};
|
||||
const getGroupClaListData = async () => {
|
||||
// const params = {
|
||||
// group_id: namespace.value,
|
||||
// page: pager.value.pageIndex,
|
||||
// per_page: pager.value.pageSize
|
||||
// };
|
||||
// const res = await reqCatch(getGroupClaList, params);
|
||||
// if (!res.error) {
|
||||
// tableData.value = res?.data?.data?.content;
|
||||
// pager.value.total = res.data.data.total;
|
||||
// }
|
||||
};
|
||||
getGroupClaListData();
|
||||
|
||||
const setClaStatus = async (row: any) => {
|
||||
// const params = {
|
||||
// group_id: namespace.value,
|
||||
// cla_id: row.object_id,
|
||||
// status: row.status
|
||||
// };
|
||||
// const res = await reqCatch(setGroupClaStatus, params);
|
||||
// if (!res.error) {
|
||||
// Message.success('操作成功!');
|
||||
// getGroupClaListData();
|
||||
// }
|
||||
};
|
||||
|
||||
const signCla = (row: any) => {
|
||||
router.push('/cla/' + row.object_id);
|
||||
};
|
||||
|
||||
const getReleaseList = async () => {
|
||||
const { data, error } = await releasePage({
|
||||
softwareName: newFormData.value.softwareName || '',
|
||||
searchType: newFormData.value.searchType || '',
|
||||
softwareVersion: newFormData.value.softwareVersion || '',
|
||||
programmingLanguage: newFormData.value.programmingLanguage || '',
|
||||
interestTag: newFormData.value.interestTag || '',
|
||||
industry: newFormData.value.industry || '',
|
||||
licenseName: newFormData.value.licenseName || '',
|
||||
dependentSoftware: newFormData.value.dependentSoftware || '',
|
||||
releaseDateStart:
|
||||
newFormData.value.dateRange && newFormData.value.dateRange.length > 0 ? newFormData.value.dateRange[0] : '',
|
||||
releaseDateEnd:
|
||||
newFormData.value.dateRange && newFormData.value.dateRange.length > 0 ? newFormData.value.dateRange[1] : '',
|
||||
current: pager.value.pageIndex,
|
||||
size: pager.value.pageSize
|
||||
});
|
||||
if (!error && data) {
|
||||
allTableData.value = data.data.records;
|
||||
tableData.value = data.data.records;
|
||||
pager.value.total = data.data.total;
|
||||
|
||||
console.log(tableData.value);
|
||||
}
|
||||
};
|
||||
|
||||
const getLanguageList = async () => {
|
||||
const res: any = await searchLanguageList();
|
||||
if (!res.error) {
|
||||
languageList.value = res.data.data;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await getLanguageList();
|
||||
nextTick(() => {
|
||||
getReleaseList();
|
||||
});
|
||||
// getReleaseList();
|
||||
});
|
||||
|
||||
const exportResult = async () => {
|
||||
const selectDatas = allTableData.value.map((d) => d.id);
|
||||
if (!allTableData.value.length || selectDatas.length <= 0) {
|
||||
Message.info('未选择任何数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const { data, error } = await getReleaseExport({
|
||||
list: selectDatas,
|
||||
});
|
||||
debugger
|
||||
if (data && !error) {
|
||||
// 方法1:如果后端返回的是文件流(Blob)
|
||||
const blob = new Blob([data.data]);
|
||||
const downloadUrl = window.URL.createObjectURL(blob);
|
||||
|
||||
// 创建一个临时的a标签触发下载
|
||||
const link = document.createElement('a');
|
||||
link.href = downloadUrl;
|
||||
|
||||
// 从Content-Disposition头中获取文件名,或者使用默认文件名
|
||||
const contentDisposition = data.headers['content-disposition'];
|
||||
let fileName = 'export.xlsx'; // 默认文件名
|
||||
// if (contentDisposition) {
|
||||
// const fileNameMatch = contentDisposition.match(/filename="?(.+)"?/);
|
||||
// if (fileNameMatch && fileNameMatch[1]) {
|
||||
// fileName = fileNameMatch[1].replace(/^[^0-9]*|[^0-9.xlsx]*$/g, "");
|
||||
// }
|
||||
// }
|
||||
|
||||
link.setAttribute('download', fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// 清理
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(downloadUrl);
|
||||
} else {
|
||||
console.error('导出失败:', error);
|
||||
// 这里可以添加错误提示,比如使用Element Plus的ElMessage
|
||||
ElMessage.error('文件导出失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 事件处理函数
|
||||
function handleRefresh() {
|
||||
console.log('刷新点击');
|
||||
// 实际业务代码示例:
|
||||
// location.reload(); // 重新加载页面
|
||||
// 或调用API刷新数据
|
||||
}
|
||||
|
||||
function handleFile() {
|
||||
console.log('文件点击');
|
||||
// 示例:触发文件上传
|
||||
// document.getElementById('file-input').click();
|
||||
}
|
||||
|
||||
function handleLike() {
|
||||
console.log('点赞点击');
|
||||
// 示例:切换点赞状态
|
||||
const likeBtn = document.querySelector('.icon-like');
|
||||
likeBtn.classList.toggle('active');
|
||||
// 这里可以添加AJAX请求提交点赞状态
|
||||
}
|
||||
|
||||
function handleDislike() {
|
||||
console.log('踩点击');
|
||||
// 类似点赞的逻辑
|
||||
const dislikeBtn = document.querySelector('.icon-dislike');
|
||||
dislikeBtn.classList.toggle('active');
|
||||
}
|
||||
|
||||
function handleCustomerService() {
|
||||
console.log('客服点击');
|
||||
// 示例:打开客服对话框
|
||||
// openChatWindow();
|
||||
}
|
||||
|
||||
function handleMore() {
|
||||
console.log('更多操作点击');
|
||||
// 示例:显示下拉菜单
|
||||
// showDropdownMenu();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import 'devui-theme/styles-var/devui-var.scss';
|
||||
|
||||
.secret-container {
|
||||
position: relative;
|
||||
min-height: 600px;
|
||||
background: #ffffff;
|
||||
padding: 20px;
|
||||
margin-top: 16px;
|
||||
border-radius: 15px;
|
||||
|
||||
.title {
|
||||
color: #191919;
|
||||
font-family: HarmonyOS Sans SC;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
letter-spacing: 0px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.secret-op {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.error {
|
||||
color: $devui-contrast;
|
||||
}
|
||||
|
||||
:deep(.devui-table__row td) {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
:deep(.devui-tag .devui-tag--default) {
|
||||
background-color: #fff;
|
||||
border-radius: 12px;
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
margin-right: 8px;
|
||||
border: 1px solid #e3e3ee;
|
||||
}
|
||||
|
||||
.one-line {
|
||||
word-break: break-all;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: #9a9b9c;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.cur-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #2d2d2e;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.output-btn {
|
||||
border-radius: 16px;
|
||||
background: #DFDFDF;
|
||||
|
||||
|
||||
color: #191919;
|
||||
font-family: HarmonyOS Sans SC;
|
||||
font-weight: regular;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
letter-spacing: 0px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.secret-breadcrumb {
|
||||
padding: 7px 20px 12px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.bubble-bottom-operations {
|
||||
margin-top: 16px;
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
gap: 8px; /* 图标之间的间隔 */
|
||||
align-items: center; /* 垂直居中图标 */
|
||||
justify-content: end;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -3,17 +3,51 @@
|
||||
<div class="home-content">
|
||||
<div v-if="startChat" ref="conversationRef" class="conversation-area">
|
||||
<template v-for="(msg, idx) in messages" :key="idx">
|
||||
<McBubble v-if="msg.from === 'user'" :content="msg.content" :align="'right'" :avatarConfig="msg.avatarConfig"></McBubble>
|
||||
<McBubble v-else :loading="msg.loading ?? false" :avatarConfig="msg.avatarConfig">
|
||||
<McMarkdownCard :content="msg.content" :theme="theme"></McMarkdownCard>
|
||||
<template #bottom>
|
||||
<div class="bubble-bottom-operations">
|
||||
<i class="icon-copy-new"></i>
|
||||
<i class="icon-like"></i>
|
||||
<i class="icon-dislike"></i>
|
||||
<McBubble v-if="msg.from === 'user'" :content="msg.content" :align="'right'" ></McBubble>
|
||||
<McBubble v-else :loading="msg.loading ?? false" >
|
||||
<div class="think-toggle-btn" @click="toggleThink(idx)">
|
||||
<div class="flex align-middle">
|
||||
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_skgc.png" />
|
||||
<span class="span1">思考过程:</span>
|
||||
<i style="margin-left: auto" :class="btnIcon"></i>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="flex align-middle" style="margin-top: 6px">
|
||||
<i style="font-size: 16px;height: 15px;margin-right: 8px" class="icon icon-right"></i>
|
||||
<span class="span1">完成回答:</span>
|
||||
</div>
|
||||
<!--开源软件列表-->
|
||||
<OssList />
|
||||
<div class="conversation-cnxw">
|
||||
<a class="flex conversation-cnxw-item">
|
||||
<span class="span2">猜你想问</span>
|
||||
<img style="height: 15px;margin-right: 8px" width="16" src="@/assets/imgs/jyh/ai/icon_generate.png" />
|
||||
</a>
|
||||
<div class="flex conversation-cnxw-item">
|
||||
<a class="g-header-copilot" @click="onSubmit('我想看Redis的详情')">
|
||||
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
|
||||
<span class="ml-xs">我想看Redis的详情</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex conversation-cnxw-item">
|
||||
<a class="g-header-copilot" @click="onSubmit('Redis的可信评分是多少')">
|
||||
<img style="height: 15px;" width="16" src="@/assets/imgs/jyh/ai/icon_cnxw.png" />
|
||||
<span class="ml-xs">Redis的可信评分是多少</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</McBubble>
|
||||
|
||||
<!-- <McBubble v-else :loading="msg.loading ?? false" :avatarConfig="msg.avatarConfig">-->
|
||||
<!-- <McMarkdownCard :content="msg.content" :theme="theme"></McMarkdownCard>-->
|
||||
<!-- <template #bottom>-->
|
||||
<!-- <div class="bubble-bottom-operations">-->
|
||||
<!-- <i class="icon-copy-new"></i>-->
|
||||
<!-- <i class="icon-like"></i>-->
|
||||
<!-- <i class="icon-dislike"></i>-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- </McBubble>-->
|
||||
</template>
|
||||
</div>
|
||||
<div v-else class="welcome-page">
|
||||
@@ -31,20 +65,20 @@
|
||||
</div>
|
||||
<!--猜你想问-->
|
||||
<div style="width: 100%;margin-top: -20px">
|
||||
<GuessYouWantToAsk />
|
||||
<GuessYouWantToAsk @submit="onSubmit"/>
|
||||
</div>
|
||||
</div>
|
||||
<!--操作按钮-->
|
||||
<div class="new-convo-button">
|
||||
<McPrompt
|
||||
v-if="startChat"
|
||||
class="simple-prompt"
|
||||
style="flex: 1"
|
||||
:list="simplePrompt"
|
||||
:direction="'horizontal'"
|
||||
@itemClick="onItemClick($event)"
|
||||
></McPrompt>
|
||||
<div v-else class="agent-knowledge">
|
||||
<!-- <McPrompt-->
|
||||
<!-- v-if="startChat"-->
|
||||
<!-- class="simple-prompt"-->
|
||||
<!-- style="flex: 1"-->
|
||||
<!-- :list="simplePrompt"-->
|
||||
<!-- :direction="'horizontal'"-->
|
||||
<!-- @itemClick="onItemClick($event)"-->
|
||||
<!-- ></McPrompt>-->
|
||||
<div class="agent-knowledge">
|
||||
<d-dropdown :position="['top']" @toggle="(val) => (isAgentOpen = val)">
|
||||
<div class="agent-wrapper">
|
||||
<img src="@/assets/imgs/jyh/ai/aiLogo2.png" />
|
||||
@@ -98,6 +132,7 @@ import { ref, defineComponent, nextTick, onMounted } from 'vue';
|
||||
import { introPrompt, simplePrompt, mockAnswer, guessQuestions } from './mock.constants';
|
||||
import SwiperComponent from './SwiperComponent.vue';
|
||||
import GuessYouWantToAsk from './GuessYouWantToAsk.vue';
|
||||
import OssList from './components/OssList.vue';
|
||||
|
||||
const inputValue = ref('');
|
||||
const startChat = ref(false);
|
||||
@@ -156,31 +191,41 @@ const onSubmit = (e, answer = undefined) => {
|
||||
behavior: 'smooth',
|
||||
});
|
||||
});
|
||||
getAIAnswer(answer ?? e);
|
||||
// getAIAnswer(answer ?? e);
|
||||
getAIAnswer(mockAnswer);
|
||||
};
|
||||
|
||||
const getAIAnswer = (content) => {
|
||||
messages.value.push({
|
||||
from: 'ai-model',
|
||||
content: '',
|
||||
content: content,
|
||||
avatarPosition: 'side-left',
|
||||
avatarConfig: { ...aiModelAvatar },
|
||||
loading: true,
|
||||
loading: false,
|
||||
});
|
||||
|
||||
/* 模拟流式数据返回 */
|
||||
setTimeout(async () => {
|
||||
messages.value.at(-1).loading = false;
|
||||
for (let i = 0; i < content.length;) {
|
||||
await new Promise(r => setTimeout(r, 300 * Math.random()));
|
||||
messages.value[messages.value.length - 1].content = content.slice(0, i += Math.random() * 10);
|
||||
nextTick(() => {
|
||||
conversationRef.value?.scrollTo({
|
||||
top: conversationRef.value.scrollHeight
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// messages.value.push({
|
||||
// from: 'ai-model',
|
||||
// content: '',
|
||||
// avatarPosition: 'side-left',
|
||||
// avatarConfig: { ...aiModelAvatar },
|
||||
// loading: true,
|
||||
// });
|
||||
|
||||
// /* 模拟流式数据返回 */
|
||||
// setTimeout(async () => {
|
||||
// messages.value.at(-1).loading = false;
|
||||
// for (let i = 0; i < content.length;) {
|
||||
// await new Promise(r => setTimeout(r, 300 * Math.random()));
|
||||
// messages.value[messages.value.length - 1].content = content.slice(0, i += Math.random() * 10);
|
||||
// nextTick(() => {
|
||||
// conversationRef.value?.scrollTo({
|
||||
// top: conversationRef.value.scrollHeight
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }, 1000);
|
||||
};
|
||||
|
||||
const onNewConvo = () => {
|
||||
@@ -201,6 +246,26 @@ const themeChange = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const isLoading = ref(false);
|
||||
let interval = null;
|
||||
const thinkBtnText = ref('思考过程');
|
||||
const btnIcon = ref('icon-chevron-down-2');
|
||||
|
||||
const toggleThink = (idx) => {
|
||||
if (isLoading.value) {
|
||||
return
|
||||
}
|
||||
const targetNode = document.querySelectorAll('.mc-bubble-content-container')[idx];
|
||||
if (targetNode) {
|
||||
const thinkBlock = targetNode.querySelector('.mc-think-block');
|
||||
if (thinkBlock) {
|
||||
const currentDisplay = getComputedStyle(thinkBlock).display;
|
||||
thinkBlock.style.display = currentDisplay === 'none' ? 'block' : 'none';
|
||||
btnIcon.value = currentDisplay === 'none' ? 'icon-chevron-up-2' :'icon-chevron-down-2'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if(typeof window !== 'undefined'){
|
||||
themeService = window['devuiThemeService'];
|
||||
@@ -215,7 +280,7 @@ onMounted(() => {
|
||||
<style scoped lang="scss">
|
||||
.home-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: calc(100vh - 56px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
@@ -227,7 +292,7 @@ onMounted(() => {
|
||||
padding-top: 3%;
|
||||
padding-bottom: 1%;
|
||||
height: 100%;
|
||||
width: 50%;
|
||||
width: 60%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-self: center;
|
||||
@@ -284,17 +349,78 @@ onMounted(() => {
|
||||
|
||||
.conversation-area,
|
||||
.welcome-page {
|
||||
height: 90%;
|
||||
//height: 90%;
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
//overflow: auto;
|
||||
overflow: auto;
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.conversation-area {
|
||||
gap: 8px;
|
||||
:deep(.mc-bubble-right) {
|
||||
.mc-bubble-content {
|
||||
background: #DFDFDF;
|
||||
}
|
||||
}
|
||||
:deep(.mc-bubble-left) {
|
||||
.mc-bubble-content-container {
|
||||
background: transparent;
|
||||
width: 100%;
|
||||
.span1{
|
||||
color: #777777;
|
||||
font-family: HarmonyOS Sans SC;
|
||||
font-weight: regular;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
letter-spacing: 0px;
|
||||
text-align: left;
|
||||
}
|
||||
.mc-bubble-content.filled {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
.conversation-cnxw {
|
||||
margin-top: 8px;
|
||||
.conversation-cnxw-item {
|
||||
cursor: pointer;
|
||||
align-items: center;
|
||||
justify-content: end;
|
||||
margin-right: 12px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.span2{
|
||||
color: black;
|
||||
font-family: HarmonyOS Sans SC;
|
||||
font-weight: regular;
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
letter-spacing: 0px;
|
||||
text-align: left;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.g-header-copilot {
|
||||
background: #fff;
|
||||
color: black;
|
||||
//width: 120px;
|
||||
padding: 0 12px;
|
||||
border-radius: 48px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
justify-content: center;
|
||||
&:hover {
|
||||
background: rgba(41, 81, 224, 0.8);
|
||||
}
|
||||
}
|
||||
.g-header-copilot:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.welcome-page {
|
||||
|
||||
@@ -32,14 +32,65 @@ export const simplePrompt = [
|
||||
},
|
||||
];
|
||||
|
||||
export const mockAnswer = {
|
||||
how_to_use_for_coding: 'MateChat 可以通过输入相关的代码需求,比如函数实现、算法逻辑等,它会为您提供代码示例和解释。您可以输入具体的代码功能描述,例如“编写一个冒泡排序算法”,MateChat 会给出相应的代码实现。',
|
||||
what_knowledge_can_query: 'MateChat 可以查询编程知识、算法、数据结构、编程语言特性、框架使用方法等。还可以查询作业相关的信息,例如任务进度、资源分配等。',
|
||||
how_to_add_knowledge: '要添加知识到 MateChat,您可以点击界面上的“添加知识”按钮,然后按照提示上传相关的文档或者输入具体的知识内容即可。',
|
||||
quick_code_example: '以下是一个简单的 JavaScript 代码示例,用于计算数组的总和:\n```javascript\nconst arr = [1, 2, 3, 4, 5];\nconst sum = arr.reduce((acc, val) => acc + val, 0);\nconsole.log(sum);\n```',
|
||||
performance_optimization: '性能优化可以从多个方面入手,例如减少循环嵌套、合理使用缓存、优化算法复杂度等。对于具体的代码,您可以提供给 MateChat 进行分析和建议。',
|
||||
write_document_assistance: 'MateChat 可以辅助您编写文档,例如生成文档大纲、填充内容等。您可以输入文档的主题和一些关键信息,然后让 MateChat 帮助您生成相关内容。',
|
||||
};
|
||||
export const mockAnswer1 = `
|
||||
<think></think>
|
||||
|
||||
|
||||
`
|
||||
|
||||
export const mockAnswer = `
|
||||
<think>
|
||||
嗯,用户让我帮他写一个快速排序。我得先回想一下快速排序的原理。快速排序是分治算法的一种,基本步骤是选一个基准元素,然后把数组分成两部分,一部分比基准小,另一部分比基准大,然后递归地对这两部分排序。
|
||||
|
||||
首先,我得确定基准的选择。通常有三种方法:选第一个元素、选中间元素或者随机选。选中间可能比较好,避免最坏情况的时间复杂度。比如数组已经有序的时候,选第一个会导致O(n²)的时间复杂度,但选中间元素可能更平衡。
|
||||
|
||||
然后,分区操作怎么做呢?分区的目标是把比基准小的放左边,大的放右边。可以用双指针的方法,左边找比基准大的,右边找比基准小的,然后交换,直到指针相遇。这时候再把基准放到正确的位置,返回基准的索引。
|
||||
|
||||
接下来是递归调用。对基准左边的子数组和右边的子数组分别进行快速排序,直到子数组的长度小于等于1,这时候数组就已经有序了。
|
||||
|
||||
现在要考虑用户的需求。用户可能对编程不太熟悉,所以代码需要简洁易懂,同时要有注释说明。或者用户可能需要一个高效的实现,不过快速排序的平均时间复杂度已经是O(n log n)了,应该没问题。
|
||||
|
||||
可能的边缘情况是数组为空或只有一个元素,这时候直接返回。所以函数里要先处理这种情况。
|
||||
|
||||
然后,测试一下这个函数是否正确。比如输入一个无序数组,比如[3,6,8,10,1,2,1],看看排序后的结果是否是[1,1,2,3,6,8,10]。或者测试已经有序的数组,比如[1,2,3,4,5],确保不会出现栈溢出或者错误的结果。
|
||||
|
||||
还有,是否需要处理重复元素?快速排序本身是能处理重复的,所以应该没问题。
|
||||
|
||||
再考虑语言的问题,用户没有说明用什么语言,但根据用户的名字或者上下文,可能想要Python的实现?或者可能其他语言。不过根据常见情况,可能先给出Python版本。
|
||||
|
||||
所以,综合这些思考,可以写出一个Python的快速排序函数。基准选中间元素,分区使用双指针,递归处理左右子数组。然后加上注释,解释每一步的作用。
|
||||
|
||||
最后,给出示例用法,让用户知道如何调用这个函数,并验证结果是否正确。
|
||||
</think>
|
||||
|
||||
以下是使用 Python 实现的快速排序算法,包含详细注释:
|
||||
|
||||
\`\`\`python
|
||||
def quick_sort(arr):
|
||||
"""实现快速排序的递归函数"""
|
||||
# 基线条件:当数组长度小于等于1时,直接返回
|
||||
if len(arr) <= 1:
|
||||
return arr
|
||||
|
||||
# 选择中间元素作为基准值(可有效避免最坏情况)
|
||||
pivot = arr[len(arr) // 2]
|
||||
|
||||
# 将数组分成三部分:小于基准、等于基准、大于基准
|
||||
left = [x for x in arr if x < pivot]
|
||||
middle = [x for x in arr if x == pivot]
|
||||
right = [x for x in arr if x > pivot]
|
||||
|
||||
# 递归排序左右子数组,合并结果
|
||||
return quick_sort(left) + middle + quick_sort(right)
|
||||
|
||||
# 示例用法
|
||||
if __name__ == "__main__":
|
||||
example_arr = [3,6,8,10,1,2,1]
|
||||
sorted_arr = quick_sort(example_arr)
|
||||
print("原数组:", example_arr)
|
||||
print("排序后:", sorted_arr)
|
||||
\`\`\`
|
||||
`
|
||||
|
||||
export const guessQuestions = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user