Skip to content

Commit cae87d3

Browse files
committed
s
1 parent 1b3d524 commit cae87d3

File tree

6 files changed

+321
-45
lines changed

6 files changed

+321
-45
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
.vercel

src/components/Check.vue

+180-38
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,15 @@
198198
<MessageOutlined/>
199199
</a>
200200
</a-tooltip>
201-
<a-tooltip :title="t('SHARE')" placement="bottom">
202-
<a @click="goShare" class="icon-button">
201+
<a-tooltip :title="!testingComplete ? t('PLEASE_WAIT_FOR_TESTING') : t('SHARE')" placement="bottom">
202+
<a-button
203+
@click="goShare"
204+
class="icon-button"
205+
:disabled="!testingComplete"
206+
type="text"
207+
icon>
203208
<ShareAltOutlined/>
204-
</a>
209+
</a-button>
205210
</a-tooltip>
206211

207212
<a-dropdown trigger="click">
@@ -379,14 +384,12 @@
379384
</a-row>
380385
</a-form>
381386
</a-modal>
382-
383387
<a-modal
384388
v-model:open="showAppSettingsModal"
385389
:title="t('SETTINGS_PANEL')"
386390
:footer="null"
387391
:width="600"
388392
@cancel="closeSettingsModal"
389-
class="settings-modal"
390393
:centered="true"
391394
:destroyOnClose="true"
392395
>
@@ -712,7 +715,7 @@ import {
712715
MessageOutlined
713716
} from '@ant-design/icons-vue';
714717
import {computed, h, onMounted, reactive, ref, nextTick, onBeforeUnmount} from 'vue';
715-
import {message, Modal, ConfigProvider, theme, Table as aTable} from 'ant-design-vue';
718+
import {message, Modal, ConfigProvider, theme, Table as aTable, notification, Collapse} from 'ant-design-vue';
716719
import {useWindowSize} from '@vueuse/core';
717720
import {useI18n} from 'vue-i18n';
718721
@@ -729,7 +732,7 @@ import {checkForUpdates} from '../utils/update.js';
729732
import ModelVerifier from '../utils/verify.js';
730733
import {toggleTheme} from '../utils/theme.js';
731734
import {createSVGDataURL} from '../utils/svg.js';
732-
import {appInfo} from '../utils/info.js';
735+
import {appInfo, announcement} from '../utils/info.js';
733736
import {cantFunctionModelList, cantTemperatureModelList, cantOfficialModelList} from "../utils/models.js";
734737
735738
// 注册必须的组件
@@ -785,7 +788,7 @@ const apiKey = ref('');
785788
const modelName = ref('');
786789
const modelTimeout = ref(10);
787790
const modelConcurrency = ref(5);
788-
const currentLanguage = ref(locale.value || 'zh');
791+
const currentLanguage = computed(() => (locale.value.startsWith('zh') ? 'zh' : 'en'));
789792
const showLanguageMenu = ref(false);
790793
const models = ref([]);
791794
const selectedModels = ref([]);
@@ -803,6 +806,7 @@ const chartContainer = ref(null);
803806
let chartInstance = null;
804807
const showSVGModal = ref(false);
805808
const svgDataUrl = ref('');
809+
const testingComplete = ref(false);
806810
807811
const appDescription = computed(() => {
808812
const currentLocale = locale.value || 'zh';
@@ -811,7 +815,7 @@ const appDescription = computed(() => {
811815
812816
// 打开官方网站的方法
813817
function openWebsite() {
814-
window.open(appInfo.website, '_blank');
818+
window.open(appInfo.officialUrl, '_blank');
815819
}
816820
817821
// 打开更新日志的方法
@@ -828,12 +832,6 @@ const paginatedData = computed(() => {
828832
// 设置面板相关状态
829833
const showAppSettingsModal = ref(false);
830834
831-
function getButtonColor(button) {
832-
const color = buttonColors[button.label] || '';
833-
console.log('Button label:', button.label, 'Color:', color);
834-
return color;
835-
}
836-
837835
// 主题切换方法
838836
const handleToggleTheme = () => {
839837
toggleTheme(isDarkMode);
@@ -849,7 +847,6 @@ const toggleLanguageMenu = () => {
849847
// 语言切换方法
850848
const setLanguage = (language) => {
851849
locale.value = language;
852-
currentLanguage.value = language;
853850
localStorage.setItem('locale', language);
854851
showLanguageMenu.value = false; // 切换语言后隐藏菜单
855852
};
@@ -878,10 +875,8 @@ onMounted(() => {
878875
879876
// 初始化设置
880877
setVh();
881-
882878
// 监听窗口尺寸变化,重新计算视口高度
883879
window.addEventListener('resize', setVh);
884-
885880
// 在组件卸载前移除事件监听
886881
onBeforeUnmount(() => {
887882
window.removeEventListener('resize', setVh);
@@ -896,8 +891,9 @@ onMounted(() => {
896891
localCacheList.value = [];
897892
}
898893
getQueryParams();
894+
});
899895
900-
896+
onMounted(() => {
901897
// 智能提取 api info
902898
document.getElementById('api_info').addEventListener('input', function () {
903899
let text = this.value;
@@ -923,17 +919,6 @@ onMounted(() => {
923919
});
924920
});
925921
926-
onMounted(async () => {
927-
const owner = appInfo.owner;
928-
const repo = appInfo.repo;
929-
930-
const updateInfo = await checkForUpdates(appInfo.version, owner, repo, t);
931-
932-
if (updateInfo && updateInfo.hasUpdate) {
933-
showUpdatePrompt(updateInfo);
934-
}
935-
});
936-
937922
// 显示更新提示的函数
938923
function showUpdatePrompt(updateInfo) {
939924
Modal.confirm({
@@ -954,9 +939,11 @@ function showUpdatePrompt(updateInfo) {
954939
}
955940
956941
// 函数:获取 URL 参数
957-
const getQueryParams = () => {
942+
const getQueryParams = async () => {
958943
const params = new URLSearchParams(window.location.search);
959944
const settings = params.get('settings');
945+
const owner = appInfo.owner;
946+
const repo = appInfo.repo;
960947
if (settings) {
961948
try {
962949
const settingsObj = JSON.parse(decodeURIComponent(settings));
@@ -976,14 +963,22 @@ const getQueryParams = () => {
976963
modelConcurrency.value = settingsObj.concurrency;
977964
}
978965
if (!settingsObj.closeAnnouncement) {
979-
showToast();
966+
showAnnouncement();
967+
const updateInfo = await checkForUpdates(appInfo.version, owner, repo, t);
968+
if (updateInfo && updateInfo.hasUpdate) {
969+
showUpdatePrompt(updateInfo);
970+
}
980971
}
981972
showSettingsModal();
982973
} catch (e) {
983974
console.error('解析URL参数失败:', e);
984975
}
985976
} else {
986-
showToast();
977+
showAnnouncement();
978+
const updateInfo = await checkForUpdates(appInfo.version, owner, repo, t);
979+
if (updateInfo && updateInfo.hasUpdate) {
980+
showUpdatePrompt(updateInfo);
981+
}
987982
}
988983
};
989984
@@ -1011,10 +1006,115 @@ const showSettingsModal = () => {
10111006
});
10121007
};
10131008
1014-
// 显示提示消息
1015-
const showToast = () => {
1016-
message.info('欢迎使用API CHECK!');
1017-
};
1009+
1010+
function showAnnouncement() {
1011+
const isOfficialSite = window.location.hostname === 'check.crond.dev';
1012+
const lang = currentLanguage.value;
1013+
let descriptionNodes = [];
1014+
descriptionNodes.push(
1015+
h(
1016+
'div',
1017+
{
1018+
style: 'font-weight: bold; font-size: 16px; margin-bottom: 8px;',
1019+
},
1020+
`${appInfo.name} v${appInfo.version}`
1021+
)
1022+
);
1023+
descriptionNodes.push(h('br'));
1024+
descriptionNodes.push(
1025+
h('div', [
1026+
t('REPO_ADDRESS'),
1027+
': ',
1028+
h(
1029+
'a',
1030+
{
1031+
href: appInfo.githubUrl,
1032+
target: '_blank',
1033+
style: 'color: #1890ff;',
1034+
},
1035+
appInfo.owner + "/" + appInfo.repo
1036+
),
1037+
])
1038+
);
1039+
descriptionNodes.push(h('div', t('STAR_PROJECT')));
1040+
descriptionNodes.push(h('br'));
1041+
descriptionNodes.push(
1042+
h('div', [
1043+
t('NEW_DOMAIN'),
1044+
': ',
1045+
h(
1046+
'a',
1047+
{
1048+
href: appInfo.officialUrl,
1049+
target: '_blank',
1050+
style: 'color: #1890ff;',
1051+
},
1052+
appInfo.officialUrl
1053+
),
1054+
])
1055+
);
1056+
if (isOfficialSite) {
1057+
descriptionNodes.push(h('br'));
1058+
announcement.officialContent[lang].forEach((line) => {
1059+
descriptionNodes.push(h('div', line));
1060+
});
1061+
}
1062+
descriptionNodes.push(h('br'));
1063+
descriptionNodes.push(h('div', {style: 'font-weight: bold;'}, t('HOW_TO_USE')));
1064+
announcement.howToUse[lang].forEach((line) => {
1065+
descriptionNodes.push(h('div', line));
1066+
});
1067+
1068+
descriptionNodes.push(h('br'));
1069+
const collapsePanels = [
1070+
h(
1071+
Collapse.Panel,
1072+
{header: t('VERSION_HISTORY'), key: '2'},
1073+
{
1074+
default: () => {
1075+
return announcement.updateLog[lang].map((log) =>
1076+
h('div', [
1077+
h('strong', `${log.version} - ${log.date}`),
1078+
h(
1079+
'ul',
1080+
{
1081+
style: 'padding-left: 20px; margin: 4px 0;',
1082+
},
1083+
log.content.map((item) => h('li', {style: 'margin: 2px 0;'}, item))
1084+
),
1085+
])
1086+
);
1087+
},
1088+
}
1089+
),
1090+
];
1091+
descriptionNodes.push(
1092+
h(
1093+
Collapse,
1094+
{
1095+
accordion: true,
1096+
class: 'announcement-collapse', // 添加类名
1097+
style: 'margin-bottom: 8px;',
1098+
},
1099+
{
1100+
default: () => collapsePanels,
1101+
}
1102+
)
1103+
);
1104+
// 显示通知
1105+
notification.open({
1106+
message: null,
1107+
description: h('div', descriptionNodes),
1108+
placement: 'topRight',
1109+
duration: 0,
1110+
onClose: () => {
1111+
localStorage.setItem('announcementShown', 'true');
1112+
},
1113+
style: {
1114+
width: '350px', // 调整通知的宽度
1115+
},
1116+
});
1117+
}
10181118
10191119
// 清除表单
10201120
const clearForm = () => {
@@ -1181,7 +1281,7 @@ async function testModels() {
11811281
totalModels.value = selectedModels.value.length;
11821282
completedModels.value = 0;
11831283
progressPercent.value = 0;
1184-
1284+
testingComplete.value = false;
11851285
testModels_spinning.value = true;
11861286
11871287
try {
@@ -1195,13 +1295,19 @@ async function testModels() {
11951295
updateTableData(progress);
11961296
completedModels.value += 1;
11971297
progressPercent.value = Math.round((completedModels.value / totalModels.value) * 100);
1298+
if (completedModels.value >= totalModels.value) {
1299+
testingComplete.value = true;
1300+
}
11981301
}
11991302
);
12001303
testModels_spinning.value = false;
12011304
showSummary(results);
12021305
} catch (error) {
12031306
testModels_spinning.value = false;
12041307
message.error('测试模型时发生错误: ' + error.message);
1308+
} finally {
1309+
testModels_spinning.value = false;
1310+
testingComplete.value = true;
12051311
}
12061312
}
12071313
@@ -2089,6 +2195,7 @@ function goChat() {
20892195
20902196
function goShare() {
20912197
// 生成 SVG Data URL
2198+
20922199
svgDataUrl.value = createSVGDataURL(results, apiUrl.value);
20932200
showSVGModal.value = true;
20942201
}
@@ -2916,6 +3023,12 @@ body.light-mode {
29163023
justify-content: center; /* 使按钮在水平方向居中 */
29173024
gap: 5px;
29183025
}
3026+
3027+
input[type='text'],
3028+
textarea,
3029+
input[type='number'] {
3030+
font-size: 16px; /* 在移动设备上将字体大小设置为 16px */
3031+
}
29193032
}
29203033
29213034
.list-item {
@@ -3091,6 +3204,35 @@ body.light-mode {
30913204
margin-left: auto; /* 将最后一个按钮(关闭按钮)推到最右侧 */
30923205
}
30933206
3207+
/* 折叠面板标题样式 */
3208+
.announcement-collapse .ant-collapse-header {
3209+
font-weight: bold;
3210+
font-size: 14px;
3211+
padding: 8px;
3212+
}
3213+
3214+
/* 折叠面板内容样式 */
3215+
.announcement-collapse .ant-collapse-content {
3216+
padding: 8px;
3217+
}
30943218
3219+
/* 调整折叠面板的边框和背景 */
3220+
.announcement-collapse .ant-collapse {
3221+
border: none;
3222+
background-color: transparent;
3223+
}
3224+
3225+
.announcement-collapse .ant-collapse-item {
3226+
border-bottom: 1px solid #e8e8e8;
3227+
}
3228+
3229+
.announcement-collapse .ant-collapse-content > .ant-collapse-content-box {
3230+
padding: 0 8px;
3231+
}
3232+
3233+
/* 调整列表项的样式 */
3234+
.announcement-collapse li {
3235+
margin: 4px 0;
3236+
}
30953237
</style>
30963238

0 commit comments

Comments
 (0)