添加权限配置

This commit is contained in:
fancl 2024-12-13 11:43:32 +08:00
parent 68c499b160
commit 7c4b7f1bda
7 changed files with 45 additions and 18 deletions

14
api.go
View File

@ -25,6 +25,11 @@ type (
OldPassword string `json:"old_password"`
NewPassword string `json:"new_password"`
}
configureValue struct {
Attribute string `json:"attribute"`
Value string `json:"value"`
}
)
func (svr *Server) handleLogin(ctx *http.Context) (err error) {
@ -96,7 +101,14 @@ func (svr *Server) handleUpdateProfile(ctx *http.Context) (err error) {
}
func (svr *Server) handleGetConfigure(ctx *http.Context) (err error) {
return ctx.Success(map[string]string{})
ms := make([]configureValue, 0, len(svr.cfg.System.Settings))
for k, v := range svr.cfg.System.Settings {
ms = append(ms, configureValue{
Attribute: k,
Value: v,
})
}
return ctx.Success(ms)
}
func (svr *Server) handleListSchema(ctx *http.Context) (err error) {

View File

@ -13,9 +13,14 @@ type Avatar struct {
Dirname string `json:"dirname" yaml:"dirname"`
}
type System struct {
Settings map[string]string `json:"settings" yaml:"settings"`
}
type Config struct {
Database Database `json:"database" yaml:"database"`
Avatar Avatar `json:"avatar" yaml:"avatar"`
System System `json:"system" yaml:"system"`
Database Database `json:"database" yaml:"database"`
AdminUsers []string `json:"admin_users" yaml:"adminUsers"`
}

View File

@ -6,3 +6,8 @@ database:
adminUsers:
- "1000"
system:
settings:
productName: "测试网址"
copyright: "xxx"

View File

@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MOTO</title>
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3832926_ya7vh14nje.css">
<script type="module" crossorigin src="/static/index-BGRRVEuU.js"></script>
<script type="module" crossorigin src="/static/index-4E04Ax0l.js"></script>
<link rel="stylesheet" crossorigin href="/static/index-BhBbL-Pz.css">
</head>

File diff suppressed because one or more lines are too long

View File

@ -83,10 +83,13 @@ const logout = () => {
}).catch(e => { })
}
const refreshUI = () => {
document.title = productName.value
}
provide('logout', logout)
onMounted(() => {
document.title = productName.value
//
getConfigure().then(res => {
const { setAttributeValue } = useSystemStore();
@ -102,6 +105,7 @@ onMounted(() => {
setAvatar(res.avatar)
setPermissions(res.permissions)
loading.value = false
refreshUI()
}).catch(e => {
console.log(e);
router.push('/login');

View File

@ -45,6 +45,7 @@ const useSystemStore = defineStore('system', {
setAttributeValue(attr, value) {
switch (attr) {
case 'name':
case 'productName':
this.productName = value;
break
case 'logo':