Files
Nilai_Clock/src/App.vue
T
sudomarcma 0676d64af3 feat: 添加密码修改功能并集成Tailwind CSS
refactor: 重构UI组件使用Tailwind CSS
feat(router): 添加密码修改路由
feat(views): 实现密码修改页面
feat(api): 添加密码修改API端点
style: 移除旧CSS文件并配置Tailwind
chore: 添加Tailwind CSS相关依赖
2025-06-26 17:16:57 +08:00

81 lines
2.3 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div
class="min-h-screen bg-gray-100 text-gray-900 dark:bg-gray-900 dark:text-gray-100 transition-colors duration-300"
>
<header
class="flex justify-between items-center px-4 py-3 sm:px-8 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm transition-colors duration-300"
>
<h1 class="text-xl sm:text-2xl font-bold">Clock-In/Out System</h1>
<div class="flex items-center gap-4">
<button
v-if="isLoggedIn"
@click="logout"
class="px-4 py-2 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 rounded-md font-semibold transition-colors duration-200"
>
Logout
</button>
<button
@click="toggleTheme"
class="flex items-center justify-center w-11 h-11 bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 text-lg rounded-full transition-colors duration-200"
title="Toggle Theme"
>
<span v-if="isDarkMode"></span>
<span v-else>🌙</span>
</button>
</div>
</header>
<main class="p-4 sm:p-8">
<RouterView />
</main>
</div>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue'
import { RouterView, useRouter, useRoute } from 'vue-router'
const isDarkMode = ref(false)
const router = useRouter()
const route = useRoute()
const isLoggedIn = ref(!!sessionStorage.getItem('userId'))
watch(
() => route.path,
() => {
isLoggedIn.value = !!sessionStorage.getItem('userId')
},
)
const logout = () => {
sessionStorage.removeItem('userId')
sessionStorage.removeItem('userRole')
isLoggedIn.value = false
router.push('/')
}
const toggleTheme = () => {
isDarkMode.value = !isDarkMode.value
localStorage.setItem('darkMode', isDarkMode.value)
updateTheme()
}
const updateTheme = () => {
if (isDarkMode.value) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
}
onMounted(() => {
const savedTheme = localStorage.getItem('darkMode')
isDarkMode.value = savedTheme === 'true'
updateTheme()
})
</script>
<style scoped>
/* All styles are now handled by Tailwind CSS classes in the template. */
</style>