File size: 6,429 Bytes
640e3d2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | <!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>貼文管理 - KSTools</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔑</text></svg>">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/posts.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<!-- Supabase 載入 -->
<script type="module">
console.log('🚀 載入 Supabase...');
try {
const { createClient } = await import('https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/+esm');
window.supabase = { createClient };
window.supabaseLoaded = true;
console.log('✅ Supabase 載入成功!');
window.dispatchEvent(new CustomEvent('supabaseReady'));
} catch (error) {
console.error('❌ ES Module 載入失敗:', error);
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2/dist/umd/supabase.min.js';
script.onload = () => {
window.supabaseLoaded = true;
window.dispatchEvent(new CustomEvent('supabaseReady'));
};
document.head.appendChild(script);
}
</script>
<style>
/* 貼文管理頁面專用樣式 */
.posts-container {
max-width: 1400px;
margin: 0 auto;
padding: 2rem;
}
.top-nav {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--border-color);
}
.nav-left {
display: flex;
align-items: center;
gap: 1rem;
}
.nav-left h1 {
margin: 0;
font-size: 1.5rem;
color: var(--text-primary);
}
.page-description {
color: var(--text-secondary);
font-size: 0.9rem;
margin: 0;
}
@media (max-width: 768px) {
.posts-container {
padding: 1rem;
}
.top-nav {
flex-direction: column;
gap: 1rem;
align-items: stretch;
}
.nav-left, .nav-right {
display: flex;
justify-content: center;
}
}
</style>
</head>
<body>
<!-- 載入中畫面 -->
<div id="loading-overlay" class="loading-overlay">
<div class="spinner"></div>
<p>載入中...</p>
</div>
<!-- 主要內容 -->
<div class="posts-container">
<!-- 頂部導航 -->
<div class="top-nav">
<div class="nav-left">
<button class="btn btn-sm btn-outline" onclick="window.location.href='/dashboard.html'" title="回到管理中心">
<i class="fas fa-home"></i>
</button>
<div>
<h1><i class="fas fa-newspaper"></i> 貼文管理</h1>
<p class="page-description">管理版本更新貼文與郵件通知</p>
</div>
</div>
<div class="nav-right">
<div class="header-actions">
<button class="btn btn-secondary" onclick="window.location.href='/versions.html'" title="前往版本管理">
<i class="fas fa-rocket"></i>
<span>版本管理</span>
</button>
<div id="userInfo" class="user-info">
<!-- User info will be populated by JavaScript -->
</div>
</div>
</div>
</div>
<!-- 貼文內容區域 -->
<div id="postsContent">
<div class="text-center mt-5">
<div class="spinner mb-3"></div>
<p>載入貼文中...</p>
</div>
</div>
</div>
<!-- Toast Notifications -->
<div id="toastContainer" class="toast-container"></div>
<!-- Modal Container -->
<div id="modalContainer"></div>
<!-- Scripts -->
<script src="config.js"></script>
<script src="js/api.js"></script>
<script src="js/utils.js"></script>
<script src="js/auth.js"></script>
<script src="js/components.js"></script>
<script src="js/pages/posts.js"></script>
<script>
// 初始化貼文管理頁面
async function initPostsPage() {
console.log('🚀 初始化貼文管理頁面...');
try {
const container = document.getElementById('postsContent');
if (container && window.postsPage) {
await window.postsPage.render(container);
} else {
container.innerHTML = `
<div class="empty-state">
<i class="fas fa-exclamation-triangle"></i>
<h3>載入失敗</h3>
<p>貼文模組載入失敗,請重新整理頁面</p>
</div>
`;
}
} catch (error) {
console.error('初始化失敗:', error);
Utils.showError('載入失敗', error.message);
}
}
// 使用 authManager 的登出方法
async function logout() {
if (window.authManager) {
await window.authManager.handleLogout();
}
}
// 頁面載入時使用統一認證初始化
document.addEventListener('DOMContentLoaded', async () => {
if (window.authManager) {
await window.authManager.initProtectedPage('posts', initPostsPage);
} else {
window.addEventListener('supabaseReady', async () => {
if (window.authManager) {
await window.authManager.initProtectedPage('posts', initPostsPage);
}
});
}
});
</script>
</body>
</html>
|