MCPcopy
hub / github.com/ocsjs/ocsjs / createSearchResultAlertElement

Function createSearchResultAlertElement

packages/scripts/src/projects/common.ts:1825–1854  ·  view source on GitHub ↗
(result: SimplifyWorkResult)

Source from the content-addressed store, hash-verified

1823};
1824
1825function createSearchResultAlertElement(result: SimplifyWorkResult) {
1826 let info: HTMLElement | null = null;
1827 let err = result.error || result.searchInfos.find((i) => i.error)?.error;
1828 if (result.requested === false && result.resolved === false) {
1829 info = h('div', { className: 'result-info unresolved' }, '等待搜索中... 🔍');
1830 } else if (err) {
1831 let href = '#';
1832 if (err?.includes('is not valid JSON')) {
1833 err = '题库返回数据错误';
1834 href = 'https://docs.ocsjs.com/docs/other/FQA#tk-data-error';
1835 } else if (err?.includes('题库连接失败')) {
1836 err = '题库连接失败';
1837 href = 'https://docs.ocsjs.com/docs/other/FQA#tk-error';
1838 }
1839 info = h('div', { className: 'result-info error' }, [
1840 '❌ ' + err,
1841 h('a', { href, target: '_blank', style: { marginLeft: '3px' } }, '解决方法?')
1842 ]);
1843 } else if (result.searchInfos.length === 0) {
1844 info = h('div', { className: 'result-info no-answer' }, '❌ 题库没搜索到答案');
1845 } else {
1846 info = result.finish
1847 ? null
1848 : result.resolved === false
1849 ? h('div', { className: 'result-info unresolved' }, '等待顺序答题中... ⏱️')
1850 : h('div', { className: 'result-info error' }, '❌ 此题未完成, 可能是没有匹配的选项。');
1851 }
1852
1853 return h('div', { className: 'alert-info-wrapper' }, [info ?? h('div')]);
1854}

Callers 1

createResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected