diff --git a/serve/route/index/tree/node/user/attach.go b/serve/route/index/tree/node/user/attach.go
index e637e79..4a96312 100644
--- a/serve/route/index/tree/node/user/attach.go
+++ b/serve/route/index/tree/node/user/attach.go
@@ -15,4 +15,5 @@ func Attach(g *echo.Group, code int) {
group.Use(acl.AllowWrite(code))
group.PUT("/add", add)
+ group.DELETE("/delete", del)
}
diff --git a/serve/route/index/tree/node/user/del.go b/serve/route/index/tree/node/user/del.go
new file mode 100644
index 0000000..334bffb
--- /dev/null
+++ b/serve/route/index/tree/node/user/del.go
@@ -0,0 +1,27 @@
+package user
+
+import (
+ "net/http"
+
+ "github.com/labstack/echo/v4"
+
+ "github.com/lucky-byte/reactgo/serve/ctx"
+ "github.com/lucky-byte/reactgo/serve/db"
+)
+
+// 解除用户绑定
+func del(c echo.Context) error {
+ cc := c.(*ctx.Context)
+
+ uuid := c.QueryParam("uuid")
+ if len(uuid) == 0 {
+ return c.NoContent(http.StatusBadRequest)
+ }
+ ql := `delete from tree_bind where uuid = ?`
+
+ if err := db.ExecOne(ql, uuid); err != nil {
+ cc.ErrLog(err).Error("解除用户绑定错")
+ return c.NoContent(http.StatusInternalServerError)
+ }
+ return c.NoContent(http.StatusOK)
+}
diff --git a/web/src/route/tree/node/user.jsx b/web/src/route/tree/node/user.jsx
index 224183b..aad0c9c 100644
--- a/web/src/route/tree/node/user.jsx
+++ b/web/src/route/tree/node/user.jsx
@@ -31,20 +31,23 @@ import Collapse from '@mui/material/Collapse';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
import AddIcon from '@mui/icons-material/Add';
+import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
import { useHotkeys } from 'react-hotkeys-hook';
import { useSnackbar } from 'notistack';
+import { useConfirm } from 'material-ui-confirm';
import dayjs from 'dayjs';
import SearchInput from '~/comp/search-input';
import OutlinedPaper from "~/comp/outlined-paper";
import progressState from "~/state/progress";
import titleState from "~/state/title";
import usePageData from '~/hook/pagedata';
-import { post, put } from '~/rest';
+import { post, put, del } from '~/rest';
export default function User() {
const navigate = useNavigate();
const location = useLocation();
const { enqueueSnackbar } = useSnackbar();
+ const confirm = useConfirm();
const setTitle = useSetRecoilState(titleState);
const [progress, setProgress] = useRecoilState(progressState);
const [pageData, setPageData] = usePageData();
@@ -105,6 +108,25 @@ export default function User() {
setPageData('rowsPerPage', rows);
}
+ // 解除绑定
+ const onRemoveClick = async row => {
+ try {
+ await confirm({
+ description: `确定要解除 ${row.user_name} 的绑定吗?`,
+ confirmationText: '确定',
+ confirmationButtonProps: { color: 'warning' },
+ contentProps: { p: 8 },
+ });
+ const params = new URLSearchParams({ uuid: row.uuid });
+ await del('/tree/node/user/delete?' + params.toString());
+ setReload(true);
+ } catch (err) {
+ if (err) {
+ enqueueSnackbar(err.message);
+ }
+ }
+ }
+
// uuid 从上个页面通过 state 传入,如果为空,则可能是直接输入 url 进入该页面
if (!node?.uuid) {
return ;
@@ -147,7 +169,11 @@ export default function User() {
{dayjs(row.create_at).format('YYYY/MM/DD HH:mm:ss')}
-
+
+ onRemoveClick(row)}>
+
+
+
))}