Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Added Settings Page

zdmc643df935f92
diff --git a/core/frontend/src/api/index.ts b/core/frontend/src/api/index.ts
index 8bc8e1f0..5db69894 100644
--- a/core/frontend/src/api/index.ts
+++ b/core/frontend/src/api/index.ts
@@ -45,16 +45,16 @@ instance.interceptors.request.use(config => {
instance.interceptors.response.use(
response => {
const { fetchOptions } = response.config
- const { code, data, msg } = response.data || {}
- if (code === 0) {
+ const { code, data, msg, success } = response.data || {}
+ if (code === 0 && success) {
if (fetchOptions?.successMessage) {
Message.success(msg)
}
return Promise.resolve(data)
}
- // if (!success && msg) {
- // Message.error(msg)
- // }
+ if (!success && msg) {
+ Message.error(msg)
+ }
if (code === 401) {
router.push('/login')
}
diff --git a/core/frontend/src/api/modules/mailbox.ts b/core/frontend/src/api/modules/mailbox.ts
index f92781ef..77ba6d27 100644
--- a/core/frontend/src/api/modules/mailbox.ts
+++ b/core/frontend/src/api/modules/mailbox.ts
@@ -10,10 +10,10 @@ export const getMailboxList = (params: {
}
type MailboxParams = {
+ full_name: string
domain: string
- username: string
password: string
- status: number
+ active: number
isAdmin: number
quota: number
}
diff --git a/core/frontend/src/api/modules/settings.ts b/core/frontend/src/api/modules/settings.ts
new file mode 100644
index 00000000..8e784016
--- /dev/null
+++ b/core/frontend/src/api/modules/settings.ts
@@ -0,0 +1,13 @@
+import { instance } from '@/api'
+
+export const getServiceList = () => {
+ return instance.get('/docker_api/list')
+}
+
+export const restartService = (params: { container_id: string }) => {
+ return instance.post('/docker_api/restart', params, {
+ fetchOptions: {
+ successMessage: true,
+ },
+ })
+}
diff --git a/core/frontend/src/components/bt-config-provider/index.vue b/core/frontend/src/components/bt-config-provider/index.vue
index a9ddf1f0..6964581e 100644
--- a/core/frontend/src/components/bt-config-provider/index.vue
+++ b/core/frontend/src/components/bt-config-provider/index.vue
@@ -37,5 +37,8 @@ const themeOverrides = {
labelPaddingHorizontal: '0 20px 0 0',
labelFontSizeTopMedium: '12px',
},
+ Dialog: {
+ contentMargin: '16px 0',
+ },
}
</script>
diff --git a/core/frontend/src/components/bt-tabs/index.vue b/core/frontend/src/components/bt-tabs/index.vue
new file mode 100644
index 00000000..0e3f6b81
--- /dev/null
+++ b/core/frontend/src/components/bt-tabs/index.vue
@@ -0,0 +1,41 @@
+<template>
+ <n-tabs v-model:value="menu" class="bt-tabs h-full" type="card" placement="top">
+ <slot></slot>
+ </n-tabs>
+</template>
+
+<script lang="ts" setup>
+const menu = defineModel<string | number>('value')
+</script>
+
+<style lang="scss" scoped>
+.bt-tabs {
+ --n-tab-gap: 4px;
+ --n-tab-border-radius: 0;
+ --n-tab-text-color-active: #333;
+ --n-tab-border-color: #cacad9;
+ --n-tab-padding-vertical: 0 16px;
+ --n-pane-padding-top: 16px;
+ --n-pane-padding-left: 0;
+ --n-pane-padding-right: 0;
+ --n-pane-padding-bottom: 0;
+ :deep(> .n-tabs-nav) {
+ .n-tabs-wrapper {
+ .n-tabs-tab-wrapper {
+ .n-tabs-tab {
+ height: 32px;
+ border-bottom: none;
+ background: -webkit-gradient(linear, 0% 0, 0% 100%, from(#f6f6f6), to(#ddd));
+ &--active {
+ background: #0000;
+ }
+ }
+ }
+ }
+ }
+ :deep(> .n-tab-pane) {
+ flex: 1;
+ overflow: auto;
+ }
+}
+</style>
diff --git a/core/frontend/src/layout/components/AppHeader.vue b/core/frontend/src/layout/components/AppHeader.vue
index 8c66c818..be627c83 100644
--- a/core/frontend/src/layout/components/AppHeader.vue
+++ b/core/frontend/src/layout/components/AppHeader.vue
@@ -1,8 +1,8 @@
<template>
<n-layout-header ref="headerRef" :style="{ top: `${top}px` }">
<div class="header-left">
- <n-button class="icon-btn" :bordered="false">
- <i class="icon i-mdi-menu-open"></i>
+ <n-button class="icon-btn" :bordered="false" @click="handleCollapse">
+ <i class="icon" :class="isCollapse ? 'i-mdi-menu-close' : 'i-mdi-menu-open'"></i>
</n-button>
<div class="text-16px">{{ routeTitle }}</div>
</div>
@@ -21,7 +21,8 @@
</template>
<script lang="ts" setup>
-import { useUserStore } from '@/store'
+import { storeToRefs } from 'pinia'
+import { useUserStore, useGlobalStore } from '@/store'
defineProps({
top: {
@@ -31,13 +32,20 @@ defineProps({
})
const route = useRoute()
-const router = useRouter()
+
const userStore = useUserStore()
+const globalStore = useGlobalStore()
+
+const { isCollapse } = storeToRefs(globalStore)
const routeTitle = computed(() => {
return `${route.meta.title}`
})
+const handleCollapse = () => {
+ globalStore.setCollapse()
+}
+
const userOptions = [
{
label: 'Logout',
@@ -48,8 +56,7 @@ const userOptions = [
const handleUserAction = (key: string) => {
switch (key) {
case 'logout':
- userStore.resetLoginInfo()
- router.push('/login')
+ userStore.logout()
break
}
}
diff --git a/core/frontend/src/layout/components/Sidebar.vue b/core/frontend/src/layout/components/Sidebar.vue
index 6f765edf..479f03e2 100644
--- a/core/frontend/src/layout/components/Sidebar.vue
+++ b/core/frontend/src/layout/components/Sidebar.vue
@@ -1,6 +1,6 @@
<template>
<n-layout-sider
- :width="264"
+ :width="isCollapse ? 64 : 240"
:content-style="{
display: 'flex',
flexDirection: 'column',
@@ -8,28 +8,39 @@
overflow: 'hidden',
}">
<!-- 应用标志和名称 -->
- <div class="app-logo">
+ <div class="app-logo" :class="{ collapse: isCollapse }">
<a href="#">
<img class="icon" src="@images/logo.png" alt="" />
- <span class="app-name">Billion Mail</span>
+ <span v-show="!isCollapse" class="app-name">Billion Mail</span>
</a>
</div>
<!-- 导航菜单 -->
<div class="nav-section">
- <n-menu :value="activeMenuKey" :options="menuOptions" :root-indent="24"> </n-menu>
+ <n-menu
+ :value="activeMenuKey"
+ :collapsed="isCollapse"
+ :collapsed-width="64"
+ :options="menuOptions"
+ :root-indent="24">
+ </n-menu>
</div>
</n-layout-sider>
</template>
<script lang="tsx" setup>
import { RouterLink, RouteRecordRaw } from 'vue-router'
-import { useMenuStore } from '@/store'
+import { useMenuStore, useGlobalStore } from '@/store'
import { menuList } from '@/router/router'
+import { storeToRefs } from 'pinia'
+import { VNodeChild } from 'vue'
const route = useRoute()
const menuStore = useMenuStore()
+const globalStore = useGlobalStore()
+
+const { isCollapse } = storeToRefs(globalStore)
// 当前菜单名称
const activeMenuKey = computed(() => {
@@ -46,6 +57,7 @@ const menuOptions = computed(() => {
return routerMenus.value.map(route => ({
key: `${route.meta?.key}`,
label: () => renderLabel(route),
+ icon: () => renderIcon(route),
}))
})
@@ -53,12 +65,22 @@ const renderLabel = (route: RouteRecordRaw) => {
const name = route.children?.[0]?.name || ''
return (
<RouterLink class="flex items-center" to={{ name }}>
- <span class={`${route.meta?.icon || ''} text-22px`}></span>
- <span class="ml-14px">{route.meta?.title || ''}</span>
+ <span class="ml-10px">{route.meta?.title || ''}</span>
</RouterLink>
)
}
+const iconMap: Record<string, VNodeChild> = {
+ domain: <i class="i-mdi-web"></i>,
+ mailbox: <i class="i-mdi-email"></i>,
+ settings: <i class="i-mdi-settings-outline"></i>,
+}
+
+const renderIcon = (route: RouteRecordRaw) => {
+ if (!route.meta?.key) return null
+ return iconMap[route.meta.key as string]
+}
+
onMounted(() => {
menuStore.setMenuList(menuList)
})
@@ -75,6 +97,10 @@ onMounted(() => {
.app-logo {
display: flex;
padding: 16px 24px;
+ &.collapse {
+ justify-content: center;
+ padding: 16px 0;
+ }
a {
display: flex;
align-items: center;
@@ -99,12 +125,18 @@ onMounted(() => {
.n-menu {
--n-item-height: 44px;
--n-item-text-color: #b7c0cd;
+ --n-item-icon-color: #b7c0cd;
--n-item-color-active: rgba(0, 0, 0, 0.1);
--n-item-text-color-active: #ffffff;
+ --n-item-icon-color-active: #ffffff;
--n-item-color-hover: rgba(0, 0, 0, 0.1);
--n-item-text-color-hover: #ffffff;
+ --n-item-icon-color-hover: #ffffff;
--n-item-color-active-hover: rgba(0, 0, 0, 0.1);
--n-item-text-color-active-hover: #ffffff;
+ --n-item-icon-color-active-hover: #ffffff;
+ --n-item-icon-color-collapsed: #b7c0cd;
+ --n-item-color-active-collapsed: rgba(0, 0, 0, 0.1);
:deep(.n-menu-item) {
margin-top: 0;
.n-menu-item-content {
diff --git a/core/frontend/src/router/modules/domain.ts b/core/frontend/src/router/modules/domain.ts
index 1e9efd1f..7d3dbd01 100644
--- a/core/frontend/src/router/modules/domain.ts
+++ b/core/frontend/src/router/modules/domain.ts
@@ -4,7 +4,7 @@ import { Layout } from '@/router/constant'
const route: RouteRecordRaw = {
path: '/domain',
component: Layout,
- meta: { sort: 5, key: 'domain', title: 'MailDomain', icon: 'i-mdi-web' },
+ meta: { sort: 5, key: 'domain', title: 'MailDomain' },
children: [
{
path: '/domain',
diff --git a/core/frontend/src/store/index.ts b/core/frontend/src/store/index.ts
index bcbc4395..13138a19 100644
--- a/core/frontend/src/store/index.ts
+++ b/core/frontend/src/store/index.ts
@@ -2,10 +2,11 @@ import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import useMenuStore from './modules/menu'
import useUserStore from './modules/user'
+import useGlobalStore from './modules/global'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
-export { useMenuStore, useUserStore }
+export { useMenuStore, useUserStore, useGlobalStore }
export default pinia
diff --git a/core/frontend/src/store/modules/global.ts b/core/frontend/src/store/modules/global.ts
new file mode 100644
index 00000000..01f6bdbb
--- /dev/null
+++ b/core/frontend/src/store/modules/global.ts
@@ -0,0 +1,14 @@
+import { defineStore } from 'pinia'
+
+export default defineStore('GlobalStore', () => {
+ const isCollapse = ref(false)
+
+ const setCollapse = () => {
+ isCollapse.value = !isCollapse.value
+ }
+
+ return {
+ isCollapse,
+ setCollapse,
+ }
+})
diff --git a/core/frontend/src/store/modules/user.ts b/core/frontend/src/store/modules/user.ts
index c4686b93..47b0073e 100644
--- a/core/frontend/src/store/modules/user.ts
+++ b/core/frontend/src/store/modules/user.ts
@@ -1,3 +1,4 @@
+import router from '@/router'
import { defineStore } from 'pinia'
export default defineStore(
@@ -35,9 +36,15 @@ export default defineStore(
login.value.expire = 0
}
+ const logout = () => {
+ resetLoginInfo()
+ router.push('/login')
+ }
+
return {
login,
isLogin,
+ logout,
setLoginInfo,
resetLoginInfo,
}
diff --git a/core/frontend/src/styles/reset.scss b/core/frontend/src/styles/reset.scss
index 805218a8..6999b708 100644
--- a/core/frontend/src/styles/reset.scss
+++ b/core/frontend/src/styles/reset.scss
@@ -30,4 +30,5 @@ a {
p,
ul {
margin: 0;
+ padding: 0;
}
diff --git a/core/frontend/src/utils/is.ts b/core/frontend/src/utils/is.ts
index 456f2503..ea295320 100644
--- a/core/frontend/src/utils/is.ts
+++ b/core/frontend/src/utils/is.ts
@@ -40,3 +40,12 @@ export const isFunction = <T = Function>(val: unknown): val is T => {
export const isUndefined = (val: unknown): val is undefined => {
return typeof val === 'undefined'
}
+
+/**
+ * @description 是否为数组
+ * @param { unknown } val 参数
+ * @returns { boolean }
+ */
+export const isArray = <T = unknown>(val: unknown): val is T[] => {
+ return Array.isArray(val)
+}
diff --git a/core/frontend/src/views/domain/components/DomainForm.vue b/core/frontend/src/views/domain/components/DomainForm.vue
index 3f7355f7..5e17e8fd 100644
--- a/core/frontend/src/views/domain/components/DomainForm.vue
+++ b/core/frontend/src/views/domain/components/DomainForm.vue
@@ -11,7 +11,7 @@
</n-input>
</div>
</n-form-item>
- <n-form-item label="A记录">
+ <n-form-item v-if="false" label="A记录">
<div class="w-320px">
<n-input
v-model:value="form.a_record"
@@ -42,7 +42,7 @@
</div>
</n-form-item>
</bt-form>
- <bt-tips>
+ <bt-tips v-if="false">
<li class="text-error">提示A记录解析失败。请检查填写的A记录域名是否已解析到服务器 IP</li>
<li>需要在您的DNS服务提供商控制台添加A记录</li>
<li>如果使用CloudFlare,请在添加记录时选择【仅DNS】</li>
diff --git a/core/frontend/src/views/domain/components/DomainSsl/OtherCert.vue b/core/frontend/src/views/domain/components/DomainSsl/OtherCert.vue
new file mode 100644
index 00000000..e664f2af
--- /dev/null
+++ b/core/frontend/src/views/domain/components/DomainSsl/OtherCert.vue
@@ -0,0 +1,118 @@
+<template>
+ <div class="ssl-cert-container">
+ <n-alert class="mb-16px" type="success" :show-icon="false">
+ <div class="brand-info">
+ <div class="info-label">品牌:</div>
+ <div class="info-value">R11</div>
+ <div class="info-label">证书域名:</div>
+ <div class="info-value font-normal!">
+ <n-tag v-for="(domain, index) in domains" :key="index" size="small">
+ {{ domain }}
+ </n-tag>
+ </div>
+ </div>
+ </n-alert>
+
+ <div class="cert-content">
+ <div class="cert-section">
+ <div class="section-title">私钥 (KEY)</div>
+ <n-input
+ v-model:value="privateKey"
+ type="textarea"
+ placeholder=""
+ :rows="10"
+ :input-props="{ spellcheck: false }">
+ </n-input>
+ </div>
+
+ <div class="cert-section">
+ <div class="section-title">证书 (CRT/PEM)</div>
+ <n-input
+ v-model:value="certificate"
+ type="textarea"
+ placeholder=""
+ :input-props="{ spellcheck: false }"
+ :rows="10">
+ </n-input>
+ </div>
+ </div>
+
+ <div class="cert-actions">
+ <n-button type="primary" @click="saveCertificate">保存</n-button>
+ <n-button @click="deleteCertificate">删除</n-button>
+ </div>
+
+ <bt-tips>
+ <li>粘贴您的 KEY 和 CRT 内容,然后保存</li>
+ <li>如果浏览器提示证书链不完整,请检查 PEM 证书是否正确拼接</li>
+ <li>PEM 格式证书 = 域名证书 .crt + 根证书 (root_bundle).crt</li>
+ <li>当未指定 SSL 默认站点时,未配置 SSL 的站点将使用 HTTPS 访问启用了 SSL 的站点</li>
+ </bt-tips>
+ </div>
+</template>
+
+<script lang="ts" setup>
+// 数据
+const domains = ref<string[]>(['lotkc.cn', 'lotkc.cn'])
+
+const privateKey = ref<string>('')
+
+const certificate = ref<string>('')
+
+// 方法
+const saveCertificate = () => {
+ // 保存证书的逻辑
+}
+
+const deleteCertificate = () => {
+ // 删除证书的逻辑
+ privateKey.value = ''
+ certificate.value = ''
+}
+</script>
+
+<style lang="scss" scoped>
+.ssl-cert-container {
+ .brand-info {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ .info-label {
+ font-weight: 500;
+ color: #606266;
+ }
+
+ .info-value {
+ margin-right: 16px;
+ font-weight: bold;
+ color: #67c23a;
+ .n-tag + .n-tag {
+ margin-left: 8px;
+ }
+ }
+ }
+
+ .cert-content {
+ display: flex;
+ gap: 20px;
+ margin-bottom: 20px;
+
+ .cert-section {
+ flex: 1;
+
+ .section-title {
+ font-weight: 500;
+ margin-bottom: 8px;
+ color: #303133;
+ }
+ }
+ }
+
+ .cert-actions {
+ display: flex;
+ gap: 12px;
+ margin-bottom: 24px;
+ }
+}
+</style>
diff --git a/core/frontend/src/views/domain/components/DomainSsl.vue b/core/frontend/src/views/domain/components/DomainSsl/index.vue
similarity index 61%
rename from core/frontend/src/views/domain/components/DomainSsl.vue
rename to core/frontend/src/views/domain/components/DomainSsl/index.vue
index e2ceeb0f..15dad57c 100644
--- a/core/frontend/src/views/domain/components/DomainSsl.vue
+++ b/core/frontend/src/views/domain/components/DomainSsl/index.vue
@@ -1,12 +1,20 @@
<template>
<modal title="Domain SSL" :width="650" :footer="false">
- <div>aaaaa</div>
+ <bt-tabs v-model:value="menu">
+ <n-tab-pane name="other" tab="Other certificate">
+ <other-cert />
+ </n-tab-pane>
+ </bt-tabs>
</modal>
</template>
<script setup lang="ts">
import { useModal } from '@/hooks/modal/useModal'
-import { MailDomain } from '../interface'
+import { MailDomain } from '../../interface'
+
+import OtherCert from './OtherCert.vue'
+
+const menu = ref('other')
const [Modal, modalApi] = useModal({
onChangeState: isOpen => {
diff --git a/core/frontend/src/views/domain/index.vue b/core/frontend/src/views/domain/index.vue
index 81f3b088..0c8e88f4 100644
--- a/core/frontend/src/views/domain/index.vue
+++ b/core/frontend/src/views/domain/index.vue
@@ -37,7 +37,7 @@ import type { MailDomain, MailDomainParams } from './interface'
import DomainForm from './components/DomainForm.vue'
import DomainCatch from './components/DomainCatch.vue'
-import DomainSsl from './components/DomainSsl.vue'
+import DomainSsl from './components/DomainSsl/index.vue'
import DomainDns from './components/DomainDns.vue'
const { tableParams, tableList, loading, tableTotal, getTableData } = useTableData<
@@ -94,35 +94,35 @@ const columns = ref<DataTableColumns<MailDomain>>([
// />
// ),
// },
- // {
- // key: 'ssl',
- // title: 'SSL',
- // render: row => {
- // if (row.ssl_status) {
- // const ssl = row.ssl_info
- // return (
- // <NButton
- // type={ssl.endtime < 0 ? 'error' : 'primary'}
- // text
- // onClick={() => {
- // handleShowSsl(row)
- // }}>
- // {ssl.endtime < 0 ? '已过期' : `剩余${ssl.endtime}天`}
- // </NButton>
- // )
- // }
- // return (
- // <NButton
- // type="warning"
- // text
- // onClick={() => {
- // handleShowSsl(row)
- // }}>
- // 未设置
- // </NButton>
- // )
- // },
- // },
+ {
+ key: 'ssl',
+ title: 'SSL',
+ render: row => {
+ // if (row.ssl_status) {
+ // const ssl = row.ssl_info
+ // return (
+ // <NButton
+ // type={ssl.endtime < 0 ? 'error' : 'primary'}
+ // text
+ // onClick={() => {
+ // handleShowSsl(row)
+ // }}>
+ // {ssl.endtime < 0 ? '已过期' : `剩余${ssl.endtime}天`}
+ // </NButton>
+ // )
+ // }
+ return (
+ <NButton
+ type="warning"
+ text
+ onClick={() => {
+ handleShowSsl(row)
+ }}>
+ 未设置
+ </NButton>
+ )
+ },
+ },
{
title: '操作',
key: 'actions',
@@ -190,15 +190,15 @@ const [CatchModal] = useModal({
// console.log(row)
// }
-const [SslModal] = useModal({
+const [SslModal, sslModalApi] = useModal({
component: DomainSsl,
})
// Handle show ssl
-// const handleShowSsl = (row: MailDomain) => {
-// sslModalApi.setState({ row })
-// sslModalApi.open()
-// }
+const handleShowSsl = (row: MailDomain) => {
+ sslModalApi.setState({ row })
+ sslModalApi.open()
+}
const [DnsModal, dnsModalApi] = useModal({
component: DomainDns,
diff --git a/core/frontend/src/views/mailbox/components/MailboxForm.vue b/core/frontend/src/views/mailbox/components/MailboxForm.vue
index 40eec330..840dbb54 100644
--- a/core/frontend/src/views/mailbox/components/MailboxForm.vue
+++ b/core/frontend/src/views/mailbox/components/MailboxForm.vue
@@ -1,41 +1,36 @@
<template>
<modal :title="title" width="520">
<bt-form ref="formRef" class="pt-20px" :model="form" :rules="rules">
- <n-form-item label="配额" path="quota">
+ <n-form-item label="邮箱地址" path="full_name">
<div class="w-280px">
<n-input-group>
- <n-input-number v-model:value="form.quota" class="flex-1" :min="1" :show-button="false">
- </n-input-number>
- <n-select v-model:value="form.unit" class="flex-1" :options="unitOptions"> </n-select>
+ <n-input v-model:value="form.full_name" class="flex-1" :disabled="isEdit"> </n-input>
+ <domain-select v-model:value="form.domain" class="flex-1" :disabled="isEdit">
+ </domain-select>
</n-input-group>
</div>
</n-form-item>
- <n-form-item label="用户类型" path="userType">
+ <n-form-item label="密码" path="password">
<div class="w-280px">
- <n-select v-model:value="form.isAdmin" :options="userTypeOptions" />
+ <n-input v-model:value="form.password" placeholder="请输入您的邮箱密码"> </n-input>
</div>
</n-form-item>
- <n-form-item label="用户名" path="username">
+ <n-form-item label="配额" path="quota">
<div class="w-280px">
<n-input-group>
- <n-input
- v-model:value="form.username"
- class="flex-1"
- :disabled="isEdit"
- placeholder="您的域名">
- </n-input>
- <domain-select v-model:value="form.domain" class="flex-1" :disabled="isEdit">
- </domain-select>
+ <n-input-number v-model:value="form.quota" class="flex-1" :min="1" :show-button="false">
+ </n-input-number>
+ <n-select v-model:value="form.unit" class="flex-1" :options="unitOptions"> </n-select>
</n-input-group>
</div>
</n-form-item>
- <n-form-item label="密码" path="password">
+ <n-form-item label="用户类型" path="userType">
<div class="w-280px">
- <n-input v-model:value="form.password" placeholder="请输入您的邮箱密码"> </n-input>
+ <n-select v-model:value="form.isAdmin" :options="userTypeOptions" />
</div>
</n-form-item>
- <n-form-item label="状态" path="status">
- <n-switch v-model:value="form.status" :checked-value="1" :unchecked-value="0" />
+ <n-form-item label="状态">
+ <n-switch v-model:value="form.active" :checked-value="1" :unchecked-value="0" />
</n-form-item>
</bt-form>
</modal>
@@ -60,10 +55,10 @@ const form = reactive({
quota: 5,
unit: 'GB',
isAdmin: 0,
- username: '',
+ full_name: '',
domain: null as string | null,
password: '',
- status: 1,
+ active: 1,
})
const unitOptions = [
@@ -77,10 +72,10 @@ const userTypeOptions = [
]
const rules: FormRules = {
- username: {
+ full_name: {
trigger: 'blur',
validator: () => {
- if (form.username.trim() === '' || !form.domain) {
+ if (form.full_name.trim() === '' || !form.domain) {
return new Error('请输入用户名')
}
return true
@@ -128,12 +123,12 @@ const getQuotaByte = (quota: number, quota_unit: string) => {
const getParams = () => {
return {
+ full_name: form.full_name,
domain: form.domain || '',
- username: form.username,
password: form.password,
quota: getQuotaByte(form.quota, form.unit),
isAdmin: form.isAdmin,
- status: form.status,
+ active: form.active,
}
}
@@ -144,12 +139,10 @@ const [Modal, modalApi] = useModal({
const { row } = state
isEdit.value = state.isEdit
if (row) {
+ form.full_name = row.full_name
form.domain = row.domain
form.isAdmin = row.is_admin
- form.status = row.active
-
- const [username] = row.username.split('@')
- form.username = username
+ form.active = row.active
const quota = getByteUnit(row.quota)
const [quotaNum, quotaUnit] = quota.split(' ')
@@ -157,13 +150,13 @@ const [Modal, modalApi] = useModal({
form.unit = quotaUnit
}
} else {
- form.username = ''
+ form.full_name = ''
form.domain = null
form.password = ''
form.quota = 5
form.unit = 'GB'
form.isAdmin = 0
- form.status = 1
+ form.active = 1
}
},
onConfirm: async () => {
diff --git a/core/frontend/src/views/mailbox/index.vue b/core/frontend/src/views/mailbox/index.vue
index 7a3e8ce3..bbfd1133 100644
--- a/core/frontend/src/views/mailbox/index.vue
+++ b/core/frontend/src/views/mailbox/index.vue
@@ -43,7 +43,7 @@ import { DataTableColumns, NButton, NFlex, NSwitch } from 'naive-ui'
import { getByteUnit } from '@/utils'
import { useModal } from '@/hooks/modal/useModal'
import { useTableData } from '@/hooks/useTableData'
-import { deleteMailbox, getMailboxList } from '@/api/modules/mailbox'
+import { deleteMailbox, getMailboxList, updateMailbox } from '@/api/modules/mailbox'
import { MailBox, MailBoxParams } from './interface'
import TablePassword from '@/components/bt-table-password/index.vue'
@@ -104,7 +104,17 @@ const columns = ref<DataTableColumns<MailBox>>([
width: '12%',
minWidth: 80,
render: row => {
- return <NSwitch value={row.active} checked-value={1} unchecked-value={0} size="small" />
+ return (
+ <NSwitch
+ value={row.active}
+ checked-value={1}
+ unchecked-value={0}
+ size="small"
+ onUpdateValue={val => {
+ handleStatusChange(row, val)
+ }}
+ />
+ )
},
},
{
@@ -148,6 +158,18 @@ const handleAdd = () => {
formModalApi.open()
}
+const handleStatusChange = async (row: MailBox, val: number) => {
+ await updateMailbox({
+ full_name: row.full_name,
+ domain: row.domain,
+ password: row.password,
+ quota: row.quota,
+ isAdmin: row.is_admin,
+ active: val,
+ })
+ row.active = val
+}
+
const handleEdit = (row: MailBox) => {
formModalApi.setState({ isEdit: true, row })
formModalApi.open()
diff --git a/core/frontend/src/views/settings/components/SettingsService.vue b/core/frontend/src/views/settings/components/SettingsService.vue
new file mode 100644
index 00000000..912ed029
--- /dev/null
+++ b/core/frontend/src/views/settings/components/SettingsService.vue
@@ -0,0 +1,81 @@
+<template>
+ <div class="settings-title">Service Status</div>
+ <n-data-table :loading="loading" :data="serviceList" :columns="columns"></n-data-table>
+</template>
+
+<script lang="tsx" setup>
+import { NButton, NTag, DataTableColumns } from 'naive-ui'
+import { isArray } from '@/utils'
+import { getServiceList, restartService } from '@/api/modules/settings'
+import { DockerService } from '../types/common'
+
+const loading = ref(false)
+
+const serviceList = ref<DockerService[]>([])
+
+const columns = ref<DataTableColumns<DockerService>>([
+ {
+ key: 'Names',
+ title: 'Service Name',
+ render: row => {
+ return row.Names[0]
+ },
+ },
+ {
+ key: 'State',
+ title: 'Status',
+ render: row => {
+ return (
+ <NTag size="small" bordered={false} type={row.State === 'running' ? 'success' : 'error'}>
+ {row.State === 'running' ? 'Running' : 'Stopped'}
+ </NTag>
+ )
+ },
+ },
+ {
+ key: 'action',
+ title: '操作',
+ align: 'right',
+ render: row => (
+ <>
+ <NButton
+ type="primary"
+ text
+ onClick={() => {
+ handleRestart(row)
+ }}>
+ 重启
+ </NButton>
+ </>
+ ),
+ },
+])
+
+const handleRestart = async (row: DockerService) => {
+ await restartService({ container_id: row.Id })
+ getList()
+}
+
+const getList = async () => {
+ try {
+ loading.value = true
+ const res = await getServiceList()
+ if (isArray<DockerService>(res)) {
+ serviceList.value = res
+ }
+ } finally {
+ loading.value = false
+ }
+}
+
+getList()
+</script>
+
+<style lang="scss" scoped>
+.settings-title {
+ margin-bottom: 16px;
+ font-size: 16px;
+ font-weight: 600;
+ color: #666666;
+}
+</style>
diff --git a/core/frontend/src/views/settings/index.vue b/core/frontend/src/views/settings/index.vue
index 575c2aa5..6d332de5 100644
--- a/core/frontend/src/views/settings/index.vue
+++ b/core/frontend/src/views/settings/index.vue
@@ -1,5 +1,11 @@
<template>
- <div>aaaaa</div>
+ <div class="py-16px px-24px">
+ <n-card :bordered="false">
+ <settings-service />
+ </n-card>
+ </div>
</template>
-<script lang="ts" setup></script>
+<script lang="ts" setup>
+import SettingsService from './components/SettingsService.vue'
+</script>
diff --git a/core/frontend/src/views/settings/types/common.ts b/core/frontend/src/views/settings/types/common.ts
new file mode 100644
index 00000000..e7edb9f9
--- /dev/null
+++ b/core/frontend/src/views/settings/types/common.ts
@@ -0,0 +1,6 @@
+export interface DockerService {
+ Id: string
+ Names: string[]
+ State: string
+ Status: string
+}
diff --git a/core/frontend/types/components.d.ts b/core/frontend/types/components.d.ts
index 5ec1f1f0..d2d95021 100644
--- a/core/frontend/types/components.d.ts
+++ b/core/frontend/types/components.d.ts
@@ -18,8 +18,10 @@ declare module 'vue' {
BtTableLayout: typeof import('./../src/components/bt-table-layout/index.vue')['default']
BtTablePage: typeof import('./../src/components/bt-table-page/index.vue')['default']
BtTablePassword: typeof import('./../src/components/bt-table-password/index.vue')['default']
+ BtTabs: typeof import('./../src/components/bt-tabs/index.vue')['default']
BtTips: typeof import('./../src/components/bt-tips/index.vue')['default']
MessageList: typeof import('./../src/components/bt-message/message-list.tsx')['default']
+ NAlert: typeof import('naive-ui')['NAlert']
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
@@ -44,6 +46,9 @@ declare module 'vue' {
NSelect: typeof import('naive-ui')['NSelect']
NSwitch: typeof import('naive-ui')['NSwitch']
NTable: typeof import('naive-ui')['NTable']
+ NTabPane: typeof import('naive-ui')['NTabPane']
+ NTabs: typeof import('naive-ui')['NTabs']
+ NTag: typeof import('naive-ui')['NTag']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}