first commit

This commit is contained in:
douboer
2026-03-21 18:57:10 +08:00
commit c49aa1a5e9
570 changed files with 107167 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
/* global Page, wx, require, getCurrentPages */
const { listLogs, getSettings } = require("../../utils/storage");
const { pageOf } = require("../../utils/pagination");
const { buildThemeStyle, applyNavigationBarTheme } = require("../../utils/themeStyle");
const { buildPageCopy, formatTemplate, normalizeUiLanguage, t } = require("../../utils/i18n");
const PAGE_SIZE = 15;
/**
* 日志页(对齐 Web LogsView
* 1. 顶部工具栏保留返回语义;
* 2. 主体为导出 + 列表 + 分页。
*/
Page({
data: {
themeStyle: "",
canGoBack: false,
copy: buildPageCopy("zh-Hans", "logs"),
page: 1,
total: 0,
totalPages: 1,
rows: [],
totalCountText: t("zh-Hans", "logs.totalCount", { total: 0 }),
pageIndicatorText: t("zh-Hans", "common.pageIndicator", { page: 1, total: 1 })
},
onShow() {
const settings = getSettings();
const language = normalizeUiLanguage(settings.uiLanguage);
const copy = buildPageCopy(language, "logs");
applyNavigationBarTheme(settings);
wx.setNavigationBarTitle({ title: copy.navTitle || "日志" });
this.setData({ themeStyle: buildThemeStyle(settings), copy });
this.syncCanGoBack();
this.reload();
},
syncCanGoBack() {
const pages = getCurrentPages();
this.setData({ canGoBack: pages.length > 1 });
},
goBack() {
if (!this.data.canGoBack) return;
wx.navigateBack({ delta: 1 });
},
reload() {
const logs = listLogs();
const paged = pageOf(logs, this.data.page, PAGE_SIZE);
const settings = getSettings();
const language = normalizeUiLanguage(settings.uiLanguage);
this.setData({
page: paged.page,
total: paged.total,
totalPages: paged.totalPages,
rows: paged.rows,
totalCountText: formatTemplate(this.data.copy.totalCount, { total: paged.total }),
pageIndicatorText: t(language, "common.pageIndicator", {
page: paged.page,
total: paged.totalPages
})
});
},
onPrev() {
this.setData({ page: Math.max(1, this.data.page - 1) }, () => this.reload());
},
onNext() {
this.setData({ page: Math.min(this.data.totalPages, this.data.page + 1) }, () => this.reload());
},
onExport() {
const rows = listLogs();
const content = rows
.map(
(item) =>
`[${item.startAt || "--"}] ${item.serverId || "-"} ${item.status || "-"}\n${item.summary || ""}`
)
.join("\n\n");
wx.setClipboardData({
data: content || "",
success: () => wx.showToast({ title: this.data.copy?.toast?.copied || "日志已复制", icon: "success" })
});
}
});

View File

@@ -0,0 +1,7 @@
{
"navigationBarTitleText": "日志",
"disableScroll": true,
"usingComponents": {
"bottom-nav": "/components/bottom-nav/index"
}
}

View File

@@ -0,0 +1,29 @@
<view class="page-root logs-page" style="{{themeStyle}}">
<view class="page-content logs-content">
<view class="surface-panel logs-panel">
<view class="actions logs-actions">
<button class="btn" bindtap="onExport">{{copy.exportButton}}</button>
<text class="settings-save-status">{{totalCountText}}</text>
</view>
<scroll-view class="surface-scroll logs-list-scroll" scroll-y="true">
<view class="list-stack logs-list">
<view wx:for="{{rows}}" wx:key="id" class="card log-item">
<view class="item-title">{{item.serverId || '-'}} · {{item.status || '-'}}</view>
<view class="item-sub">{{item.startAt || '--'}} -> {{item.endAt || '--'}}</view>
<view class="item-sub">{{item.summary || '--'}}</view>
</view>
<text wx:if="{{rows.length === 0}}" class="empty">{{copy.empty}}</text>
</view>
</scroll-view>
<view class="records-pagination">
<button class="btn" disabled="{{page <= 1}}" bindtap="onPrev">{{copy.prev}}</button>
<text class="records-pagination-text">{{pageIndicatorText}}</text>
<button class="btn" disabled="{{page >= totalPages}}" bindtap="onNext">{{copy.next}}</button>
</view>
</view>
</view>
<bottom-nav page="logs" />
</view>

View File

@@ -0,0 +1,34 @@
.logs-content {
padding-top: 16rpx;
}
.logs-panel {
padding: 0 0 16rpx;
}
.logs-actions {
justify-content: space-between;
}
.logs-list-scroll {
flex: 1;
min-height: 0;
}
.logs-list {
min-height: 0;
}
.log-item {
border-radius: 20rpx;
}
.item-title {
font-weight: 600;
margin-bottom: 6rpx;
}
.item-sub {
font-size: 22rpx;
color: var(--muted);
}