feat: 用户端显示金山文档在线状态
- 新增 /api/kdocs/status 接口(用户端简化版) - 工具栏显示"表格上传: ✅ 就绪"或"⚠️ 离线" - 页面加载时获取状态,每60秒自动刷新 - 系统未启用时不显示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -348,3 +348,37 @@ def get_run_stats():
|
|||||||
"today_attachments": stats.get("total_attachments", 0),
|
"today_attachments": stats.get("total_attachments", 0),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@api_user_bp.route("/api/kdocs/status", methods=["GET"])
|
||||||
|
@login_required
|
||||||
|
def get_kdocs_status_for_user():
|
||||||
|
"""获取金山文档在线状态(用户端简化版)"""
|
||||||
|
try:
|
||||||
|
# 检查系统是否启用了金山文档功能
|
||||||
|
cfg = database.get_system_config() or {}
|
||||||
|
kdocs_enabled = int(cfg.get("kdocs_enabled") or 0)
|
||||||
|
|
||||||
|
if not kdocs_enabled:
|
||||||
|
return jsonify({"enabled": False, "online": False, "message": "未启用"})
|
||||||
|
|
||||||
|
# 获取金山文档状态
|
||||||
|
from services.kdocs_uploader import get_kdocs_uploader
|
||||||
|
|
||||||
|
kdocs = get_kdocs_uploader()
|
||||||
|
status = kdocs.get_status()
|
||||||
|
|
||||||
|
login_required_flag = status.get("login_required", False)
|
||||||
|
last_login_ok = status.get("last_login_ok")
|
||||||
|
|
||||||
|
# 判断是否在线
|
||||||
|
is_online = not login_required_flag and last_login_ok is True
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"enabled": True,
|
||||||
|
"online": is_online,
|
||||||
|
"message": "就绪" if is_online else "离线"
|
||||||
|
})
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"获取金山文档状态失败: {e}")
|
||||||
|
return jsonify({"enabled": False, "online": False, "message": "获取失败"})
|
||||||
|
|||||||
@@ -552,6 +552,12 @@
|
|||||||
<label class="checkbox-wrapper"><input type="checkbox" id="selectAll" onchange="toggleSelectAll()"><span>全选</span></label>
|
<label class="checkbox-wrapper"><input type="checkbox" id="selectAll" onchange="toggleSelectAll()"><span>全选</span></label>
|
||||||
<span style="color: var(--md-on-surface-medium); font-size: 13px;">已选 <span id="selectedCount">0</span> 个</span>
|
<span style="color: var(--md-on-surface-medium); font-size: 13px;">已选 <span id="selectedCount">0</span> 个</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="toolbar-group" id="kdocsStatusGroup" style="display: none;">
|
||||||
|
<span style="font-size: 13px; color: var(--md-on-surface-medium);">
|
||||||
|
表格上传:
|
||||||
|
<span id="kdocsStatusBadge" style="display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;"></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="toolbar-divider"></div>
|
<div class="toolbar-divider"></div>
|
||||||
<div class="toolbar-group">
|
<div class="toolbar-group">
|
||||||
<select class="select-inline" id="batchBrowseType">
|
<select class="select-inline" id="batchBrowseType">
|
||||||
@@ -1141,6 +1147,33 @@
|
|||||||
}
|
}
|
||||||
closeAnnouncementOnce();
|
closeAnnouncementOnce();
|
||||||
}
|
}
|
||||||
|
// 加载金山文档在线状态
|
||||||
|
function loadKdocsStatus() {
|
||||||
|
fetch('/api/kdocs/status')
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
|
var group = document.getElementById('kdocsStatusGroup');
|
||||||
|
var badge = document.getElementById('kdocsStatusBadge');
|
||||||
|
if (!data.enabled) {
|
||||||
|
group.style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
group.style.display = '';
|
||||||
|
if (data.online) {
|
||||||
|
badge.innerHTML = '✅ 就绪';
|
||||||
|
badge.style.background = '#E8F5E9';
|
||||||
|
badge.style.color = '#2E7D32';
|
||||||
|
} else {
|
||||||
|
badge.innerHTML = '⚠️ 离线';
|
||||||
|
badge.style.background = '#FFF3E0';
|
||||||
|
badge.style.color = '#E65100';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function() {
|
||||||
|
document.getElementById('kdocsStatusGroup').style.display = 'none';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
initTabs();
|
initTabs();
|
||||||
loadVipStatus();
|
loadVipStatus();
|
||||||
@@ -1150,7 +1183,9 @@
|
|||||||
loadSchedules();
|
loadSchedules();
|
||||||
loadScreenshots();
|
loadScreenshots();
|
||||||
checkAccountLimit();
|
checkAccountLimit();
|
||||||
|
loadKdocsStatus(); // 加载金山文档状态
|
||||||
setInterval(loadStats, 30000);
|
setInterval(loadStats, 30000);
|
||||||
|
setInterval(loadKdocsStatus, 60000); // 每60秒刷新一次状态
|
||||||
setupImagePreviewEvents();
|
setupImagePreviewEvents();
|
||||||
// 周日期选择器点击事件
|
// 周日期选择器点击事件
|
||||||
document.querySelectorAll('#weekdaySelector .weekday-chip').forEach(function(chip) {
|
document.querySelectorAll('#weekdaySelector .weekday-chip').forEach(function(chip) {
|
||||||
|
|||||||
Reference in New Issue
Block a user