Compare commits
3
Commits
19f1f4c458
...
f80e901b21
No files matched your search
@@ -33,18 +33,21 @@ jobs:
|
||||
- name: 检查部署密钥
|
||||
env:
|
||||
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
|
||||
run: test -n "$DEPLOY_HOOK_KEY"
|
||||
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
run: test -n "$DEPLOY_HOOK_KEY" && test -n "$DEPLOY_TOKEN"
|
||||
- name: 部署到 page 分支
|
||||
env:
|
||||
COMMIT_MESSAGE: ${{ gitea.event.head_commit.message }}
|
||||
DEPLOY_ACTOR: ${{ gitea.actor }}
|
||||
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
||||
run: |
|
||||
cd ./dist
|
||||
git init
|
||||
git config user.name "${{ gitea.actor }}"
|
||||
git config user.email "${{ gitea.actor }}@noreply.gitea.io"
|
||||
git config user.name "$DEPLOY_ACTOR"
|
||||
git config user.email "$DEPLOY_ACTOR@noreply.gitea.io"
|
||||
git add .
|
||||
git commit -m "${COMMIT_MESSAGE:-Deploy} -- [$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
|
||||
git push --force --quiet "https://${{ gitea.actor }}:${{ secrets.DEPLOY_TOKEN }}@git.biss.click/biss/blog.git" master:page
|
||||
git push --force --quiet "https://${DEPLOY_ACTOR}:${DEPLOY_TOKEN}@git.biss.click/biss/blog.git" HEAD:refs/heads/page
|
||||
- name: 触发服务器部署
|
||||
env:
|
||||
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
let searchInstance = null;
|
||||
let isInitialized = false;
|
||||
let isSearchOpen = false;
|
||||
let previousFocus = null;
|
||||
let previousOverflow = '';
|
||||
let closeTimer = null;
|
||||
let initRetryCount = 0;
|
||||
const MAX_INIT_RETRIES = CONFIG.ui.maxInitRetries || 30; // 最多重试30次 (3秒)
|
||||
|
||||
@@ -73,12 +76,12 @@
|
||||
// ============================================================================
|
||||
const searchHTML = `
|
||||
<div id="typesense-search-mask" class="ts-mask" style="display:none;">
|
||||
<div id="typesense-search-container" class="ts-container">
|
||||
<div id="typesense-search-container" class="ts-container" role="dialog" aria-modal="true" aria-labelledby="typesense-search-title" tabindex="-1">
|
||||
<div class="ts-header">
|
||||
<span class="ts-title">
|
||||
<span class="ts-title" id="typesense-search-title">
|
||||
<i class="fas fa-search"></i> 本站搜索
|
||||
</span>
|
||||
<span id="close-typesense" class="ts-close" aria-label="关闭搜索">×</span>
|
||||
<button type="button" id="close-typesense" class="ts-close" aria-label="关闭搜索">×</button>
|
||||
</div>
|
||||
<div id="searchbox"></div>
|
||||
<div id="stats" class="ts-stats"></div>
|
||||
@@ -138,6 +141,9 @@
|
||||
}
|
||||
.ts-close {
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
font-size: 28px;
|
||||
color: var(--font-color, #333);
|
||||
line-height: 1;
|
||||
@@ -313,11 +319,15 @@
|
||||
// ============================================================================
|
||||
function openSearch() {
|
||||
if (isSearchOpen) return;
|
||||
if (closeTimer) clearTimeout(closeTimer);
|
||||
previousFocus = document.activeElement;
|
||||
previousOverflow = document.body.style.overflow;
|
||||
isSearchOpen = true;
|
||||
mask.style.display = 'block';
|
||||
void mask.offsetWidth;
|
||||
mask.classList.add('active');
|
||||
document.body.style.overflow = 'hidden';
|
||||
container.focus();
|
||||
|
||||
if (!isInitialized) {
|
||||
loadDependencies().then(() => {
|
||||
@@ -335,19 +345,23 @@
|
||||
if (!isSearchOpen) return;
|
||||
isSearchOpen = false;
|
||||
mask.classList.remove('active');
|
||||
setTimeout(function() {
|
||||
document.body.style.overflow = previousOverflow;
|
||||
if (previousFocus instanceof HTMLElement) previousFocus.focus();
|
||||
closeTimer = setTimeout(function() {
|
||||
if (isSearchOpen) return;
|
||||
mask.style.display = 'none';
|
||||
document.body.style.overflow = '';
|
||||
closeTimer = null;
|
||||
}, CONFIG.ui.animationDuration || 300);
|
||||
}
|
||||
|
||||
function focusSearchInput(retryCount) {
|
||||
retryCount = retryCount || 0;
|
||||
const input = document.querySelector('.ais-SearchBox-input');
|
||||
if (input) {
|
||||
if (!isSearchOpen) return;
|
||||
if (input && (document.activeElement === container || document.activeElement === input)) {
|
||||
input.focus();
|
||||
input.select();
|
||||
} else if (retryCount < (CONFIG.ui.maxRetries || 10)) {
|
||||
} else if (!input && retryCount < (CONFIG.ui.maxRetries || 10)) {
|
||||
setTimeout(function() {
|
||||
focusSearchInput(retryCount + 1);
|
||||
}, CONFIG.ui.retryDelay || 100);
|
||||
@@ -379,6 +393,18 @@
|
||||
e.preventDefault();
|
||||
openSearch();
|
||||
}
|
||||
if (e.key === 'Tab' && isSearchOpen) {
|
||||
const focusable = [...container.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])')]
|
||||
.filter((element) => element.getClientRects().length);
|
||||
if (!focusable.length) { e.preventDefault(); container.focus(); return; }
|
||||
const first = focusable[0];
|
||||
const last = focusable[focusable.length - 1];
|
||||
if (e.shiftKey && (document.activeElement === first || document.activeElement === container)) {
|
||||
e.preventDefault(); last.focus();
|
||||
} else if (!e.shiftKey && document.activeElement === last) {
|
||||
e.preventDefault(); first.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================================
|
||||
@@ -456,7 +482,7 @@
|
||||
instantsearch.widgets.searchBox({
|
||||
container: '#searchbox',
|
||||
placeholder: CONFIG.ui.placeholder || '输入关键词寻找故事...',
|
||||
autofocus: true,
|
||||
autofocus: false,
|
||||
showReset: true,
|
||||
showSubmit: false,
|
||||
showLoadingIndicator: true
|
||||
@@ -517,15 +543,6 @@
|
||||
|
||||
console.log('✅ Typesense 初始化成功!');
|
||||
|
||||
searchInstance.on('render', function() {
|
||||
if (isSearchOpen) {
|
||||
const input = document.querySelector('.ais-SearchBox-input');
|
||||
if (input && document.activeElement !== input) {
|
||||
input.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 初始化失败:', error);
|
||||
showErrorMessage();
|
||||
|
||||
+13
-8
@@ -298,7 +298,7 @@ function renderTalks() {
|
||||
date,
|
||||
location: '',
|
||||
tags: Array.isArray(item.tags) && item.tags.length ? item.tags.map(t => t.name) : ['无标签'],
|
||||
text: content.replace(/\[(.*?)\]\((.*?)\)/g, '[链接]')
|
||||
text: String(item.content || '').replace(/\[(.*?)\]\((.*?)\)/g, '$1')
|
||||
};
|
||||
};
|
||||
|
||||
@@ -343,8 +343,9 @@ function renderTalks() {
|
||||
//tags.appendChild(loc);
|
||||
|
||||
const commentLink = document.createElement('a');
|
||||
commentLink.href = 'javascript:;';
|
||||
commentLink.onclick = () => goComment(item.text);
|
||||
commentLink.href = '#post-comment';
|
||||
commentLink.setAttribute('aria-label', '引用这条说说到评论区');
|
||||
commentLink.onclick = (event) => { event.preventDefault(); goComment(item.text); };
|
||||
const icon = document.createElement('span');
|
||||
icon.className = 'icon';
|
||||
icon.innerHTML = '<i class="fa-solid fa-message fa-fw"></i>';
|
||||
@@ -360,11 +361,15 @@ function renderTalks() {
|
||||
return talkItem;
|
||||
};
|
||||
|
||||
const goComment = (e) => {
|
||||
const match = e.match(/<div class="talk_content_text">([\s\S]*?)<\/div>/);
|
||||
const textContent = match ? match[1] : "";
|
||||
const textarea = document.querySelector("#twikoo .el-textarea__inner");
|
||||
textarea.value = `> ${textContent}\n\n`;
|
||||
const goComment = (text) => {
|
||||
const textarea = document.querySelector('#twikoo-wrap textarea');
|
||||
if (!textarea) {
|
||||
document.getElementById('post-comment')?.scrollIntoView({ behavior: 'smooth' });
|
||||
btf.snackbarShow('评论区尚未加载完成,请稍后再试');
|
||||
return;
|
||||
}
|
||||
textarea.value = `${text.split(/\r?\n/).map(line => `> ${line}`).join('\n')}\n\n`;
|
||||
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
textarea.focus();
|
||||
btf.snackbarShow("已为您引用该说说,不删除空格效果更佳");
|
||||
};
|
||||
|
||||
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user