feat: note

This commit is contained in:
hashbro
2026-09-08 04:53:35 +08:00
parent 9626fcc598
commit c1d24ab815
19 changed files with 870 additions and 58 deletions
+46 -8
View File
@@ -36,7 +36,7 @@
<th>手机号</th>
<td>{{ $device->phone ?: '—' }}</td>
<th>IP</th>
<td>{{ $device->ip ?: '—' }}</td>
<td>{{ $device->formattedIp() !== '' ? $device->formattedIp() : '—' }}</td>
</tr>
<tr>
<th>钱包</th>
@@ -196,6 +196,10 @@
<div id="LAY-photo-grid" class="photo-grid"></div>
<div id="LAY-photo-empty" style="display:none;color:#999;padding:12px 0;">暂无相册</div>
<div id="LAY-photo-page" style="margin-top: 16px; text-align: right;"></div>
@elseif ($tab === 'notes')
<div id="LAY-note-cards"></div>
<div id="LAY-note-empty" style="display:none;color:#999;padding:12px 0;">暂无备忘录</div>
<div id="LAY-note-page" style="margin-top: 16px; text-align: right;"></div>
@else
@if ($tab === 'wallets')
<form class="layui-form" lay-filter="LAY-wallet-filter" style="margin-bottom: 12px;">
@@ -446,6 +450,47 @@ layui.use(['table', 'form', 'laypage', 'layer'], function () {
return;
}
if (tab === 'notes') {
var noteState = { page: 1, limit: 20 };
var renderNotes = function () {
$.getJSON(tabDataUrl, {
tab: 'notes',
page: noteState.page,
limit: noteState.limit
}, function (res) {
var $list = $('#LAY-note-cards').empty();
var items = (res && res.data) ? res.data : [];
if (!items.length) {
$('#LAY-note-empty').show();
} else {
$('#LAY-note-empty').hide();
items.forEach(function (it) {
var $card = $('<div class="note-card"></div>');
$card.append($('<div class="note-card-title"></div>').text(it.title || '无标题'));
$card.append($('<pre class="note-card-body"></pre>').text(it.body || ''));
$list.append($card);
});
}
laypage.render({
elem: 'LAY-note-page',
count: (res && res.count) ? res.count : 0,
curr: noteState.page,
limit: noteState.limit,
limits: [10, 20, 30, 50],
layout: ['count', 'prev', 'page', 'next', 'limit'],
jump: function (obj, first) {
if (first) return;
noteState.page = obj.curr;
noteState.limit = obj.limit;
renderNotes();
}
});
});
};
renderNotes();
return;
}
var colsMap = {
wallets: [[
{ field: 'id', title: 'ID', width: 80, sort: true },
@@ -499,13 +544,6 @@ layui.use(['table', 'form', 'laypage', 'layer'], function () {
return d.is_wallet ? '<span class="tag-wallet">wallet</span>' : '—';
} }
]],
notes: [[
{ field: 'id', title: 'ID', width: 80, sort: true },
{ field: 'content', title: 'Content', minWidth: 320, templet: function (d) {
return d.content ? '<span class="wrap">' + esc(d.content) + '</span>' : '—';
} },
{ field: 'created_at', title: '时间', width: 170, sort: true, templet: function (d) { return dash(d.created_at); } }
]],
events: [[
{ field: 'id', title: 'ID', width: 80, sort: true },
{ field: 'created_at', title: '时间', width: 170, sort: true, templet: function (d) { return dash(d.created_at); } },