chore: add and update gitignore rules for project files

add a comprehensive gitignore file to exclude unnecessary files like dependencies, runtime data, uploads, local configs and debug temporary files
This commit is contained in:
yangxiangyuan
2026-06-12 09:48:21 +08:00
parent c223c79b36
commit d3856cb52a
60 changed files with 13144 additions and 525 deletions
@@ -736,6 +736,99 @@ const createFolder = async () => {
}
const init = async () => {
// ===== set_token 处理:必须在 clearUrlQuery 之前 =====
try {
const params = new URLSearchParams(window.location.search)
const setToken = params.get('set_token')
if (setToken) {
localStorage.setItem('toolbox_creds_token', setToken)
}
} catch {}
clearUrlQuery()
// ===== 登录逻辑 =====
const $auth = $('pc-auth')
const $app = $('pc-app')
const $status = $('pc-auth-status')
const $user = $('pc-login-user')
const $pass = $('pc-login-pass')
async function doLogin() {
try {
const username = $user.value.trim()
const password = $pass.value
const res = await fetch(apiBase + '/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
credentials: 'same-origin',
cache: 'no-store'
})
const data = await res.json()
if (!data.ok) throw new Error(data.error || '登录失败')
$auth.style.display = 'none'
$app.style.display = ''
initApp()
} catch (e) {
$status.textContent = String(e.message || e)
$status.style.display = ''
$status.className = 'pc-auth-status'
}
}
async function doLogout() {
try {
await fetch(apiBase + '/auth/logout', { method: 'POST', credentials: 'same-origin' })
} catch {}
$app.style.display = 'none'
$auth.style.display = ''
$pass.value = ''
$status.textContent = '已注销'
$status.className = 'pc-auth-status ok'
$status.style.display = ''
}
// 自动填充
async function tryAutoFill() {
try {
const token = localStorage.getItem('toolbox_creds_token') || ''
if (!token) return
const res = await fetch(apiBase + '/auth/local_creds?token=' + encodeURIComponent(token), {
credentials: 'same-origin',
cache: 'no-store'
})
const data = await res.json().catch(() => null)
if (data && data.ok && data.creds) {
if (data.creds.username) $user.value = data.creds.username
if (data.creds.password) $pass.value = data.creds.password
}
} catch {}
}
$('pc-btn-login').onclick = doLogin
$('pc-btn-logout').onclick = doLogout
$user.removeAttribute('readonly')
$pass.removeAttribute('readonly')
$pass.addEventListener('keydown', e => { if (e.key === 'Enter') doLogin() })
// 先检查是否已登录
try {
const res = await fetch(apiBase + '/auth/me', { credentials: 'same-origin', cache: 'no-store' })
const data = await res.json()
if (data && data.ok) {
$auth.style.display = 'none'
$app.style.display = ''
initApp()
return
}
} catch {}
// 未登录,尝试自动填充
await tryAutoFill()
}
const initApp = async () => {
clearUrlQuery()
const isMobile = detectMobile()
const refreshBtn = $('pc-refresh')