From 00d6c2f2866fde8ed07080c7ae2df0409bf6d152 Mon Sep 17 00:00:00 2001 From: Super12138 <70494801+Super12138@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:26:26 +0800 Subject: [PATCH] Improve layout styles --- src/index.css | 55 ++++++++++++++++++++++--------------------- src/settings/index.ts | 2 +- src/test/index.ts | 24 ++++++++++++------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/index.css b/src/index.css index e5330a5..2cb064f 100644 --- a/src/index.css +++ b/src/index.css @@ -90,11 +90,37 @@ strong { transition: 0.1s opacity; } -a { +#nullTip { + display: none; + width: 100%; +} + +#testArea { + display: none; +} + +#references { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + width: 100%; +} + +#resultArea { + margin-top: 3%; + display: none; +} + +#backBtn { + display: none; +} + +.link { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; - max-width: 200px; + margin: 0; + /* max-width: 200px; */ /* 设置最大宽度 */ } @@ -145,31 +171,6 @@ a { text-align: center; } -#nullTip { - display: none; - width: 100%; -} - -#testArea { - display: none; -} - -#references { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - width: 100%; -} - -#resultArea { - margin-top: 3%; - display: none; -} - -#backBtn { - display: none; -} - .result-tips { line-height: var(--mdui-typescale-body-large-line-height); font-size: var(--mdui-typescale-body-large-size); diff --git a/src/settings/index.ts b/src/settings/index.ts index 280b839..2dbc340 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -25,7 +25,7 @@ document.addEventListener('settingsPageLoaded', async () => { const appVersion: HTMLParagraphElement = document.querySelector('#appVersion')!; const listVersion: HTMLParagraphElement = document.querySelector('#listVersion')!; appVersion.innerHTML = `网站版本:${VERSION_NAME}-${VARIANT}-${COMMIT_HASH} (${VERSION_CODE})`; - + getFile(`https://cdn.jsdelivr.net/gh/Super12138/AY-Questionnaires-DB@main/list.json?${new Date().getTime()}`) .then((response: string) => { const json: QuestionnairesList = JSON.parse(response); diff --git a/src/test/index.ts b/src/test/index.ts index dceb833..4593bb7 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -107,14 +107,22 @@ document.addEventListener('testPageLoaded', async () => { document.querySelector('#questionnaireDescription')!.textContent = json.description; // 将问卷描述设置为问卷描述 document.querySelector('#questionnaireTips')!.textContent = json.answerTips; // 将提示设置为问卷提示 - for (const links of json.references) { // 将引用内容上屏 - const a: HTMLAnchorElement = document.createElement('a'); - const br: HTMLBRElement = document.createElement('br'); - a.target = '_blank'; // 在新页面打开链接 - a.href = links; - a.textContent = links; - referencesElement.appendChild(a); - referencesElement.appendChild(br); + for (const link of json.references) { // 将引用内容上屏 + if (link.includes("http")) { // 判断是不是URL + const a: HTMLAnchorElement = document.createElement('a'); + const br: HTMLBRElement = document.createElement('br'); + a.target = '_blank'; // 在新页面打开链接 + a.href = link; + a.classList.add('link'); + a.textContent = link; + referencesElement.appendChild(a); + referencesElement.appendChild(br); + } else { + const p: HTMLParagraphElement = document.createElement('p'); + p.textContent = link; + p.classList.add('link'); + referencesElement.appendChild(p); + } } /**