fix: auth
Some checks failed
build quyun / Build (push) Failing after 1m26s

This commit is contained in:
2025-12-20 11:18:59 +08:00
parent c42f2c651f
commit fdbf26d751
6 changed files with 71 additions and 97 deletions

View File

@@ -257,7 +257,11 @@ func (ctl *posts) Mine(
conds := []gen.Condition{ conds := []gen.Condition{
models.PostQuery.Status.Eq(fields.PostStatusPublished), models.PostQuery.Status.Eq(fields.PostStatusPublished),
models.PostQuery.Title.Like(database.WrapLike(*query.Keyword)), }
if query.Keyword != nil && *query.Keyword != "" {
conds = append(conds,
models.PostQuery.Title.Like(database.WrapLike(*query.Keyword)),
)
} }
pager, err := services.Users.PostList(ctx, user.ID, pagination, conds...) pager, err := services.Users.PostList(ctx, user.ID, pagination, conds...)

View File

@@ -56,39 +56,26 @@ func (m *users) PostList(
// OFFSET(pagination.Offset) // OFFSET(pagination.Offset)
// m.log().Infof("sql: %s", stmt.DebugSql()) // m.log().Infof("sql: %s", stmt.DebugSql())
// var posts []Posts tbl, query := models.UserPostQuery.QueryContext(ctx)
// err := stmt.QueryContext(ctx, db, &posts) pagePosts, cnt, err := query.Select(tbl.PostID).
// if err != nil { Where(tbl.UserID.Eq(userId)).
// if errors.Is(err, qrm.ErrNoRows) { FindByPage(int(pagination.Offset()), int(pagination.Limit))
// return &requests.Pager{
// Items: nil,
// Total: 0,
// Pagination: *pagination,
// }, nil
// }
// m.log().Errorf("error querying posts: %v", err)
// return nil, err
// }
// // total count if err != nil {
// var cnt struct { return nil, err
// Cnt int64 }
// } postIds := lo.Map(pagePosts, func(item *models.UserPost, _ int) int64 { return item.PostID })
// stmtCnt := tblUserPosts.SELECT(COUNT(tblUserPosts.ID).AS("cnt")).WHERE(tblUserPosts.UserID.EQ(Int64(userId))) postTbl, postQuery := models.PostQuery.QueryContext(ctx)
// m.log().Infof("sql: %s", stmtCnt.DebugSql()) items, err := postQuery.Where(postTbl.ID.In(postIds...)).Find()
if err != nil {
// if err := stmtCnt.QueryContext(ctx, db, &cnt); err != nil { return nil, err
// m.log().Errorf("error counting users: %v", err) }
// return nil, err return &requests.Pager{
// } Items: items,
Total: cnt,
// return &requests.Pager{ Pagination: *pagination,
// Items: posts, }, nil
// Total: cnt.Cnt,
// Pagination: *pagination,
// }, nil
return nil, nil
} }
// GetUsersMapByIDs // GetUsersMapByIDs

View File

@@ -1,11 +0,0 @@
import client from './client';
export const wechatApi = {
jsSdk() {
return client.get('/wechats/js-sdk', {
params: {
url: window.location.href.split('#')[0],
},
});
},
}

View File

@@ -1,6 +1,8 @@
import wx from "weixin-js-sdk"; import wx from "weixin-js-sdk";
export function useWxSDK() { export function useWxSDK() {
let ready = false;
/** /**
* 初始化设置 * 初始化设置
*/ */
@@ -24,8 +26,13 @@ export function useWxSDK() {
}); });
wx.ready(() => { wx.ready(() => {
console.log("wx.ready called"); console.log("wx.ready called");
ready = true;
resolve(true); resolve(true);
}); });
wx.error(() => {
ready = false;
resolve(false);
});
}); });
} }
@@ -35,39 +42,46 @@ export function useWxSDK() {
onSuccess = () => { }, onSuccess = () => { },
onCancel = () => { } onCancel = () => { }
) { ) {
if (!ready) {
return;
}
console.log("setShareInfo called", shareInfo); console.log("setShareInfo called", shareInfo);
wx.updateTimelineShareData({ try {
title: shareInfo.title, // 分享标题 wx.updateTimelineShareData({
link: shareInfo.link, // 分享链接可以不是当前页面该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 title: shareInfo.title, // 分享标题
imgUrl: shareInfo.imgUrl, link: shareInfo.link, // 分享链接可以不是当前页面该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
success: function (e) { imgUrl: shareInfo.imgUrl,
console.log("分享朋友圈成功", e); success: function (e) {
// 用户确认分享后执行的回调函数 console.log("分享朋友圈成功", e);
onSuccess(); // 用户确认分享后执行的回调函数
}, onSuccess();
cancel: function (e) { },
console.log("分享朋友圈取消", e); cancel: function (e) {
onCancel(); console.log("分享朋友圈取消", e);
// 用户取消分享后执行的回调函数 onCancel();
}, // 用户取消分享后执行的回调函数
}); },
wx.updateAppMessageShareData({ });
title: shareInfo.title, // 分享标题 wx.updateAppMessageShareData({
desc: shareInfo.desc, title: shareInfo.title, // 分享标题
link: shareInfo.link, // 分享链接可以不是当前页面该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 desc: shareInfo.desc,
imgUrl: shareInfo.imgUrl, link: shareInfo.link, // 分享链接可以不是当前页面该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
type: "link", // 分享类型,music、video或link不填默认为link imgUrl: shareInfo.imgUrl,
success: function (e) { type: "link", // 分享类型,music、video或link不填默认为link
// 用户确认分享后执行的回调函数 success: function (e) {
console.log("分享成功", e); // 用户确认分享后执行的回调函数
onSuccess(); console.log("分享成功", e);
}, onSuccess();
cancel: function (e) { },
// 用户取消分享后执行的回调函数 cancel: function (e) {
console.log("分享取消", e); // 用户取消分享后执行的回调函数
onCancel(); console.log("分享取消", e);
}, onCancel();
}); },
});
} catch {
// ignore
}
} }
/** 是否是ios微信 */ /** 是否是ios微信 */
@@ -80,4 +94,4 @@ export function useWxSDK() {
setShareInfo, setShareInfo,
isiOSWechat, isiOSWechat,
}; };
} }

View File

@@ -9,7 +9,6 @@ import { onMounted, onUnmounted, ref } from "vue";
import { BsChevronLeft } from "vue-icons-plus/bs"; import { BsChevronLeft } from "vue-icons-plus/bs";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { postApi } from "../api/postApi"; import { postApi } from "../api/postApi";
import { wechatApi } from "../api/wechatApi";
import { useWxSDK } from "../hooks/useWxSDK"; import { useWxSDK } from "../hooks/useWxSDK";
const wx = useWxSDK(); const wx = useWxSDK();
@@ -172,25 +171,6 @@ const handleBack = () => {
}; };
onMounted(async () => { onMounted(async () => {
wechatApi
.jsSdk()
.then((resp) => {
wx.initConfig(resp.data).then(() => {
wx.setShareInfo({
title: article.value.title,
desc: article.value.content,
link: window.location.href,
imgUrl: article.value.head_images[0],
});
});
})
.catch((error) => {
console.error("Failed to initialize WeChat SDK:", error);
})
.finally(() => {
});
await fetchArticle(); await fetchArticle();
}); });

File diff suppressed because one or more lines are too long