update
This commit is contained in:
@@ -308,7 +308,7 @@ input { font-family: inherit; }
|
||||
}
|
||||
|
||||
.sidebar-section-content {
|
||||
overflow: hidden;
|
||||
overflow: hidden auto;
|
||||
max-height: 600px;
|
||||
transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
|
||||
opacity 0.2s ease,
|
||||
@@ -317,6 +317,24 @@ input { font-family: inherit; }
|
||||
margin-bottom: var(--spacer-sm);
|
||||
}
|
||||
|
||||
/* 侧边栏内容滚动条美化 */
|
||||
.sidebar-section-content::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.sidebar-section-content::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.sidebar-section-content::-webkit-scrollbar-thumb {
|
||||
background: var(--border-gray);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.sidebar-section-content::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-light);
|
||||
}
|
||||
|
||||
.sidebar-section-group.collapsed .sidebar-section-content {
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::Database;
|
||||
use crate::models::*;
|
||||
use sqlx::Row;
|
||||
use sqlx::{Acquire, Row};
|
||||
use uuid::Uuid;
|
||||
|
||||
impl Database {
|
||||
@@ -234,12 +234,35 @@ impl Database {
|
||||
pub async fn update_album_tags(&self, album_id: &str, tags_json: &str, all_words_json: &str) {
|
||||
sqlx::query("UPDATE albums SET tags = ?, all_words = ?, processed_at = datetime('now') WHERE id = ?")
|
||||
.bind(tags_json).bind(all_words_json).bind(album_id).execute(&self.pool).await.ok();
|
||||
sqlx::query("DELETE FROM album_tags WHERE album_id = ?").bind(album_id).execute(&self.pool).await.ok();
|
||||
|
||||
// 用一个事务批量替换 album_tags,避免逐条 autocommit 导致巨慢
|
||||
if let Ok(tags) = serde_json::from_str::<Vec<String>>(tags_json) {
|
||||
for tag in &tags {
|
||||
sqlx::query("INSERT OR IGNORE INTO album_tags (album_id, tag) VALUES (?, ?)")
|
||||
.bind(album_id).bind(tag).execute(&self.pool).await.ok();
|
||||
let mut tx = match self.pool.begin().await {
|
||||
Ok(t) => t,
|
||||
Err(_) => return,
|
||||
};
|
||||
|
||||
// 单条 DELETE + 一条多值 INSERT
|
||||
sqlx::query("DELETE FROM album_tags WHERE album_id = ?")
|
||||
.bind(album_id)
|
||||
.execute(&mut *tx)
|
||||
.await.ok();
|
||||
|
||||
// 构建多值 INSERT, 避免逐条执行
|
||||
if !tags.is_empty() {
|
||||
let placeholders: Vec<String> = tags.iter().map(|_| "(?, ?)".to_string()).collect();
|
||||
let sql = format!(
|
||||
"INSERT OR IGNORE INTO album_tags (album_id, tag) VALUES {}",
|
||||
placeholders.join(", ")
|
||||
);
|
||||
let mut q = sqlx::query(&sql);
|
||||
for tag in &tags {
|
||||
q = q.bind(album_id).bind(tag);
|
||||
}
|
||||
q.execute(&mut *tx).await.ok();
|
||||
}
|
||||
|
||||
tx.commit().await.ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user