Skip to content

Commit 4856297

Browse files
committed
Feature :table pagination and enhance model display functionality.
1 parent a8bfe0a commit 4856297

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

src/components/Check.vue

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240

241241
<div class="left-icons">
242242
<a-tooltip :title="t('CHAT')" placement="bottom">
243-
<a @click="goChat" class="icon-button">
243+
<a @click="goChat()" class="icon-button">
244244
<MessageOutlined />
245245
</a>
246246
</a-tooltip>
@@ -292,17 +292,23 @@
292292
<a-table
293293
:columns="columns"
294294
:data-source="tableData"
295-
:pagination="{ pageSize: 8 }"
295+
:pagination="pagination"
296296
:row-key="record => record.key"
297297
size="small"
298298
class="result-table"
299+
@change="handleTableChange"
300+
@resizeColumn="handleResizeColumn"
299301
>
300302
<template #bodyCell="{ text, record, column, index }">
301303
<template v-if="column.dataIndex === 'status'">
302304
{{ record.status }}
303305
</template>
304306
<template v-else-if="column.dataIndex === 'model'">
305-
<span @click="copyText(item.model)">
307+
<span style="display: flex; align-items: center">
308+
<MessageOutlined
309+
style="margin-right: 8px; cursor: pointer"
310+
@click="goChat(record.model)"
311+
/>
306312
{{ record.model }}
307313
</span>
308314
</template>
@@ -1157,6 +1163,21 @@ let chartInstance = null;
11571163
const showSVGModal = ref(false);
11581164
const svgDataUrl = ref('');
11591165
const testingComplete = ref(false);
1166+
const tableData = ref([]);
1167+
const totalModels = ref(0);
1168+
const completedModels = ref(0);
1169+
const progressPercent = ref(0);
1170+
const pagination = reactive({
1171+
current: 1,
1172+
pageSize: 8, // 默认每页显示8条,可以根据需要调整
1173+
pageSizeOptions: ['8', '12', '20'], // 可供选择的每页条数
1174+
showSizeChanger: true, // 显示每页条数切换器
1175+
total: computed(() => tableData.value.length), // 数据总数
1176+
});
1177+
const handleTableChange = (paginationInfo, filters, sorter) => {
1178+
pagination.current = paginationInfo.current;
1179+
pagination.pageSize = paginationInfo.pageSize;
1180+
};
11601181
11611182
const appDescription = computed(() => {
11621183
const currentLocale = locale.value || 'zh';
@@ -1596,11 +1617,6 @@ const checkQuota = async () => {
15961617
}
15971618
};
15981619
1599-
const tableData = ref([]);
1600-
const totalModels = ref(0);
1601-
const completedModels = ref(0);
1602-
const progressPercent = ref(0);
1603-
16041620
// 添加 testModels 函数
16051621
async function testModels() {
16061622
// 重置结果
@@ -1909,6 +1925,7 @@ const columns = [
19091925
key: 'model',
19101926
width: 180,
19111927
ellipsis: true,
1928+
resizable: true,
19121929
sorter: (a, b) => a.model.localeCompare(b.model),
19131930
customCell: () => ({ attrs: { 'data-label': t('MODEL_NAME_LABEL') } }),
19141931
},
@@ -1917,6 +1934,7 @@ const columns = [
19171934
dataIndex: 'responseTime',
19181935
width: 70,
19191936
key: 'responseTime',
1937+
resizable: true,
19201938
sorter: (a, b) => parseFloat(a.responseTime) - parseFloat(b.responseTime),
19211939
customCell: () => ({ attrs: { 'data-label': t('RESPONSE_TIME_LABEL') } }),
19221940
},
@@ -1926,6 +1944,7 @@ const columns = [
19261944
key: 'remark',
19271945
width: 100,
19281946
ellipsis: true,
1947+
resizable: true,
19291948
customCell: () => ({ attrs: { 'data-label': t('REMARK_LABEL') } }),
19301949
},
19311950
{
@@ -1940,6 +1959,10 @@ const columns = [
19401959
},
19411960
];
19421961
1962+
function handleResizeColumn(w, col) {
1963+
col.width = w;
1964+
}
1965+
19431966
// 复制文本函数
19441967
function copyText(text) {
19451968
navigator.clipboard
@@ -2644,8 +2667,17 @@ onMounted(() => {
26442667
});
26452668
26462669
// goChat
2647-
function goChat() {
2648-
const url = `https://chat.crond.dev/#/?settings={"key":"${apiKey.value}","url":"${apiUrl.value}"}`;
2670+
function goChat(modelName) {
2671+
// 模拟获取模型并打印数据
2672+
if (!apiKey.value || !apiUrl.value) {
2673+
message.error('请先填写 API Key 和 API URL');
2674+
return;
2675+
}
2676+
//判断是否有modelName 没有就不给url 传值
2677+
let url = `https://chat.crond.dev/#/?settings={"key":"${apiKey.value}","url":"${apiUrl.value}"}`;
2678+
if (modelName) {
2679+
url = `https://chat.crond.dev/#/?settings={"key":"${apiKey.value}","url":"${apiUrl.value}","model":"${modelName}"}`;
2680+
}
26492681
window.open(url);
26502682
}
26512683
@@ -2718,7 +2750,8 @@ function copyModels(type) {
27182750
message.info(t('NO_MODELS_TO_COPY'));
27192751
return;
27202752
}
2721-
const textToCopy = models.join('\n');
2753+
//需要加入,分割
2754+
const textToCopy = models.join(',');
27222755
navigator.clipboard
27232756
.writeText(textToCopy)
27242757
.then(() => {

src/utils/models.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,10 @@ export const presetPromptsList = [
7676
description:
7777
'o1系列能答对,gemini-1.5-pro-002概率答对\n(可以根据思考时间分辨):\n 1 2 1 1 2 3 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7',
7878
},
79+
{
80+
title: '给主人留下些什么吧英文翻译',
81+
content: '给主人留下些什么吧翻译成英文',
82+
description:
83+
'gpt-4o:乱回答 \n 比如:好好表现 can be translated into English as perform well or do well.',
84+
},
7985
];

0 commit comments

Comments
 (0)