支持多用户
支持SSL证书支持DNS验证
增加mysql测试用例
修复DNS设置时的展示歧义
This commit is contained in:
Jinnrry authored and GitHub committed 2024-07-02 21:02:00 +08:00
1 parent 76bc24d2bd
commit 01cbdc9875
73 files changed
+4722 -538

No files matched your search

+6 -5
View File
@@ -17,11 +17,12 @@
</template>
<script setup>
import $http from "../http/http";
import { reactive, ref } from 'vue'
import { reactive, ref, getCurrentInstance } from 'vue'
import lang from '../i18n/i18n';
const data = reactive([])
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
$http.get('/api/group').then(res => {
data.push(...res.data)
@@ -29,7 +30,7 @@ $http.get('/api/group').then(res => {
const del = function (node, data) {
if (data.id != -1) {
$http.post("/api/group/del", { "id": data.id }).then(res => {
this.$axios.post("/api/group/del", { "id": data.id }).then(res => {
if (res.errorNo != 0) {
ElMessage({
message: res.errorMsg,
@@ -79,14 +80,14 @@ const addRoot = function () {
const onInputBlur = function (item) {
if (item.label != "") {
$http.post("/api/group/add", { "name": item.label, "parent_id": item.parent_id }).then(res => {
this.$axios.post("/api/group/add", { "name": item.label, "parent_id": item.parent_id }).then(res => {
if (res.errorNo != 0) {
ElMessage({
message: res.errorMsg,
type: 'error',
})
} else {
$http.get('/api/group').then(res => {
this.$axios.get('/api/group').then(res => {
data.splice(0, data.length)
data.push(...res.data)
})
+4 -1
View File
@@ -8,10 +8,12 @@
<script setup>
import { useRouter } from 'vue-router'
import $http from "../http/http";
import { reactive, ref } from 'vue'
import useGroupStore from '../stores/group'
import lang from '../i18n/i18n';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const groupStore = useGroupStore()
const router = useRouter()
@@ -19,6 +21,7 @@ const router = useRouter()
const data = ref([])
$http.get('/api/group').then(res => {
data.value = res.data
})
+31 -3
View File
@@ -3,7 +3,7 @@
<div id="logo">
<span style="padding-left: 20px;">PMail</span>
</div>
<div id="settings" @click="settings">
<div id="settings" @click="settings" v-if="$isLogin">
<el-icon style="font-size: 25px;">
<Setting style="color:#FFFFFF" />
</el-icon>
@@ -21,6 +21,10 @@
<el-tab-pane :label="lang.rule_setting">
<RuleSettings />
</el-tab-pane>
<el-tab-pane v-if="$userInfos.is_admin" :label="lang.user_management">
<UserManagement />
</el-tab-pane>
</el-tabs>
</el-drawer>
@@ -30,15 +34,39 @@
<script setup>
import { Setting } from '@element-plus/icons-vue';
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'
import { ElMessage } from 'element-plus'
import SecuritySettings from '@/components/SecuritySettings.vue'
import lang from '../i18n/i18n';
import GroupSettings from './GroupSettings.vue';
import RuleSettings from './RuleSettings.vue';
import UserManagement from './UserManagement.vue';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const $isLogin = app.appContext.config.globalProperties.$isLogin
const $userInfos = app.appContext.config.globalProperties.$userInfos
const openSettings = ref(false)
const settings = function () {
openSettings.value = true;
if (Object.keys($userInfos.value).length == 0) {
$http.post("/api/user/info", {}).then(res => {
if (res.errorNo == 0) {
$userInfos.value = res.data
openSettings.value = true;
} else {
ElMessage({
type: 'error',
message: res.errorMsg,
})
}
})
}else{
openSettings.value = true;
}
}
</script>
+12 -4
View File
@@ -98,7 +98,6 @@
<script setup>
import { ref, reactive } from 'vue';
import $http from "../http/http";
import lang from '../i18n/i18n';
import {
Plus,
@@ -106,6 +105,12 @@ import {
Edit,
InfoFilled
} from '@element-plus/icons-vue'
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const data = ref([])
const dialogVisible = ref(false)
const READ = 1
@@ -134,10 +139,13 @@ const groupData = reactive({
const reflushGroupInfos = function () {
$http.get('/api/group/list').then(res => {
groupData.list = res.data
for (let i = 0; i < groupData.list.length; i++) {
groupData.list[i].id += ""
if (res.data != null) {
groupData.list = res.data
for (let i = 0; i < groupData.list.length; i++) {
groupData.list[i].id += ""
}
}
})
}
+21 -1
View File
@@ -1,5 +1,8 @@
<template>
<el-form :model="ruleForm" :rules="rules" status-icon>
<el-divider content-position="left">{{lang.modify_pwd}}</el-divider>
<el-form-item :label="lang.modify_pwd" prop="new_pwd">
<el-input type="password" v-model="ruleForm.new_pwd" />
</el-form-item>
@@ -13,14 +16,25 @@
{{ lang.submit }}
</el-button>
</el-form-item>
<el-divider content-position="left">{{lang.logout}}</el-divider>
<el-form-item>
<el-button type="primary" @click="logout">
{{ lang.logout }}
</el-button>
</el-form-item>
</el-form>
</template>
<script setup>
import { reactive, ref } from 'vue'
import { ElNotification } from 'element-plus'
import $http from "../http/http";
import lang from '../i18n/i18n';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const ruleForm = reactive({
new_pwd: "",
new_pwd2: ""
@@ -32,6 +46,12 @@ const rules = reactive({
})
const logout = function(){
$http.post("/api/logout", { }).then(res => {
location.reload();
})
}
const submit = function () {
if (ruleForm.new_pwd == ""){
return
+181
View File
@@ -0,0 +1,181 @@
<template>
<div id="main">
<el-table :data="userList" style="width: 100%">
<el-table-column label="ID" prop="ID" />
<el-table-column :label="lang.account" prop="Account" />
<el-table-column :label="lang.user_name" prop="Name" />
<el-table-column :label="lang.disabled" prop="Disabled">
<template #default="scope">
<span>{{ scope.row.Disabled == 1 ? lang.disabled : lang.enabled }}</span>
</template>
</el-table-column>
<el-table-column align="right">
<template #header>
<el-button type="primary" size="small" @click="createUser">
New
</el-button>
</template>
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">
Edit
</el-button>
</template>
</el-table-column>
</el-table>
<div id="paginationBox">
<el-pagination v-model:current-page="currentPage" small background layout="prev, pager, next"
:page-count="totalPage" class="mt-4" @current-change="reflushList" />
</div>
<el-dialog v-model="userInfoDialog" :title="title" width="500">
<el-form>
<el-form-item label-width="100px" :label="lang.account">
<el-input :disabled="editModel == 'edit'" v-model="editUserInfo.account" autocomplete="off" />
</el-form-item>
<el-form-item label-width="100px" :label="lang.user_name">
<el-input v-model="editUserInfo.name" autocomplete="off" />
</el-form-item>
<el-form-item label-width="100px" :label="lang.password">
<el-input :placeholder="lang.resetPwd" v-model="editUserInfo.password" autocomplete="off" />
</el-form-item>
<div style="display: flex;">
<div
style="display: inline-flex;justify-content: flex-end;align-items: flex-start;flex: 0 0 auto;font-size: var(--el-form-label-font-size); height: 32px;line-height: 32px;padding: 0 12px 0 60px;box-sizing: border-box; ">
<el-switch v-model="editUserInfo.disabled" class="ml-2" :active-text="lang.disabled"
:inactive-text="lang.enabled" />
</div>
</div>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="userInfoDialog = false">Cancel</el-button>
<el-button type="primary" @click="submit">
Confirm
</el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup>
import { reactive, ref, getCurrentInstance } from 'vue'
import lang from '../i18n/i18n';
const userList = reactive([])
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const currentPage = ref(1)
const totalPage = ref(1)
const userInfoDialog = ref(false)
const editModel = ref("edit")
const editUserInfo = reactive({
"account": "",
"name": "",
"password": "",
"disabled": false
})
const title = ref(lang.editUser)
const reflushList = function () {
$http.post('/api/user/list', { "current_page": currentPage.value, "page_size": 10 }).then(res => {
userList.length = 0
totalPage.value = res.data.total_page
userList.push(...res.data["list"])
})
}
const handleEdit = function (idx, row) {
editUserInfo.account = row.Account
editUserInfo.name = row.Name
editUserInfo.disabled = row.Disabled == 1
editUserInfo.password = ""
editModel.value = "edit"
title.value = lang.editUser
userInfoDialog.value = true
}
const createUser = function(){
editUserInfo.account = ""
editUserInfo.name = ""
editUserInfo.disabled = false
editUserInfo.password = ""
editModel.value = "create"
title.value = lang.newUser
userInfoDialog.value = true
}
const submit = function () {
if (editModel.value == 'edit') {
let newData = {
"account": editUserInfo.account,
"username": editUserInfo.name,
"disabled": editUserInfo.disabled ? 1 : 0
}
if (editUserInfo.password != "") {
newData["password"] = editUserInfo.password
}
$http.post('/api/user/edit', newData).then(res => {
ElNotification({
title: res.errorNo == 0 ? lang.succ : lang.fail,
message: res.errorNo == 0 ? "" : res.data,
type: res.errorNo == 0 ? 'success' : 'error',
})
if (res.errorNo == 0) {
reflushList()
userInfoDialog.value = false
}
})
}else{
let newData = {
"account": editUserInfo.account,
"username": editUserInfo.name,
"disabled": editUserInfo.disabled ? 1 : 0,
"password":editUserInfo.password
}
$http.post('/api/user/create', newData).then(res => {
ElNotification({
title: res.errorNo == 0 ? lang.succ : lang.fail,
message: res.errorNo == 0 ? "" : res.data,
type: res.errorNo == 0 ? 'success' : 'error',
})
if (res.errorNo == 0) {
reflushList()
userInfoDialog.value = false
}
})
}
}
reflushList()
</script>
<style scoped>
#paginationBox {
margin-top: 10px;
display: flex;
justify-content: center;
}
</style>
-101
View File
@@ -1,101 +0,0 @@
// http/index.js
import axios from 'axios'
import router from "@/router"; //根路由对象
import lang from '../i18n/i18n';
//创建axios的一个实例
var $http = axios.create({
baseURL: import.meta.env.VITE_APP_URL, //接口统一域名
timeout: 60000, //设置超时
headers: {
'Content-Type': 'application/json;charset=UTF-8;',
'Lang': lang.lang
}
})
//请求拦截器
$http.interceptors.request.use((config) => {
//若请求方式为post,则将data参数转为JSON字符串
if (config.method === 'POST') {
config.data = JSON.stringify(config.data);
}
return config;
}, (error) =>
// 对请求错误做些什么
Promise.reject(error));
//响应拦截器
$http.interceptors.response.use((response) => {
//响应成功
if (response.data.errorNo == 403) {
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
}
//响应成功
if (response.data.errorNo == 402) {
router.replace({
path: '/setup',
query: {
redirect: router.currentRoute.fullPath
}
})
}
return response.data;
}, (error) => {
//响应错误
if (error.response && error.response.status) {
const status = error.response.status
let message = ""
switch (status) {
case 400:
message = '请求错误';
break;
case 401:
message = '请求错误';
break;
case 403:
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
break;
case 404:
message = '请求地址出错';
break;
case 408:
message = '请求超时';
break;
case 500:
message = '服务器内部错误!';
break;
case 501:
message = '服务未实现!';
break;
case 502:
message = '网关错误!';
break;
case 503:
message = '服务不可用!';
break;
case 504:
message = '网关超时!';
break;
case 505:
message = 'HTTP版本不受支持';
break;
default:
message = '请求失败'
}
return Promise.reject(error);
}
return Promise.reject(error);
});
export default $http;
+29 -1
View File
@@ -1,4 +1,12 @@
var lang = {
"logout": "Logout",
"resetPwd": "Reset the account password",
"disabled": "Disabled",
"enabled": "Enabled",
"newUser": "Create Account",
"editUser": "Edit Account",
"user_name": "User Name",
"user_management": "user management",
"lang": "en",
"submit": "submit",
"compose": "compose",
@@ -55,6 +63,12 @@ var lang = {
"web_domain": "Web Domain",
"dns_desc": "Please add the following information to your DNS records",
"ssl_auto": "Automatically configure SSL certificates (recommended)",
"wait_desc":"HTTP challenge mode completes in approximately 1 minute and DNS API challenge mode completes in approximately 10 minutes.",
"ssl_challenge_type":"Challenge Type",
"ssl_auto_http":"Http Request",
"ssl_auto_dns":"DNS Records",
"challenge_typ_desc":"If PMail uses port 80 directly, it is recommended that you use the HTTP challenge method. If PMail does not use port 80 directly, it is recommended to use DNS challenge method, DNS API key to ask your domain name service provider to apply.",
"oomain_service_provider":"Domain Name Service Provider",
"ssl_manuallyf": "Manually configure an SSL certificate",
"ssl_key_path": "ssl key file path",
"ssl_crt_path": "ssl crt file path",
@@ -92,11 +106,19 @@ var lang = {
var zhCN = {
"logout": "注销",
"resetPwd": "重置账号密码",
"disabled": "禁用",
"enabled": "启用",
"user_name": "用户名",
"newUser": "新增用户",
"editUser": "编辑用户",
"user_management": "用户管理",
"lang": "zhCn",
"submit": "提交",
"compose": "发件",
"new": "新",
"account": "用户名",
"account": "账号",
"password": "密码",
"login": "登录",
"search": "搜索邮件",
@@ -148,7 +170,13 @@ var zhCN = {
"web_domain": "Web域名地址",
"dns_desc": "请将以下信息添加到DNS记录中",
"ssl_auto": "自动配置SSL证书(推荐)",
"oomain_service_provider":"域名服务商",
"ssl_auto_http":"HTTP请求",
"ssl_auto_dns":"DNS记录",
"ssl_challenge_type":"验证方式",
"ssl_manuallyf": "手动配置SSL证书",
"challenge_typ_desc":"如果PMail直接使用80端口,建议使用HTTP验证方式。如果PMail没有直接使用80端口,建议使用DNS验证方式,DNS API Key找你的域名服务商申请",
"wait_desc":"HTTP验证模式大约1分钟完成,DNS API验证模式大约15分钟完成。",
"ssl_key_path": "ssl key文件位置",
"ssl_crt_path": "ssl crt文件位置",
"group_settings": "分组",
+107 -2
View File
@@ -3,14 +3,119 @@ import 'element-plus/dist/index.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import {ref} from 'vue'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.config.globalProperties.$isLogin = ref(true)
app.config.globalProperties.$userInfos = ref({})
app.use(createPinia())
app.use(router)
import axios from 'axios'
import lang from './i18n/i18n';
//创建axios的一个实例
var $http = axios.create({
baseURL: import.meta.env.VITE_APP_URL, //接口统一域名
timeout: 60000, //设置超时
headers: {
'Content-Type': 'application/json;charset=UTF-8;',
'Lang': lang.lang
}
})
//请求拦截器
$http.interceptors.request.use((config) => {
//若请求方式为post,则将data参数转为JSON字符串
if (config.method === 'POST') {
config.data = JSON.stringify(config.data);
}
return config;
}, (error) =>
// 对请求错误做些什么
Promise.reject(error));
//响应拦截器
$http.interceptors.response.use((response) => {
//响应成功
if (response.data.errorNo == 403) {
app.config.globalProperties.$isLogin.value = false
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
}
//响应成功
if (response.data.errorNo == 402) {
router.replace({
path: '/setup',
query: {
redirect: router.currentRoute.fullPath
}
})
}
return response.data;
}, (error) => {
//响应错误
if (error.response && error.response.status) {
const status = error.response.status
let message = ""
switch (status) {
case 400:
message = '请求错误';
break;
case 401:
message = '请求错误';
break;
case 403:
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
})
break;
case 404:
message = '请求地址出错';
break;
case 408:
message = '请求超时';
break;
case 500:
message = '服务器内部错误!';
break;
case 501:
message = '服务未实现!';
break;
case 502:
message = '网关错误!';
break;
case 503:
message = '服务不可用!';
break;
case 504:
message = '网关超时!';
break;
case 505:
message = 'HTTP版本不受支持';
break;
default:
message = '请求失败'
}
return Promise.reject(error);
}
return Promise.reject(error);
});
// 注册到全局
app.config.globalProperties.$http = $http
app.mount('#app')
+4
View File
@@ -42,4 +42,8 @@ const router = createRouter({
]
})
export default router
+26 -5
View File
@@ -2,7 +2,7 @@
<div id="main">
<el-form label-width="100px" :rules="rules" ref="ruleFormRef" :model="ruleForm" status-icon>
<el-form-item :label="lang.sender" prop="sender">
<el-input v-model="ruleForm.sender" :placeholder="lang.sender_desc"></el-input>
<el-input :disabled="!$userInfos.is_admin" v-model="ruleForm.sender" :placeholder="lang.sender_desc"></el-input>
</el-form-item>
@@ -76,8 +76,6 @@
<script setup>
import $http from '../http/http';
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { ElMessage } from 'element-plus'
import { onBeforeUnmount, ref, shallowRef, reactive, onMounted } from 'vue'
@@ -85,10 +83,15 @@ import { Close } from '@element-plus/icons-vue';
import lang from '../i18n/i18n';
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
import { i18nChangeLanguage } from '@wangeditor/editor'
import router from "@/router"; //根路由对象
import { useRouter } from 'vue-router';
const router = useRouter();
import useGroupStore from '../stores/group'
const groupStore = useGroupStore()
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const $isLogin = app.appContext.config.globalProperties.$isLogin
const $userInfos = app.appContext.config.globalProperties.$userInfos
if (lang.lang == "zhCn"){
i18nChangeLanguage('zh-CN')
@@ -124,6 +127,24 @@ const ruleForm = reactive({
const fileList = reactive([]);
const init =function(){
if (Object.keys($userInfos.value).length == 0) {
$http.post("/api/user/info", {}).then(res => {
if (res.errorNo == 0) {
$userInfos.value = res.data
} else {
ElMessage({
type: 'error',
message: res.errorMsg,
})
}
})
}
}
init()
ruleForm.sender = $userInfos.value.account
const validateSender = function (rule, value, callback) {
if (typeof ruleForm.sender === "undefined" || ruleForm.sender === null || ruleForm.sender.trim() === "") {
callback(new Error(lang.err_sender_must))
+5 -3
View File
@@ -35,15 +35,17 @@
</template>
<script setup>
import $http from "../http/http";
import { RouterLink } from 'vue-router'
import { reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import router from "@/router"; //根路由对象
import { Document } from '@element-plus/icons-vue';
import lang from '../i18n/i18n';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const route = useRoute()
const detailData = ref({
attachments:[]
+11 -2
View File
@@ -81,13 +81,22 @@
<script setup>
import $http from "../http/http";
import { ArrowDown } from '@element-plus/icons-vue'
import { RouterLink } from 'vue-router'
import { reactive, ref, watch } from 'vue'
import router from "@/router"; //根路由对象
import useGroupStore from '../stores/group'
import lang from '../i18n/i18n';
import { useRouter } from 'vue-router';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const router = useRouter();
const groupStore = useGroupStore()
+7 -2
View File
@@ -20,11 +20,14 @@
<script setup>
import { reactive } from 'vue'
import $http from "../http/http";
import { ElMessage } from 'element-plus'
import router from "@/router"; //根路由对象
import lang from '../i18n/i18n';
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const $isLogin = app.appContext.config.globalProperties.$isLogin
const $userInfos = app.appContext.config.globalProperties.$userInfos
const form = reactive({
account: '',
@@ -36,6 +39,8 @@ const onSubmit = () => {
if (res.errorNo != 0) {
ElMessage.error(res.errorMsg)
} else {
$isLogin.value = true
$userInfos.value = res.data
router.replace({
path: '/',
query: {
+248 -13
View File
@@ -28,7 +28,8 @@
<div class="form" style="width: 400px;">
<el-form label-width="120px">
<el-form-item :label="lang.type">
<el-select :placeholder="lang.db_select_ph" v-model="dbSettings.type" @change="dbSettings.dsn=''">
<el-select :placeholder="lang.db_select_ph" v-model="dbSettings.type"
@change="dbSettings.dsn = ''">
<el-option label="MySQL" value="mysql" />
<el-option label="SQLite3" value="sqlite" />
</el-select>
@@ -121,9 +122,8 @@
</div>
</div>
<el-alert :closable="false" title="Warning!" type="error" center v-if="active == 5 && sslSettings.type == 0 && port != 80 "
:description="lang.autoSSLWarn"
/>
<el-alert :closable="false" title="Warning!" type="error" center
v-if="active == 5 && sslSettings.type == 0 && port != 80" :description="lang.autoSSLWarn" />
<div v-if="active == 5" class="ctn">
<div class="desc">
@@ -139,6 +139,166 @@
</el-select>
</el-form-item>
<el-form-item :label="lang.ssl_challenge_type" v-if="sslSettings.type == '0'">
<el-select :placeholder="lang.ssl_auto_http" v-model="sslSettings.challenge">
<el-option :label="lang.ssl_auto_http" value="http" />
<el-option :label="lang.ssl_auto_dns" value="dns" />
</el-select>
<el-tooltip class="box-item" effect="dark" :content="lang.challenge_typ_desc"
placement="top-start">
<span style="margin-left: 6px; font-size:18px; font-weight: bolder;">?</span>
</el-tooltip>
</el-form-item>
<el-form-item :label="lang.oomain_service_provider"
v-if="sslSettings.type == '0' && sslSettings.challenge == 'dns'">
<el-select @change="provide_change" :placeholder="lang.oomain_service_provider"
v-model="sslSettings.provider">
<el-option label="acme-dns" value="acme-dns" />
<el-option label="alidns" value="alidns" />
<el-option label="allinkl" value="allinkl" />
<el-option label="arvancloud" value="arvancloud" />
<el-option label="azure" value="azure" />
<el-option label="azuredns" value="azuredns" />
<el-option label="auroradns" value="auroradns" />
<el-option label="autodns" value="autodns" />
<el-option label="bindman" value="bindman" />
<el-option label="bluecat" value="bluecat" />
<el-option label="brandit" value="brandit" />
<el-option label="bunny" value="bunny" />
<el-option label="checkdomain" value="checkdomain" />
<el-option label="civo" value="civo" />
<el-option label="clouddns" value="clouddns" />
<el-option label="cloudflare" value="cloudflare" />
<el-option label="cloudns" value="cloudns" />
<el-option label="cloudru" value="cloudru" />
<el-option label="cloudxns" value="cloudxns" />
<el-option label="conoha" value="conoha" />
<el-option label="constellix" value="constellix" />
<el-option label="cpanel" value="cpanel" />
<el-option label="derak" value="derak" />
<el-option label="desec" value="desec" />
<el-option label="designate" value="designate" />
<el-option label="digitalocean" value="digitalocean" />
<el-option label="dnshomede" value="dnshomede" />
<el-option label="dnsimple" value="dnsimple" />
<el-option label="dnsmadeeasy" value="dnsmadeeasy" />
<el-option label="dnspod" value="dnspod" />
<el-option label="dode" value="dode" />
<el-option label="domeneshop" value="domeneshop" />
<el-option label="domainnameshop" value="domainnameshop" />
<el-option label="dreamhost" value="dreamhost" />
<el-option label="duckdns" value="duckdns" />
<el-option label="dyn" value="dyn" />
<el-option label="dynu" value="dynu" />
<el-option label="easydns" value="easydns" />
<el-option label="edgedns" value="edgedns" />
<el-option label="fastdns" value="fastdns" />
<el-option label="efficientip" value="efficientip" />
<el-option label="epik" value="epik" />
<el-option label="exec" value="exec" />
<el-option label="exoscale" value="exoscale" />
<el-option label="freemyip" value="freemyip" />
<el-option label="gandi" value="gandi" />
<el-option label="gandiv5" value="gandiv5" />
<el-option label="gcloud" value="gcloud" />
<el-option label="gcore" value="gcore" />
<el-option label="glesys" value="glesys" />
<el-option label="godaddy" value="godaddy" />
<el-option label="googledomains" value="googledomains" />
<el-option label="hetzner" value="hetzner" />
<el-option label="hostingde" value="hostingde" />
<el-option label="hosttech" value="hosttech" />
<el-option label="httpreq" value="httpreq" />
<el-option label="hurricane" value="hurricane" />
<el-option label="hyperone" value="hyperone" />
<el-option label="ibmcloud" value="ibmcloud" />
<el-option label="iij" value="iij" />
<el-option label="iijdpf" value="iijdpf" />
<el-option label="infoblox" value="infoblox" />
<el-option label="infomaniak" value="infomaniak" />
<el-option label="internetbs" value="internetbs" />
<el-option label="inwx" value="inwx" />
<el-option label="ionos" value="ionos" />
<el-option label="ipv64" value="ipv64" />
<el-option label="iwantmyname" value="iwantmyname" />
<el-option label="joker" value="joker" />
<el-option label="liara" value="liara" />
<el-option label="lightsail" value="lightsail" />
<el-option label="linode" value="linode" />
<el-option label="linodev4" value="linodev4" />
<el-option label="liquidweb" value="liquidweb" />
<el-option label="loopia" value="loopia" />
<el-option label="luadns" value="luadns" />
<el-option label="mailinabox" value="mailinabox" />
<el-option label="manual" value="manual" />
<el-option label="metaname" value="metaname" />
<el-option label="mydnsjp" value="mydnsjp" />
<el-option label="mythicbeasts" value="mythicbeasts" />
<el-option label="namecheap" value="namecheap" />
<el-option label="namedotcom" value="namedotcom" />
<el-option label="namesilo" value="namesilo" />
<el-option label="nearlyfreespeech" value="nearlyfreespeech" />
<el-option label="netcup" value="netcup" />
<el-option label="netlify" value="netlify" />
<el-option label="nicmanager" value="nicmanager" />
<el-option label="nifcloud" value="nifcloud" />
<el-option label="njalla" value="njalla" />
<el-option label="nodion" value="nodion" />
<el-option label="ns1" value="ns1" />
<el-option label="oraclecloud" value="oraclecloud" />
<el-option label="otc" value="otc" />
<el-option label="ovh" value="ovh" />
<el-option label="pdns" value="pdns" />
<el-option label="plesk" value="plesk" />
<el-option label="porkbun" value="porkbun" />
<el-option label="rackspace" value="rackspace" />
<el-option label="rcodezero" value="rcodezero" />
<el-option label="regru" value="regru" />
<el-option label="rfc2136" value="rfc2136" />
<el-option label="rimuhosting" value="rimuhosting" />
<el-option label="route53" value="route53" />
<el-option label="safedns" value="safedns" />
<el-option label="sakuracloud" value="sakuracloud" />
<el-option label="scaleway" value="scaleway" />
<el-option label="selectel" value="selectel" />
<el-option label="servercow" value="servercow" />
<el-option label="shellrent" value="shellrent" />
<el-option label="simply" value="simply" />
<el-option label="sonic" value="sonic" />
<el-option label="stackpath" value="stackpath" />
<el-option label="tencentcloud" value="tencentcloud" />
<el-option label="transip" value="transip" />
<el-option label="ultradns" value="ultradns" />
<el-option label="variomedia" value="variomedia" />
<el-option label="vegadns" value="vegadns" />
<el-option label="vercel" value="vercel" />
<el-option label="versio" value="versio" />
<el-option label="vinyldns" value="vinyldns" />
<el-option label="vkcloud" value="vkcloud" />
<el-option label="vscale" value="vscale" />
<el-option label="vultr" value="vultr" />
<el-option label="webnames" value="webnames" />
<el-option label="websupport" value="websupport" />
<el-option label="wedos" value="wedos" />
<el-option label="yandex" value="yandex" />
<el-option label="yandex360" value="yandex360" />
<el-option label="yandexcloud" value="yandexcloud" />
<el-option label="zoneee" value="zoneee" />
<el-option label="zonomi" value="zonomi" />
</el-select>
</el-form-item>
<el-form-item :label="item"
v-if="sslSettings.paramsList.length != 0 && sslSettings.type == 0 && sslSettings.challenge == 'dns'"
v-for="item in sslSettings.paramsList">
<el-input style="width: 240px" :placeholder="item" v-model="dnsApiParams[item]" />
</el-form-item>
<el-form-item :label="lang.ssl_key_path" v-if="sslSettings.type == '1'">
<el-input placeholder="./config/ssl/private.key" v-model="sslSettings.key_path"></el-input>
</el-form-item>
@@ -153,19 +313,21 @@
</div>
<el-button v-loading.fullscreen.lock="fullscreenLoading" id="next" style="margin-top: 12px" @click="next">{{
<el-button :element-loading-text="lang.wait_desc" v-loading.fullscreen.lock="fullscreenLoading" id="next" style="margin-top: 12px" @click="next">{{
lang.next }}</el-button>
</div>
</template>
<script setup>
import $http from "../http/http";
import { reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import router from "@/router"; //根路由对象
import lang from '../i18n/i18n';
import axios from 'axios'
import { getCurrentInstance } from 'vue'
const app = getCurrentInstance()
const $http = app.appContext.config.globalProperties.$http
const adminSettings = reactive({
"account": "admin",
@@ -187,10 +349,15 @@ const domainSettings = reactive({
const sslSettings = reactive({
"type": "0",
"provider": "",
"challenge": "http",
"key_path": "./config/ssl/private.key",
"crt_path": "./config/ssl/public.crt"
"crt_path": "./config/ssl/public.crt",
"paramsList": {},
})
const dnsApiParams = reactive({})
const active = ref(0)
const fullscreenLoading = ref(false)
@@ -288,6 +455,12 @@ const getSSLConfig = () => {
ElMessage.error(res.errorMsg)
} else {
sslSettings.type = res.data.type
if (sslSettings.type == "2"){
sslSettings.type = "0"
sslSettings.challenge="dns"
}
port.value = res.data.port
}
})
@@ -296,20 +469,68 @@ const getSSLConfig = () => {
const setSSLConfig = () => {
fullscreenLoading.value = true;
$http.post("/api/setup", { "action": "set", "step": "ssl", "ssl_type": sslSettings.type, "key_path": sslSettings.key_path, "crt_path": sslSettings.crt_path }).then((res) => {
let sslType = sslSettings.type;
if (sslType == "0" && sslSettings.challenge == "dns") {
sslType = "2"
}
if (sslType == "2") {
let params = { "action": "setParams", "step": "ssl", };
params = Object.assign(params, dnsApiParams);
// dns验证方式先提交DNS api Key
$http.post("/api/setup", params).then((res) => {
if (res.errorNo != 0) {
fullscreenLoading.value = false;
ElMessage.error(res.errorMsg);
return;
}
})
}
$http.post("/api/setup", {
"action": "set",
"step": "ssl",
"ssl_type": sslType,
"key_path": sslSettings.key_path,
"crt_path": sslSettings.crt_path,
"serviceName": sslSettings.provider
}).then((res) => {
if (res.errorNo != 0) {
fullscreenLoading.value = false;
ElMessage.error(res.errorMsg)
} else {
setTimeout(function () {
window.location.href = "https://" + domainSettings.web_domain;
}, 10000);
checkStatus();
}
})
}
const checkStatus = () => {
axios.post("/api/ping", {}).then((res) => {
if (res.data.errorNo != 0) {
setTimeout(function () {
checkStatus()
}, 1000);
} else {
window.location.href = "https://" + domainSettings.web_domain;
}
}).catch((error) => {
setTimeout(function () {
checkStatus()
}, 1000);
})
}
const setDomainConfig = () => {
$http.post("/api/setup", { "action": "set", "step": "domain", "web_domain": domainSettings.web_domain, "smtp_domain": domainSettings.smtp_domain }).then((res) => {
if (res.errorNo != 0) {
@@ -321,6 +542,19 @@ const setDomainConfig = () => {
})
}
const provide_change = () => {
console.log(sslSettings.provider)
$http.post("/api/setup", { "action": "getParams", "step": "ssl", "serverName": sslSettings.provider }).then((res) => {
if (res.errorNo != 0) {
ElMessage.error(res.errorMsg)
} else {
sslSettings.paramsList = res.data
}
})
}
const next = () => {
switch (active.value) {
@@ -377,5 +611,6 @@ const next = () => {
flex-direction: column;
}
#next {}
</style>