Skip to content

Commit

Permalink
fix: 后台 setting 页面刷新后表单为空
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Jun 28, 2023
1 parent 1e22105 commit 1764b76
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ func getAllTool(db *sql.DB) []Tool {
if sort == nil {
tool.Sort = 0
} else {
tool.Sort = sort.(int)
i64 := sort.(int64)
tool.Sort = int(i64)
}
checkErr(err)
results = append(results, tool)
Expand Down
25 changes: 13 additions & 12 deletions public/admin/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理后台</title>
</head>

<body>
管理后台
</body>

</html>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/admin/assets/favicon-5021e58a.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Van Nav</title>
<script type="module" crossorigin src="/admin/assets/index-1afa3318.js"></script>
<link rel="stylesheet" href="/admin/assets/index-812ee62a.css">
</head>
<body>
<div id="root"></div>

</body>
</html>
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="cn"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Van Nav"/><link rel="manifest" href="/manifest.json"/><script>const mode=window.localStorage.getItem("theme");if(mode&&"dark"==mode){const e=document.querySelector("body");e&&e.classList.toggle("dark-mode",!0)}</script><link href="/static/css/main.65b0a5b8.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function t(t){for(var n,l,f=t[0],i=t[1],a=t[2],c=0,s=[];c<f.length;c++)l=f[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(t);s.length;)s.shift()();return u.push.apply(u,a||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,f=1;f<r.length;f++){var i=r[f];0!==o[i]&&(n=!1)}n&&(u.splice(t--,1),e=l(l.s=r[0]))}return e}var n={},o={1:0},u=[];function l(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,l),r.l=!0,r.exports}l.m=e,l.c=n,l.d=function(e,t,r){l.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,t){if(1&t&&(e=l(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(l.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)l.d(r,n,function(t){return e[t]}.bind(null,n));return r},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,"a",t),t},l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},l.p="/";var f=this.webpackJsonptool=this.webpackJsonptool||[],i=f.push.bind(f);f.push=t,f=f.slice();for(var a=0;a<f.length;a++)t(f[a]);var p=i;r()}([])</script><script src="/static/js/2.18d88822.chunk.js"></script><script src="/static/js/main.05c9145a.chunk.js"></script></body></html>
10 changes: 8 additions & 2 deletions ui/admin/src/pages/Setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import "./index.css";
export interface SettingProps { }
export const Setting: React.FC<SettingProps> = (props) => {
const { store, reload, loading } = useContext(GlobalContext);
console.log(store.setting)
const [userForm] = Form.useForm();
const [settingForm] = Form.useForm();
useEffect(() => {
userForm.setFieldsValue(store?.user ?? {})
settingForm.setFieldsValue(store?.setting ?? {})
}, [store])
const handleUpdateUser = useCallback(
async (values: any) => {
try {
Expand Down Expand Up @@ -37,7 +42,7 @@ export const Setting: React.FC<SettingProps> = (props) => {
<div>
<Card title={`修改用户信息`} style={{ marginBottom: 32 }}>
<Spin spinning={loading}>
<Form onFinish={handleUpdateUser} initialValues={store?.user ?? {}}>
<Form onFinish={handleUpdateUser} initialValues={store?.user ?? {}} form={userForm}>
<Form.Item
label="用户名"
name="name"
Expand Down Expand Up @@ -68,6 +73,7 @@ export const Setting: React.FC<SettingProps> = (props) => {
onFinish={handleUpdateWebSite}
initialValues={store?.setting ?? {}}
labelCol={{ span: 6 }}
form={settingForm}
>
<Form.Item
label="网站 logo"
Expand Down

0 comments on commit 1764b76

Please sign in to comment.