Browse Source

feat: 1pctl reset 命令改为多级 (#1098)

pull/1100/head
ssongliu 2 years ago committed by GitHub
parent
commit
152cc76e3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      cmd/server/cmd/reset.go
  2. 4
      frontend/src/components/error-message/err_domain.vue
  3. 4
      frontend/src/components/error-message/err_ip.vue

49
cmd/server/cmd/reset.go

@ -5,14 +5,22 @@ import (
) )
func init() { func init() {
RootCmd.AddCommand(resetMFACmd) RootCmd.AddCommand(resetCmd)
RootCmd.AddCommand(resetSSLCmd) resetCmd.AddCommand(resetMFACmd)
RootCmd.AddCommand(resetEntranceCmd) resetCmd.AddCommand(resetSSLCmd)
resetCmd.AddCommand(resetEntranceCmd)
resetCmd.AddCommand(resetBindIpsCmd)
resetCmd.AddCommand(resetDomainCmd)
}
var resetCmd = &cobra.Command{
Use: "reset",
Short: "重置系统信息",
} }
var resetMFACmd = &cobra.Command{ var resetMFACmd = &cobra.Command{
Use: "reset-mfa", Use: "mfa",
Short: "关闭 1Panel 两步验证", Short: "取消 1Panel 两步验证",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
db, err := loadDBConn() db, err := loadDBConn()
if err != nil { if err != nil {
@ -22,10 +30,9 @@ var resetMFACmd = &cobra.Command{
return setSettingByKey(db, "MFAStatus", "disable") return setSettingByKey(db, "MFAStatus", "disable")
}, },
} }
var resetSSLCmd = &cobra.Command{ var resetSSLCmd = &cobra.Command{
Use: "reset-https", Use: "https",
Short: "取消 1Panel https 方式登录", Short: "取消 1Panel https 方式登录",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
db, err := loadDBConn() db, err := loadDBConn()
if err != nil { if err != nil {
@ -36,7 +43,7 @@ var resetSSLCmd = &cobra.Command{
}, },
} }
var resetEntranceCmd = &cobra.Command{ var resetEntranceCmd = &cobra.Command{
Use: "reset-entrance", Use: "entrance",
Short: "取消 1Panel 安全入口", Short: "取消 1Panel 安全入口",
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
db, err := loadDBConn() db, err := loadDBConn()
@ -47,3 +54,27 @@ var resetEntranceCmd = &cobra.Command{
return setSettingByKey(db, "SecurityEntrance", "") return setSettingByKey(db, "SecurityEntrance", "")
}, },
} }
var resetBindIpsCmd = &cobra.Command{
Use: "ips",
Short: "取消 1Panel 授权 IP 限制",
RunE: func(cmd *cobra.Command, args []string) error {
db, err := loadDBConn()
if err != nil {
return err
}
return setSettingByKey(db, "AllowIPs", "")
},
}
var resetDomainCmd = &cobra.Command{
Use: "domain",
Short: "取消 1Panel 访问域名绑定",
RunE: func(cmd *cobra.Command, args []string) error {
db, err := loadDBConn()
if err != nil {
return err
}
return setSettingByKey(db, "BindDomain", "")
},
}

4
frontend/src/components/error-message/err_domain.vue

@ -5,7 +5,7 @@
<h2>{{ $t('commons.login.notSafe') }}</h2> <h2>{{ $t('commons.login.notSafe') }}</h2>
<h4>{{ $t('commons.login.errDomain1') }}</h4> <h4>{{ $t('commons.login.errDomain1') }}</h4>
<div> <div>
<h4>{{ $t('commons.login.errHelper') }} 1pctl reset-domain</h4> <h4>{{ $t('commons.login.errHelper') }} 1pctl reset domain</h4>
<div style="cursor: pointer; float: left"> <div style="cursor: pointer; float: left">
<el-icon color="#409EFC" style="margin-left: 5px; margin-top: 33px" :size="18" @click="onCopy()"> <el-icon color="#409EFC" style="margin-left: 5px; margin-top: 33px" :size="18" @click="onCopy()">
<DocumentCopy /> <DocumentCopy />
@ -22,7 +22,7 @@ import { MsgSuccess } from '@/utils/message';
const onCopy = () => { const onCopy = () => {
let input = document.createElement('input'); let input = document.createElement('input');
input.value = '1pctl reset-domain'; input.value = '1pctl reset domain';
document.body.appendChild(input); document.body.appendChild(input);
input.select(); input.select();
document.execCommand('Copy'); document.execCommand('Copy');

4
frontend/src/components/error-message/err_ip.vue

@ -5,7 +5,7 @@
<h2>{{ $t('commons.login.notSafe') }}</h2> <h2>{{ $t('commons.login.notSafe') }}</h2>
<h4>{{ $t('commons.login.errIP1') }}</h4> <h4>{{ $t('commons.login.errIP1') }}</h4>
<div> <div>
<h4>{{ $t('commons.login.errHelper') }} 1pctl reset-ips</h4> <h4>{{ $t('commons.login.errHelper') }} 1pctl reset ips</h4>
<div style="cursor: pointer; float: left"> <div style="cursor: pointer; float: left">
<el-icon color="#409EFC" style="margin-left: 5px; margin-top: 33px" :size="18" @click="onCopy()"> <el-icon color="#409EFC" style="margin-left: 5px; margin-top: 33px" :size="18" @click="onCopy()">
<DocumentCopy /> <DocumentCopy />
@ -22,7 +22,7 @@ import { MsgSuccess } from '@/utils/message';
const onCopy = () => { const onCopy = () => {
let input = document.createElement('input'); let input = document.createElement('input');
input.value = '1pctl reset-ips'; input.value = '1pctl reset ips';
document.body.appendChild(input); document.body.appendChild(input);
input.select(); input.select();
document.execCommand('Copy'); document.execCommand('Copy');

Loading…
Cancel
Save