我正在构建一个内部/自定义的等级系统,它与徽章(badges)密切相关。我发现,在管理界面中编辑已创建的徽章时,需要打开一个新标签页和/或访问一个新的 URL,这非常反直觉。
我并不了解具体的技术限制,但我认为,将徽章视图添加或混合到主题包装器(topic wrapper)的显示中可能就足够了,并且可以提供与“分类”(Categories)中非常相似(甚至相同)的行为,在那里 .navigation-controls 允许对已创建的元素进行简单直接的编辑。
这将增加视觉和技术上的一致性,将特定的独立视图整合到一个干净且完整的视角中。
所以基本上,是在每个徽章旁边放一个链接,点击后跳转到该徽章的后台编辑页面?
那这个方案怎么样?
import { apiInitializer } from "discourse/lib/api";
import Component from "@glimmer/component";
import { concat } from "@ember/helper";
export default apiInitializer((api) => {
const currentUser = api.getCurrentUser();
api.renderInOutlet("badge-contents-top",
class LinkTB extends Component {
static shouldRender(args, helper) {
return helper.currentUser && helper.currentUser.admin;
}
<template>
<a href={{concat "/admin/badges/" @badge.id}}>编辑 {{@badge.name}}</a>
</template>
}
)
});