优化代码

This commit is contained in:
pengxiaolong
2025-09-25 19:40:54 +08:00
parent 8cabf98bd9
commit ea50c14175
17 changed files with 1462 additions and 271 deletions

View File

@@ -9,32 +9,46 @@
<hostsList />
</div>
<!-- <div style="position: absolute; bottom: 0; right: 0;">{{ version }}</div> -->
</div>
<div class="footer">
到期时间{{ time }}
</div>
</div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue";
// import Sidebar from '../components/Sidebar.vue';
import { RouterLink, RouterView } from 'vue-router'
import hostsList from '@/views/hosts/hostsList.vue'
import { ElMessage } from 'element-plus';
import { getUser } from "@/utils/storage";
// import workbenches from '@/views/hosts/workbenches.vue'
import { ref } from 'vue'
import { getUser } from '@/utils/storage'
// import { usePythonBridge } from '@/utils/pythonBridge'
// let activeIndexA = ref(1)
// function activeIndexFn(data) {
// activeIndexA.value = data
// console.log(data)
// }
import { tokenStore,UserStore } from '@/stores/notice'
const userCache = UserStore()
const time = ref(formatTimestamp(userCache.user.brotherExpireTime))
// 时间格式化方法 - 将12位时间戳转为YYYY-MM-DD HH:mm:ss格式
function formatTimestamp(timestamp) {
try {
// 转换为数字
const ts = Number(timestamp);
if (isNaN(ts)) {
return '--';
}
// 处理13位时间戳毫秒级
const date = new Date(ts > 999999999999 ? ts : ts * 1000);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
} catch (e) {
console.error('时间格式化错误:', e);
return '--';
}
}
</script>
@@ -45,6 +59,11 @@ html {
margin: 0;
padding: 0;
height: 100%;
/* 页面无法选中 */
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.app-container {
@@ -77,7 +96,7 @@ html {
margin-left: 25px;
margin-right: 25px;
width: 1540px;
height: 868px;
height: 848px;
background: #FFFFFF;
border-radius: 36px;
margin-top: 16px;
@@ -88,4 +107,11 @@ html {
justify-content: space-around;
align-items: center;
}
.footer{
position: absolute;
bottom: 10px;
left: calc(50% - 150px);
color: aqua;
font-size: 16px;
}
</style>