js
const article = await dispatch<any>(thunkCreateArticle({
classId: classId,
content: content,
keys: keys,
memo: memo,
other: JSON.parse(other),
summary: summary,
tags: tags,
title: title
}));
openNoticeInfoPop("保存成功")
navigate("/blogManage/createOrUpdateArticle/" + article.id)
rust
#[derive(Template, Default)]
#[template(path = "page_tag.html")]
pub struct TagIndexTemplate<'a> {
pub article_tag_group: WebArticleTagGroup<'a>,
pub article_class_tree: WebArticleClassTree<'a>,
pub header_area: WebHeaderArea<'a>,
pub footer_area: WebFooterArea<'a>,
pub breadcrumb: WebBreadcrumb<'a>,
pub selected_tag: Option<String>,
pub title: &'a str,
pub desc: &'a str,
pub keywords: &'a str,
pub articles: Vec<ViewArticle>, // tag标签
}
golang
// NewReceiverUnion 通过反射创建接收单元 通过泛型进行方法包装
func NewReceiverUnion[T any](action func(ctx context.Context, msg T) error) *ReceiverUnion {
res := &ReceiverUnion{}
// 确定routerKeyvar t T
res.RouterKey = typeutil.GetTypeBaseNameByGType(t)
// 包装类型转化逻辑
res.Receive = func(ctx context.Context, msg []byte) (err error) {
defer func() {
if rErr := recover(); rErr != nil {
err = errors.New(fmt.Sprintf("%v", rErr))
slog.ErrorContext(ctx, fmt.Sprintf("消息队列处理函数panic %v %v", rErr, string(debug.Stack())))
}
}()
var t T
err = json.Unmarshal(msg, &t)
if err != nil {
slog.ErrorContext(ctx, fmt.Sprintf("mq接受消息转化为json失败 err:%v", err))
return err
}
return action(ctx, t)
}
return res
}本篇为原创内容,未经允许,不得转载