198
198
<MessageOutlined />
199
199
</a >
200
200
</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 >
203
208
<ShareAltOutlined />
204
- </a >
209
+ </a-button >
205
210
</a-tooltip >
206
211
207
212
<a-dropdown trigger =" click" >
379
384
</a-row >
380
385
</a-form >
381
386
</a-modal >
382
-
383
387
<a-modal
384
388
v-model:open =" showAppSettingsModal"
385
389
:title =" t('SETTINGS_PANEL')"
386
390
:footer =" null"
387
391
:width =" 600"
388
392
@cancel =" closeSettingsModal"
389
- class =" settings-modal"
390
393
:centered =" true"
391
394
:destroyOnClose =" true"
392
395
>
@@ -712,7 +715,7 @@ import {
712
715
MessageOutlined
713
716
} from ' @ant-design/icons-vue' ;
714
717
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' ;
716
719
import {useWindowSize } from ' @vueuse/core' ;
717
720
import {useI18n } from ' vue-i18n' ;
718
721
@@ -729,7 +732,7 @@ import {checkForUpdates} from '../utils/update.js';
729
732
import ModelVerifier from ' ../utils/verify.js' ;
730
733
import {toggleTheme } from ' ../utils/theme.js' ;
731
734
import {createSVGDataURL } from ' ../utils/svg.js' ;
732
- import {appInfo } from ' ../utils/info.js' ;
735
+ import {appInfo , announcement } from ' ../utils/info.js' ;
733
736
import {cantFunctionModelList , cantTemperatureModelList , cantOfficialModelList } from " ../utils/models.js" ;
734
737
735
738
// 注册必须的组件
@@ -785,7 +788,7 @@ const apiKey = ref('');
785
788
const modelName = ref (' ' );
786
789
const modelTimeout = ref (10 );
787
790
const modelConcurrency = ref (5 );
788
- const currentLanguage = ref ( locale .value || ' zh' );
791
+ const currentLanguage = computed (() => ( locale .value . startsWith ( ' zh ' ) ? ' zh' : ' en ' ) );
789
792
const showLanguageMenu = ref (false );
790
793
const models = ref ([]);
791
794
const selectedModels = ref ([]);
@@ -803,6 +806,7 @@ const chartContainer = ref(null);
803
806
let chartInstance = null ;
804
807
const showSVGModal = ref (false );
805
808
const svgDataUrl = ref (' ' );
809
+ const testingComplete = ref (false );
806
810
807
811
const appDescription = computed (() => {
808
812
const currentLocale = locale .value || ' zh' ;
@@ -811,7 +815,7 @@ const appDescription = computed(() => {
811
815
812
816
// 打开官方网站的方法
813
817
function openWebsite () {
814
- window .open (appInfo .website , ' _blank' );
818
+ window .open (appInfo .officialUrl , ' _blank' );
815
819
}
816
820
817
821
// 打开更新日志的方法
@@ -828,12 +832,6 @@ const paginatedData = computed(() => {
828
832
// 设置面板相关状态
829
833
const showAppSettingsModal = ref (false );
830
834
831
- function getButtonColor (button ) {
832
- const color = buttonColors[button .label ] || ' ' ;
833
- console .log (' Button label:' , button .label , ' Color:' , color);
834
- return color;
835
- }
836
-
837
835
// 主题切换方法
838
836
const handleToggleTheme = () => {
839
837
toggleTheme (isDarkMode);
@@ -849,7 +847,6 @@ const toggleLanguageMenu = () => {
849
847
// 语言切换方法
850
848
const setLanguage = (language ) => {
851
849
locale .value = language;
852
- currentLanguage .value = language;
853
850
localStorage .setItem (' locale' , language);
854
851
showLanguageMenu .value = false ; // 切换语言后隐藏菜单
855
852
};
@@ -878,10 +875,8 @@ onMounted(() => {
878
875
879
876
// 初始化设置
880
877
setVh ();
881
-
882
878
// 监听窗口尺寸变化,重新计算视口高度
883
879
window .addEventListener (' resize' , setVh);
884
-
885
880
// 在组件卸载前移除事件监听
886
881
onBeforeUnmount (() => {
887
882
window .removeEventListener (' resize' , setVh);
@@ -896,8 +891,9 @@ onMounted(() => {
896
891
localCacheList .value = [];
897
892
}
898
893
getQueryParams ();
894
+ });
899
895
900
-
896
+ onMounted (() => {
901
897
// 智能提取 api info
902
898
document .getElementById (' api_info' ).addEventListener (' input' , function () {
903
899
let text = this .value ;
@@ -923,17 +919,6 @@ onMounted(() => {
923
919
});
924
920
});
925
921
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
-
937
922
// 显示更新提示的函数
938
923
function showUpdatePrompt (updateInfo ) {
939
924
Modal .confirm ({
@@ -954,9 +939,11 @@ function showUpdatePrompt(updateInfo) {
954
939
}
955
940
956
941
// 函数:获取 URL 参数
957
- const getQueryParams = () => {
942
+ const getQueryParams = async () => {
958
943
const params = new URLSearchParams (window .location .search );
959
944
const settings = params .get (' settings' );
945
+ const owner = appInfo .owner ;
946
+ const repo = appInfo .repo ;
960
947
if (settings) {
961
948
try {
962
949
const settingsObj = JSON .parse (decodeURIComponent (settings));
@@ -976,14 +963,22 @@ const getQueryParams = () => {
976
963
modelConcurrency .value = settingsObj .concurrency ;
977
964
}
978
965
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
+ }
980
971
}
981
972
showSettingsModal ();
982
973
} catch (e) {
983
974
console .error (' 解析URL参数失败:' , e);
984
975
}
985
976
} else {
986
- showToast ();
977
+ showAnnouncement ();
978
+ const updateInfo = await checkForUpdates (appInfo .version , owner, repo, t);
979
+ if (updateInfo && updateInfo .hasUpdate ) {
980
+ showUpdatePrompt (updateInfo);
981
+ }
987
982
}
988
983
};
989
984
@@ -1011,10 +1006,115 @@ const showSettingsModal = () => {
1011
1006
});
1012
1007
};
1013
1008
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
+ }
1018
1118
1019
1119
// 清除表单
1020
1120
const clearForm = () => {
@@ -1181,7 +1281,7 @@ async function testModels() {
1181
1281
totalModels .value = selectedModels .value .length ;
1182
1282
completedModels .value = 0 ;
1183
1283
progressPercent .value = 0 ;
1184
-
1284
+ testingComplete . value = false ;
1185
1285
testModels_spinning .value = true ;
1186
1286
1187
1287
try {
@@ -1195,13 +1295,19 @@ async function testModels() {
1195
1295
updateTableData (progress);
1196
1296
completedModels .value += 1 ;
1197
1297
progressPercent .value = Math .round ((completedModels .value / totalModels .value ) * 100 );
1298
+ if (completedModels .value >= totalModels .value ) {
1299
+ testingComplete .value = true ;
1300
+ }
1198
1301
}
1199
1302
);
1200
1303
testModels_spinning .value = false ;
1201
1304
showSummary (results);
1202
1305
} catch (error) {
1203
1306
testModels_spinning .value = false ;
1204
1307
message .error (' 测试模型时发生错误: ' + error .message );
1308
+ } finally {
1309
+ testModels_spinning .value = false ;
1310
+ testingComplete .value = true ;
1205
1311
}
1206
1312
}
1207
1313
@@ -2089,6 +2195,7 @@ function goChat() {
2089
2195
2090
2196
function goShare () {
2091
2197
// 生成 SVG Data URL
2198
+
2092
2199
svgDataUrl .value = createSVGDataURL (results, apiUrl .value );
2093
2200
showSVGModal .value = true ;
2094
2201
}
@@ -2916,6 +3023,12 @@ body.light-mode {
2916
3023
justify-content : center ; /* 使按钮在水平方向居中 */
2917
3024
gap : 5px ;
2918
3025
}
3026
+
3027
+ input [type = ' text' ],
3028
+ textarea ,
3029
+ input [type = ' number' ] {
3030
+ font-size : 16px ; /* 在移动设备上将字体大小设置为 16px */
3031
+ }
2919
3032
}
2920
3033
2921
3034
.list-item {
@@ -3091,6 +3204,35 @@ body.light-mode {
3091
3204
margin-left : auto ; /* 将最后一个按钮(关闭按钮)推到最右侧 */
3092
3205
}
3093
3206
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
+ }
3094
3218
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
+ }
3095
3237
</style >
3096
3238
0 commit comments