diff --git a/js/oper.js b/js/oper.js
index 5554a4e..14e4d2f 100644
--- a/js/oper.js
+++ b/js/oper.js
@@ -293,14 +293,12 @@ $('#opensite').click(function () {
})
// 0.23.1版本 GET api/v1/{parent}/tags 接口已移除,参考 https://github.com/usememos/memos/issues/4161
-// TODO 可使用/api/v1/memos?filter=creator == 'users/1'&view=MEMO_VIEW_METADATA_ONLY 接口实现
$('#tags').click(function () {
get_info(function (info) {
if (info.apiUrl) {
- var parent = "memos/-";
- // 如果不使用 user 过滤,会返回所有用户的标签
- var filter = "?filter=" + encodeURIComponent(`creator == 'users/${info.userid}'`);
- var tagUrl = info.apiUrl + 'api/v1/' + parent + '/tags' + filter;
+ var parent = `users/${info.userid}`;
+ // 从最近的1000条memo中获取tags,因此不保证获取能全部的
+ var tagUrl = info.apiUrl + 'api/v1/' + parent + '/memos?pageSize=1000';
var tagDom = "";
$.ajax({
url: tagUrl,
@@ -309,7 +307,10 @@ $('#tags').click(function () {
dataType: "json",
headers: { 'Authorization': 'Bearer ' + info.apiTokens },
success: function (data) {
- $.each(data.tagAmounts, function (tag, amount) {
+ // 提前并去重所有标签
+ const allTags = data.memos.flatMap(memo => memo.tags);
+ const uniTags = [...new Set(allTags)];
+ $.each(uniTags, function (_, tag) {
tagDom += '#' + tag + '';
});
tagDom += ''