chore: code format

This commit is contained in:
xiaojunnuo
2025-06-29 14:09:09 +08:00
parent 04422a4637
commit 4fcfd089d8
644 changed files with 10845 additions and 13184 deletions
@@ -11,7 +11,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
},
@@ -19,7 +19,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
},
@@ -27,7 +27,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
},
@@ -35,7 +35,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
},
@@ -43,7 +43,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
},
@@ -51,7 +51,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/simpleInfo",
method: "post",
params: { id }
params: { id },
});
},
@@ -59,7 +59,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/getSecretPlain",
method: "post",
data: { id, key }
data: { id, key },
});
},
@@ -67,7 +67,7 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/define",
method: "post",
params: { type }
params: { type },
});
},
@@ -75,8 +75,8 @@ export function createAccessApi(from = "user") {
return await request({
url: apiPrefix + "/defineByAccessType",
method: "post",
params: { type }
params: { type },
});
}
},
};
}
@@ -1,13 +1,13 @@
<template>
<fs-page>
<template #header>
<div class="title">
{{ t("certd.authorizationManagement") }}
<span class="sub">{{ t("certd.manageThirdPartyAuth") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
<fs-page>
<template #header>
<div class="title">
{{ t("certd.authorizationManagement") }}
<span class="sub">{{ t("certd.manageThirdPartyAuth") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
</template>
<script lang="ts">
@@ -17,27 +17,26 @@ import createCrudOptions from "./crud";
import { createAccessApi } from "/@/views/certd/access/api";
import { useI18n } from "vue-i18n";
export default defineComponent({
name: "AccessManager",
setup() {
const { t } = useI18n();
const api = createAccessApi("user");
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });
name: "AccessManager",
setup() {
const { t } = useI18n();
const api = createAccessApi("user");
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { api } });
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
});
onActivated(() => {
crudExpose.doRefresh();
});
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
});
onActivated(() => {
crudExpose.doRefresh();
});
return {
crudBinding,
crudRef,
t
};
},
return {
crudBinding,
crudRef,
t,
};
},
});
</script>
@@ -6,7 +6,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -14,7 +14,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -22,7 +22,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -30,7 +30,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -38,7 +38,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -46,7 +46,7 @@ export async function GetDetail(id: any) {
return await request({
url: apiPrefix + "/detail",
method: "post",
params: { id }
params: { id },
});
}
@@ -54,7 +54,7 @@ export async function DeleteBatch(ids: any[]) {
return await request({
url: apiPrefix + "/deleteByIds",
method: "post",
data: { ids }
data: { ids },
});
}
@@ -63,7 +63,7 @@ export async function DoVerify(id: number) {
url: apiPrefix + "/verify",
method: "post",
data: {
id
}
id,
},
});
}
@@ -8,272 +8,272 @@ import { useSettingStore } from "/@/store/settings";
import { message } from "ant-design-vue";
import CnameTip from "/@/components/plugins/cert/domains-verify-plan-editor/cname-tip.vue";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const dictRef = dict({
data: [
{ label: t('certd.pending_cname_setup'), value: "cname", color: "warning" },
{ label: t('certd.validating'), value: "validating", color: "blue" },
{ label: t('certd.validation_successful'), value: "valid", color: "green" },
{ label: t('certd.validation_failed'), value: "failed", color: "red" },
{ label: t('certd.validation_timed_out'), value: "timeout", color: "red" },
],
});
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
tabs: {
name: "status",
show: true,
},
rowHandle: {
minWidth: 200,
fixed: "right",
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 80,
},
form: {
show: false,
},
},
domain: {
title: t('certd.proxied_domain'),
type: "text",
search: {
show: true,
},
editForm: {
component: {
disabled: true,
},
},
},
hostRecord: {
title: t('certd.host_record'),
type: "text",
form: {
show: false,
},
column: {
width: 250,
cellRender: ({ value }) => {
return <fs-copyable v-model={value} />;
},
},
},
recordValue: {
title: t('certd.please_set_cname'),
type: "copyable",
form: {
show: false,
},
column: {
width: 500,
},
},
cnameProviderId: {
title: t('certd.cname_service'),
type: "dict-select",
dict: dict({
url: "/cname/provider/list",
value: "id",
label: "domain",
}),
form: {
component: {
onDictChange: ({ form, dict }: any) => {
if (!form.cnameProviderId) {
const list = dict.data.filter((item: any) => {
return !item.disabled;
});
let item = list.find((item: any) => item.isDefault);
if (!item && list.length > 0) {
item = list[0];
}
if (item) {
form.cnameProviderId = item.id;
}
}
},
renderLabel(item: any) {
if (item.title) {
return `${item.domain}<${item.title}>`;
} else {
return item.domain;
}
},
},
helper: {
render() {
const closeForm = () => {
crudExpose.getFormWrapperRef().close();
};
return (
<div>
{t('certd.default_public_cname')}
<router-link to={"/sys/cname/provider"} onClick={closeForm}>
{t('certd.customize_cname')}
</router-link>
</div>
);
},
},
},
column: {
width: 120,
align: "center",
cellRender({ value }) {
if (value < 0) {
return <a-tag color={"green"}>{t('certd.public_cname')}</a-tag>;
} else {
return <a-tag color={"blue"}>{t('certd.custom_cname')}</a-tag>;
}
},
},
},
status: {
title: t('certd.fields.status'),
type: "dict-select",
dict: dictRef,
addForm: {
show: false,
},
column: {
width: 120,
align: "center",
cellRender({ value, row }) {
return (
<div class={"flex flex-center"}>
<fs-values-format modelValue={value} dict={dictRef}></fs-values-format>
{row.error && (
<a-tooltip title={row.error}>
<fs-icon class={"ml-5 color-red"} icon="ion:warning-outline"></fs-icon>
</a-tooltip>
)}
</div>
);
},
},
},
triggerValidate: {
title: t('certd.validate'),
type: "text",
form: {
show: false,
},
column: {
conditionalRenderDisabled: true,
width: 130,
align: "center",
cellRender({ row, value }) {
if (row.status === "valid") {
return "-";
}
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const dictRef = dict({
data: [
{ label: t("certd.pending_cname_setup"), value: "cname", color: "warning" },
{ label: t("certd.validating"), value: "validating", color: "blue" },
{ label: t("certd.validation_successful"), value: "valid", color: "green" },
{ label: t("certd.validation_failed"), value: "failed", color: "red" },
{ label: t("certd.validation_timed_out"), value: "timeout", color: "red" },
],
});
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
tabs: {
name: "status",
show: true,
},
rowHandle: {
minWidth: 200,
fixed: "right",
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 80,
},
form: {
show: false,
},
},
domain: {
title: t("certd.proxied_domain"),
type: "text",
search: {
show: true,
},
editForm: {
component: {
disabled: true,
},
},
},
hostRecord: {
title: t("certd.host_record"),
type: "text",
form: {
show: false,
},
column: {
width: 250,
cellRender: ({ value }) => {
return <fs-copyable v-model={value} />;
},
},
},
recordValue: {
title: t("certd.please_set_cname"),
type: "copyable",
form: {
show: false,
},
column: {
width: 500,
},
},
cnameProviderId: {
title: t("certd.cname_service"),
type: "dict-select",
dict: dict({
url: "/cname/provider/list",
value: "id",
label: "domain",
}),
form: {
component: {
onDictChange: ({ form, dict }: any) => {
if (!form.cnameProviderId) {
const list = dict.data.filter((item: any) => {
return !item.disabled;
});
let item = list.find((item: any) => item.isDefault);
if (!item && list.length > 0) {
item = list[0];
}
if (item) {
form.cnameProviderId = item.id;
}
}
},
renderLabel(item: any) {
if (item.title) {
return `${item.domain}<${item.title}>`;
} else {
return item.domain;
}
},
},
helper: {
render() {
const closeForm = () => {
crudExpose.getFormWrapperRef().close();
};
return (
<div>
{t("certd.default_public_cname")}
<router-link to={"/sys/cname/provider"} onClick={closeForm}>
{t("certd.customize_cname")}
</router-link>
</div>
);
},
},
},
column: {
width: 120,
align: "center",
cellRender({ value }) {
if (value < 0) {
return <a-tag color={"green"}>{t("certd.public_cname")}</a-tag>;
} else {
return <a-tag color={"blue"}>{t("certd.custom_cname")}</a-tag>;
}
},
},
},
status: {
title: t("certd.fields.status"),
type: "dict-select",
dict: dictRef,
addForm: {
show: false,
},
column: {
width: 120,
align: "center",
cellRender({ value, row }) {
return (
<div class={"flex flex-center"}>
<fs-values-format modelValue={value} dict={dictRef}></fs-values-format>
{row.error && (
<a-tooltip title={row.error}>
<fs-icon class={"ml-5 color-red"} icon="ion:warning-outline"></fs-icon>
</a-tooltip>
)}
</div>
);
},
},
},
triggerValidate: {
title: t("certd.validate"),
type: "text",
form: {
show: false,
},
column: {
conditionalRenderDisabled: true,
width: 130,
align: "center",
cellRender({ row, value }) {
if (row.status === "valid") {
return "-";
}
async function doVerify() {
row._validating_ = true;
try {
const res = await api.DoVerify(row.id);
if (res === true) {
message.success(t('certd.validation_successful'));
row.status = "valid";
} else if (res === false) {
message.success(t('certd.validation_timed_out'));
row.status = "timeout";
} else {
message.success(t('certd.validation_started'));
}
await crudExpose.doRefresh();
} catch (e: any) {
console.error(e);
message.error(e.message);
} finally {
row._validating_ = false;
}
}
async function doVerify() {
row._validating_ = true;
try {
const res = await api.DoVerify(row.id);
if (res === true) {
message.success(t("certd.validation_successful"));
row.status = "valid";
} else if (res === false) {
message.success(t("certd.validation_timed_out"));
row.status = "timeout";
} else {
message.success(t("certd.validation_started"));
}
await crudExpose.doRefresh();
} catch (e: any) {
console.error(e);
message.error(e.message);
} finally {
row._validating_ = false;
}
}
return (
<div>
<a-button onClick={doVerify} loading={row._validating_} size={"small"} type={"primary"}>
{t('certd.click_to_validate')}
</a-button>
<CnameTip record={row} />
</div>
);
},
},
},
createTime: {
title: t('certd.create_time'),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t('certd.update_time'),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
return (
<div>
<a-button onClick={doVerify} loading={row._validating_} size={"small"} type={"primary"}>
{t("certd.click_to_validate")}
</a-button>
<CnameTip record={row} />
</div>
);
},
},
},
createTime: {
title: t("certd.create_time"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.update_time"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
}
@@ -1,26 +1,25 @@
<template>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t('certd.cnameRecord') }}
<span class="sub">
<a href="https://certd.docmirror.cn/guide/feature/cname/" target="_blank">
{{ t('certd.cname_feature_guide') }}
</a>
</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batch_delete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.cnameRecord") }}
<span class="sub">
<a href="https://certd.docmirror.cn/guide/feature/cname/" target="_blank">
{{ t("certd.cname_feature_guide") }}
</a>
</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batch_delete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
import { onActivated, onMounted } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -32,35 +31,34 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "CnameRecord",
name: "CnameRecord",
});
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
const selectedRowKeys = context.selectedRowKeys;
const handleBatchDelete = () => {
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t('certd.confirm'),
content: t('certd.confirm_delete_count', { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t('certd.delete_successful'));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t('certd.please_select_records'));
}
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.confirm_delete_count", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.delete_successful"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.please_select_records"));
}
};
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
await crudExpose.doRefresh();
});
</script>
<style lang="less"></style>
@@ -8,209 +8,209 @@ import { useSettingStore } from "/@/store/settings";
import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
actionbar: {
buttons: {
add: {
show: false,
},
},
},
search: {
formItem: {
labelCol: {
style: {
// width: "100px"
},
},
wrapperCol: {
style: {
width: "50%",
},
},
},
},
rowHandle: {
minWidth: 200,
fixed: "right",
buttons: {
edit: {
show: false,
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100,
},
form: {
show: false,
},
},
userId: {
title: t("certd.fields.userId"),
type: "number",
search: {
show: computed(() => {
return userStore.isAdmin && settingStore.sysPublic.managerOtherUserPipeline;
}),
},
form: {
show: false,
},
column: {
show: computed(() => {
return userStore.isAdmin && settingStore.sysPublic.managerOtherUserPipeline;
}),
width: 100,
},
},
pipelineId: {
title: t("certd.fields.pipelineId"),
type: "number",
search: {
show: true,
},
form: {
show: false,
},
column: {
width: 100,
},
},
pipelineTitle: {
title: t('certd.fields.pipelineName'),
type: "text",
search: {
show: true,
},
column: {
width: 300,
tooltip: true,
ellipsis: true,
cellRender: ({ row, value }) => {
return <router-link to={{ path: "/certd/pipeline/detail", query: { id: row.pipelineId, editMode: false, historyId: row.id } }}>{value}</router-link>;
},
},
},
triggerType: {
title: t("certd.fields.triggerType"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: [
{ value: "user", label: t("certd.triggerTypes.manual") },
{ value: "timer", label: t("certd.triggerTypes.timer") },
],
}),
form: {
show: false,
value: "custom",
},
column: {
sorter: true,
width: 90,
align: "center",
show: true,
component: {
color: "auto",
},
},
},
status: {
title: t("certd.fields.status"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: statusUtil.getOptions(),
}),
form: {
show: false,
},
column: {
sorter: true,
width: 120,
align: "center",
},
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.fields.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
actionbar: {
buttons: {
add: {
show: false,
},
},
},
search: {
formItem: {
labelCol: {
style: {
// width: "100px"
},
},
wrapperCol: {
style: {
width: "50%",
},
},
},
},
rowHandle: {
minWidth: 200,
fixed: "right",
buttons: {
edit: {
show: false,
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100,
},
form: {
show: false,
},
},
userId: {
title: t("certd.fields.userId"),
type: "number",
search: {
show: computed(() => {
return userStore.isAdmin && settingStore.sysPublic.managerOtherUserPipeline;
}),
},
form: {
show: false,
},
column: {
show: computed(() => {
return userStore.isAdmin && settingStore.sysPublic.managerOtherUserPipeline;
}),
width: 100,
},
},
pipelineId: {
title: t("certd.fields.pipelineId"),
type: "number",
search: {
show: true,
},
form: {
show: false,
},
column: {
width: 100,
},
},
pipelineTitle: {
title: t("certd.fields.pipelineName"),
type: "text",
search: {
show: true,
},
column: {
width: 300,
tooltip: true,
ellipsis: true,
cellRender: ({ row, value }) => {
return <router-link to={{ path: "/certd/pipeline/detail", query: { id: row.pipelineId, editMode: false, historyId: row.id } }}>{value}</router-link>;
},
},
},
triggerType: {
title: t("certd.fields.triggerType"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: [
{ value: "user", label: t("certd.triggerTypes.manual") },
{ value: "timer", label: t("certd.triggerTypes.timer") },
],
}),
form: {
show: false,
value: "custom",
},
column: {
sorter: true,
width: 90,
align: "center",
show: true,
component: {
color: "auto",
},
},
},
status: {
title: t("certd.fields.status"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
data: statusUtil.getOptions(),
}),
form: {
show: false,
},
column: {
sorter: true,
width: 120,
align: "center",
},
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.fields.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
}
@@ -13,7 +13,6 @@
</fs-page>
</template>
<script lang="ts" setup>
import { onActivated, onMounted } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -3,7 +3,7 @@ import { request } from "/src/api/service";
export async function getMineInfo() {
return await request({
url: "/mine/info",
method: "POST"
method: "POST",
});
}
@@ -11,6 +11,6 @@ export async function changePassword(form: any) {
return await request({
url: "/mine/changePassword",
method: "POST",
data: form
data: form,
});
}
@@ -1,7 +1,7 @@
<template>
<a-button v-if="showButton" type="primary" @click="open">
{{ $t("authentication.changePasswordButton") }}
</a-button>
<a-button v-if="showButton" type="primary" @click="open">
{{ $t("authentication.changePasswordButton") }}
</a-button>
</template>
<script setup lang="ts">
@@ -15,100 +15,100 @@ import { notification } from "ant-design-vue";
import { useUserStore } from "/@/store/user";
defineProps<{
showButton: boolean;
showButton: boolean;
}>();
let passwordFormRef = ref();
const validatePass1 = async (rule: any, value: any) => {
if (value === "") {
throw new Error(t("authentication.enterPassword"));
}
const formData = passwordFormRef.value.getFormData();
if (formData.confirmNewPassword !== "") {
passwordFormRef.value.formRef.formRef.validateFields(["confirmNewPassword"]);
}
if (formData.password === formData.newPassword) {
throw new Error(t("authentication.newPasswordNotSameOld"));
}
if (value === "") {
throw new Error(t("authentication.enterPassword"));
}
const formData = passwordFormRef.value.getFormData();
if (formData.confirmNewPassword !== "") {
passwordFormRef.value.formRef.formRef.validateFields(["confirmNewPassword"]);
}
if (formData.password === formData.newPassword) {
throw new Error(t("authentication.newPasswordNotSameOld"));
}
};
const validatePass2 = async (rule: any, value: any) => {
if (value === "") {
throw new Error(t("authentication.enterPasswordAgain"));
} else if (value !== passwordFormRef.value.getFormData().newPassword) {
throw new Error(t("authentication.passwordsNotMatch"));
}
if (value === "") {
throw new Error(t("authentication.enterPasswordAgain"));
} else if (value !== passwordFormRef.value.getFormData().newPassword) {
throw new Error(t("authentication.passwordsNotMatch"));
}
};
const userStore = useUserStore();
const { openDialog } = useFormWrapper();
const { buildFormOptions } = useColumns();
const passwordFormOptions: CrudOptions = {
form: {
col: {
span: 24,
},
wrapper: {
title: t("authentication.title"),
width: "500px",
},
async doSubmit({ form }) {
await api.changePassword(form);
//重新加载用户信息
await userStore.loadUserInfo();
},
async afterSubmit() {
notification.success({ message: t("authentication.successMessage") });
},
},
columns: {
password: {
title: t("authentication.oldPassword"),
type: "password",
form: {
rules: [{ required: true, message: t("authentication.oldPasswordRequired") }],
},
},
newPassword: {
title: t("authentication.newPassword"),
type: "password",
form: {
rules: [
{ required: true, message: t("authentication.newPasswordRequired") },
//@ts-ignore
{ validator: validatePass1, trigger: "blur" },
],
},
},
confirmNewPassword: {
title: t("authentication.confirmNewPassword"),
type: "password",
form: {
rules: [
{
required: true,
message: t("authentication.confirmNewPasswordRequired"),
},
//@ts-ignore
{ validator: validatePass2, trigger: "blur" },
],
},
},
},
form: {
col: {
span: 24,
},
wrapper: {
title: t("authentication.title"),
width: "500px",
},
async doSubmit({ form }) {
await api.changePassword(form);
//重新加载用户信息
await userStore.loadUserInfo();
},
async afterSubmit() {
notification.success({ message: t("authentication.successMessage") });
},
},
columns: {
password: {
title: t("authentication.oldPassword"),
type: "password",
form: {
rules: [{ required: true, message: t("authentication.oldPasswordRequired") }],
},
},
newPassword: {
title: t("authentication.newPassword"),
type: "password",
form: {
rules: [
{ required: true, message: t("authentication.newPasswordRequired") },
//@ts-ignore
{ validator: validatePass1, trigger: "blur" },
],
},
},
confirmNewPassword: {
title: t("authentication.confirmNewPassword"),
type: "password",
form: {
rules: [
{
required: true,
message: t("authentication.confirmNewPasswordRequired"),
},
//@ts-ignore
{ validator: validatePass2, trigger: "blur" },
],
},
},
},
};
async function open(opts: { password: "" }) {
const formOptions = buildFormOptions(passwordFormOptions);
formOptions.newInstance = true; //新实例打开
passwordFormRef.value = await openDialog(formOptions);
passwordFormRef.value.setFormData({
password: opts.password,
});
console.log(passwordFormRef.value);
const formOptions = buildFormOptions(passwordFormOptions);
formOptions.newInstance = true; //新实例打开
passwordFormRef.value = await openDialog(formOptions);
passwordFormRef.value.setFormData({
password: opts.password,
});
console.log(passwordFormRef.value);
}
const scope = ref({
open: open,
open: open,
});
defineExpose(scope.value);
@@ -1,82 +1,75 @@
<template>
<fs-page class="page-user-settings page-two-factor">
<template #header>
<div class="title">{{ t("certd.securitySettings") }}</div>
</template>
<fs-page class="page-user-settings page-two-factor">
<template #header>
<div class="title">{{ t("certd.securitySettings") }}</div>
</template>
<div class="user-settings-form settings-form">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off">
<a-form-item :label="t('certd.twoFactorAuth')" :name="['authenticator', 'enabled']">
<div class="flex mt-5">
<a-switch v-model:checked="formState.authenticator.enabled" :disabled="!settingsStore.isPlus"
@change="onAuthenticatorEnabledChanged" />
<div class="user-settings-form settings-form">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
<a-form-item :label="t('certd.twoFactorAuth')" :name="['authenticator', 'enabled']">
<div class="flex mt-5">
<a-switch v-model:checked="formState.authenticator.enabled" :disabled="!settingsStore.isPlus" @change="onAuthenticatorEnabledChanged" />
<a-button v-if="formState.authenticator.enabled && formState.authenticator.verified"
:disabled="authenticatorOpenRef || !settingsStore.isPlus" size="small" class="ml-5"
type="primary" @click="authenticatorForm.open = true">
{{ t('certd.rebind') }}
</a-button>
<a-button
v-if="formState.authenticator.enabled && formState.authenticator.verified"
:disabled="authenticatorOpenRef || !settingsStore.isPlus"
size="small"
class="ml-5"
type="primary"
@click="authenticatorForm.open = true"
>
{{ t("certd.rebind") }}
</a-button>
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t('certd.twoFactorAuthHelper') }}</div>
</a-form-item>
<div class="helper">{{ t("certd.twoFactorAuthHelper") }}</div>
</a-form-item>
<a-form-item v-if="authenticatorOpenRef" :label="t('certd.bindDevice')" class="authenticator-config">
<h3 class="font-bold m-5">{{ t('certd.step1') }}</h3>
<div class="ml-20">
<ul>
<li>
<a-tooltip :title="t('certd.tooltipGoogleServiceError')">
<a href="https://appgallery.huawei.com/app/C100262999" target="_blank">Microsoft
Authenticator</a>
</a-tooltip>
</li>
<li>
<a href="https://sj.qq.com/appdetail/com.tencent.authenticator"
target="_blank">腾讯身份验证器</a>
</li>
<li>
<a href="https://www.synology.cn/zh-cn/dsm/feature/authentication"
target="_blank">群晖身份验证器</a>
</li>
<li>
<a-tooltip :title="t('certd.tooltipGoogleServiceError')">
<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2"
target="_blank">Google Authenticator</a>
</a-tooltip>
</li>
<li>
<a href="https://play.google.com/store/apps/details?id=com.authy.authy"
target="_blank">Authy</a>
</li>
</ul>
</div>
<h3 class="font-bold m-10">{{ t('certd.step2') }}</h3>
<div v-if="authenticatorForm.qrcodeSrc" class="qrcode">
<div class="ml-20">
<img class="full-w" :src="authenticatorForm.qrcodeSrc" />
</div>
</div>
<h3 class="font-bold m-10">{{ t('certd.step3') }}</h3>
<div class="ml-20">
<a-input v-model:value="authenticatorForm.verifyCode"
:placeholder="t('certd.inputVerifyCode')" />
</div>
<div class="ml-20 flex mt-10">
<loading-button type="primary" html-type="button" :click="doAuthenticatorSave">{{
t('certd.confirm')
}}</loading-button>
<a-button class="ml-1" @click="authenticatorForm.open = false">{{ t('certd.cancel')
}}</a-button>
</div>
</a-form-item>
</a-form>
</div>
</fs-page>
<a-form-item v-if="authenticatorOpenRef" :label="t('certd.bindDevice')" class="authenticator-config">
<h3 class="font-bold m-5">{{ t("certd.step1") }}</h3>
<div class="ml-20">
<ul>
<li>
<a-tooltip :title="t('certd.tooltipGoogleServiceError')">
<a href="https://appgallery.huawei.com/app/C100262999" target="_blank">Microsoft Authenticator</a>
</a-tooltip>
</li>
<li>
<a href="https://sj.qq.com/appdetail/com.tencent.authenticator" target="_blank">腾讯身份验证器</a>
</li>
<li>
<a href="https://www.synology.cn/zh-cn/dsm/feature/authentication" target="_blank">群晖身份验证器</a>
</li>
<li>
<a-tooltip :title="t('certd.tooltipGoogleServiceError')">
<a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target="_blank">Google Authenticator</a>
</a-tooltip>
</li>
<li>
<a href="https://play.google.com/store/apps/details?id=com.authy.authy" target="_blank">Authy</a>
</li>
</ul>
</div>
<h3 class="font-bold m-10">{{ t("certd.step2") }}</h3>
<div v-if="authenticatorForm.qrcodeSrc" class="qrcode">
<div class="ml-20">
<img class="full-w" :src="authenticatorForm.qrcodeSrc" />
</div>
</div>
<h3 class="font-bold m-10">{{ t("certd.step3") }}</h3>
<div class="ml-20">
<a-input v-model:value="authenticatorForm.verifyCode" :placeholder="t('certd.inputVerifyCode')" />
</div>
<div class="ml-20 flex mt-10">
<loading-button type="primary" html-type="button" :click="doAuthenticatorSave">{{ t("certd.confirm") }}</loading-button>
<a-button class="ml-1" @click="authenticatorForm.open = false">{{ t("certd.cancel") }}</a-button>
</div>
</a-form-item>
</a-form>
</div>
</fs-page>
</template>
<script setup lang="tsx">
@@ -91,87 +84,85 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
const settingsStore = useSettingStore();
defineOptions({
name: "UserSecurity",
name: "UserSecurity",
});
const formState = reactive<Partial<UserTwoFactorSetting>>({
authenticator: {
enabled: false,
verified: false,
},
authenticator: {
enabled: false,
verified: false,
},
});
const authenticatorForm = reactive({
qrcodeSrc: "",
verifyCode: "",
open: false,
qrcodeSrc: "",
verifyCode: "",
open: false,
});
const authenticatorOpenRef = computed(() => {
return formState.authenticator.enabled && (authenticatorForm.open || !formState.authenticator.verified);
return formState.authenticator.enabled && (authenticatorForm.open || !formState.authenticator.verified);
});
watch(
() => {
return authenticatorOpenRef.value;
},
async open => {
if (open) {
//base64 转图片
authenticatorForm.qrcodeSrc = await api.TwoFactorAuthenticatorGet();
} else {
authenticatorForm.qrcodeSrc = "";
authenticatorForm.verifyCode = "";
}
}
() => {
return authenticatorOpenRef.value;
},
async open => {
if (open) {
//base64 转图片
authenticatorForm.qrcodeSrc = await api.TwoFactorAuthenticatorGet();
} else {
authenticatorForm.qrcodeSrc = "";
authenticatorForm.verifyCode = "";
}
}
);
async function loadUserSettings() {
const data: any = await api.TwoFactorSettingsGet();
merge(formState, data);
const data: any = await api.TwoFactorSettingsGet();
merge(formState, data);
}
loadUserSettings();
const doAuthenticatorSave = async (form: any) => {
await api.TwoFactorAuthenticatorSave({
verifyCode: authenticatorForm.verifyCode,
});
notification.success({
message: t("certd.saveSuccess"),
});
authenticatorForm.open = false;
formState.authenticator.verified = true;
await api.TwoFactorAuthenticatorSave({
verifyCode: authenticatorForm.verifyCode,
});
notification.success({
message: t("certd.saveSuccess"),
});
authenticatorForm.open = false;
formState.authenticator.verified = true;
};
function onAuthenticatorEnabledChanged(value: any) {
if (!value) {
//要关闭
if (formState.authenticator.verified) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.confirmDisable2FA"),
async onOk() {
await api.TwoFactorAuthenticatorOff();
notification.success({
message: t("certd.disabledSuccess"),
});
loadUserSettings();
},
onCancel() {
formState.authenticator.enabled = true;
},
});
}
}
if (!value) {
//要关闭
if (formState.authenticator.verified) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.confirmDisable2FA"),
async onOk() {
await api.TwoFactorAuthenticatorOff();
notification.success({
message: t("certd.disabledSuccess"),
});
loadUserSettings();
},
onCancel() {
formState.authenticator.enabled = true;
},
});
}
}
}
</script>
<style lang="less">
.page-user-settings {
.user-settings-form {
width: 600px;
margin: 20px;
}
.user-settings-form {
width: 600px;
margin: 20px;
}
}
</style>
@@ -1,34 +1,28 @@
<template>
<fs-page class="page-user-profile">
<template #header>
<div class="title">{{ t("certd.myInfo") }}</div>
</template>
<div class="p-10">
<a-descriptions title="" bordered :column="1">
<a-descriptions-item :label="t('authentication.username')">{{ userInfo.username }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.avatar')">
<a-avatar v-if="userInfo.avatar" size="large"
:src="'api/basic/file/download?&key=' + userInfo.avatar" style="background-color: #eee">
</a-avatar>
<a-avatar v-else size="large" style="background-color: #00b4f5">
{{ userInfo.username }}
</a-avatar>
</a-descriptions-item>
<a-descriptions-item :label="t('authentication.nickName')">{{ userInfo.nickName }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.email')">{{ userInfo.email }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.phoneNumber')">{{ userInfo.phoneCode }}{{ userInfo.mobile
}}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.changePassword')">
<change-password-button :show-button="true"> </change-password-button>
</a-descriptions-item>
</a-descriptions>
</div>
</fs-page>
<fs-page class="page-user-profile">
<template #header>
<div class="title">{{ t("certd.myInfo") }}</div>
</template>
<div class="p-10">
<a-descriptions title="" bordered :column="1">
<a-descriptions-item :label="t('authentication.username')">{{ userInfo.username }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.avatar')">
<a-avatar v-if="userInfo.avatar" size="large" :src="'api/basic/file/download?&key=' + userInfo.avatar" style="background-color: #eee"> </a-avatar>
<a-avatar v-else size="large" style="background-color: #00b4f5">
{{ userInfo.username }}
</a-avatar>
</a-descriptions-item>
<a-descriptions-item :label="t('authentication.nickName')">{{ userInfo.nickName }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.email')">{{ userInfo.email }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.phoneNumber')">{{ userInfo.phoneCode }}{{ userInfo.mobile }}</a-descriptions-item>
<a-descriptions-item :label="t('authentication.changePassword')">
<change-password-button :show-button="true"> </change-password-button>
</a-descriptions-item>
</a-descriptions>
</div>
</fs-page>
</template>
<script lang="ts" setup>
import * as api from "./api";
import { Ref, ref } from "vue";
@@ -38,13 +32,13 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "UserProfile"
name: "UserProfile",
});
const userInfo: Ref = ref({});
const getUserInfo = async () => {
userInfo.value = await api.getMineInfo();
userInfo.value = await api.getMineInfo();
};
getUserInfo();
</script>
@@ -11,288 +11,286 @@ import CertView from "/@/views/certd/pipeline/cert-view.vue";
import { useCertUpload } from "/@/views/certd/pipeline/cert-upload/use";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = certInfoApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const { t } = useI18n();
const api = certInfoApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const { openCrudFormDialog } = useFormWrapper();
const router = useRouter();
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const { openCrudFormDialog } = useFormWrapper();
const router = useRouter();
const model = useModal();
const viewCert = async (row: any) => {
const cert = await api.GetCert(row.id);
if (!cert) {
notification.error({ message: t("certd.certificateNotGenerated") });
return;
}
const model = useModal();
const viewCert = async (row: any) => {
const cert = await api.GetCert(row.id);
if (!cert) {
notification.error({ message: t("certd.certificateNotGenerated") });
return;
}
model.success({
title: t("certd.modal.viewCertificateTitle"),
maskClosable: true,
okText: t("certd.modal.close"),
width: 800,
content: () => {
return <CertView cert={cert}></CertView>;
},
});
};
model.success({
title: t("certd.modal.viewCertificateTitle"),
maskClosable: true,
okText: t("certd.modal.close"),
width: 800,
content: () => {
return <CertView cert={cert}></CertView>;
},
});
};
const { openUploadCreateDialog, openUpdateCertDialog } = useCertUpload();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
show: true,
buttons: {
add: {
text: t('certd.uploadCustomCert'),
type: "primary",
show: false,
async click() {
await openUploadCreateDialog();
},
},
},
},
tabs: {
name: "fromType",
show: true,
},
rowHandle: {
width: 100,
fixed: "right",
buttons: {
view: { show: false },
viewCert: {
order: 3,
title: t("certd.viewCert.title"),
type: "link",
icon: "ph:certificate",
async click({ row }) {
await viewCert(row);
},
},
copy: { show: false },
edit: { show: false },
remove: {
order: 10,
show: false,
},
download: {
order: 9,
title: t("certd.download.title"),
type: "link",
icon: "ant-design:download-outlined",
async click({ row }) {
if (!row.certFile) {
notification.error({ message: t("certd.certificateNotGenerated") });
return;
}
window.open("/api/monitor/cert/download?id=" + row.id);
},
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
fromType: {
title: t('certd.sourcee'),
search: {
show: true,
},
type: "dict-select",
dict: dict({
data: [
{ label: t('certd.sourcePipeline'), value: "pipeline" },
{ label: t('certd.sourceManualUpload'), value: "upload" },
],
}),
form: {
show: false,
},
column: {
width: 100,
sorter: true,
component: {
color: "auto",
},
conditionalRender: false,
},
valueBuilder({ value, row, key }) {
if (!value) {
row[key] = "pipeline";
}
},
},
domains: {
title: t('certd.domains'),
search: {
show: true,
},
type: "text",
form: {
rules: [{ required: true, message: t('certd.enterDomain') }],
},
column: {
width: 450,
sorter: true,
component: {
name: "fs-values-format",
color: "auto",
},
},
},
domainCount: {
title: t('certd.domainCount'),
type: "number",
form: {
show: false,
},
column: {
width: 120,
sorter: true,
show: false,
},
},
expiresLeft: {
title: t('certd.validDays'),
search: {
show: false,
},
type: "date",
form: {
show: false,
},
column: {
sorter: true,
conditionalRender: false,
cellRender({ row }) {
const value = row.expiresTime;
if (!value) {
return "-";
}
const expireDate = dayjs(value).format("YYYY-MM-DD");
const leftDays = dayjs(value).diff(dayjs(), "day");
const color = leftDays < 20 ? "red" : "#389e0d";
const percent = (leftDays / 90) * 100;
return <a-progress title={expireDate + t('certd.expires')} percent={percent} strokeColor={color} format={(percent: number) => `${leftDays}${t('certd.days')}`} />;
},
},
},
expiresTime: {
title: t('certd.expireTime'),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
},
},
certProvider: {
title: t('certd.certIssuer'),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
},
},
applyTime: {
title: t('certd.applyTime'),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
},
},
"pipeline.title": {
title: t('certd.relatedPipeline'),
search: { show: false },
type: "link",
form: {
show: false,
},
column: {
width: 350,
sorter: true,
component: {
on: {
onClick({ row }) {
router.push({ path: "/certd/pipeline/detail", query: { id: row.pipelineId, editMode: "false" } });
},
},
},
},
},
},
},
};
const { openUploadCreateDialog, openUpdateCertDialog } = useCertUpload();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
show: true,
buttons: {
add: {
text: t("certd.uploadCustomCert"),
type: "primary",
show: false,
async click() {
await openUploadCreateDialog({});
},
},
},
},
tabs: {
name: "fromType",
show: true,
},
rowHandle: {
width: 100,
fixed: "right",
buttons: {
view: { show: false },
viewCert: {
order: 3,
title: t("certd.viewCert.title"),
type: "link",
icon: "ph:certificate",
async click({ row }) {
await viewCert(row);
},
},
copy: { show: false },
edit: { show: false },
remove: {
order: 10,
show: false,
},
download: {
order: 9,
title: t("certd.download.title"),
type: "link",
icon: "ant-design:download-outlined",
async click({ row }) {
if (!row.certFile) {
notification.error({ message: t("certd.certificateNotGenerated") });
return;
}
window.open("/api/monitor/cert/download?id=" + row.id);
},
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
fromType: {
title: t("certd.sourcee"),
search: {
show: true,
},
type: "dict-select",
dict: dict({
data: [
{ label: t("certd.sourcePipeline"), value: "pipeline" },
{ label: t("certd.sourceManualUpload"), value: "upload" },
],
}),
form: {
show: false,
},
column: {
width: 100,
sorter: true,
component: {
color: "auto",
},
conditionalRender: false,
},
valueBuilder({ value, row, key }) {
if (!value) {
row[key] = "pipeline";
}
},
},
domains: {
title: t("certd.domains"),
search: {
show: true,
},
type: "text",
form: {
rules: [{ required: true, message: t("certd.enterDomain") }],
},
column: {
width: 450,
sorter: true,
component: {
name: "fs-values-format",
color: "auto",
},
},
},
domainCount: {
title: t("certd.domainCount"),
type: "number",
form: {
show: false,
},
column: {
width: 120,
sorter: true,
show: false,
},
},
expiresLeft: {
title: t("certd.validDays"),
search: {
show: false,
},
type: "date",
form: {
show: false,
},
column: {
sorter: true,
conditionalRender: false,
cellRender({ row }) {
const value = row.expiresTime;
if (!value) {
return "-";
}
const expireDate = dayjs(value).format("YYYY-MM-DD");
const leftDays = dayjs(value).diff(dayjs(), "day");
const color = leftDays < 20 ? "red" : "#389e0d";
const percent = (leftDays / 90) * 100;
return <a-progress title={expireDate + t("certd.expires")} percent={percent} strokeColor={color} format={(percent: number) => `${leftDays}${t("certd.days")}`} />;
},
},
},
expiresTime: {
title: t("certd.expireTime"),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
},
},
certProvider: {
title: t("certd.certIssuer"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
},
},
applyTime: {
title: t("certd.applyTime"),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
},
},
"pipeline.title": {
title: t("certd.relatedPipeline"),
search: { show: false },
type: "link",
form: {
show: false,
},
column: {
width: 350,
sorter: true,
component: {
on: {
onClick({ row }) {
router.push({ path: "/certd/pipeline/detail", query: { id: row.pipelineId, editMode: "false" } });
},
},
},
},
},
},
},
};
}
@@ -1,13 +1,13 @@
<template>
<fs-page>
<template #header>
<div class="title">
{{ t("certd.certificateRepo.title") }}
<span class="sub">{{ t("certd.certificateRepo.sub") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
<fs-page>
<template #header>
<div class="title">
{{ t("certd.certificateRepo.title") }}
<span class="sub">{{ t("certd.certificateRepo.sub") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
@@ -19,15 +19,15 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "CertStore",
name: "CertStore",
});
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
onActivated(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
</script>
File diff suppressed because it is too large Load Diff
@@ -1,28 +1,27 @@
<template>
<fs-page>
<template #header>
<div class="title flex items-center">
{{ t("certd.monitor.title") }}
<div class="sub flex-1">
<div>
{{ t("certd.monitor.description") }}
<router-link to="/certd/monitor/setting">{{ t("certd.monitor.settingLink") }}</router-link>
</div>
<div class="flex items-center">
{{ t("certd.monitor.limitInfo") }}
<vip-button class="ml-5" mode="nav"></vip-button>
</div>
</div>
</div>
<div class="more">
<a-button type="primary" @click="checkAll">{{ t("certd.monitor.checkAll") }}</a-button>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
<fs-page>
<template #header>
<div class="title flex items-center">
{{ t("certd.monitor.title") }}
<div class="sub flex-1">
<div>
{{ t("certd.monitor.description") }}
<router-link to="/certd/monitor/setting">{{ t("certd.monitor.settingLink") }}</router-link>
</div>
<div class="flex items-center">
{{ t("certd.monitor.limitInfo") }}
<vip-button class="ml-5" mode="nav"></vip-button>
</div>
</div>
</div>
<div class="more">
<a-button type="primary" @click="checkAll">{{ t("certd.monitor.checkAll") }}</a-button>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
import { onActivated, onMounted } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -33,29 +32,28 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "SiteCertMonitor",
name: "SiteCertMonitor",
});
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: {} });
function checkAll() {
Modal.confirm({
title: t("certd.monitor.confirmTitle"), // "确认"
content: t("certd.monitor.confirmContent"), // "确认触发检查全部站点证书吗?"
onOk: async () => {
await siteInfoApi.CheckAll();
notification.success({
message: t("certd.monitor.checkSubmitted"), // "检查任务已提交"
description: t("certd.monitor.pleaseRefresh"), // "请稍后刷新页面查看结果"
});
},
});
Modal.confirm({
title: t("certd.monitor.confirmTitle"), // "确认"
content: t("certd.monitor.confirmContent"), // "确认触发检查全部站点证书吗?"
onOk: async () => {
await siteInfoApi.CheckAll();
notification.success({
message: t("certd.monitor.checkSubmitted"), // "检查任务已提交"
description: t("certd.monitor.pleaseRefresh"), // "请稍后刷新页面查看结果"
});
},
});
}
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
onActivated(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
</script>
@@ -7,354 +7,354 @@ import { Modal, notification } from "ant-design-vue";
import { useSiteIpMonitor } from "/@/views/certd/monitor/site/ip/use";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = siteIpApi;
const { t } = useI18n();
const api = siteIpApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
if (!query.query) {
query.query = {};
}
query.query.siteId = context.props.siteId;
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
if (!query.query) {
query.query = {};
}
query.query.siteId = context.props.siteId;
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
form.siteId = context.props.siteId;
const res = await api.AddObj(form);
return res;
};
const addRequest = async (req: AddReq) => {
const { form } = req;
form.siteId = context.props.siteId;
const res = await api.AddObj(form);
return res;
};
const checkStatusDict = dict({
data: [
{ label: t("certd.statusSuccess"), value: "ok", color: "green" },
{ label: t("certd.statusChecking"), value: "checking", color: "blue" },
{ label: t("certd.statusError"), value: "error", color: "red" },
],
});
const { openSiteIpImportDialog } = useSiteIpMonitor();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: {
async click() {
await crudExpose.openAdd({});
},
},
import: {
show: true,
text: t("certd.actionImportBatch"),
type: "primary",
async click() {
openSiteIpImportDialog({
siteId: context.props.siteId,
afterSubmit() {
crudExpose.doRefresh();
},
});
},
},
load: {
text: t("certd.actionSyncIp"),
type: "primary",
async click() {
Modal.confirm({
title: t("certd.modalTitleSyncIp"),
content: t("certd.modalContentSyncIp"),
onOk: async () => {
await api.DoSync(context.props.siteId);
await crudExpose.doRefresh();
notification.success({
message: t("certd.notificationSyncComplete"),
});
},
});
},
},
checkAll: {
text: t("certd.actionCheckAll"),
type: "primary",
click: () => {
Modal.confirm({
title: t("certd.modalTitleConfirm"),
content: t("certd.modalContentCheckAll"),
onOk: async () => {
await siteIpApi.CheckAll(context.props.siteId);
notification.success({
message: t("certd.notificationCheckSubmitted"),
description: t("certd.notificationCheckDescription"),
});
},
});
},
},
},
},
rowHandle: {
fixed: "right",
width: 240,
buttons: {
check: {
order: 0,
type: "link",
text: null,
tooltip: {
title: t("certd.tooltipCheckNow"),
},
icon: "ion:play-sharp",
click: async ({ row }) => {
await api.DoCheck(row.id);
await crudExpose.doRefresh();
notification.success({
message: t("certd.notificationCheckSubmittedPleaseRefresh"),
});
},
},
},
},
columns: {
id: {
title: t("certd.columnId"),
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 80,
align: "center",
},
form: {
show: false,
},
},
ipAddress: {
title: t("certd.columnIp"),
search: {
show: true,
},
type: "text",
helper: t("certd.helperIpCname"),
form: {
rules: [{ required: true, message: t("certd.ruleIpRequired") }],
},
column: {
width: 160,
},
},
certDomains: {
title: t("certd.columnCertDomains"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
sorter: true,
show: false,
cellRender({ value }) {
return (
<a-tooltip title={value} placement="left">
{value}
</a-tooltip>
);
},
},
},
certProvider: {
title: t("certd.columnCertProvider"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
show: false,
sorter: true,
cellRender({ value }) {
return <a-tooltip title={value}>{value}</a-tooltip>;
},
},
},
certStatus: {
title: t("certd.columnCertStatus"),
search: {
show: true,
},
type: "dict-select",
dict: dict({
data: [
{ label: t("certd.statusNormal"), value: "ok", color: "green" },
{ label: t("certd.statusExpired"), value: "expired", color: "red" },
],
}),
form: {
show: false,
},
column: {
width: 100,
sorter: true,
show: true,
align: "center",
},
},
certExpiresTime: {
title: t("certd.columnCertExpiresTime"),
search: {
show: false,
},
type: "date",
form: {
show: false,
},
column: {
sorter: true,
cellRender({ value }) {
if (!value) {
return "-";
}
const expireDate = dayjs(value).format("YYYY-MM-DD");
const leftDays = dayjs(value).diff(dayjs(), "day");
const color = leftDays < 20 ? "red" : "#389e0d";
const percent = (leftDays / 90) * 100;
return <a-progress title={expireDate + " " + t("certd.expired")} percent={percent} strokeColor={color} format={(percent: number) => `${leftDays} ${t("certd.days")}`} />;
},
},
},
checkStatus: {
title: t("certd.columnCheckStatus"),
search: {
show: false,
},
type: "dict-select",
dict: checkStatusDict,
form: {
show: false,
},
column: {
width: 100,
align: "center",
sorter: true,
cellRender({ value, row, key }) {
return (
<a-tooltip title={row.error}>
<fs-values-format v-model={value} dict={checkStatusDict}></fs-values-format>
</a-tooltip>
);
},
},
},
lastCheckTime: {
title: t("certd.columnLastCheckTime"),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 155,
},
},
from: {
title: t("certd.columnSource"),
search: {
show: false,
},
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.sourceSync"), value: "sync", color: "green" },
{ label: t("certd.sourceManual"), value: "manual", color: "blue" },
{ label: t("certd.sourceImport"), value: "import", color: "blue" },
],
}),
form: {
value: false,
},
column: {
width: 100,
sorter: true,
align: "center",
},
},
disabled: {
title: t("certd.columnDisabled"),
search: {
show: false,
},
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: false, color: "green" },
{ label: t("certd.disabled"), value: true, color: "red" },
],
}),
form: {
value: false,
},
column: {
width: 100,
sorter: true,
align: "center",
},
},
remark: {
title: t("certd.columnRemark"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
sorter: true,
tooltip: true,
},
},
},
},
};
const checkStatusDict = dict({
data: [
{ label: t("certd.statusSuccess"), value: "ok", color: "green" },
{ label: t("certd.statusChecking"), value: "checking", color: "blue" },
{ label: t("certd.statusError"), value: "error", color: "red" },
],
});
const { openSiteIpImportDialog } = useSiteIpMonitor();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: {
async click() {
await crudExpose.openAdd({});
},
},
import: {
show: true,
text: t("certd.actionImportBatch"),
type: "primary",
async click() {
openSiteIpImportDialog({
siteId: context.props.siteId,
afterSubmit() {
crudExpose.doRefresh();
},
});
},
},
load: {
text: t("certd.actionSyncIp"),
type: "primary",
async click() {
Modal.confirm({
title: t("certd.modalTitleSyncIp"),
content: t("certd.modalContentSyncIp"),
onOk: async () => {
await api.DoSync(context.props.siteId);
await crudExpose.doRefresh();
notification.success({
message: t("certd.notificationSyncComplete"),
});
},
});
},
},
checkAll: {
text: t("certd.actionCheckAll"),
type: "primary",
click: () => {
Modal.confirm({
title: t("certd.modalTitleConfirm"),
content: t("certd.modalContentCheckAll"),
onOk: async () => {
await siteIpApi.CheckAll(context.props.siteId);
notification.success({
message: t("certd.notificationCheckSubmitted"),
description: t("certd.notificationCheckDescription"),
});
},
});
},
},
},
},
rowHandle: {
fixed: "right",
width: 240,
buttons: {
check: {
order: 0,
type: "link",
text: null,
tooltip: {
title: t("certd.tooltipCheckNow"),
},
icon: "ion:play-sharp",
click: async ({ row }) => {
await api.DoCheck(row.id);
await crudExpose.doRefresh();
notification.success({
message: t("certd.notificationCheckSubmittedPleaseRefresh"),
});
},
},
},
},
columns: {
id: {
title: t("certd.columnId"),
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 80,
align: "center",
},
form: {
show: false,
},
},
ipAddress: {
title: t("certd.columnIp"),
search: {
show: true,
},
type: "text",
helper: t("certd.helperIpCname"),
form: {
rules: [{ required: true, message: t("certd.ruleIpRequired") }],
},
column: {
width: 160,
},
},
certDomains: {
title: t("certd.columnCertDomains"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
sorter: true,
show: false,
cellRender({ value }) {
return (
<a-tooltip title={value} placement="left">
{value}
</a-tooltip>
);
},
},
},
certProvider: {
title: t("certd.columnCertProvider"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
show: false,
sorter: true,
cellRender({ value }) {
return <a-tooltip title={value}>{value}</a-tooltip>;
},
},
},
certStatus: {
title: t("certd.columnCertStatus"),
search: {
show: true,
},
type: "dict-select",
dict: dict({
data: [
{ label: t("certd.statusNormal"), value: "ok", color: "green" },
{ label: t("certd.statusExpired"), value: "expired", color: "red" },
],
}),
form: {
show: false,
},
column: {
width: 100,
sorter: true,
show: true,
align: "center",
},
},
certExpiresTime: {
title: t("certd.columnCertExpiresTime"),
search: {
show: false,
},
type: "date",
form: {
show: false,
},
column: {
sorter: true,
cellRender({ value }) {
if (!value) {
return "-";
}
const expireDate = dayjs(value).format("YYYY-MM-DD");
const leftDays = dayjs(value).diff(dayjs(), "day");
const color = leftDays < 20 ? "red" : "#389e0d";
const percent = (leftDays / 90) * 100;
return <a-progress title={expireDate + " " + t("certd.expired")} percent={percent} strokeColor={color} format={(percent: number) => `${leftDays} ${t("certd.days")}`} />;
},
},
},
checkStatus: {
title: t("certd.columnCheckStatus"),
search: {
show: false,
},
type: "dict-select",
dict: checkStatusDict,
form: {
show: false,
},
column: {
width: 100,
align: "center",
sorter: true,
cellRender({ value, row, key }) {
return (
<a-tooltip title={row.error}>
<fs-values-format v-model={value} dict={checkStatusDict}></fs-values-format>
</a-tooltip>
);
},
},
},
lastCheckTime: {
title: t("certd.columnLastCheckTime"),
search: {
show: false,
},
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 155,
},
},
from: {
title: t("certd.columnSource"),
search: {
show: false,
},
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.sourceSync"), value: "sync", color: "green" },
{ label: t("certd.sourceManual"), value: "manual", color: "blue" },
{ label: t("certd.sourceImport"), value: "import", color: "blue" },
],
}),
form: {
value: false,
},
column: {
width: 100,
sorter: true,
align: "center",
},
},
disabled: {
title: t("certd.columnDisabled"),
search: {
show: false,
},
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: false, color: "green" },
{ label: t("certd.disabled"), value: true, color: "red" },
],
}),
form: {
value: false,
},
column: {
width: 100,
sorter: true,
align: "center",
},
},
remark: {
title: t("certd.columnRemark"),
search: {
show: false,
},
type: "text",
form: {
show: false,
},
column: {
width: 200,
sorter: true,
tooltip: true,
},
},
},
},
};
}
@@ -1,41 +1,37 @@
<template>
<fs-page class="page-user-settings page-site-monitor-setting">
<template #header>
<div class="title">{{ t("certd.siteMonitorSettings") }}</div>
</template>
<div class="user-settings-form settings-form">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off">
<a-form-item :label="t('certd.notificationChannel')" :name="['notificationId']">
<div class="flex">
<NotificationSelector v-model="formState.notificationId" />
</div>
<div class="helper">{{ t('certd.setNotificationChannel') }}</div>
</a-form-item>
<a-form-item :label="t('certd.retryTimes')" :name="['retryTimes']">
<div class="flex">
<a-input-number v-model:value="formState.retryTimes" />
</div>
<div class="helper">{{ t('certd.monitorRetryTimes') }}</div>
</a-form-item>
<a-form-item :label="t('certd.monitorCronSetting')" :name="['cron']">
<div class="flex flex-baseline">
<cron-editor v-model="formState.cron" :disabled="!settingsStore.isPlus"
:allow-every-min="userStore.isAdmin" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t('certd.cronTrigger') }}</div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<loading-button type="primary" html-type="button" :click="doSave">{{ t('certd.save')
}}</loading-button>
</a-form-item>
</a-form>
</div>
</fs-page>
<fs-page class="page-user-settings page-site-monitor-setting">
<template #header>
<div class="title">{{ t("certd.siteMonitorSettings") }}</div>
</template>
<div class="user-settings-form settings-form">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
<a-form-item :label="t('certd.notificationChannel')" :name="['notificationId']">
<div class="flex">
<NotificationSelector v-model="formState.notificationId" />
</div>
<div class="helper">{{ t("certd.setNotificationChannel") }}</div>
</a-form-item>
<a-form-item :label="t('certd.retryTimes')" :name="['retryTimes']">
<div class="flex">
<a-input-number v-model:value="formState.retryTimes" />
</div>
<div class="helper">{{ t("certd.monitorRetryTimes") }}</div>
</a-form-item>
<a-form-item :label="t('certd.monitorCronSetting')" :name="['cron']">
<div class="flex flex-baseline">
<cron-editor v-model="formState.cron" :disabled="!settingsStore.isPlus" :allow-every-min="userStore.isAdmin" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t("certd.cronTrigger") }}</div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<loading-button type="primary" html-type="button" :click="doSave">{{ t("certd.save") }}</loading-button>
</a-form-item>
</a-form>
</div>
</fs-page>
</template>
<script setup lang="tsx">
import { reactive } from "vue";
import * as api from "./api";
@@ -52,34 +48,34 @@ const { t } = useI18n();
const settingsStore = useSettingStore();
const userStore = useUserStore();
defineOptions({
name: "UserSecurity",
name: "UserSecurity",
});
const formState = reactive<Partial<UserSiteMonitorSetting>>({
notificationId: 0,
notificationId: 0,
});
async function loadUserSettings() {
const data: any = await api.SiteMonitorSettingsGet();
merge(formState, data);
const data: any = await api.SiteMonitorSettingsGet();
merge(formState, data);
}
loadUserSettings();
const doSave = async (form: any) => {
await api.SiteMonitorSettingsSave({
...formState,
});
notification.success({
message: t("certd.saveSuccess"),
});
await api.SiteMonitorSettingsSave({
...formState,
});
notification.success({
message: t("certd.saveSuccess"),
});
};
</script>
<style lang="less">
.page-user-settings {
.user-settings-form {
width: 700px;
margin: 20px;
}
.user-settings-form {
width: 700px;
margin: 20px;
}
}
</style>
@@ -3,42 +3,42 @@ import { siteInfoApi } from "./api";
import { useI18n } from "vue-i18n";
export function useSiteImport() {
const { t } = useI18n();
const { openCrudFormDialog } = useFormWrapper();
const { t } = useI18n();
const { openCrudFormDialog } = useFormWrapper();
async function openSiteImportDialog(opts: { afterSubmit: any }) {
const { afterSubmit } = opts;
await openCrudFormDialog<any>({
crudOptions: {
columns: {
text: {
type: "textarea",
title: t("certd.domainList.title"), // 域名列表
form: {
helper: t("certd.domainList.helper"),
rules: [{ required: true, message: t("certd.domainList.required") }],
component: {
placeholder: t("certd.domainList.placeholder"),
rows: 8,
},
col: {
span: 24,
},
},
},
},
async function openSiteImportDialog(opts: { afterSubmit: any }) {
const { afterSubmit } = opts;
await openCrudFormDialog<any>({
crudOptions: {
columns: {
text: {
type: "textarea",
title: t("certd.domainList.title"), // 域名列表
form: {
helper: t("certd.domainList.helper"),
rules: [{ required: true, message: t("certd.domainList.required") }],
component: {
placeholder: t("certd.domainList.placeholder"),
rows: 8,
},
col: {
span: 24,
},
},
},
},
form: {
async doSubmit({ form }) {
return siteInfoApi.Import(form);
},
afterSubmit,
},
},
});
}
form: {
async doSubmit({ form }) {
return siteInfoApi.Import(form);
},
afterSubmit,
},
},
});
}
return {
openSiteImportDialog,
};
return {
openSiteImportDialog,
};
}
@@ -8,238 +8,238 @@ import { mitter } from "/@/utils/util.mitt";
import { useI18n } from "vue-i18n";
export function notificationProvide(api: any) {
provide("notificationApi", api);
provide("get:plugin:type", () => {
return "notification";
});
provide("notificationApi", api);
provide("get:plugin:type", () => {
return "notification";
});
}
export function getCommonColumnDefine(crudExpose: any, typeRef: any, api: any) {
const { t } = useI18n();
const { t } = useI18n();
const notificationTypeDictRef = dict({
url: "/pi/notification/getTypeDict",
});
const defaultPluginConfig = {
component: {
name: "a-input",
vModel: "value",
},
};
const notificationTypeDictRef = dict({
url: "/pi/notification/getTypeDict",
});
const defaultPluginConfig = {
component: {
name: "a-input",
vModel: "value",
},
};
function buildDefineFields(define: any, form: any, mode: string) {
const formWrapperRef = crudExpose.getFormWrapperRef();
const columnsRef = toRef(formWrapperRef.formOptions, "columns");
function buildDefineFields(define: any, form: any, mode: string) {
const formWrapperRef = crudExpose.getFormWrapperRef();
const columnsRef = toRef(formWrapperRef.formOptions, "columns");
for (const key in columnsRef.value) {
if (key.indexOf(".") >= 0) {
delete columnsRef.value[key];
}
}
console.log('crudBinding.value[mode + "Form"].columns', columnsRef.value);
forEach(define.input, (value: any, mapKey: any) => {
const key = "body." + mapKey;
const field = {
...value,
key,
};
const column = merge({ title: key }, defaultPluginConfig, field);
//eval
useReference(column);
for (const key in columnsRef.value) {
if (key.indexOf(".") >= 0) {
delete columnsRef.value[key];
}
}
console.log('crudBinding.value[mode + "Form"].columns', columnsRef.value);
forEach(define.input, (value: any, mapKey: any) => {
const key = "body." + mapKey;
const field = {
...value,
key,
};
const column = merge({ title: key }, defaultPluginConfig, field);
//eval
useReference(column);
if (column.required) {
if (!column.rules) {
column.rules = [];
}
column.rules.push({ required: true, message: t("certd.requiredField") });
}
if (column.required) {
if (!column.rules) {
column.rules = [];
}
column.rules.push({ required: true, message: t("certd.requiredField") });
}
//设置默认值
if (column.value != null && get(form, key) == null) {
set(form, key, column.value);
}
//字段配置赋值
columnsRef.value[key] = column;
console.log("form", columnsRef.value, form);
});
}
//设置默认值
if (column.value != null && get(form, key) == null) {
set(form, key, column.value);
}
//字段配置赋值
columnsRef.value[key] = column;
console.log("form", columnsRef.value, form);
});
}
const currentDefine = ref();
const currentDefine = ref();
return {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100,
},
form: {
show: false,
},
},
type: {
title: t("certd.notificationType"),
type: "dict-select",
dict: notificationTypeDictRef,
search: {
show: false,
},
column: {
width: 200,
component: {
color: "auto",
},
},
editForm: {
component: {
disabled: false,
},
},
form: {
component: {
disabled: false,
showSearch: true,
filterOption: (input: string, option: any) => {
input = input?.toLowerCase();
return option.value.toLowerCase().indexOf(input) >= 0 || option.label.toLowerCase().indexOf(input) >= 0;
},
renderLabel(item: any) {
return (
<span class={"flex-o flex-between"}>
{item.label}
{item.needPlus && <fs-icon icon={"mingcute:vip-1-line"} className={"color-plus"}></fs-icon>}
</span>
);
},
},
rules: [{ required: true, message: t("certd.selectNotificationType") }],
valueChange: {
immediate: true,
async handle({ value, mode, form, immediate }) {
if (value == null) {
return;
}
const lastTitle = currentDefine.value?.title;
const define = await api.GetProviderDefine(value);
currentDefine.value = define;
console.log("define", define);
return {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100,
},
form: {
show: false,
},
},
type: {
title: t("certd.notificationType"),
type: "dict-select",
dict: notificationTypeDictRef,
search: {
show: false,
},
column: {
width: 200,
component: {
color: "auto",
},
},
editForm: {
component: {
disabled: false,
},
},
form: {
component: {
disabled: false,
showSearch: true,
filterOption: (input: string, option: any) => {
input = input?.toLowerCase();
return option.value.toLowerCase().indexOf(input) >= 0 || option.label.toLowerCase().indexOf(input) >= 0;
},
renderLabel(item: any) {
return (
<span class={"flex-o flex-between"}>
{item.label}
{item.needPlus && <fs-icon icon={"mingcute:vip-1-line"} className={"color-plus"}></fs-icon>}
</span>
);
},
},
rules: [{ required: true, message: t("certd.selectNotificationType") }],
valueChange: {
immediate: true,
async handle({ value, mode, form, immediate }) {
if (value == null) {
return;
}
const lastTitle = currentDefine.value?.title;
const define = await api.GetProviderDefine(value);
currentDefine.value = define;
console.log("define", define);
if (!immediate) {
form.body = {};
if (define.needPlus) {
mitter.emit("openVipModal");
}
}
if (!immediate) {
form.body = {};
if (define.needPlus) {
mitter.emit("openVipModal");
}
}
if (!form.name || form.name === lastTitle) {
form.name = define.title;
}
buildDefineFields(define, form, mode);
},
},
helper: computed(() => {
const define = currentDefine.value;
if (define == null) {
return "";
}
return define.desc;
}),
},
} as ColumnCompositionProps,
name: {
title: t("certd.notificationName"),
search: {
show: true,
},
type: ["text"],
form: {
rules: [{ required: true, message: t("certd.enterName") }],
helper: t("certd.helperNotificationName"),
},
column: {
width: 200,
},
},
isDefault: {
title: t("certd.isDefault"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.yes"), value: true, color: "success" },
{ label: t("certd.no"), value: false, color: "default" },
],
}),
form: {
value: false,
rules: [{ required: true, message: t("certd.selectIsDefault") }],
order: 999,
},
column: {
align: "center",
width: 100,
component: {
name: "a-switch",
vModel: "checked",
disabled: compute(({ value }) => {
return value === true;
}),
on: {
change({ row }) {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmSetDefaultNotification"),
onOk: async () => {
await api.SetDefault(row.id);
await crudExpose.doRefresh();
},
onCancel: async () => {
await crudExpose.doRefresh();
},
});
},
},
},
},
} as ColumnCompositionProps,
test: {
title: t("certd.test"),
form: {
show: compute(({ form }) => {
return !!form.type;
}),
component: {
name: "api-test",
action: "TestRequest",
},
order: 990,
col: {
span: 24,
},
},
column: {
show: false,
},
},
setting: {
column: { show: false },
form: {
show: false,
valueBuilder({ value, form }) {
form.body = {};
if (!value) {
return;
}
const setting = JSON.parse(value);
for (const key in setting) {
form.body[key] = setting[key];
}
},
valueResolve({ form }) {
const setting = form.body;
form.setting = JSON.stringify(setting);
},
},
} as ColumnCompositionProps,
};
if (!form.name || form.name === lastTitle) {
form.name = define.title;
}
buildDefineFields(define, form, mode);
},
},
helper: computed(() => {
const define = currentDefine.value;
if (define == null) {
return "";
}
return define.desc;
}),
},
} as ColumnCompositionProps,
name: {
title: t("certd.notificationName"),
search: {
show: true,
},
type: ["text"],
form: {
rules: [{ required: true, message: t("certd.enterName") }],
helper: t("certd.helperNotificationName"),
},
column: {
width: 200,
},
},
isDefault: {
title: t("certd.isDefault"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.yes"), value: true, color: "success" },
{ label: t("certd.no"), value: false, color: "default" },
],
}),
form: {
value: false,
rules: [{ required: true, message: t("certd.selectIsDefault") }],
order: 999,
},
column: {
align: "center",
width: 100,
component: {
name: "a-switch",
vModel: "checked",
disabled: compute(({ value }) => {
return value === true;
}),
on: {
change({ row }) {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmSetDefaultNotification"),
onOk: async () => {
await api.SetDefault(row.id);
await crudExpose.doRefresh();
},
onCancel: async () => {
await crudExpose.doRefresh();
},
});
},
},
},
},
} as ColumnCompositionProps,
test: {
title: t("certd.test"),
form: {
show: compute(({ form }) => {
return !!form.type;
}),
component: {
name: "api-test",
action: "TestRequest",
},
order: 990,
col: {
span: 24,
},
},
column: {
show: false,
},
},
setting: {
column: { show: false },
form: {
show: false,
valueBuilder({ value, form }) {
form.body = {};
if (!value) {
return;
}
const setting = JSON.parse(value);
for (const key in setting) {
form.body[key] = setting[key];
}
},
valueResolve({ form }) {
const setting = form.body;
form.setting = JSON.stringify(setting);
},
},
} as ColumnCompositionProps,
};
}
@@ -1,26 +1,36 @@
<template>
<div class="notification-selector">
<div class="flex-o w-100">
<fs-dict-select class="flex-1" :value="modelValue" :dict="optionsDictRef" :disabled="disabled"
:render-label="renderLabel" :slots="selectSlots" :allow-clear="true" v-bind="select"
@update:value="onChange" />
<fs-table-select ref="tableSelectRef" class="flex-0" :model-value="modelValue" :dict="optionsDictRef"
:create-crud-options="createCrudOptions" :crud-options-override="{
search: { show: false },
table: {
scroll: {
x: 540,
},
},
}" :show-current="false" :show-select="false" :dialog="{ width: 960 }" :destroy-on-close="false" height="400px"
v-bind="tableSelect" @update:model-value="onChange" @dialog-closed="doRefresh">
<template #default="scope">
<fs-button class="ml-5" :disabled="disabled" :size="size" type="primary"
icon="ant-design:edit-outlined" @click="scope.open"></fs-button>
</template>
</fs-table-select>
</div>
</div>
<div class="notification-selector">
<div class="flex-o w-100">
<fs-dict-select class="flex-1" :value="modelValue" :dict="optionsDictRef" :disabled="disabled" :render-label="renderLabel" :slots="selectSlots" :allow-clear="true" v-bind="select" @update:value="onChange" />
<fs-table-select
ref="tableSelectRef"
class="flex-0"
:model-value="modelValue"
:dict="optionsDictRef"
:create-crud-options="createCrudOptions"
:crud-options-override="{
search: { show: false },
table: {
scroll: {
x: 540,
},
},
}"
:show-current="false"
:show-select="false"
:dialog="{ width: 960 }"
:destroy-on-close="false"
height="400px"
v-bind="tableSelect"
@update:model-value="onChange"
@dialog-closed="doRefresh"
>
<template #default="scope">
<fs-button class="ml-5" :disabled="disabled" :size="size" type="primary" icon="ant-design:edit-outlined" @click="scope.open"></fs-button>
</template>
</fs-table-select>
</div>
</div>
</template>
<script lang="tsx" setup>
@@ -36,21 +46,21 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "NotificationSelector",
name: "NotificationSelector",
});
const props = defineProps<{
modelValue?: number | string | number[] | string[];
type?: string;
placeholder?: string;
size?: string;
disabled?: boolean;
select?: any;
tableSelect?: any;
modelValue?: number | string | number[] | string[];
type?: string;
placeholder?: string;
size?: string;
disabled?: boolean;
select?: any;
tableSelect?: any;
}>();
const onChange = async (value: number) => {
await emitValue(value);
await emitValue(value);
};
const emit = defineEmits(["update:modelValue", "selectedChange", "change"]);
@@ -69,90 +79,90 @@ notificationProvide(api);
// loadNotificationTypes();
const tableSelectRef = ref();
const optionsDictRef = dict({
url: "/pi/notification/options",
value: "id",
label: "name",
onReady: ({ dict }) => {
const data = [
{
id: 0,
name: t("certd.notificationDefault"),
icon: "ion:notifications",
},
...dict.data,
];
dict.setData(data);
},
url: "/pi/notification/options",
value: "id",
label: "name",
onReady: ({ dict }) => {
const data = [
{
id: 0,
name: t("certd.notificationDefault"),
icon: "ion:notifications",
},
...dict.data,
];
dict.setData(data);
},
});
const renderLabel = (option: any) => {
return <span>{option.name}</span>;
return <span>{option.name}</span>;
};
async function openTableSelectDialog() {
selectOpened.value = false;
await tableSelectRef.value.open({});
await tableSelectRef.value.crudExpose.openAdd({});
selectOpened.value = false;
await tableSelectRef.value.open({});
await tableSelectRef.value.crudExpose.openAdd({});
}
const selectOpened = ref(false);
const selectSlots = ref({
dropdownRender({ menuNode, props }: any) {
const res = [];
res.push(menuNode);
// res.push(<a-divider style="margin: 4px 0" />);
// res.push(<a-space style="padding: 4px 8px" />);
// res.push(<fs-button class="w-100" type="text" icon="plus-outlined" text="新建通知渠道" onClick={openTableSelectDialog}></fs-button>);
return res;
},
dropdownRender({ menuNode, props }: any) {
const res = [];
res.push(menuNode);
// res.push(<a-divider style="margin: 4px 0" />);
// res.push(<a-space style="padding: 4px 8px" />);
// res.push(<fs-button class="w-100" type="text" icon="plus-outlined" text="新建通知渠道" onClick={openTableSelectDialog}></fs-button>);
return res;
},
});
const target: Ref<any> = ref({});
function clear() {
if (props.disabled) {
return;
}
emitValue(null);
if (props.disabled) {
return;
}
emitValue(null);
}
const userStore = useUserStore();
async function emitValue(value: any) {
// target.value = optionsDictRef.dataMap[value];
const userId = userStore.userInfo.id;
if (pipeline?.value && pipeline.value.userId !== userId) {
message.error("对不起,您不能修改他人流水线的通知");
return;
}
emit("change", value);
emit("update:modelValue", value);
// target.value = optionsDictRef.dataMap[value];
const userId = userStore.userInfo.id;
if (pipeline?.value && pipeline.value.userId !== userId) {
message.error("对不起,您不能修改他人流水线的通知");
return;
}
emit("change", value);
emit("update:modelValue", value);
}
watch(
() => {
return props.modelValue;
},
async value => {
await optionsDictRef.loadDict();
//@ts-ignore
target.value = optionsDictRef.dataMap[value];
emit("selectedChange", target.value);
},
{
immediate: true,
}
() => {
return props.modelValue;
},
async value => {
await optionsDictRef.loadDict();
//@ts-ignore
target.value = optionsDictRef.dataMap[value];
emit("selectedChange", target.value);
},
{
immediate: true,
}
);
//当不在pipeline中编辑时,可能为空
const pipeline = inject("pipeline", null);
async function doRefresh() {
await optionsDictRef.reloadDict();
await optionsDictRef.reloadDict();
}
</script>
<style lang="less">
.notification-selector {
width: 100%;
width: 100%;
}
</style>
@@ -47,46 +47,46 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
pageRequest,
addRequest,
editRequest,
delRequest
delRequest,
},
toolbar: {
show: false
show: false,
},
search: {
show: false
show: false,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "145px"
}
}
width: "145px",
},
},
},
rowHandle: {
width: 200
width: 200,
},
table: {
scroll: {
x: 700
x: 700,
},
rowSelection: {
type: "radio",
selectedRowKeys: selectedRowKey,
onChange: onSelectChange
onChange: onSelectChange,
},
customRow: (record: any) => {
return {
onClick: () => {
onSelectChange([record.id]);
} // 点击行
}, // 点击行
};
}
},
},
columns: {
...commonColumnsDefine
}
}
...commonColumnsDefine,
},
},
};
}
@@ -13,7 +13,7 @@ import { createNotificationApi } from "../../api";
export default defineComponent({
name: "CertNotificationModal",
props: {
modelValue: {}
modelValue: {},
},
emits: ["update:modelValue"],
setup(props, ctx) {
@@ -26,9 +26,9 @@ export default defineComponent({
return {
crudBinding,
crudRef
crudRef,
};
}
},
});
</script>
<style lang="less">
@@ -8,7 +8,7 @@ export const openkeyApi = {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
},
@@ -16,7 +16,7 @@ export const openkeyApi = {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
},
@@ -24,7 +24,7 @@ export const openkeyApi = {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
},
@@ -32,7 +32,7 @@ export const openkeyApi = {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
},
@@ -40,14 +40,14 @@ export const openkeyApi = {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
},
async GetApiToken(id: number) {
return await request({
url: apiPrefix + "/getApiToken",
method: "post",
data: { id }
data: { id },
});
}
},
};
@@ -5,182 +5,181 @@ import { OPEN_API_DOC, openkeyApi } from "./api";
import { useModal } from "/@/use/use-modal";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = openkeyApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const { t } = useI18n();
const api = openkeyApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const model = useModal();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
search: {
show: false,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: {
text: t("certd.actionbar.add"),
},
},
},
rowHandle: {
width: 300,
fixed: "right",
buttons: {
view: { show: true },
copy: { show: false },
edit: { show: false },
remove: { show: true },
gen: {
text: t("certd.gen.text"),
size: "mini",
icon: "devicon-plain:vitest",
type: "primary",
async click({ row }) {
const apiToken = await api.GetApiToken(row.id);
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const model = useModal();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
search: {
show: false,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: {
text: t("certd.actionbar.add"),
},
},
},
rowHandle: {
width: 300,
fixed: "right",
buttons: {
view: { show: true },
copy: { show: false },
edit: { show: false },
remove: { show: true },
gen: {
text: t("certd.gen.text"),
size: "mini",
icon: "devicon-plain:vitest",
type: "primary",
async click({ row }) {
const apiToken = await api.GetApiToken(row.id);
model.success({
title: t("certd.gen.title"),
maskClosable: true,
okText: t("certd.gen.okText"),
width: 600,
content: () => {
return (
<div>
<div class={"m-10 p-10"}>
{t("certd.gen.contentPart1")}
<a href={OPEN_API_DOC} target={"_blank"}>
{t("certd.gen.openApi")}
</a>
{t("certd.gen.contentPart2")}
</div>
<div class={"m-10 p-10"} style={{ border: "1px solid #333" }}>
<fs-copyable model-value={apiToken}></fs-copyable>
</div>
</div>
);
},
});
},
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
keyId: {
title: "KeyId",
type: ["text", "copyable"],
search: {
show: true,
},
form: {
show: false,
},
column: {
width: 250,
sorter: true,
},
},
keySecret: {
title: "KeySecret",
type: ["text", "copyable"],
form: {
show: false,
},
column: {
width: 580,
sorter: true,
},
},
scope: {
title: t("certd.scope"),
type: "dict-radio",
dict: dict({
data: [
{ label: t("certd.scopeOpenApiOnly"), value: "open", color: "blue" },
{ label: t("certd.scopeFullAccount"), value: "user", color: "red" },
],
}),
form: {
value: "open",
show: true,
rules: [{ required: true, message: t("certd.required") }],
helper: t("certd.scopeHelper"),
component: {
vModel: "value",
},
},
column: {
width: 120,
align: "center",
sorter: true,
},
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
search: {
show: false,
},
form: {
show: false,
},
},
},
},
};
model.success({
title: t("certd.gen.title"),
maskClosable: true,
okText: t("certd.gen.okText"),
width: 600,
content: () => {
return (
<div>
<div class={"m-10 p-10"}>
{t("certd.gen.contentPart1")}
<a href={OPEN_API_DOC} target={"_blank"}>
{t("certd.gen.openApi")}
</a>
{t("certd.gen.contentPart2")}
</div>
<div class={"m-10 p-10"} style={{ border: "1px solid #333" }}>
<fs-copyable model-value={apiToken}></fs-copyable>
</div>
</div>
);
},
});
},
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
keyId: {
title: "KeyId",
type: ["text", "copyable"],
search: {
show: true,
},
form: {
show: false,
},
column: {
width: 250,
sorter: true,
},
},
keySecret: {
title: "KeySecret",
type: ["text", "copyable"],
form: {
show: false,
},
column: {
width: 580,
sorter: true,
},
},
scope: {
title: t("certd.scope"),
type: "dict-radio",
dict: dict({
data: [
{ label: t("certd.scopeOpenApiOnly"), value: "open", color: "blue" },
{ label: t("certd.scopeFullAccount"), value: "user", color: "red" },
],
}),
form: {
value: "open",
show: true,
rules: [{ required: true, message: t("certd.required") }],
helper: t("certd.scopeHelper"),
component: {
vModel: "value",
},
},
column: {
width: 120,
align: "center",
sorter: true,
},
},
createTime: {
title: t("certd.fields.createTime"),
type: "datetime",
search: {
show: false,
},
form: {
show: false,
},
},
},
},
};
}
@@ -7,7 +7,7 @@ export async function GetList(query: any) {
const list = await request({
url: apiPrefix + "/list",
method: "post",
data: query
data: query,
});
for (const item of list) {
if (item.pipeline && typeof item.pipeline === "string") {
@@ -21,7 +21,7 @@ export async function GetDetail(query: any): Promise<RunHistory> {
const detail = await request({
url: apiPrefix + "/detail",
method: "post",
params: query
params: query,
});
const pipeline = JSON.parse(detail.history?.pipeline || "{}");
@@ -29,6 +29,6 @@ export async function GetDetail(query: any): Promise<RunHistory> {
return {
id: detail.history.id,
pipeline,
logs
logs,
} as RunHistory;
}
@@ -32,7 +32,7 @@ const props = defineProps<{
const certFiles = ref([
{ name: "证书", fileName: "fullchain.pem", key: "crt", content: props.cert.crt },
{ name: "私钥", fileName: "private.pem", key: "key", content: props.cert.key },
{ name: "中间证书", fileName: "chain.pem", key: "ic", content: props.cert.ic }
{ name: "中间证书", fileName: "chain.pem", key: "ic", content: props.cert.ic },
]);
</script>
@@ -1,9 +1,7 @@
<template>
<fs-button icon="mdi:format-list-group" type="link" :text="t('certd.editSchedule')"
@click="openFormDialog"></fs-button>
<fs-button icon="mdi:format-list-group" type="link" :text="t('certd.editSchedule')" @click="openFormDialog"></fs-button>
</template>
<script setup lang="ts">
import * as api from "../api";
import { useFormWrapper } from "@fast-crud/fast-crud";
@@ -12,59 +10,57 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
const props = defineProps<{
selectedRowKeys: any[];
selectedRowKeys: any[];
}>();
const emit = defineEmits<{
change: any;
change: any;
}>();
async function batchUpdateRequest(form: any) {
await api.BatchUpdateTrigger(props.selectedRowKeys, {
title: "定时触发",
type: "timer",
props: form.props,
});
emit("change");
await api.BatchUpdateTrigger(props.selectedRowKeys, {
title: "定时触发",
type: "timer",
props: form.props,
});
emit("change");
}
const { openCrudFormDialog } = useFormWrapper();
async function openFormDialog() {
const crudOptions: any = {
columns: {
"props.cron": {
title: t("certd.schedule"),
form: {
component: {
name: "cron-editor",
vModel: "modelValue",
},
rules: [{ required: true, message: t("certd.selectCron") }],
},
},
},
form: {
mode: "edit",
//@ts-ignore
async doSubmit({ form }) {
await batchUpdateRequest(form);
},
col: {
span: 22,
},
labelCol: {
style: {
width: "100px",
},
},
wrapper: {
title: t("certd.batchEditSchedule"),
width: 600,
},
},
} as any;
await openCrudFormDialog({ crudOptions });
const crudOptions: any = {
columns: {
"props.cron": {
title: t("certd.schedule"),
form: {
component: {
name: "cron-editor",
vModel: "modelValue",
},
rules: [{ required: true, message: t("certd.selectCron") }],
},
},
},
form: {
mode: "edit",
//@ts-ignore
async doSubmit({ form }) {
await batchUpdateRequest(form);
},
col: {
span: 22,
},
labelCol: {
style: {
width: "100px",
},
},
wrapper: {
title: t("certd.batchEditSchedule"),
width: 600,
},
},
} as any;
await openCrudFormDialog({ crudOptions });
}
</script>
@@ -7,7 +7,7 @@ export function createApi() {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
},
@@ -15,7 +15,7 @@ export function createApi() {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
},
@@ -23,7 +23,7 @@ export function createApi() {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
},
@@ -31,7 +31,7 @@ export function createApi() {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
},
@@ -39,15 +39,15 @@ export function createApi() {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
},
async ListAll() {
return await request({
url: apiPrefix + "/all",
method: "post"
method: "post",
});
}
},
};
}
@@ -5,131 +5,131 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi
import { pipelineGroupApi } from "./api";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = pipelineGroupApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const { t } = useI18n();
const api = pipelineGroupApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
return {
crudOptions: {
settings: {
plugins: {
mobile: {
props: {
rowHandle: {
width: 160,
},
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
rowHandle: {
width: 200,
group: {
editable: {
edit: {
text: t('certd.edit'),
order: -1,
type: "primary",
click({ row, index }) {
crudExpose.openEdit({
index,
row,
});
},
},
},
},
},
table: {
editable: {
enabled: true,
mode: "cell",
exclusive: true,
//排他式激活效果,将其他行的编辑状态触发保存
exclusiveEffect: "save", //自动保存其他行编辑状态,cancel = 自动关闭其他行编辑状态
async updateCell(opts) {
const { row, key, value } = opts;
//如果是添加,需要返回{[rowKey]:xxx},比如:{id:2}
return await api.UpdateObj({ id: row.id, [key]: value });
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: true,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
name: {
title: t('certd.groupName'),
search: {
show: true,
},
type: "text",
form: {
rules: [
{
required: true,
message: t('certd.enterGroupName'),
},
],
},
column: {
width: 400,
},
}
},
},
};
return {
crudOptions: {
settings: {
plugins: {
mobile: {
props: {
rowHandle: {
width: 160,
},
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
rowHandle: {
width: 200,
group: {
editable: {
edit: {
text: t("certd.edit"),
order: -1,
type: "primary",
click({ row, index }) {
crudExpose.openEdit({
index,
row,
});
},
},
},
},
},
table: {
editable: {
enabled: true,
mode: "cell",
exclusive: true,
//排他式激活效果,将其他行的编辑状态触发保存
exclusiveEffect: "save", //自动保存其他行编辑状态,cancel = 自动关闭其他行编辑状态
async updateCell(opts) {
const { row, key, value } = opts;
//如果是添加,需要返回{[rowKey]:xxx},比如:{id:2}
return await api.UpdateObj({ id: row.id, [key]: value });
},
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: true,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
name: {
title: t("certd.groupName"),
search: {
show: true,
},
type: "text",
form: {
rules: [
{
required: true,
message: t("certd.enterGroupName"),
},
],
},
column: {
width: 400,
},
},
},
},
};
}
@@ -26,22 +26,22 @@ export default defineComponent({
type: Object,
default() {
return {};
}
},
},
historyId: {
type: Number
type: Number,
},
type: {
type: String,
default: "icon"
default: "icon",
},
isCurrent: {
type: Boolean
type: Boolean,
},
editMode: {
type: Boolean,
default: false
}
default: false,
},
},
emits: ["view", "cancel"],
setup(props: any, ctx: any) {
@@ -64,18 +64,18 @@ export default defineComponent({
onOk: async () => {
await api.Cancel(props.historyId);
notification.success({
message: "任务取消成功"
message: "任务取消成功",
});
}
},
});
}
return {
status,
cancel,
view,
cancelTask
cancelTask,
};
}
},
});
</script>
<style lang="less">
@@ -1,23 +1,25 @@
<template>
<div>
<fs-form-item v-model="optionsFormState.receivers" :item="{
title: t('certd.email.title'),
key: 'type',
component: {
name: 'a-select',
vModel: 'value',
mode: 'tags',
open: false
},
helper: t('certd.email.helper'),
rules: [{ required: true, message: t('certd.email.required') }]
}" />
<div>
<fs-form-item
v-model="optionsFormState.receivers"
:item="{
title: t('certd.email.title'),
key: 'type',
component: {
name: 'a-select',
vModel: 'value',
mode: 'tags',
open: false,
},
helper: t('certd.email.helper'),
rules: [{ required: true, message: t('certd.email.required') }],
}"
/>
<a-alert v-if="!settingStore.isPlus" class="m-1" type="info">
<template #message> 还没有配置邮件服务器<router-link :to="{ path: '/sys/settings/email' }">现在就去</router-link>
</template>
</a-alert>
</div>
<a-alert v-if="!settingStore.isPlus" class="m-1" type="info">
<template #message> 还没有配置邮件服务器<router-link :to="{ path: '/sys/settings/email' }">现在就去</router-link> </template>
</a-alert>
</div>
</template>
<script lang="ts" setup>
import { Ref, ref, watch } from "vue";
@@ -28,10 +30,10 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
const props = defineProps({
options: {
type: Object as PropType<any>,
default: () => { }
}
options: {
type: Object as PropType<any>,
default: () => {},
},
});
const settingStore = useSettingStore();
@@ -39,30 +41,30 @@ const settingStore = useSettingStore();
const optionsFormState: Ref<any> = ref({});
watch(
() => {
return props.options;
},
() => {
optionsFormState.value = {
...props.options
};
},
{
immediate: true
}
() => {
return props.options;
},
() => {
optionsFormState.value = {
...props.options,
};
},
{
immediate: true,
}
);
const emit = defineEmits(["change"]);
function doEmit() {
emit("change", { ...optionsFormState.value });
emit("change", { ...optionsFormState.value });
}
function getValue() {
return { ...optionsFormState.value };
return { ...optionsFormState.value };
}
defineExpose({
doEmit,
getValue
doEmit,
getValue,
});
</script>
@@ -18,12 +18,12 @@ export default defineComponent({
props: {
status: {
type: [String, Number],
default: ""
default: "",
},
type: {
type: String,
default: "icon"
}
default: "icon",
},
},
setup(props, ctx) {
const statusRef = computed(() => {
@@ -31,9 +31,9 @@ export default defineComponent({
});
return {
statusRef
statusRef,
};
}
},
});
</script>
<style lang="less">
@@ -17,19 +17,19 @@ const StatusEnum: StatusEnumType = {
label: "成功",
color: "green",
spin: false,
icon: "ant-design:check-circle-outlined"
icon: "ant-design:check-circle-outlined",
},
error: {
value: "error",
label: "错误",
color: "red",
icon: "ant-design:info-circle-outlined"
icon: "ant-design:info-circle-outlined",
},
skip: {
value: "skip",
label: "跳过",
color: "blue",
icon: "fluent:arrow-step-over-20-filled"
icon: "fluent:arrow-step-over-20-filled",
},
start: {
value: "start",
@@ -37,33 +37,33 @@ const StatusEnum: StatusEnumType = {
color: "blue",
spin: true,
iconSpin: true,
icon: "ant-design:sync-outlined"
icon: "ant-design:sync-outlined",
},
canceled: {
value: "canceled",
label: "已取消",
color: "yellow",
iconColor: "#d4b106",
icon: "ant-design:minus-circle-twotone"
icon: "ant-design:minus-circle-twotone",
},
none: {
value: "none",
label: "未运行",
color: "blue",
icon: "ant-design:minus-circle-twotone"
icon: "ant-design:minus-circle-twotone",
},
disabled: {
value: "disabled",
label: "禁用",
color: "gray",
icon: "ant-design:stop-outlined"
icon: "ant-design:stop-outlined",
},
no_deploy_count: {
value: "no_deploy_count",
label: "次数不足",
color: "gray",
icon: "ant-design:stop-outlined"
}
icon: "ant-design:stop-outlined",
},
};
export const statusUtil = {
getColor(status = "none") {
@@ -79,5 +79,5 @@ export const statusUtil = {
options.push(StatusEnum[key]);
}
return options;
}
},
};
@@ -4,136 +4,136 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi
import { useI18n } from "vue-i18n";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
// tabs: {
// name: "status",
// show: true,
// },
rowHandle: {
minWidth: 200,
fixed: "right",
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 80,
},
form: {
show: false,
},
},
domain: {
title: t('certd.subdomainHosted'),
type: "text",
search: {
show: true,
},
form: {
helper: {
render() {
return (
<div>
{t('certd.subdomainHelpText')}
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
{t('certd.subdomainManagement')}
</a>
</div>
);
},
},
},
editForm: {
component: {
disabled: true,
},
},
},
disabled: {
title: t('certd.isDisabled'),
type: "dict-switch",
dict: dict({
data: [
{ value: false, label: t('certd.enabled'), color: "green" },
{ value: true, label: t('certd.disabled'), color: "gray" },
],
}),
search: {
show: true,
},
form: {
value: false,
},
},
createTime: {
title: t('certd.createTime'),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t('certd.updateTime'),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
// tabs: {
// name: "status",
// show: true,
// },
rowHandle: {
minWidth: 200,
fixed: "right",
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 80,
},
form: {
show: false,
},
},
domain: {
title: t("certd.subdomainHosted"),
type: "text",
search: {
show: true,
},
form: {
helper: {
render() {
return (
<div>
{t("certd.subdomainHelpText")}
<a href={"https://help.aliyun.com/zh/dns/subdomain-management"} target={"_blank"}>
{t("certd.subdomainManagement")}
</a>
</div>
);
},
},
},
editForm: {
component: {
disabled: true,
},
},
},
disabled: {
title: t("certd.isDisabled"),
type: "dict-switch",
dict: dict({
data: [
{ value: false, label: t("certd.enabled"), color: "green" },
{ value: true, label: t("certd.disabled"), color: "gray" },
],
}),
search: {
show: true,
},
form: {
value: false,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
},
},
},
},
};
}
@@ -1,19 +1,19 @@
<template>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t('certd.subdomainHosting') }}
<span class="sub">{{ t('certd.subdomainHostingHint') }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batchDelete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.subdomainHosting") }}
<span class="sub">{{ t("certd.subdomainHostingHint") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batchDelete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
@@ -27,35 +27,34 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "CnameRecord",
name: "CnameRecord",
});
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
const selectedRowKeys = context.selectedRowKeys;
const handleBatchDelete = () => {
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t('certd.confirm'),
content: t('certd.batchDeleteConfirm', { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t('certd.deleteSuccess'));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t('certd.selectRecordFirst'));
}
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.batchDeleteConfirm", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.deleteSuccess"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.selectRecordFirst"));
}
};
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
await crudExpose.doRefresh();
});
</script>
<style lang="less"></style>
@@ -16,8 +16,8 @@ export const durationDict = dict({
{ label: "8年", value: 2920 },
{ label: "9年", value: 3285 },
{ label: "10年", value: 3650 },
{ label: "永久", value: -1 }
]
{ label: "永久", value: -1 },
],
});
export type OrderModalOpenReq = {
@@ -29,7 +29,7 @@ export type OrderModalOpenReq = {
export async function ProductList() {
return await request({
url: "/suite/product/list",
method: "POST"
method: "POST",
});
}
@@ -37,7 +37,7 @@ export async function ProductInfo(productId: number) {
return await request({
url: "/suite/product/info",
method: "POST",
data: { id: productId }
data: { id: productId },
});
}
@@ -52,7 +52,7 @@ export async function TradeCreate(form: TradeCreateReq) {
return await request({
url: "/suite/trade/create",
method: "POST",
data: form
data: form,
});
}
@@ -60,20 +60,20 @@ export async function TradeCreateFree(form: TradeCreateReq) {
return await request({
url: "/suite/trade/createFree",
method: "POST",
data: form
data: form,
});
}
export async function GetPaymentTypes() {
return await request({
url: "/suite/trade/payments",
method: "POST"
method: "POST",
});
}
export async function GetSuiteSetting() {
return await request({
url: "/suite/settings/get",
method: "POST"
method: "POST",
});
}
@@ -21,7 +21,7 @@ export const mySuiteApi = {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
},
@@ -29,7 +29,7 @@ export const mySuiteApi = {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
},
@@ -37,7 +37,7 @@ export const mySuiteApi = {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
},
@@ -45,7 +45,7 @@ export const mySuiteApi = {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
},
@@ -53,19 +53,19 @@ export const mySuiteApi = {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
},
async ListAll() {
return await request({
url: apiPrefix + "/all",
method: "post"
method: "post",
});
},
async SuiteDetailGet() {
return await request({
url: `${apiPrefix}/detail`,
method: "post"
method: "post",
});
}
},
};
@@ -7,310 +7,310 @@ import DurationValue from "/@/views/sys/suite/product/duration-value.vue";
import UserSuiteStatus from "/@/views/certd/suite/mine/user-suite-status.vue";
import dayjs from "dayjs";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.AddObj(form);
return res;
};
const router = useRouter();
const router = useRouter();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px"
}
},
col: {
span: 22
},
wrapper: {
width: 600
}
},
actionbar: {
buttons: {
add: { show: false },
buy: {
text: "购买",
type: "primary",
click() {
router.push({
path: "/certd/suite/buy"
});
}
}
}
},
rowHandle: {
width: 200,
fixed: "right",
buttons: {
view: { show: false },
copy: { show: false },
edit: { show: false },
remove: { show: false }
// continue:{
// text:"续期",
// type:"link",
// click(){
// console.log("续期");
// }
// }
}
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false
},
column: {
width: 100,
editable: {
disabled: true
}
},
form: {
show: false
}
},
title: {
title: "套餐名称",
type: "text",
search: {
show: true
},
form: {
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 200
}
},
productType: {
title: "类型",
type: "dict-select",
editForm: {
component: {
disabled: true
}
},
dict: dict({
data: [
{ label: "套餐", value: "suite", color: "green" },
{ label: "加量包", value: "addon", color: "blue" }
]
}),
form: {
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 80,
align: "center"
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
}
},
"content.maxDomainCount": {
title: "域名数量",
type: "text",
form: {
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "个"
},
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "个"
},
align: "center"
}
},
"content.maxPipelineCount": {
title: "流水线数量",
type: "text",
form: {
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "条"
},
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "条"
},
align: "center"
}
},
"content.maxDeployCount": {
title: "部署次数",
type: "text",
form: {
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "次"
},
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "次",
used: compute(({ row }) => {
return row.deployCountUsed;
})
},
align: "center"
}
},
"content.maxMonitorCount": {
title: "证书监控数量",
type: "text",
form: {
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "个"
},
rules: [{ required: true, message: "此项必填" }]
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "个"
},
align: "center"
}
},
duration: {
title: "时长",
type: "text",
form: {},
column: {
component: {
name: DurationValue,
vModel: "modelValue"
},
width: 100,
align: "center"
}
},
status: {
title: "状态",
type: "text",
form: { show: false },
column: {
width: 100,
align: "center",
component: {
name: UserSuiteStatus,
userSuite: compute(({ row }) => {
return row;
}),
currentSuite: context.currentSuite
},
conditionalRender: {
match() {
return false;
}
}
}
},
activeTime: {
title: "激活时间",
type: "date",
column: {
width: 150
}
},
expiresTime: {
title: "过期时间",
type: "date",
column: {
width: 150,
component: {
name: "expires-time-text",
vModel: "value",
mode: "tag",
title: compute(({ value }) => {
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
})
}
}
},
isPresent: {
title: "是否赠送",
type: "dict-switch",
dict: dict({
data: [
{ label: "是", value: true, color: "success" },
{ label: "否", value: false, color: "blue" }
]
}),
form: {
value: true
},
column: {
width: 100,
align: "center"
}
}
}
}
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: { show: false },
buy: {
text: "购买",
type: "primary",
click() {
router.push({
path: "/certd/suite/buy",
});
},
},
},
},
rowHandle: {
width: 200,
fixed: "right",
buttons: {
view: { show: false },
copy: { show: false },
edit: { show: false },
remove: { show: false },
// continue:{
// text:"续期",
// type:"link",
// click(){
// console.log("续期");
// }
// }
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
title: {
title: "套餐名称",
type: "text",
search: {
show: true,
},
form: {
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 200,
},
},
productType: {
title: "类型",
type: "dict-select",
editForm: {
component: {
disabled: true,
},
},
dict: dict({
data: [
{ label: "套餐", value: "suite", color: "green" },
{ label: "加量包", value: "addon", color: "blue" },
],
}),
form: {
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 80,
align: "center",
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
},
},
"content.maxDomainCount": {
title: "域名数量",
type: "text",
form: {
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "个",
},
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "个",
},
align: "center",
},
},
"content.maxPipelineCount": {
title: "流水线数量",
type: "text",
form: {
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "条",
},
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "条",
},
align: "center",
},
},
"content.maxDeployCount": {
title: "部署次数",
type: "text",
form: {
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "次",
},
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "次",
used: compute(({ row }) => {
return row.deployCountUsed;
}),
},
align: "center",
},
},
"content.maxMonitorCount": {
title: "证书监控数量",
type: "text",
form: {
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: "个",
},
rules: [{ required: true, message: "此项必填" }],
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: "个",
},
align: "center",
},
},
duration: {
title: "时长",
type: "text",
form: {},
column: {
component: {
name: DurationValue,
vModel: "modelValue",
},
width: 100,
align: "center",
},
},
status: {
title: "状态",
type: "text",
form: { show: false },
column: {
width: 100,
align: "center",
component: {
name: UserSuiteStatus,
userSuite: compute(({ row }) => {
return row;
}),
currentSuite: context.currentSuite,
},
conditionalRender: {
match() {
return false;
},
},
},
},
activeTime: {
title: "激活时间",
type: "date",
column: {
width: 150,
},
},
expiresTime: {
title: "过期时间",
type: "date",
column: {
width: 150,
component: {
name: "expires-time-text",
vModel: "value",
mode: "tag",
title: compute(({ value }) => {
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
}),
},
},
},
isPresent: {
title: "是否赠送",
type: "dict-switch",
dict: dict({
data: [
{ label: "是", value: true, color: "success" },
{ label: "否", value: false, color: "blue" },
],
}),
form: {
value: true,
},
column: {
width: 100,
align: "center",
},
},
},
},
};
}
@@ -22,7 +22,7 @@ import { mySuiteApi, SuiteDetail } from "/@/views/certd/suite/mine/api";
import SuiteCard from "/@/views/framework/home/dashboard/suite-card.vue";
defineOptions({
name: "MySuites"
name: "MySuites",
});
const detail = ref<SuiteDetail>({});
const currentSuite = computed(() => {
@@ -7,7 +7,7 @@ import { ref, computed } from "vue";
import dayjs from "dayjs";
defineOptions({
name: "UserSuiteStatus"
name: "UserSuiteStatus",
});
const props = defineProps<{
@@ -2,45 +2,38 @@
<a-modal v-model:open="openRef" class="order-modal" :title="$t('order.confirmTitle')" @ok="orderCreate">
<div v-if="product" class="order-box">
<div class="flex-o mt-5">
<span class="label">{{$t('order.package')}}</span>{{ product.title }}
<span class="label">{{ $t("order.package") }}</span>{{ product.title }}
</div>
<div class="flex-o mt-5">
<span class="label">{{$t('order.description')}}</span>{{ product.intro }}
<span class="label">{{ $t("order.description") }}</span>{{ product.intro }}
</div>
<div class="flex-o mt-5">
<span class="label">{{$t('order.specifications')}}</span>
<span class="label">{{ $t("order.specifications") }}</span>
<span class="flex-o flex-wrap">
<span class="flex-o">
{{$t('order.pipeline')}}<suite-value class="ml-5" :model-value="product.content.maxPipelineCount" unit="{{$t('order.unit.pieces')}}" />
</span>
<span class="flex-o">
{{$t('order.domain')}}<suite-value class="ml-5" :model-value="product.content.maxDomainCount" unit="{{$t('order.unit.count')}}" />
</span>
<span class="flex-o">
{{$t('order.deployTimes')}}<suite-value class="ml-5" :model-value="product.content.maxDeployCount" unit="{{$t('order.unit.times')}}" />
</span>
<span class="flex-o"> {{ $t("order.pipeline") }}<suite-value class="ml-5" :model-value="product.content.maxPipelineCount" unit="{{$t('order.unit.pieces')}}" /> </span>
<span class="flex-o"> {{ $t("order.domain") }}<suite-value class="ml-5" :model-value="product.content.maxDomainCount" unit="{{$t('order.unit.count')}}" /> </span>
<span class="flex-o"> {{ $t("order.deployTimes") }}<suite-value class="ml-5" :model-value="product.content.maxDeployCount" unit="{{$t('order.unit.times')}}" /> </span>
</span>
</div>
<div class="flex-o mt-5">
<span class="label">{{$t('order.duration')}}</span>
<span class="label">{{ $t("order.duration") }}</span>
<duration-value v-model="formRef.duration"></duration-value>
</div>
<div class="flex-o mt-5">
<span class="label">{{$t('order.price')}}</span>
<span class="label">{{ $t("order.price") }}</span>
<price-input :edit="false" :model-value="durationSelected.price"></price-input>
</div>
<div class="flex-o mt-5">
<span class="label">{{$t('order.paymentMethod')}}</span>
<div v-if="durationSelected.price === 0">{{$t('order.free')}}</div>
<span class="label">{{ $t("order.paymentMethod") }}</span>
<div v-if="durationSelected.price === 0">{{ $t("order.free") }}</div>
<fs-dict-select v-else v-model:value="formRef.payType" :dict="paymentsDictRef" style="width: 200px"> </fs-dict-select>
</div>
</div>
</a-modal>
</template>
<script setup lang="tsx">
import { ref } from "vue";
import { GetPaymentTypes, OrderModalOpenReq, TradeCreate } from "/@/views/certd/suite/api";
@@ -105,7 +105,7 @@ async function doOrder() {
display: flex;
flex-wrap: wrap;
.duration-item {
width: 50px;
width: 45px;
border: 1px solid #cdcdcd;
text-align: center;
padding: 2px;
@@ -6,7 +6,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -14,7 +14,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -22,7 +22,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -30,7 +30,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -38,7 +38,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -46,7 +46,7 @@ export async function GetDetail(id: any) {
return await request({
url: apiPrefix + "/detail",
method: "post",
params: { id }
params: { id },
});
}
@@ -54,7 +54,7 @@ export async function DeleteBatch(ids: any[]) {
return await request({
url: apiPrefix + "/deleteByIds",
method: "post",
data: { ids }
data: { ids },
});
}
@@ -62,6 +62,6 @@ export async function SyncStatus(id: any) {
return await request({
url: apiPrefix + "/syncStatus",
method: "post",
data: { id }
data: { id },
});
}
@@ -48,16 +48,16 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
props: {
multiple: true,
crossPage: true,
selectedRowKeys
}
}
}
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest
delRequest,
},
rowHandle: {
width: 240,
@@ -79,23 +79,23 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
onOk: async () => {
await api.SyncStatus(row.id);
await crudExpose.doRefresh();
}
},
});
}
}
}
},
},
},
},
actionbar: {
buttons: {
add: {
show: false
}
}
show: false,
},
},
},
toolbar: { show: false },
tabs: {
name: "status",
show: true
show: true,
},
columns: {
id: {
@@ -103,30 +103,30 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
key: "id",
type: "number",
column: {
width: 100
width: 100,
},
form: {
show: false
}
show: false,
},
},
tradeNo: {
title: "订单号",
type: "text",
search: { show: true },
form: {
show: false
show: false,
},
column: {
width: 250
}
width: 250,
},
},
title: {
title: "商品名称",
type: "text",
search: { show: true },
column: {
width: 150
}
width: 150,
},
},
duration: {
title: "时长",
@@ -135,9 +135,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
width: 100,
component: {
name: DurationValue,
vModel: "modelValue"
}
}
vModel: "modelValue",
},
},
},
amount: {
title: "金额",
@@ -147,9 +147,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
component: {
name: PriceInput,
vModel: "modelValue",
edit: false
}
}
edit: false,
},
},
},
status: {
title: "状态",
@@ -159,13 +159,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
data: [
{ label: "待支付", value: "wait_pay", color: "warning" },
{ label: "已支付", value: "paid", color: "success" },
{ label: "已关闭", value: "closed", color: "error" }
]
{ label: "已关闭", value: "closed", color: "error" },
],
}),
column: {
width: 100,
align: "center"
}
align: "center",
},
},
payType: {
title: "支付方式",
@@ -176,48 +176,48 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
{ label: "聚合支付", value: "yizhifu" },
{ label: "支付宝", value: "alipay" },
{ label: "微信", value: "wxpay" },
{ label: "免费", value: "free" }
]
{ label: "免费", value: "free" },
],
}),
column: {
width: 100,
component: {
color: "auto"
color: "auto",
},
align: "center"
}
align: "center",
},
},
payTime: {
title: "支付时间",
type: "datetime",
column: {
width: 160
}
width: 160,
},
},
createTime: {
title: "创建时间",
type: "datetime",
form: {
show: false
show: false,
},
column: {
sorter: true,
width: 160,
align: "center"
}
align: "center",
},
},
updateTime: {
title: "更新时间",
type: "datetime",
form: {
show: false
show: false,
},
column: {
show: true,
width: 160
}
}
}
}
width: 160,
},
},
},
},
};
}
@@ -13,7 +13,7 @@ export default {
methods: {
toHome() {
this.$router.push({ path: "/" });
}
}
},
},
};
</script>
@@ -13,7 +13,7 @@ export default {
methods: {
toHome() {
this.$router.push({ path: "/" });
}
}
},
},
};
</script>
@@ -23,17 +23,17 @@ const props = withDefaults(
{
data: () => {
return [];
}
},
}
);
const dates = computed(() => {
return props.data.map((item) => {
return props.data.map(item => {
return item.name;
});
});
const counts = computed(() => {
return props.data.map((item) => {
return props.data.map(item => {
return item.value;
});
});
@@ -43,15 +43,15 @@ const option = ref({
show: props.data.length === 0, // 没数据才显示
extStyle: {
color: "grey",
fontSize: 20
fontSize: 20,
},
text: "暂无数据",
left: "center",
top: "center"
top: "center",
},
tooltip: {
trigger: "item"
trigger: "item",
},
// tooltip: {
// trigger: "axis",
@@ -70,19 +70,19 @@ const option = ref({
left: "20px",
right: "20px",
bottom: "10px",
containLabel: true
containLabel: true,
},
xAxis: [
{
type: "category",
boundaryGap: false,
data: dates
}
data: dates,
},
],
yAxis: [
{
type: "value"
}
type: "value",
},
],
series: [
{
@@ -91,16 +91,16 @@ const option = ref({
stack: "Total",
label: {
show: true,
position: "top"
position: "top",
},
smooth: true,
areaStyle: {},
emphasis: {
focus: "series"
focus: "series",
},
data: counts
}
]
data: counts,
},
],
});
</script>
@@ -22,19 +22,19 @@ const props = defineProps<{
const option = ref({
color: ["#91cc75", "#73c0de", "#ee6666", "#fac858", "#5470c6", "#3ba272", "#fc8452", "#9a60b4", "#ea7ccc", "#5470c6"],
tooltip: {
trigger: "item"
trigger: "item",
},
legend: {
orient: "vertical",
bottom: "5%",
left: "left"
left: "left",
},
grid: {
top: "20px",
left: "20px",
right: "20px",
bottom: "10px",
containLabel: true
containLabel: true,
},
series: [
{
@@ -46,25 +46,25 @@ const option = ref({
itemStyle: {
borderRadius: 0,
borderColor: "#fff",
borderWidth: 1
borderWidth: 1,
},
label: {
show: false,
position: "center"
position: "center",
},
emphasis: {
label: {
show: false,
fontSize: 18,
fontWeight: "bold"
}
fontWeight: "bold",
},
},
labelLine: {
show: false
show: false,
},
data: props.data
}
]
data: props.data,
},
],
});
</script>
@@ -11,14 +11,12 @@
<div class="text">
<div class="left">
<div>
<span>{{ t('certd.dashboard.greeting', { name: userInfo.nickName || userInfo.username, site: siteInfo.title }) }}</span>
<span>{{ t("certd.dashboard.greeting", { name: userInfo.nickName || userInfo.username, site: siteInfo.title }) }}</span>
</div>
<div class="flex-o flex-wrap profile-badges">
<a-tooltip :title="deltaTimeTip">
<a-badge :dot="deltaTimeWarning">
<a-tag :color="deltaTimeWarning ? 'red' : 'green'" class="flex-inline pointer">
<fs-icon icon="ion:time-outline"></fs-icon> {{ now }}
</a-tag>
<a-tag :color="deltaTimeWarning ? 'red' : 'green'" class="flex-inline pointer"> <fs-icon icon="ion:time-outline"></fs-icon> {{ now }} </a-tag>
</a-badge>
</a-tooltip>
@@ -50,7 +48,7 @@
<tutorial-button class="flex-center mt-2">
<a-tooltip :title="t('certd.dashboard.tutorialTooltip')">
<a-tag color="blue" class="flex-center">
{{ t('certd.dashboard.tutorialText') }}
{{ t("certd.dashboard.tutorialText") }}
<fs-icon class="font-size-16 ml-5" icon="mingcute:question-line"></fs-icon>
</a-tag>
</a-tooltip>
@@ -61,10 +59,9 @@
<div v-if="!settingStore.isComm" class="warning">
<a-alert type="warning" show-icon>
<template #message>
{{ t('certd.dashboard.alertMessage') }}
<a class="ml-5 flex-inline" href="https://gitee.com/certd/certd" target="_blank">gitee</a>
<a class="ml-5 flex-inline" href="https://github.com/certd/certd" target="_blank">github</a>
<a class="ml-5 flex-inline" href="https://certd.docmirror.cn" target="_blank">{{ t('certd.dashboard.helpDoc') }}</a>
{{ t("certd.dashboard.alertMessage") }}
<a class="ml-5 flex-inline" href="https://gitee.com/certd/certd" target="_blank">gitee</a> <a class="ml-5 flex-inline" href="https://github.com/certd/certd" target="_blank">github</a>
<a class="ml-5 flex-inline" href="https://certd.docmirror.cn" target="_blank">{{ t("certd.dashboard.helpDoc") }}</a>
</template>
</a-alert>
</div>
@@ -75,14 +72,12 @@
<statistic-card :title="t('certd.dashboard.pipelineCount')" :count="count.pipelineCount">
<template v-if="count.pipelineCount === 0" #default>
<div class="flex-center flex-1 flex-col">
<div style="font-size: 18px; font-weight: 700">{{ t('certd.dashboard.noPipeline') }}</div>
<fs-button type="primary" class="mt-10" icon="ion:add-circle-outline" @click="goPipeline">{{ t('certd.dashboard.createNow') }}</fs-button>
<div style="font-size: 18px; font-weight: 700">{{ t("certd.dashboard.noPipeline") }}</div>
<fs-button type="primary" class="mt-10" icon="ion:add-circle-outline" @click="goPipeline">{{ t("certd.dashboard.createNow") }}</fs-button>
</div>
</template>
<template #footer>
<router-link to="/certd/pipeline" class="flex">
<fs-icon icon="ion:settings-outline" class="mr-5 fs-16" /> {{ t('certd.dashboard.managePipeline') }}
</router-link>
<router-link to="/certd/pipeline" class="flex"> <fs-icon icon="ion:settings-outline" class="mr-5 fs-16" /> {{ t("certd.dashboard.managePipeline") }} </router-link>
</template>
</statistic-card>
</a-col>
@@ -107,7 +102,7 @@
<div v-if="pluginGroups" class="plugin-list">
<a-card>
<template #title>
{{ t('certd.dashboard.supportedTasks') }}
{{ t("certd.dashboard.supportedTasks") }}
<a-tag color="green">{{ pluginGroups.groups.all.plugins.length }}</a-tag>
</template>
<a-row :gutter="10">
@@ -136,7 +131,6 @@
</div>
</template>
<script lang="ts" setup>
import { FsIcon } from "@fast-crud/fast-crud";
import SimpleSteps from "/@/components/tutorial/simple-steps.vue";
@@ -36,9 +36,7 @@
</span>
<span>(<expires-time-text :value="item.expiresTime" />)</span>
</a-tag>
<div v-if="detail.suites?.length === 0" class="flex-o ml-5">
暂无套餐 <a-button class="ml-5" type="primary" size="small" @click="goBuy">去购买</a-button>
</div>
<div v-if="detail.suites?.length === 0" class="flex-o ml-5">暂无套餐 <a-button class="ml-5" type="primary" size="small" @click="goBuy">去购买</a-button></div>
</div>
</a-popover>
</div>
@@ -54,7 +52,7 @@ import { FsIcon } from "@fast-crud/fast-crud";
import { useRouter } from "vue-router";
defineOptions({
name: "SuiteCard"
name: "SuiteCard",
});
const detail = ref<SuiteDetail>({});
@@ -68,7 +66,7 @@ loadSuiteDetail();
const router = useRouter();
function goBuy() {
router.push({
path: "/certd/suite/buy"
path: "/certd/suite/buy",
});
}
</script>
@@ -2,10 +2,7 @@
<fs-page class="home—index bg-neutral-100 dark:bg-black">
<!-- <page-content />-->
<dashboard-user />
<change-password-button
ref="changePasswordButtonRef"
:show-button="false"
></change-password-button>
<change-password-button ref="changePasswordButtonRef" :show-button="false"></change-password-button>
</fs-page>
</template>
@@ -1,16 +1,6 @@
<template>
<div class="main">
<a-form
ref="formRef"
class="user-layout-register"
name="custom-validation"
:model="formState"
:rules="rules"
v-bind="layout"
:label-col="{ span: 6 }"
@finish="handleFinish"
@finish-failed="handleFinishFailed"
>
<a-form ref="formRef" class="user-layout-register" name="custom-validation" :model="formState" :rules="rules" v-bind="layout" :label-col="{ span: 6 }" @finish="handleFinish" @finish-failed="handleFinishFailed">
<a-tabs v-model:active-key="registerType">
<a-tab-pane key="username" tab="用户名注册" :disabled="!settingsStore.sysPublic.usernameRegisterEnabled">
<template v-if="registerType === 'username'">
@@ -104,7 +94,7 @@ export default defineComponent({
if (!settingsStore.sysPublic.usernameRegisterEnabled) {
registerType.value = "";
notification.error({
message: "没有启用任何一种注册方式"
message: "没有启用任何一种注册方式",
});
}
}
@@ -117,7 +107,7 @@ export default defineComponent({
username: "",
password: "",
confirmPassword: "",
randomStr: ""
randomStr: "",
});
const rules = {
@@ -125,32 +115,32 @@ export default defineComponent({
{
required: true,
trigger: "change",
message: "请输入用户名"
}
message: "请输入用户名",
},
],
email: [
{
required: true,
trigger: "change",
message: "请输入邮箱"
message: "请输入邮箱",
},
{
type: "email",
message: "请输入正确的邮箱"
}
message: "请输入正确的邮箱",
},
],
password: [
{
required: true,
trigger: "change",
message: "请输入密码"
}
message: "请输入密码",
},
],
confirmPassword: [
{
required: true,
trigger: "change",
message: "请确认密码"
message: "请确认密码",
},
{
validator: async (rule: any, value: any) => {
@@ -158,41 +148,41 @@ export default defineComponent({
throw new Error("两次输入密码不一致");
}
return true;
}
}
},
},
],
imgCode: [
{
required: true,
message: "请输入图片验证码"
message: "请输入图片验证码",
},
{
min: 4,
max: 4,
message: "请输入4位图片验证码"
}
message: "请输入4位图片验证码",
},
],
smsCode: [
{
required: true,
message: "请输入短信验证码"
}
message: "请输入短信验证码",
},
],
validateCode: [
{
required: true,
message: "请输入邮件验证码"
}
]
message: "请输入邮件验证码",
},
],
};
const layout = {
labelCol: {
span: 0
span: 0,
},
wrapperCol: {
span: 24
}
span: 24,
},
};
const handleFinish = async (values: any) => {
@@ -204,7 +194,7 @@ export default defineComponent({
imgCode: formState.imgCode,
randomStr: formState.randomStr,
email: formState.email,
validateCode: formState.validateCode
validateCode: formState.validateCode,
}) as any
);
};
@@ -235,9 +225,9 @@ export default defineComponent({
handleFinish,
resetForm,
registerType,
settingsStore
settingsStore,
};
}
},
});
</script>
@@ -4,7 +4,7 @@ export async function PreBindUser(userId: number) {
await request({
url: "/sys/account/preBindUser",
method: "post",
data: { userId }
data: { userId },
});
}
@@ -12,7 +12,7 @@ export async function BindUser(userId: number) {
await request({
url: "/sys/account/bindUser",
method: "post",
data: { userId }
data: { userId },
});
}
@@ -20,7 +20,7 @@ export async function UnbindUser(userId: number) {
await request({
url: "/sys/account/unbindUser",
method: "post",
data: { userId }
data: { userId },
});
}
@@ -28,6 +28,6 @@ export async function UpdateLicense(data: any) {
await request({
url: "/sys/account/updateLicense",
method: "post",
data
data,
});
}
@@ -4,14 +4,14 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
export async function GetTree() {
return await request({
url: apiPrefix + "/tree",
method: "post"
method: "post",
});
}
@@ -19,7 +19,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -27,7 +27,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -35,7 +35,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -43,6 +43,6 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -3,150 +3,149 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, Edi
import { useI18n } from "vue-i18n";
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
const list = await api.GetTree();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
const list = await api.GetTree();
return {
offset: 0,
records: list,
total: 10000,
limit: 10000
};
};
return {
offset: 0,
records: list,
total: 10000,
limit: 10000,
};
};
async function afterChange() {
await permissionTreeDict.reloadDict();
}
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const ret = await api.UpdateObj(form);
await afterChange();
return ret;
};
const delRequest = async ({ row }: DelReq) => {
const ret = await api.DelObj(row.id);
await afterChange();
return ret;
};
async function afterChange() {
await permissionTreeDict.reloadDict();
}
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const ret = await api.UpdateObj(form);
await afterChange();
return ret;
};
const delRequest = async ({ row }: DelReq) => {
const ret = await api.DelObj(row.id);
await afterChange();
return ret;
};
const addRequest = async ({ form }: AddReq) => {
const ret = await api.AddObj(form);
await afterChange();
return ret;
};
const permissionTreeDict = dict({
url: "/sys/authority/permission/tree",
isTree: true,
value: "id",
label: "title",
async onReady({ dict }: any) {
dict.setData([{ id: -1, title: t("certd.rootNode"), children: dict.data }]);
}
});
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
actionbar: {
show: false
},
toolbar: {
show: false
},
table: {
show: false
// scroll: { fixed: true }
},
rowHandle: {
fixed: "right"
},
search: {
show: false
},
pagination: {
show: false,
pageSize: 100000
},
columns: {
id: {
title: "id",
type: "number",
form: { show: false }, // 表单配置
column: {
width: 120,
sortable: "custom"
}
},
title: {
title: t("certd.permissionName"),
type: "text",
form: {
rules: [
{ required: true, message: t("certd.enterPermissionName") },
{ max: 50, message: t("certd.max50Chars") }
],
component: {
placeholder: t("certd.permissionName")
}
},
column: {
width: 200
}
},
permission: {
title: t("certd.permissionCode"),
type: "text",
column: {
width: 170
},
form: {
rules: [
{ required: true, message: t("certd.enterPermissionCode") },
{ max: 100, message: t("certd.max100Chars") }
],
component: {
placeholder: t("certd.examplePermissionCode")
}
}
},
sort: {
title: t("certd.sortOrder"),
type: "number",
column: {
width: 100
},
form: {
value: 100,
rules: [{ required: true, type: "number", message: t("certd.sortRequired") }]
}
},
parentId: {
title: t("certd.parentNode"),
type: "dict-tree",
column: {
width: 100
},
dict: permissionTreeDict,
form: {
value: -1,
component: {
multiple: false,
defaultExpandAll: true,
dict: { cache: false },
fieldNames: {
value: "id",
label: "title"
}
}
}
}
}
}
};
const addRequest = async ({ form }: AddReq) => {
const ret = await api.AddObj(form);
await afterChange();
return ret;
};
const permissionTreeDict = dict({
url: "/sys/authority/permission/tree",
isTree: true,
value: "id",
label: "title",
async onReady({ dict }: any) {
dict.setData([{ id: -1, title: t("certd.rootNode"), children: dict.data }]);
},
});
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
actionbar: {
show: false,
},
toolbar: {
show: false,
},
table: {
show: false,
// scroll: { fixed: true }
},
rowHandle: {
fixed: "right",
},
search: {
show: false,
},
pagination: {
show: false,
pageSize: 100000,
},
columns: {
id: {
title: "id",
type: "number",
form: { show: false }, // 表单配置
column: {
width: 120,
sortable: "custom",
},
},
title: {
title: t("certd.permissionName"),
type: "text",
form: {
rules: [
{ required: true, message: t("certd.enterPermissionName") },
{ max: 50, message: t("certd.max50Chars") },
],
component: {
placeholder: t("certd.permissionName"),
},
},
column: {
width: 200,
},
},
permission: {
title: t("certd.permissionCode"),
type: "text",
column: {
width: 170,
},
form: {
rules: [
{ required: true, message: t("certd.enterPermissionCode") },
{ max: 100, message: t("certd.max100Chars") },
],
component: {
placeholder: t("certd.examplePermissionCode"),
},
},
},
sort: {
title: t("certd.sortOrder"),
type: "number",
column: {
width: 100,
},
form: {
value: 100,
rules: [{ required: true, type: "number", message: t("certd.sortRequired") }],
},
},
parentId: {
title: t("certd.parentNode"),
type: "dict-tree",
column: {
width: 100,
},
dict: permissionTreeDict,
form: {
value: -1,
component: {
multiple: false,
defaultExpandAll: true,
dict: { cache: false },
fieldNames: {
value: "id",
label: "title",
},
},
},
},
},
},
};
}
@@ -1,20 +1,27 @@
<template>
<a-tree v-if="computedTree" ref="treeRef" class="fs-permission-tree" :class="{ 'is-editable': editable }"
:selectable="false" show-line :show-icon="false" :default-expand-all="true" :tree-data="computedTree"
@check="onChecked">
<template #title="scope">
<div class="node-title-pane">
<div class="node-title">{{ scope.title }}</div>
<div v-if="editable === true" class="node-suffix">
<fs-icon v-if="actions.add !== false" :icon="$fsui.icons.add" @click.stop="add(scope)" />
<fs-icon v-if="actions.edit !== false && scope.id !== -1" :icon="$fsui.icons.edit"
@click.stop="edit(scope)" />
<fs-icon v-if="actions.remove !== false && scope.id !== -1" :icon="$fsui.icons.remove"
@click.stop="remove(scope)" />
</div>
</div>
</template>
</a-tree>
<a-tree
v-if="computedTree"
ref="treeRef"
class="fs-permission-tree"
:class="{ 'is-editable': editable }"
:selectable="false"
show-line
:show-icon="false"
:default-expand-all="true"
:tree-data="computedTree"
@check="onChecked"
>
<template #title="scope">
<div class="node-title-pane">
<div class="node-title">{{ scope.title }}</div>
<div v-if="editable === true" class="node-suffix">
<fs-icon v-if="actions.add !== false" :icon="$fsui.icons.add" @click.stop="add(scope)" />
<fs-icon v-if="actions.edit !== false && scope.id !== -1" :icon="$fsui.icons.edit" @click.stop="edit(scope)" />
<fs-icon v-if="actions.remove !== false && scope.id !== -1" :icon="$fsui.icons.remove" @click.stop="remove(scope)" />
</div>
</div>
</template>
</a-tree>
</template>
<script lang="ts">
@@ -24,171 +31,170 @@ import { computed, defineComponent, ref } from "vue";
import { useI18n } from "vue-i18n";
export default defineComponent({
name: "FsPermissionTree",
props: {
/**
* 树形数据
* */
tree: {},
/**
* 是否可编辑
*/
editable: {
default: true
},
actions: {
default: {}
}
} as any,
emits: ["add", "edit", "remove"],
setup(props: any, ctx) {
const { t } = useI18n();
const treeRef = ref();
const computedTree = computed(() => {
if (props.tree == null) {
return null;
}
const clone = cloneDeep(props.tree);
utils.deepdash.forEachDeep(clone, (value: any, key: any, pNode: any, context: any) => {
if (value == null) {
return;
}
if (!(value instanceof Object) || value instanceof Array) {
return;
}
if (value.class === "is-leaf") {
//处理过,无需再次处理
return;
}
value.class = "is-twig";
if (value.children != null && value.children.length > 0) {
return;
}
const parents = context.parents;
if (parents.length < 2) {
return;
}
const parent = parents[parents.length - 2].value;
//看parent下面的children,是否全部都没有children
for (const child of parent.children) {
if (child.children != null && child.children.length > 0) {
//存在child有children
return;
}
}
// 所有的子节点都没有children
parent.class = "is-twig"; // 连接叶子节点的末梢枝杈节点
let i = 0;
for (const child of parent.children) {
child.class = "is-leaf";
if (i !== 0) {
child.class += " leaf-after";
}
i++;
}
});
return [
{
title: t("certd.rootNode"),
id: -1,
children: clone
}
];
});
function add(scope: any) {
ctx.emit("add", scope.dataRef);
}
function edit(scope: any) {
ctx.emit("edit", scope.dataRef);
}
function remove(scope: any) {
ctx.emit("remove", scope.dataRef);
}
function onChecked(a: any, b: any, c: any) {
utils.logger.info("chedcked", a, b, c);
}
function getChecked() {
const checked = treeRef.value.checkedKeys;
const halfChecked = treeRef.value.halfCheckedKeys;
return {
checked,
halfChecked
};
}
return {
computedTree,
add,
edit,
remove,
treeRef,
onChecked,
getChecked,
t
};
}
name: "FsPermissionTree",
props: {
/**
* 树形数据
* */
tree: {},
/**
* 是否可编辑
*/
editable: {
default: true,
},
actions: {
default: {},
},
} as any,
emits: ["add", "edit", "remove"],
setup(props: any, ctx) {
const { t } = useI18n();
const treeRef = ref();
const computedTree = computed(() => {
if (props.tree == null) {
return null;
}
const clone = cloneDeep(props.tree);
utils.deepdash.forEachDeep(clone, (value: any, key: any, pNode: any, context: any) => {
if (value == null) {
return;
}
if (!(value instanceof Object) || value instanceof Array) {
return;
}
if (value.class === "is-leaf") {
//处理过,无需再次处理
return;
}
value.class = "is-twig";
if (value.children != null && value.children.length > 0) {
return;
}
const parents = context.parents;
if (parents.length < 2) {
return;
}
const parent = parents[parents.length - 2].value;
//看parent下面的children,是否全部都没有children
for (const child of parent.children) {
if (child.children != null && child.children.length > 0) {
//存在child有children
return;
}
}
// 所有的子节点都没有children
parent.class = "is-twig"; // 连接叶子节点的末梢枝杈节点
let i = 0;
for (const child of parent.children) {
child.class = "is-leaf";
if (i !== 0) {
child.class += " leaf-after";
}
i++;
}
});
return [
{
title: t("certd.rootNode"),
id: -1,
children: clone,
},
];
});
function add(scope: any) {
ctx.emit("add", scope.dataRef);
}
function edit(scope: any) {
ctx.emit("edit", scope.dataRef);
}
function remove(scope: any) {
ctx.emit("remove", scope.dataRef);
}
function onChecked(a: any, b: any, c: any) {
utils.logger.info("chedcked", a, b, c);
}
function getChecked() {
const checked = treeRef.value.checkedKeys;
const halfChecked = treeRef.value.halfCheckedKeys;
return {
checked,
halfChecked,
};
}
return {
computedTree,
add,
edit,
remove,
treeRef,
onChecked,
getChecked,
t,
};
},
});
</script>
<style lang="less">
.fs-permission-tree {
.ant-tree-list-holder-inner {
flex-direction: row !important;
flex-wrap: wrap;
.ant-tree-list-holder-inner {
flex-direction: row !important;
flex-wrap: wrap;
.is-twig {
width: 100%;
}
.is-twig {
width: 100%;
}
.is-leaf {
.is-leaf {
//border-bottom: 1px solid #ddd;
&::before {
display: none;
}
//border-bottom: 1px solid #ddd;
&::before {
display: none;
}
&.leaf-after {
.ant-tree-indent-unit {
display: none;
}
}
&.leaf-after {
.ant-tree-indent-unit {
display: none;
}
}
.node-title-pane {
border-bottom: 1px solid #ddd;
}
}
}
.node-title-pane {
border-bottom: 1px solid #ddd;
}
}
}
//.is-twig ul {
// display: flex;
// flex-wrap: wrap;
//}
.node-title-pane {
display: flex;
//.is-twig ul {
// display: flex;
// flex-wrap: wrap;
//}
.node-title-pane {
display: flex;
.node-title {
width: 110px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.node-title {
width: 110px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
&.is-editable {
.ant-tree-title {
&:hover {
.node-suffix {
visibility: visible;
}
}
}
&.is-editable {
.ant-tree-title {
&:hover {
.node-suffix {
visibility: visible;
}
}
}
.node-suffix {
visibility: hidden;
.node-suffix {
visibility: hidden;
>* {
margin-left: 3px;
}
}
}
> * {
margin-left: 3px;
}
}
}
}
</style>
@@ -1,20 +1,18 @@
<template>
<fs-page>
<template #header>
<div class="title">{{ t("certd.permissionManagement") }}</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<a-button v-permission="'1sys:auth:per:add'" style="margin-left: 20px" @click="addHandle({})">
<fs-icon :icon="ui.icons.add"></fs-icon>
{{ t("certd.adda") }}
</a-button>
<fs-permission-tree class="permission-tree mt-10" :tree="crudBinding.data" :checkable="false"
:actions="permission" @add="addHandle" @edit="editHandle" @remove="removeHandle"></fs-permission-tree>
</fs-crud>
</fs-page>
<fs-page>
<template #header>
<div class="title">{{ t("certd.permissionManagement") }}</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<a-button v-permission="'1sys:auth:per:add'" style="margin-left: 20px" @click="addHandle({})">
<fs-icon :icon="ui.icons.add"></fs-icon>
{{ t("certd.adda") }}
</a-button>
<fs-permission-tree class="permission-tree mt-10" :tree="crudBinding.data" :checkable="false" :actions="permission" @add="addHandle" @edit="editHandle" @remove="removeHandle"></fs-permission-tree>
</fs-crud>
</fs-page>
</template>
<script lang="ts">
import { defineComponent, onActivated, onMounted, ref } from "vue";
import createCrudOptions from "./crud.js";
@@ -24,58 +22,58 @@ import { useFs, useUi } from "@fast-crud/fast-crud";
import { useI18n } from "vue-i18n";
export default defineComponent({
name: "AuthorityManager",
components: { FsPermissionTree },
setup() {
// 此处传入permission进行通用按钮权限设置,会通过commonOptions去设置actionbar和rowHandle的按钮的show属性
// 更多关于按钮权限的源代码设置,请参考 ./src/plugin/fast-crud/index.js 75-77行)
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { permission: "sys:auth:per" } });
const { t } = useI18n();
name: "AuthorityManager",
components: { FsPermissionTree },
setup() {
// 此处传入permission进行通用按钮权限设置,会通过commonOptions去设置actionbar和rowHandle的按钮的show属性
// 更多关于按钮权限的源代码设置,请参考 ./src/plugin/fast-crud/index.js 75-77行)
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { permission: "sys:auth:per" } });
const { t } = useI18n();
// 页面打开后获取列表数据
onMounted(async () => {
await crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
});
// 页面打开后获取列表数据
onMounted(async () => {
await crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
});
const { ui } = useUi();
const { ui } = useUi();
//用户业务代码
//用户业务代码
async function addHandle(item: any) {
await crudExpose.openAdd({ row: { parentId: item?.id ?? -1 } });
}
async function editHandle(item: any) {
await crudExpose.openEdit({ row: item });
}
async function removeHandle(item: any) {
await crudExpose.doRemove({ row: { id: item.id }, index: null });
}
async function addHandle(item: any) {
await crudExpose.openAdd({ row: { parentId: item?.id ?? -1 } });
}
async function editHandle(item: any) {
await crudExpose.openEdit({ row: item });
}
async function removeHandle(item: any) {
await crudExpose.doRemove({ row: { id: item.id }, index: null });
}
const { hasPermissions } = usePermission();
const permission = ref({
add: hasPermissions("1sys:auth:per:add"),
edit: hasPermissions("1sys:auth:per:edit"),
remove: hasPermissions("1sys:auth:per:remove"),
});
const { hasPermissions } = usePermission();
const permission = ref({
add: hasPermissions("1sys:auth:per:add"),
edit: hasPermissions("1sys:auth:per:edit"),
remove: hasPermissions("1sys:auth:per:remove"),
});
return {
ui,
crudBinding,
crudRef,
addHandle,
editHandle,
removeHandle,
permission,
t
};
},
return {
ui,
crudBinding,
crudRef,
addHandle,
editHandle,
removeHandle,
permission,
t,
};
},
});
</script>
<style lang="less">
.permission-tree {
margin-left: 20px;
margin-left: 20px;
}
</style>
@@ -4,7 +4,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -12,7 +12,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -20,7 +20,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -28,7 +28,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -36,7 +36,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -50,7 +50,7 @@ export async function getPermissionIds(roleId: any) {
return await request({
url: apiPrefix + "/getPermissionIds",
method: "post",
params: { id: roleId }
params: { id: roleId },
});
}
@@ -65,6 +65,6 @@ export async function DoAuthz(roleId: any, permissionIds: any) {
return await request({
url: apiPrefix + "/authz",
method: "post",
data: { roleId, permissionIds }
data: { roleId, permissionIds },
});
}
@@ -3,84 +3,84 @@ import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq,
import { useI18n } from "vue-i18n";
export default function ({ crudExpose, context: { authz } }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
return await api.AddObj(form);
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
rowHandle: {
width: 300,
buttons: {
authz: {
type: "link",
text: "授权",
async click(context) {
await authz.authzOpen(context.record.id);
}
}
}
},
columns: {
id: {
title: "id",
type: "text",
form: { show: false }, // 表单配置
column: {
width: 70,
sorter: true
}
},
name: {
title: t("certd.roleName"),
type: "text",
search: { show: true },
form: {
rules: [
{ required: true, message: t("certd.enterRoleName") },
{ max: 50, message: t("certd.max50Chars") }
]
}, // 表单配置
column: {
sorter: true
}
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
column: {
sorter: true
},
form: {
show: false
}
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
column: {
sorter: true
},
form: { show: false } // 表单配置
}
}
}
};
const addRequest = async ({ form }: AddReq) => {
return await api.AddObj(form);
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
rowHandle: {
width: 300,
buttons: {
authz: {
type: "link",
text: "授权",
async click(context) {
await authz.authzOpen(context.record.id);
},
},
},
},
columns: {
id: {
title: "id",
type: "text",
form: { show: false }, // 表单配置
column: {
width: 70,
sorter: true,
},
},
name: {
title: t("certd.roleName"),
type: "text",
search: { show: true },
form: {
rules: [
{ required: true, message: t("certd.enterRoleName") },
{ max: 50, message: t("certd.max50Chars") },
],
}, // 表单配置
column: {
sorter: true,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
column: {
sorter: true,
},
form: {
show: false,
},
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
column: {
sorter: true,
},
form: { show: false }, // 表单配置
},
},
},
};
}
@@ -1,18 +1,15 @@
<template>
<fs-page>
<template #header>
<div class="title">{{ t("certd.roleManagement") }}</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding" />
<a-modal v-model:open="authzDialogVisible" width="860px" :title="t('certd.assignPermissions')"
@ok="updatePermission">
<fs-permission-tree ref="permissionTreeRef" v-model:checked-keys="checkedKeys" :tree="permissionTreeData"
:editable="false" checkable :replace-fields="{ key: 'id', label: 'title' }"> </fs-permission-tree>
</a-modal>
</fs-page>
<fs-page>
<template #header>
<div class="title">{{ t("certd.roleManagement") }}</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding" />
<a-modal v-model:open="authzDialogVisible" width="860px" :title="t('certd.assignPermissions')" @ok="updatePermission">
<fs-permission-tree ref="permissionTreeRef" v-model:checked-keys="checkedKeys" :tree="permissionTreeData" :editable="false" checkable :replace-fields="{ key: 'id', label: 'title' }"> </fs-permission-tree>
</a-modal>
</fs-page>
</template>
<script lang="ts">
import { defineComponent, onActivated, onMounted, ref } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -25,103 +22,103 @@ import { UseCrudPermissionCompProps, UseCrudPermissionExtraProps } from "/@/plug
import { useI18n } from "vue-i18n";
function useAuthz() {
const checkedKeys = ref();
const checkedKeys = ref();
const permissionTreeData = ref();
const permissionTreeData = ref();
const permissionTreeRef = ref();
const authzDialogVisible = ref(false);
const permissionTreeRef = ref();
const authzDialogVisible = ref(false);
const currentRoleId = ref();
const currentRoleId = ref();
// 如果勾选节点中存在非叶子节点,tree组件会将其所有子节点全部勾选
// 所以要找出所有叶子节点,仅勾选叶子节点,tree组件会将父节点同步勾选
function getAllCheckedLeafNodeId(tree: any, checkedIds: any, temp: any) {
for (let i = 0; i < tree.length; i++) {
const item = tree[i];
if (item.children && item.children.length !== 0) {
getAllCheckedLeafNodeId(item.children, checkedIds, temp);
} else {
if (checkedIds.indexOf(item.id) !== -1) {
temp.push(item.id);
}
}
}
return temp;
}
function authzClose() {
authzDialogVisible.value = false;
}
async function authzOpen(roleId: any) {
permissionTreeData.value = await permissionApi.GetTree();
checkedKeys.value = [];
currentRoleId.value = roleId;
// this.treeData = ret.data
await updateChecked(roleId);
authzDialogVisible.value = true;
}
async function updateChecked(roleId: any) {
let checkedIds = await api.getPermissionIds(roleId);
// 找出所有的叶子节点
checkedIds = getAllCheckedLeafNodeId(permissionTreeData.value, checkedIds, []);
checkedKeys.value = checkedIds;
}
async function updatePermission() {
const roleId = currentRoleId.value;
const { checked, halfChecked } = permissionTreeRef.value.getChecked();
const allChecked = [...checked, ...halfChecked];
await api.DoAuthz(roleId, allChecked);
authzClose();
//await updateChecked(roleId);
// 如果勾选节点中存在非叶子节点,tree组件会将其所有子节点全部勾选
// 所以要找出所有叶子节点,仅勾选叶子节点,tree组件会将父节点同步勾选
function getAllCheckedLeafNodeId(tree: any, checkedIds: any, temp: any) {
for (let i = 0; i < tree.length; i++) {
const item = tree[i];
if (item.children && item.children.length !== 0) {
getAllCheckedLeafNodeId(item.children, checkedIds, temp);
} else {
if (checkedIds.indexOf(item.id) !== -1) {
temp.push(item.id);
}
}
}
return temp;
}
function authzClose() {
authzDialogVisible.value = false;
}
async function authzOpen(roleId: any) {
permissionTreeData.value = await permissionApi.GetTree();
checkedKeys.value = [];
currentRoleId.value = roleId;
// this.treeData = ret.data
await updateChecked(roleId);
authzDialogVisible.value = true;
}
async function updateChecked(roleId: any) {
let checkedIds = await api.getPermissionIds(roleId);
// 找出所有的叶子节点
checkedIds = getAllCheckedLeafNodeId(permissionTreeData.value, checkedIds, []);
checkedKeys.value = checkedIds;
}
async function updatePermission() {
const roleId = currentRoleId.value;
const { checked, halfChecked } = permissionTreeRef.value.getChecked();
const allChecked = [...checked, ...halfChecked];
await api.DoAuthz(roleId, allChecked);
authzClose();
//await updateChecked(roleId);
message.success("授权成功");
}
message.success("授权成功");
}
return {
authzOpen,
updatePermission,
authzDialogVisible,
permissionTreeData,
checkedKeys,
permissionTreeRef,
};
return {
authzOpen,
updatePermission,
authzDialogVisible,
permissionTreeData,
checkedKeys,
permissionTreeRef,
};
}
export default defineComponent({
name: "RoleManager",
components: { FsPermissionTree },
setup() {
//授权配置
const { t } = useI18n();
const authz = useAuthz();
const permission: UseCrudPermissionCompProps = {
prefix: "sys:auth:role", //权限代码前缀
extra: ({ hasActionPermission }: UseCrudPermissionExtraProps): any => {
//额外按钮权限控制
return { rowHandle: { buttons: { authz: { show: hasActionPermission("authz") } } } };
},
};
name: "RoleManager",
components: { FsPermissionTree },
setup() {
//授权配置
const { t } = useI18n();
const authz = useAuthz();
const permission: UseCrudPermissionCompProps = {
prefix: "sys:auth:role", //权限代码前缀
extra: ({ hasActionPermission }: UseCrudPermissionExtraProps): any => {
//额外按钮权限控制
return { rowHandle: { buttons: { authz: { show: hasActionPermission("authz") } } } };
},
};
// 初始化crud配置
// 此处传入permission进行通用按钮权限设置,会通过commonOptions去设置actionbar和rowHandle的按钮的show属性
// 更多关于按钮权限的源代码设置,请参考 ./src/plugin/fast-crud/index.js 75-77行)
// 初始化crud配置
// 此处传入permission进行通用按钮权限设置,会通过commonOptions去设置actionbar和rowHandle的按钮的show属性
// 更多关于按钮权限的源代码设置,请参考 ./src/plugin/fast-crud/index.js 75-77行)
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { authz, permission } });
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: { authz, permission } });
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
});
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
});
return {
crudBinding,
crudRef,
...authz,
t
};
},
onActivated(async () => {
await crudExpose.doRefresh();
});
return {
crudBinding,
crudRef,
...authz,
t,
};
},
});
</script>
@@ -6,282 +6,281 @@ import dayjs from "dayjs";
import { useSettingStore } from "/@/store/settings";
import { useI18n } from "vue-i18n";
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
return await api.AddObj(form);
};
const addRequest = async ({ form }: AddReq) => {
return await api.AddObj(form);
};
const userStore = useUserStore();
const userStore = useUserStore();
const settingStore = useSettingStore();
const userValidTimeEnabled = compute(() => {
return settingStore.sysPublic.userValidTimeEnabled === true;
});
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
rowHandle: {
fixed: "right",
buttons: {
unlock: {
title: t("certd.unlockLogin"),
text: null,
type: "link",
icon: "ion:lock-open-outline",
click: async ({ row }) => {
Modal.confirm({
title: t("certd.notice"),
content: t("certd.confirmUnlock"),
onOk: async () => {
await api.Unlock(row.id);
notification.success({
message: t("certd.unlockSuccess"),
});
},
});
},
},
},
},
table: {
scroll: {
//使用固定列时需要设置此值,并且大于等于列宽度之和的值
x: 1400,
},
},
columns: {
id: {
title: "id",
type: "text",
form: { show: false }, // 表单配置
column: {
width: 100,
sorter: true,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: { show: false }, // 表单配置
column: {
width: 180,
sorter: true,
},
},
// updateTime: {
// title: "修改时间",
// type: "datetime",
// form: { show: false }, // 表单配置
// column: {
// sortable: "update_time",
// width: 180
// }
// },
username: {
title: t("certd.username"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [
{ required: true, message: t("certd.enterUsername") },
{ max: 50, message: t("certd.max50Chars") },
],
},
editForm: { component: { disabled: false } },
column: {
sorter: true,
width: 200,
},
},
password: {
title: t("certd.password"),
type: "text",
key: "password",
column: {
show: false,
},
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
component: {
showPassword: true,
},
helper: t("certd.modifyPasswordIfFilled"),
},
},
nickName: {
title: t("certd.nickName"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
},
},
email: {
title: t("certd.emaila"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
width: 160,
},
},
mobile: {
title: t("certd.mobile"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
width: 130,
},
},
avatar: {
title: t("certd.avatar"),
type: "cropper-uploader",
column: {
width: 70,
component: {
style: {
height: "30px",
width: "auto",
},
buildUrl(key: string) {
return `api/basic/file/download?&key=` + key;
},
},
},
form: {
component: {
vModel: "modelValue",
valueType: "key",
cropper: {
aspectRatio: 1,
autoCropArea: 1,
viewMode: 0,
},
onReady: null,
uploader: {
type: "form",
action: "/basic/file/upload",
name: "file",
headers: {
Authorization: "Bearer " + userStore.getToken,
},
successHandle(res: any) {
return res;
},
},
buildUrl(key: string) {
return `api/basic/file/download?&key=` + key;
},
},
},
},
status: {
title: t("certd.status"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: 1, color: "green" },
{ label: t("certd.disabled"), value: 0, color: "red" },
],
}),
column: {
align: "center",
sorter: true,
width: 100,
},
},
validTime: {
title: t("certd.validTime"),
type: "date",
form: {
show: userValidTimeEnabled,
},
column: {
align: "center",
sorter: true,
width: 100,
show: userValidTimeEnabled,
cellRender({ value }) {
if (value == null || value === 0) {
return "";
}
if (value < dayjs().valueOf()) {
return <a-tag color={"red"}>{t("certd.expired")}</a-tag>;
}
const date = dayjs(value).format("YYYY-MM-DD");
return (
<a-tag color={"green"} title={date}>
<fs-time-humanize modelValue={value} options={{ largest: 1, units: ["y", "d", "h"] }} useFormatGreater={30000000000} />
</a-tag>
);
},
},
valueBuilder({ value, row, key }) {
if (value != null) {
row[key] = dayjs(value);
}
},
valueResolve({ value, row, key }) {
if (value != null) {
row[key] = value.valueOf();
}
},
},
remark: {
title: t("certd.remark"),
type: "text",
column: {
sorter: true,
},
form: {
rules: [{ max: 100, message: t("certd.max100Chars") }],
},
},
roles: {
title: t("certd.roles"),
type: "dict-select",
dict: dict({
url: "/sys/authority/role/list",
value: "id",
label: "name",
}), // 数据字典
form: {
component: { mode: "multiple" },
},
column: {
width: 250,
sortable: true,
},
},
},
},
};
const settingStore = useSettingStore();
const userValidTimeEnabled = compute(() => {
return settingStore.sysPublic.userValidTimeEnabled === true;
});
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
rowHandle: {
fixed: "right",
buttons: {
unlock: {
title: t("certd.unlockLogin"),
text: null,
type: "link",
icon: "ion:lock-open-outline",
click: async ({ row }) => {
Modal.confirm({
title: t("certd.notice"),
content: t("certd.confirmUnlock"),
onOk: async () => {
await api.Unlock(row.id);
notification.success({
message: t("certd.unlockSuccess"),
});
},
});
},
},
},
},
table: {
scroll: {
//使用固定列时需要设置此值,并且大于等于列宽度之和的值
x: 1400,
},
},
columns: {
id: {
title: "id",
type: "text",
form: { show: false }, // 表单配置
column: {
width: 100,
sorter: true,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: { show: false }, // 表单配置
column: {
width: 180,
sorter: true,
},
},
// updateTime: {
// title: "修改时间",
// type: "datetime",
// form: { show: false }, // 表单配置
// column: {
// sortable: "update_time",
// width: 180
// }
// },
username: {
title: t("certd.username"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [
{ required: true, message: t("certd.enterUsername") },
{ max: 50, message: t("certd.max50Chars") },
],
},
editForm: { component: { disabled: false } },
column: {
sorter: true,
width: 200,
},
},
password: {
title: t("certd.password"),
type: "text",
key: "password",
column: {
show: false,
},
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
component: {
showPassword: true,
},
helper: t("certd.modifyPasswordIfFilled"),
},
},
nickName: {
title: t("certd.nickName"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
},
},
email: {
title: t("certd.emaila"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
width: 160,
},
},
mobile: {
title: t("certd.mobile"),
type: "text",
search: { show: true }, // 开启查询
form: {
rules: [{ max: 50, message: t("certd.max50Chars") }],
},
column: {
sorter: true,
width: 130,
},
},
avatar: {
title: t("certd.avatar"),
type: "cropper-uploader",
column: {
width: 70,
component: {
style: {
height: "30px",
width: "auto",
},
buildUrl(key: string) {
return `api/basic/file/download?&key=` + key;
},
},
},
form: {
component: {
vModel: "modelValue",
valueType: "key",
cropper: {
aspectRatio: 1,
autoCropArea: 1,
viewMode: 0,
},
onReady: null,
uploader: {
type: "form",
action: "/basic/file/upload",
name: "file",
headers: {
Authorization: "Bearer " + userStore.getToken,
},
successHandle(res: any) {
return res;
},
},
buildUrl(key: string) {
return `api/basic/file/download?&key=` + key;
},
},
},
},
status: {
title: t("certd.status"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: 1, color: "green" },
{ label: t("certd.disabled"), value: 0, color: "red" },
],
}),
column: {
align: "center",
sorter: true,
width: 100,
},
},
validTime: {
title: t("certd.validTime"),
type: "date",
form: {
show: userValidTimeEnabled,
},
column: {
align: "center",
sorter: true,
width: 100,
show: userValidTimeEnabled,
cellRender({ value }) {
if (value == null || value === 0) {
return "";
}
if (value < dayjs().valueOf()) {
return <a-tag color={"red"}>{t("certd.expired")}</a-tag>;
}
const date = dayjs(value).format("YYYY-MM-DD");
return (
<a-tag color={"green"} title={date}>
<fs-time-humanize modelValue={value} options={{ largest: 1, units: ["y", "d", "h"] }} useFormatGreater={30000000000} />
</a-tag>
);
},
},
valueBuilder({ value, row, key }) {
if (value != null) {
row[key] = dayjs(value);
}
},
valueResolve({ value, row, key }) {
if (value != null) {
row[key] = value.valueOf();
}
},
},
remark: {
title: t("certd.remark"),
type: "text",
column: {
sorter: true,
},
form: {
rules: [{ max: 100, message: t("certd.max100Chars") }],
},
},
roles: {
title: t("certd.roles"),
type: "dict-select",
dict: dict({
url: "/sys/authority/role/list",
value: "id",
label: "name",
}), // 数据字典
form: {
component: { mode: "multiple" },
},
column: {
width: 250,
sortable: true,
},
},
},
},
};
}
@@ -6,7 +6,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -14,7 +14,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -22,7 +22,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -30,7 +30,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -38,7 +38,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -46,7 +46,7 @@ export async function GetDetail(id: any) {
return await request({
url: apiPrefix + "/detail",
method: "post",
params: { id }
params: { id },
});
}
@@ -54,7 +54,7 @@ export async function DeleteBatch(ids: any[]) {
return await request({
url: apiPrefix + "/deleteByIds",
method: "post",
data: { ids }
data: { ids },
});
}
@@ -62,7 +62,7 @@ export async function SetDefault(id: any) {
return await request({
url: apiPrefix + "/setDefault",
method: "post",
data: { id }
data: { id },
});
}
@@ -70,6 +70,6 @@ export async function SetDisabled(id: any, disabled: boolean) {
return await request({
url: apiPrefix + "/setDisabled",
method: "post",
data: { id, disabled }
data: { id, disabled },
});
}
@@ -8,244 +8,244 @@ import { useSettingStore } from "/@/store/settings";
import { Modal } from "ant-design-vue";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const router = useRouter();
const { t } = useI18n();
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
const userStore = useUserStore();
const settingStore = useSettingStore();
const selectedRowKeys: Ref<any[]> = ref([]);
context.selectedRowKeys = selectedRowKeys;
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys
}
}
}
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
rowHandle: {
minWidth: 200,
fixed: "right"
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100
},
form: {
show: false
}
},
domain: {
title: t("certd.cnameDomain"),
type: "text",
editForm: {
component: {
disabled: true,
},
},
search: {
show: true,
},
form: {
component: {
placeholder: t("certd.cnameDomainPlaceholder"),
},
helper: t("certd.cnameDomainHelper"),
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 200,
},
},
dnsProviderType: {
title: t("certd.dnsProvider"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
url: "pi/dnsProvider/list",
value: "key",
label: "title",
}),
form: {
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 150,
component: {
color: "auto",
},
},
},
accessId: {
title: t("certd.dnsProviderAuthorization"),
type: "dict-select",
dict: dict({
url: "/pi/access/list",
value: "id",
label: "name",
}),
form: {
component: {
name: "access-selector",
vModel: "modelValue",
type: compute(({ form }) => {
return form.dnsProviderType;
}),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 150,
component: {
color: "auto",
},
},
},
isDefault: {
title: t("certd.isDefault"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.yes"), value: true, color: "success" },
{ label: t("certd.no"), value: false, color: "default" },
],
}),
form: {
value: false,
rules: [{ required: true, message: t("certd.selectIsDefault") }],
},
column: {
align: "center",
width: 100,
},
},
setDefault: {
title: t("certd.setDefault"),
type: "text",
form: {
show: false,
},
column: {
width: 100,
align: "center",
conditionalRenderDisabled: true,
cellRender: ({ row }) => {
if (row.isDefault) {
return;
}
const onClick = async () => {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmSetDefault"),
onOk: async () => {
await api.SetDefault(row.id);
await crudExpose.doRefresh();
},
});
};
return {
crudOptions: {
settings: {
plugins: {
//这里使用行选择插件,生成行选择crudOptions配置,最终会与crudOptions合并
rowSelection: {
enabled: true,
order: -2,
before: true,
// handle: (pluginProps,useCrudProps)=>CrudOptions,
props: {
multiple: true,
crossPage: true,
selectedRowKeys,
},
},
},
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
rowHandle: {
minWidth: 200,
fixed: "right",
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
column: {
width: 100,
},
form: {
show: false,
},
},
domain: {
title: t("certd.cnameDomain"),
type: "text",
editForm: {
component: {
disabled: true,
},
},
search: {
show: true,
},
form: {
component: {
placeholder: t("certd.cnameDomainPlaceholder"),
},
helper: t("certd.cnameDomainHelper"),
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 200,
},
},
dnsProviderType: {
title: t("certd.dnsProvider"),
type: "dict-select",
search: {
show: true,
},
dict: dict({
url: "pi/dnsProvider/list",
value: "key",
label: "title",
}),
form: {
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 150,
component: {
color: "auto",
},
},
},
accessId: {
title: t("certd.dnsProviderAuthorization"),
type: "dict-select",
dict: dict({
url: "/pi/access/list",
value: "id",
label: "name",
}),
form: {
component: {
name: "access-selector",
vModel: "modelValue",
type: compute(({ form }) => {
return form.dnsProviderType;
}),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 150,
component: {
color: "auto",
},
},
},
isDefault: {
title: t("certd.isDefault"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.yes"), value: true, color: "success" },
{ label: t("certd.no"), value: false, color: "default" },
],
}),
form: {
value: false,
rules: [{ required: true, message: t("certd.selectIsDefault") }],
},
column: {
align: "center",
width: 100,
},
},
setDefault: {
title: t("certd.setDefault"),
type: "text",
form: {
show: false,
},
column: {
width: 100,
align: "center",
conditionalRenderDisabled: true,
cellRender: ({ row }) => {
if (row.isDefault) {
return;
}
const onClick = async () => {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmSetDefault"),
onOk: async () => {
await api.SetDefault(row.id);
await crudExpose.doRefresh();
},
});
};
return (
<a-button type={"link"} size={"small"} onClick={onClick}>
{t("certd.setAsDefault")}
</a-button>
);
},
},
},
disabled: {
title: t("certd.disabled"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: false, color: "success" },
{ label: t("certd.disabledLabel"), value: true, color: "error" },
],
}),
form: {
value: false,
},
column: {
width: 100,
component: {
title: t("certd.clickToToggle"),
on: {
async click({ value, row }) {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmToggleStatus", { action: !value ? t("certd.disable") : t("certd.enable") }),
onOk: async () => {
await api.SetDisabled(row.id, !value);
await crudExpose.doRefresh();
},
});
},
},
},
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
width: 160,
},
},
}
}
};
return (
<a-button type={"link"} size={"small"} onClick={onClick}>
{t("certd.setAsDefault")}
</a-button>
);
},
},
},
disabled: {
title: t("certd.disabled"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.enabled"), value: false, color: "success" },
{ label: t("certd.disabledLabel"), value: true, color: "error" },
],
}),
form: {
value: false,
},
column: {
width: 100,
component: {
title: t("certd.clickToToggle"),
on: {
async click({ value, row }) {
Modal.confirm({
title: t("certd.prompt"),
content: t("certd.confirmToggleStatus", { action: !value ? t("certd.disable") : t("certd.enable") }),
onOk: async () => {
await api.SetDisabled(row.id, !value);
await crudExpose.doRefresh();
},
});
},
},
},
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
width: 160,
},
},
},
},
};
}
@@ -1,27 +1,26 @@
<template>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.cnameTitle") }}
<span class="sub">
{{ t("certd.cnameDescription") }}
<a href="https://certd.docmirror.cn/guide/feature/cname/" target="_blank">
{{ t("certd.cnameLinkText") }}
</a>
</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batchDelete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.cnameTitle") }}
<span class="sub">
{{ t("certd.cnameDescription") }}
<a href="https://certd.docmirror.cn/guide/feature/cname/" target="_blank">
{{ t("certd.cnameLinkText") }}
</a>
</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #pagination-left>
<a-tooltip :title="t('certd.batchDelete')">
<fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>
</a-tooltip>
</template>
</fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
import { onActivated, onMounted } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -33,35 +32,34 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "CnameProvider",
name: "CnameProvider",
});
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
const selectedRowKeys = context.selectedRowKeys;
const handleBatchDelete = () => {
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirmTitle"),
content: t("certd.confirmDeleteBatch", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.deleteSuccess"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.selectRecordsFirst"));
}
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirmTitle"),
content: t("certd.confirmDeleteBatch", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.deleteSuccess"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.selectRecordsFirst"));
}
};
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
onActivated(async () => {
await crudExpose.doRefresh();
await crudExpose.doRefresh();
});
</script>
<style lang="less"></style>
@@ -3,6 +3,6 @@ import { request } from "/@/api/service";
export async function GetStatisticCount() {
return await request({
url: "/sys/statistic/count",
method: "POST"
method: "POST",
});
}
@@ -57,7 +57,7 @@ import { GetStatisticCount } from "./api";
const count: Ref = ref({});
function transformCountPerDayToChartData(key: string) {
count.value[key] = count.value[key].map((item:any) => {
count.value[key] = count.value[key].map((item: any) => {
return {
name: item.date,
value: item.count,
File diff suppressed because it is too large Load Diff
@@ -15,7 +15,7 @@ script: |
accessKeyId = '';
secretAccessKey = '';
}
return {
AliyunClient
}
@@ -1,22 +1,21 @@
<template>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.pluginManagement") }}
<span class="sub">{{ t("certd.pluginBetaWarning") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<!-- <template #pagination-left>-->
<!-- <a-tooltip :title="t('certd.batchDelete')">-->
<!-- <fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>-->
<!-- </a-tooltip>-->
<!-- </template>-->
</fs-crud>
</fs-page>
<fs-page class="page-cert">
<template #header>
<div class="title">
{{ t("certd.pluginManagement") }}
<span class="sub">{{ t("certd.pluginBetaWarning") }}</span>
</div>
</template>
<fs-crud ref="crudRef" v-bind="crudBinding">
<!-- <template #pagination-left>-->
<!-- <a-tooltip :title="t('certd.batchDelete')">-->
<!-- <fs-button icon="DeleteOutlined" @click="handleBatchDelete"></fs-button>-->
<!-- </a-tooltip>-->
<!-- </template>-->
</fs-crud>
</fs-page>
</template>
<script lang="ts" setup>
import { onActivated, onMounted } from "vue";
import { useFs } from "@fast-crud/fast-crud";
@@ -28,36 +27,35 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "SysPlugin",
name: "SysPlugin",
});
const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions });
onActivated(async () => {
await crudExpose.doRefresh();
await crudExpose.doRefresh();
});
const selectedRowKeys = context.selectedRowKeys;
const handleBatchDelete = () => {
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.batchDeleteConfirm", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.deleteSuccess"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.pleaseSelectRecord"));
}
if (selectedRowKeys.value?.length > 0) {
Modal.confirm({
title: t("certd.confirm"),
content: t("certd.batchDeleteConfirm", { count: selectedRowKeys.value.length }),
async onOk() {
await DeleteBatch(selectedRowKeys.value);
message.info(t("certd.deleteSuccess"));
crudExpose.doRefresh();
selectedRowKeys.value = [];
},
});
} else {
message.error(t("certd.pleaseSelectRecord"));
}
};
// 页面打开后获取列表数据
onMounted(() => {
crudExpose.doRefresh();
crudExpose.doRefresh();
});
</script>
<style lang="less"></style>
@@ -103,4 +103,3 @@ export async function GetSmsTypeDefine(type: string) {
},
});
}
@@ -6,7 +6,7 @@ export async function TestSend(receiver: string) {
url: apiPrefix + "/test",
method: "post",
data: {
receiver
}
receiver,
},
});
}
@@ -1,86 +1,75 @@
<template>
<fs-page class="page-setting-email">
<template #header>
<div class="title">
{{ t('certd.emailServerSettings') }}
<span class="sub">{{ t('certd.setEmailSendingServer') }}</span>
</div>
</template>
<fs-page class="page-setting-email">
<template #header>
<div class="title">
{{ t("certd.emailServerSettings") }}
<span class="sub">{{ t("certd.setEmailSendingServer") }}</span>
</div>
</template>
<div class="flex-o">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off" class="email-form-box" @finish="onFinish" @finish-failed="onFinishFailed">
<div v-if="!formState.usePlus" class="email-form">
<a-form-item :label="t('certd.useCustomEmailServer')"> </a-form-item>
<a-form-item :label="t('certd.smtpDomain')" name="host"
:rules="[{ required: true, message: t('certd.pleaseEnterSmtpDomain') }]">
<a-input v-model:value="formState.host" />
</a-form-item>
<div class="flex-o">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" class="email-form-box" @finish="onFinish" @finish-failed="onFinishFailed">
<div v-if="!formState.usePlus" class="email-form">
<a-form-item :label="t('certd.useCustomEmailServer')"> </a-form-item>
<a-form-item :label="t('certd.smtpDomain')" name="host" :rules="[{ required: true, message: t('certd.pleaseEnterSmtpDomain') }]">
<a-input v-model:value="formState.host" />
</a-form-item>
<a-form-item :label="t('certd.smtpPort')" name="port"
:rules="[{ required: true, message: t('certd.pleaseEnterSmtpPort') }]">
<a-input v-model:value="formState.port" />
</a-form-item>
<a-form-item :label="t('certd.smtpPort')" name="port" :rules="[{ required: true, message: t('certd.pleaseEnterSmtpPort') }]">
<a-input v-model:value="formState.port" />
</a-form-item>
<a-form-item :label="t('certd.username')" :name="['auth', 'user']"
:rules="[{ required: true, message: t('certd.pleaseEnterUsername') }]">
<a-input v-model:value="formState.auth.user" />
</a-form-item>
<a-form-item :label="t('certd.password')" :name="['auth', 'pass']"
:rules="[{ required: true, message: t('certd.pleaseEnterPassword') }]">
<a-input-password v-model:value="formState.auth.pass" />
<div class="helper">{{ t('certd.qqEmailAuthCodeHelper') }}</div>
</a-form-item>
<a-form-item :label="t('certd.senderEmail')" name="sender"
:rules="[{ required: true, message: t('certd.pleaseEnterSenderEmail') }]">
<a-input v-model:value="formState.sender" />
</a-form-item>
<a-form-item :label="t('certd.useSsl')" name="secure">
<a-switch v-model:checked="formState.secure" />
<div class="helper">{{ t('certd.sslPortNote') }}</div>
</a-form-item>
<a-form-item :label="t('certd.ignoreCertValidation')" :name="['tls', 'rejectUnauthorized']">
<a-switch v-model:checked="formState.tls.rejectUnauthorized" />
</a-form-item>
<a-form-item :label="t('certd.username')" :name="['auth', 'user']" :rules="[{ required: true, message: t('certd.pleaseEnterUsername') }]">
<a-input v-model:value="formState.auth.user" />
</a-form-item>
<a-form-item :label="t('certd.password')" :name="['auth', 'pass']" :rules="[{ required: true, message: t('certd.pleaseEnterPassword') }]">
<a-input-password v-model:value="formState.auth.pass" />
<div class="helper">{{ t("certd.qqEmailAuthCodeHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.senderEmail')" name="sender" :rules="[{ required: true, message: t('certd.pleaseEnterSenderEmail') }]">
<a-input v-model:value="formState.sender" />
</a-form-item>
<a-form-item :label="t('certd.useSsl')" name="secure">
<a-switch v-model:checked="formState.secure" />
<div class="helper">{{ t("certd.sslPortNote") }}</div>
</a-form-item>
<a-form-item :label="t('certd.ignoreCertValidation')" :name="['tls', 'rejectUnauthorized']">
<a-switch v-model:checked="formState.tls.rejectUnauthorized" />
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button type="primary" html-type="submit">{{ t('certd.save') }}</a-button>
</a-form-item>
</div>
<div class="email-form">
<a-form-item :label="t('certd.useOfficialEmailServer')" name="usePlus">
<div class="flex-o">
<a-switch v-model:checked="formState.usePlus" :disabled="!settingStore.isPlus"
@change="onUsePlusChanged" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t('certd.useOfficialEmailServerHelper') }}</div>
</a-form-item>
</div>
</a-form>
</div>
<div class="email-form">
<a-form :model="testFormState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off" @finish="onTestSend">
<a-form-item :label="t('certd.testReceiverEmail')" name="receiver"
:rules="[{ required: true, message: t('certd.pleaseEnterTestReceiverEmail') }]">
<a-input v-model:value="testFormState.receiver" />
<div class="helper">{{ t('certd.saveBeforeTest') }}</div>
<div class="helper">{{ t('certd.sendFailHelpDoc') }}<a
href="https://certd.docmirror.cn/guide/use/email/" target="_blank">{{
t('certd.emailConfigHelpDoc') }}</a></div>
<div class="helper">{{ t('certd.tryOfficialEmailServer') }}</div>
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button type="primary" :loading="testFormState.loading" html-type="submit">{{ t('certd.test')
}}</a-button>
</a-form-item>
</a-form>
</div>
</fs-page>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button type="primary" html-type="submit">{{ t("certd.save") }}</a-button>
</a-form-item>
</div>
<div class="email-form">
<a-form-item :label="t('certd.useOfficialEmailServer')" name="usePlus">
<div class="flex-o">
<a-switch v-model:checked="formState.usePlus" :disabled="!settingStore.isPlus" @change="onUsePlusChanged" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t("certd.useOfficialEmailServerHelper") }}</div>
</a-form-item>
</div>
</a-form>
</div>
<div class="email-form">
<a-form :model="testFormState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onTestSend">
<a-form-item :label="t('certd.testReceiverEmail')" name="receiver" :rules="[{ required: true, message: t('certd.pleaseEnterTestReceiverEmail') }]">
<a-input v-model:value="testFormState.receiver" />
<div class="helper">{{ t("certd.saveBeforeTest") }}</div>
<div class="helper">
{{ t("certd.sendFailHelpDoc") }}<a href="https://certd.docmirror.cn/guide/use/email/" target="_blank">{{ t("certd.emailConfigHelpDoc") }}</a>
</div>
<div class="helper">{{ t("certd.tryOfficialEmailServer") }}</div>
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button type="primary" :loading="testFormState.loading" html-type="submit">{{ t("certd.test") }}</a-button>
</a-form-item>
</a-form>
</div>
</fs-page>
</template>
<script setup lang="ts">
import { reactive } from "vue";
import * as api from "../api";
@@ -92,98 +81,96 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "EmailSetting",
name: "EmailSetting",
});
interface FormState {
host: string;
port: number;
auth: {
user: string;
pass: string;
};
secure: boolean; // use TLS
tls: {
// do not fail on invalid certs
rejectUnauthorized?: boolean;
};
sender: string;
usePlus: boolean;
host: string;
port: number;
auth: {
user: string;
pass: string;
};
secure: boolean; // use TLS
tls: {
// do not fail on invalid certs
rejectUnauthorized?: boolean;
};
sender: string;
usePlus: boolean;
}
const formState = reactive<Partial<FormState>>({
auth: {
user: "",
pass: "",
},
tls: {},
usePlus: false,
auth: {
user: "",
pass: "",
},
tls: {},
usePlus: false,
});
async function load() {
const data: any = await api.EmailSettingsGet();
_.merge(formState, data);
const data: any = await api.EmailSettingsGet();
_.merge(formState, data);
}
load();
const onFinish = async (form: any) => {
console.log("Success:", form);
await api.EmailSettingsSave(form);
notification.success({
message: t("certd.saveSuccess"),
});
console.log("Success:", form);
await api.EmailSettingsSave(form);
notification.success({
message: t("certd.saveSuccess"),
});
};
const onFinishFailed = (errorInfo: any) => {
// console.log("Failed:", errorInfo);
// console.log("Failed:", errorInfo);
};
async function onUsePlusChanged() {
await api.EmailSettingsSave(formState);
await api.EmailSettingsSave(formState);
}
interface TestFormState {
receiver: string;
loading: boolean;
receiver: string;
loading: boolean;
}
const testFormState = reactive<TestFormState>({
receiver: "",
loading: false,
receiver: "",
loading: false,
});
async function onTestSend() {
testFormState.loading = true;
try {
await emailApi.TestSend(testFormState.receiver);
notification.success({
message: t("certd.sendSuccess"),
});
} finally {
testFormState.loading = false;
}
testFormState.loading = true;
try {
await emailApi.TestSend(testFormState.receiver);
notification.success({
message: t("certd.sendSuccess"),
});
} finally {
testFormState.loading = false;
}
}
const settingStore = useSettingStore();
</script>
<style lang="less">
.page-setting-email {
.email-form-box {
display: flex;
}
.email-form-box {
display: flex;
}
.email-form {
width: 500px;
margin: 20px;
}
.email-form {
width: 500px;
margin: 20px;
}
.helper {
padding: 1px;
margin: 0px;
color: #999;
font-size: 10px;
}
.helper {
padding: 1px;
margin: 0px;
color: #999;
font-size: 10px;
}
}
</style>
@@ -33,13 +33,13 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
records: records,
total: records.length,
limit: 9999999,
offset: 0
offset: 0,
};
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
let found: any = undefined;
utils.tree.eachTree(settingStore.headerMenus?.menus || [], (item) => {
utils.tree.eachTree(settingStore.headerMenus?.menus || [], item => {
if (item.id === row.id) {
merge(item, form);
found = item;
@@ -49,7 +49,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
return found;
};
const delRequest = async ({ row }: DelReq) => {
utils.tree.eachTree([{ children: settingStore.headerMenus?.menus }], (item) => {
utils.tree.eachTree([{ children: settingStore.headerMenus?.menus }], item => {
if (item.children) {
remove(item.children, (child: any) => child.id === row.id);
}
@@ -60,7 +60,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
const addRequest = async ({ form }: AddReq) => {
form.id = nanoid();
if (form.parentId) {
utils.tree.eachTree(settingStore.headerMenus?.menus || [], (item) => {
utils.tree.eachTree(settingStore.headerMenus?.menus || [], item => {
if (item.id === form.parentId) {
if (!item.children) {
item.children = [];
@@ -81,10 +81,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
pageRequest,
addRequest,
editRequest,
delRequest
delRequest,
},
search: {
show: false
show: false,
},
table: {
expandRowByClick: true,
@@ -92,7 +92,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
expandedRowKeys: expandedRowKeys,
"onUpdate:expandedRowKeys": (val: string[]) => {
expandedRowKeys.value = val;
}
},
},
pagination: { show: false, pageSize: 9999999 },
rowHandle: {
@@ -107,12 +107,12 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
click: ({ row }) => {
crudExpose.openAdd({
row: {
parentId: row.id
}
parentId: row.id,
},
});
}
}
}
},
},
},
},
columns: {
id: {
@@ -121,26 +121,26 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
type: "text",
column: {
width: 200,
show: false
show: false,
},
form: {
show: false
}
show: false,
},
},
title: {
title: "菜单标题",
type: "text",
column: {
width: 300
width: 300,
},
form: {
rules: [
{
required: true,
message: "请输入标题"
}
]
}
message: "请输入标题",
},
],
},
},
icon: {
title: "图标",
@@ -149,34 +149,34 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
width: 300,
cellRender: ({ row }) => {
return <fs-icon class={"fs-16"} icon={row.icon}></fs-icon>;
}
},
},
form: {
component: {
placeholder: "ion:add-circle"
}
}
placeholder: "ion:add-circle",
},
},
},
path: {
title: "链接",
type: "link",
column: {
width: 300
width: 300,
},
form: {
rules: [
{
required: true,
message: "请输入链接"
message: "请输入链接",
},
{
type: "url",
message: "请输入正确的链接"
}
]
}
}
}
}
message: "请输入正确的链接",
},
],
},
},
},
},
};
}
@@ -1,59 +1,54 @@
<template>
<div class="sys-settings-form sys-settings-base">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off"
@finish="onFinish" @finish-failed="onFinishFailed">
<a-form-item :label="t('certd.icpRegistrationNumber')" :name="['public', 'icpNo']">
<a-input v-model:value="formState.public.icpNo" :placeholder="t('certd.icpPlaceholder')" />
</a-form-item>
<a-form-item :label="t('certd.publicSecurityRegistrationNumber')" :name="['public', 'mpsNo']">
<a-input v-model:value="formState.public.mpsNo" :placeholder="t('certd.publicSecurityPlaceholder')" />
</a-form-item>
<div class="sys-settings-form sys-settings-base">
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish" @finish-failed="onFinishFailed">
<a-form-item :label="t('certd.icpRegistrationNumber')" :name="['public', 'icpNo']">
<a-input v-model:value="formState.public.icpNo" :placeholder="t('certd.icpPlaceholder')" />
</a-form-item>
<a-form-item :label="t('certd.publicSecurityRegistrationNumber')" :name="['public', 'mpsNo']">
<a-input v-model:value="formState.public.mpsNo" :placeholder="t('certd.publicSecurityPlaceholder')" />
</a-form-item>
<a-form-item :label="t('certd.enableAssistant')" :name="['public', 'aiChatEnabled']">
<a-switch v-model:checked="formState.public.aiChatEnabled" />
</a-form-item>
<a-form-item :label="t('certd.allowCrawlers')" :name="['public', 'robots']">
<a-switch v-model:checked="formState.public.robots" />
</a-form-item>
<a-form-item :label="t('certd.enableAssistant')" :name="['public', 'aiChatEnabled']">
<a-switch v-model:checked="formState.public.aiChatEnabled" />
</a-form-item>
<a-form-item :label="t('certd.allowCrawlers')" :name="['public', 'robots']">
<a-switch v-model:checked="formState.public.robots" />
</a-form-item>
<a-form-item :label="t('certd.httpProxy')" :name="['private', 'httpProxy']" :rules="urlRules">
<a-input v-model:value="formState.private.httpProxy" :placeholder="t('certd.httpProxyPlaceholder')" />
<div class="helper">{{ t('certd.httpProxyHelper') }}</div>
</a-form-item>
<a-form-item :label="t('certd.httpProxy')" :name="['private', 'httpProxy']" :rules="urlRules">
<a-input v-model:value="formState.private.httpProxy" :placeholder="t('certd.httpProxyPlaceholder')" />
<div class="helper">{{ t("certd.httpProxyHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.httpsProxy')" :name="['private', 'httpsProxy']" :rules="urlRules">
<div class="flex">
<a-input v-model:value="formState.private.httpsProxy"
:placeholder="t('certd.httpsProxyPlaceholder')" />
<a-button class="ml-5" type="primary" :loading="testProxyLoading"
:title="t('certd.saveThenTestTitle')" @click="testProxy">{{ t('certd.testButton') }}</a-button>
</div>
<div class="helper">{{ t('certd.httpsProxyHelper') }}</div>
</a-form-item>
<a-form-item :label="t('certd.httpsProxy')" :name="['private', 'httpsProxy']" :rules="urlRules">
<div class="flex">
<a-input v-model:value="formState.private.httpsProxy" :placeholder="t('certd.httpsProxyPlaceholder')" />
<a-button class="ml-5" type="primary" :loading="testProxyLoading" :title="t('certd.saveThenTestTitle')" @click="testProxy">{{ t("certd.testButton") }}</a-button>
</div>
<div class="helper">{{ t("certd.httpsProxyHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.dualStackNetwork')" :name="['private', 'dnsResultOrder']">
<a-select v-model:value="formState.private.dnsResultOrder">
<a-select-option value="verbatim">{{ t('certd.default') }}</a-select-option>
<a-select-option value="ipv4first">{{ t('certd.ipv4Priority') }}</a-select-option>
<a-select-option value="ipv6first">{{ t('certd.ipv6Priority') }}</a-select-option>
</a-select>
<div class="helper">{{ t('certd.dualStackNetworkHelper') }}</div>
</a-form-item>
<a-form-item :label="t('certd.dualStackNetwork')" :name="['private', 'dnsResultOrder']">
<a-select v-model:value="formState.private.dnsResultOrder">
<a-select-option value="verbatim">{{ t("certd.default") }}</a-select-option>
<a-select-option value="ipv4first">{{ t("certd.ipv4Priority") }}</a-select-option>
<a-select-option value="ipv6first">{{ t("certd.ipv6Priority") }}</a-select-option>
</a-select>
<div class="helper">{{ t("certd.dualStackNetworkHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.enableCommonCnameService')" :name="['private', 'commonCnameEnabled']">
<a-switch v-model:checked="formState.private.commonCnameEnabled" />
<div class="helper" v-html="t('certd.commonCnameHelper')"></div>
</a-form-item>
<a-form-item :label="t('certd.enableCommonCnameService')" :name="['private', 'commonCnameEnabled']">
<a-switch v-model:checked="formState.private.commonCnameEnabled" />
<div class="helper" v-html="t('certd.commonCnameHelper')"></div>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t('certd.saveButton')
}}</a-button>
</a-form-item>
</a-form>
</div>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t("certd.saveButton") }}</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script setup lang="tsx">
import { reactive, ref } from "vue";
import { SysSettings } from "/@/views/sys/settings/api";
@@ -67,89 +62,92 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "SettingBase",
name: "SettingBase",
});
const formState = reactive<Partial<SysSettings>>({
public: {
icpNo: "",
mpsNo: "",
},
private: {},
public: {
icpNo: "",
mpsNo: "",
},
private: {},
});
const urlRules = ref({
type: "url",
message: "请输入正确的URL",
type: "url",
message: "请输入正确的URL",
});
async function loadSysSettings() {
const data: any = await api.SysSettingsGet();
merge(formState, data);
const data: any = await api.SysSettingsGet();
merge(formState, data);
}
const saveLoading = ref(false);
loadSysSettings();
const settingsStore = useSettingStore();
const onFinish = async (form: any) => {
try {
saveLoading.value = true;
await api.SysSettingsSave(form);
await settingsStore.loadSysSettings();
notification.success({
message: t('certd.saveSuccess'),
});
} finally {
saveLoading.value = false;
}
try {
saveLoading.value = true;
await api.SysSettingsSave(form);
await settingsStore.loadSysSettings();
notification.success({
message: t("certd.saveSuccess"),
});
} finally {
saveLoading.value = false;
}
};
const onFinishFailed = (errorInfo: any) => {
// console.log("Failed:", errorInfo);
// console.log("Failed:", errorInfo);
};
async function stopOtherUserTimer() {
await api.stopOtherUserTimer();
notification.success({
message: t('certd.stopSuccess'),
});
await api.stopOtherUserTimer();
notification.success({
message: t("certd.stopSuccess"),
});
}
const testProxyLoading = ref(false);
async function testProxy() {
testProxyLoading.value = true;
try {
const res = await api.TestProxy();
let success = true;
if (res.google !== true || res.baidu !== true) {
success = false;
}
const content = () => {
return (
<div>
<div>{t('certd.google')}: {res.google === true ? t('certd.success') : util.maxLength(res.google)}</div>
<div>{t('certd.baidu')}: {res.baidu === true ? t('certd.success') : util.maxLength(res.baidu)}</div>
</div>
);
};
if (!success) {
notification.error({
message: t('certd.testFailed'),
description: content,
});
return;
}
notification.success({
message: t('certd.testCompleted'),
description: content,
});
} finally {
testProxyLoading.value = false;
}
testProxyLoading.value = true;
try {
const res = await api.TestProxy();
let success = true;
if (res.google !== true || res.baidu !== true) {
success = false;
}
const content = () => {
return (
<div>
<div>
{t("certd.google")}: {res.google === true ? t("certd.success") : util.maxLength(res.google)}
</div>
<div>
{t("certd.baidu")}: {res.baidu === true ? t("certd.success") : util.maxLength(res.baidu)}
</div>
</div>
);
};
if (!success) {
notification.error({
message: t("certd.testFailed"),
description: content,
});
return;
}
notification.success({
message: t("certd.testCompleted"),
description: content,
});
} finally {
testProxyLoading.value = false;
}
}
</script>
<style lang="less">
.sys-settings-base {}
.sys-settings-base {
}
</style>
@@ -42,23 +42,23 @@ import { notification } from "ant-design-vue";
import { request } from "/@/api/service";
defineOptions({
name: "SettingPayment"
name: "SettingPayment",
});
const api = {
async SettingGet() {
return await request({
url: "/sys/settings/payment/get",
method: "post"
method: "post",
});
},
async SettingSave(data: any) {
return await request({
url: "/sys/settings/payment/save",
method: "post",
data
data,
});
}
},
};
const formRef = ref<any>(null);
@@ -76,7 +76,7 @@ const formState = reactive<
>({
yizhifu: { enabled: false },
alipay: { enabled: false },
wxpay: { enabled: false }
wxpay: { enabled: false },
});
async function loadSettings() {
@@ -90,7 +90,7 @@ const onClick = async () => {
await api.SettingSave(form);
await loadSettings();
notification.success({
message: "保存成功"
message: "保存成功",
});
};
</script>
@@ -1,78 +1,69 @@
<template>
<div class="sys-settings-form sys-settings-register">
<a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off" @finish="onFinish">
<a-form-item :label="t('certd.manageOtherUserPipeline')" :name="['public', 'managerOtherUserPipeline']">
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
</a-form-item>
<a-form-item :label="t('certd.limitUserPipelineCount')" :name="['public', 'limitUserPipelineCount']">
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
<div class="helper">{{ t('certd.limitUserPipelineCountHelper') }}</div>
</a-form-item>
<a-form-item :label="t('certd.enableSelfRegistration')" :name="['public', 'registerEnabled']">
<a-switch v-model:checked="formState.public.registerEnabled" />
</a-form-item>
<a-form-item :label="t('certd.enableUserValidityPeriod')" :name="['public', 'userValidTimeEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.userValidTimeEnabled"
:disabled="!settingsStore.isPlus" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t('certd.userValidityPeriodHelper') }}</div>
</a-form-item>
<template v-if="formState.public.registerEnabled">
<a-form-item :label="t('certd.enableUsernameRegistration')"
:name="['public', 'usernameRegisterEnabled']">
<a-switch v-model:checked="formState.public.usernameRegisterEnabled" />
</a-form-item>
<div class="sys-settings-form sys-settings-register">
<a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
<a-form-item :label="t('certd.manageOtherUserPipeline')" :name="['public', 'managerOtherUserPipeline']">
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
</a-form-item>
<a-form-item :label="t('certd.limitUserPipelineCount')" :name="['public', 'limitUserPipelineCount']">
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
<div class="helper">{{ t("certd.limitUserPipelineCountHelper") }}</div>
</a-form-item>
<a-form-item :label="t('certd.enableSelfRegistration')" :name="['public', 'registerEnabled']">
<a-switch v-model:checked="formState.public.registerEnabled" />
</a-form-item>
<a-form-item :label="t('certd.enableUserValidityPeriod')" :name="['public', 'userValidTimeEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.userValidTimeEnabled" :disabled="!settingsStore.isPlus" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">{{ t("certd.userValidityPeriodHelper") }}</div>
</a-form-item>
<template v-if="formState.public.registerEnabled">
<a-form-item :label="t('certd.enableUsernameRegistration')" :name="['public', 'usernameRegisterEnabled']">
<a-switch v-model:checked="formState.public.usernameRegisterEnabled" />
</a-form-item>
<a-form-item :label="t('certd.enableEmailRegistration')" :name="['public', 'emailRegisterEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.emailRegisterEnabled"
:disabled="!settingsStore.isPlus" :title="t('certd.proFeature')" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">
<router-link to="/sys/settings/email">{{ t('certd.emailServerSetup') }}</router-link>
</div>
</a-form-item>
<a-form-item :label="t('certd.enableSmsLoginRegister')" :name="['public', 'smsLoginEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.smsLoginEnabled" :disabled="!settingsStore.isComm"
:title="t('certd.commFeature')" />
<vip-button class="ml-5" mode="comm"></vip-button>
</div>
</a-form-item>
<template v-if="formState.public.smsLoginEnabled">
<a-form-item :label="t('certd.smsProvider')" :name="['private', 'sms', 'type']">
<a-select v-model:value="formState.private.sms.type" @change="smsTypeChange">
<a-select-option value="aliyun">{{ t('certd.aliyunSms') }}</a-select-option>
<a-select-option value="yfysms">{{ t('certd.yfySms') }}</a-select-option>
</a-select>
</a-form-item>
<template v-for="item of smsTypeDefineInputs" :key="item.simpleKey">
<fs-form-item v-model="formState.private.sms.config[item.simpleKey]"
:path="'private.sms.config' + item.key" :item="item" />
</template>
<a-form-item :label="t('certd.enableEmailRegistration')" :name="['public', 'emailRegisterEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.emailRegisterEnabled" :disabled="!settingsStore.isPlus" :title="t('certd.proFeature')" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">
<router-link to="/sys/settings/email">{{ t("certd.emailServerSetup") }}</router-link>
</div>
</a-form-item>
<a-form-item :label="t('certd.enableSmsLoginRegister')" :name="['public', 'smsLoginEnabled']">
<div class="flex-o">
<a-switch v-model:checked="formState.public.smsLoginEnabled" :disabled="!settingsStore.isComm" :title="t('certd.commFeature')" />
<vip-button class="ml-5" mode="comm"></vip-button>
</div>
</a-form-item>
<template v-if="formState.public.smsLoginEnabled">
<a-form-item :label="t('certd.smsProvider')" :name="['private', 'sms', 'type']">
<a-select v-model:value="formState.private.sms.type" @change="smsTypeChange">
<a-select-option value="aliyun">{{ t("certd.aliyunSms") }}</a-select-option>
<a-select-option value="yfysms">{{ t("certd.yfySms") }}</a-select-option>
</a-select>
</a-form-item>
<template v-for="item of smsTypeDefineInputs" :key="item.simpleKey">
<fs-form-item v-model="formState.private.sms.config[item.simpleKey]" :path="'private.sms.config' + item.key" :item="item" />
</template>
<a-form-item :label="t('certd.smsTest')">
<div class="flex">
<a-input v-model:value="testMobile" :placeholder="t('certd.testMobilePlaceholder')" />
<loading-button class="ml-5" :title="t('certd.saveThenTest')" type="primary"
:click="testSendSms">{{
t('certd.testButton') }}</loading-button>
</div>
<div class="helper">{{ t('certd.saveThenTest') }}</div>
</a-form-item>
</template>
</template>
<a-form-item :label="t('certd.smsTest')">
<div class="flex">
<a-input v-model:value="testMobile" :placeholder="t('certd.testMobilePlaceholder')" />
<loading-button class="ml-5" :title="t('certd.saveThenTest')" type="primary" :click="testSendSms">{{ t("certd.testButton") }}</loading-button>
</div>
<div class="helper">{{ t("certd.saveThenTest") }}</div>
</a-form-item>
</template>
</template>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t('certd.saveButton')
}}</a-button>
</a-form-item>
</a-form>
</div>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t("certd.saveButton") }}</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script setup lang="tsx">
@@ -87,122 +78,122 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "SettingRegister",
name: "SettingRegister",
});
const testMobile = ref("");
async function testSendSms() {
if (!testMobile.value) {
notification.error({
message: t('certd.enterTestMobile'),
});
return;
}
await api.TestSms({
mobile: testMobile.value,
});
notification.success({
message: t('certd.sendSuccess'),
});
if (!testMobile.value) {
notification.error({
message: t("certd.enterTestMobile"),
});
return;
}
await api.TestSms({
mobile: testMobile.value,
});
notification.success({
message: t("certd.sendSuccess"),
});
}
const formState = reactive<Partial<SysSettings>>({
public: {
registerEnabled: false,
},
private: {
sms: {
type: "aliyun",
config: {},
},
},
public: {
registerEnabled: false,
},
private: {
sms: {
type: "aliyun",
config: {},
},
},
});
const rules = {
leastOneLogin: {
validator: (rule: any, value: any) => {
if (!formState.public.passwordLoginEnabled && !formState.public.smsLoginEnabled) {
return Promise.reject(t('certd.atLeastOneLoginRequired'));
}
return Promise.resolve();
},
},
required: {
required: true,
trigger: "change",
message: t('certd.fieldRequired'),
},
leastOneLogin: {
validator: (rule: any, value: any) => {
if (!formState.public.passwordLoginEnabled && !formState.public.smsLoginEnabled) {
return Promise.reject(t("certd.atLeastOneLoginRequired"));
}
return Promise.resolve();
},
},
required: {
required: true,
trigger: "change",
message: t("certd.fieldRequired"),
},
};
async function smsTypeChange(value: string) {
if (formState.private?.sms?.config) {
formState.private.sms.config = {};
}
if (formState.private?.sms?.config) {
formState.private.sms.config = {};
}
await loadTypeDefine(value);
await loadTypeDefine(value);
}
const smsTypeDefineInputs: Ref = ref({});
async function loadTypeDefine(type: string) {
const define: any = await api.GetSmsTypeDefine(type);
const keys = Object.keys(define.input);
const inputs: any = {};
keys.forEach(key => {
const value = define.input[key];
value.simpleKey = key;
value.key = "private.sms.config." + key;
if (!value.component) {
value.component = {
name: "a-input",
};
}
if (!value.component.name) {
value.component.vModel = "value";
}
if (!value.rules) {
value.rules = [];
}
if (value.required) {
value.rules.push(rules.required);
}
const define: any = await api.GetSmsTypeDefine(type);
const keys = Object.keys(define.input);
const inputs: any = {};
keys.forEach(key => {
const value = define.input[key];
value.simpleKey = key;
value.key = "private.sms.config." + key;
if (!value.component) {
value.component = {
name: "a-input",
};
}
if (!value.component.name) {
value.component.vModel = "value";
}
if (!value.rules) {
value.rules = [];
}
if (value.required) {
value.rules.push(rules.required);
}
inputs[key] = define.input[key];
});
smsTypeDefineInputs.value = inputs;
inputs[key] = define.input[key];
});
smsTypeDefineInputs.value = inputs;
}
async function loadSysSettings() {
const data: any = await api.SysSettingsGet();
merge(formState, data);
if (data?.private.sms?.type) {
await loadTypeDefine(data.private.sms.type);
}
if (!settingsStore.isPlus) {
formState.public.userValidTimeEnabled = false;
formState.public.emailRegisterEnabled = false;
}
const data: any = await api.SysSettingsGet();
merge(formState, data);
if (data?.private.sms?.type) {
await loadTypeDefine(data.private.sms.type);
}
if (!settingsStore.isPlus) {
formState.public.userValidTimeEnabled = false;
formState.public.emailRegisterEnabled = false;
}
if (!settingsStore.isComm) {
formState.public.smsLoginEnabled = false;
}
if (!settingsStore.isComm) {
formState.public.smsLoginEnabled = false;
}
}
const saveLoading = ref(false);
loadSysSettings();
const settingsStore = useSettingStore();
const onFinish = async (form: any) => {
try {
saveLoading.value = true;
await api.SysSettingsSave(form);
await settingsStore.loadSysSettings();
notification.success({
message: t('certd.saveSuccess'),
});
} finally {
saveLoading.value = false;
}
try {
saveLoading.value = true;
await api.SysSettingsSave(form);
await settingsStore.loadSysSettings();
notification.success({
message: t("certd.saveSuccess"),
});
} finally {
saveLoading.value = false;
}
};
</script>
<style lang="less">
.sys-settings-site {}
.sys-settings-site {
}
</style>
@@ -1,63 +1,54 @@
<template>
<div class="sys-settings-form sys-settings-safe">
<a-form ref="formRef" :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
autocomplete="off">
<h2>{{ t('certd.siteHide') }}</h2>
<a-form-item :label="t('certd.enableSiteHide')" :name="['hidden', 'enabled']" :required="true">
<div class="flex">
<a-switch v-model:checked="formState.hidden.enabled" />
</div>
<div class="sys-settings-form sys-settings-safe">
<a-form ref="formRef" :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
<h2>{{ t("certd.siteHide") }}</h2>
<a-form-item :label="t('certd.enableSiteHide')" :name="['hidden', 'enabled']" :required="true">
<div class="flex">
<a-switch v-model:checked="formState.hidden.enabled" />
</div>
<div class="helper">
{{ t('certd.siteHideDescription') }}
<a href="https://certd.docmirror.cn/guide/feature/safe/hidden" class="flex items-center"
target="_blank">
<span>{{ t('certd.helpDoc') }}</span>
<fs-icon class="ml-1" icon="mingcute:question-line"></fs-icon></a>
</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.randomAddress')"
:name="['hidden', 'openPath']" :required="true">
<a-input-search v-model:value="formState.hidden.openPath" :allow-clear="true" @search="changeOpenPath">
<template #enterButton>
<fs-icon icon="ion:refresh"></fs-icon>
</template>
</a-input-search>
<div class="helper">{{ t('certd.siteHideUrlHelper') }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.fullUnlockUrl')"
:name="['hidden', 'openPath']" :required="true">
<div class="flex"><fs-copyable v-model="openUrl" class="flex-inline"></fs-copyable></div>
<div class="helper red">{{ t('certd.saveThisUrl') }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.unlockPassword')"
:name="['hidden', 'openPassword']" :required="false">
<a-input-password v-model:value="formState.hidden.openPassword" :allow-clear="true" />
<div class="helper">{{ t('certd.unlockPasswordHelper') }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.autoHideTime')"
:name="['hidden', 'autoHiddenTimes']" :required="true">
<a-input-number v-model:value="formState.hidden.autoHiddenTimes" :allow-clear="true" />
<div class="helper">{{ t('certd.autoHideTimeHelper') }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideOpenApi')"
:name="['hidden', 'hiddenOpenApi']" :required="true">
<a-switch v-model:checked="formState.hidden.hiddenOpenApi" />
<div class="helper">{{ t('certd.hideOpenApiHelper') }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideSiteImmediately')">
<loading-button class="ml-1" type="primary" html-type="button" :click="doHiddenImmediate">{{
t('certd.hideImmediately') }}</loading-button>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<loading-button type="primary" html-type="button" :click="onClick">{{ t('certd.save')
}}</loading-button>
</a-form-item>
</a-form>
</div>
<div class="helper">
{{ t("certd.siteHideDescription") }}
<a href="https://certd.docmirror.cn/guide/feature/safe/hidden" class="flex items-center" target="_blank">
<span>{{ t("certd.helpDoc") }}</span>
<fs-icon class="ml-1" icon="mingcute:question-line"></fs-icon
></a>
</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.randomAddress')" :name="['hidden', 'openPath']" :required="true">
<a-input-search v-model:value="formState.hidden.openPath" :allow-clear="true" @search="changeOpenPath">
<template #enterButton>
<fs-icon icon="ion:refresh"></fs-icon>
</template>
</a-input-search>
<div class="helper">{{ t("certd.siteHideUrlHelper") }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.fullUnlockUrl')" :name="['hidden', 'openPath']" :required="true">
<div class="flex"><fs-copyable v-model="openUrl" class="flex-inline"></fs-copyable></div>
<div class="helper red">{{ t("certd.saveThisUrl") }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.unlockPassword')" :name="['hidden', 'openPassword']" :required="false">
<a-input-password v-model:value="formState.hidden.openPassword" :allow-clear="true" />
<div class="helper">{{ t("certd.unlockPasswordHelper") }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.autoHideTime')" :name="['hidden', 'autoHiddenTimes']" :required="true">
<a-input-number v-model:value="formState.hidden.autoHiddenTimes" :allow-clear="true" />
<div class="helper">{{ t("certd.autoHideTimeHelper") }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideOpenApi')" :name="['hidden', 'hiddenOpenApi']" :required="true">
<a-switch v-model:checked="formState.hidden.hiddenOpenApi" />
<div class="helper">{{ t("certd.hideOpenApiHelper") }}</div>
</a-form-item>
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideSiteImmediately')">
<loading-button class="ml-1" type="primary" html-type="button" :click="doHiddenImmediate">{{ t("certd.hideImmediately") }}</loading-button>
</a-form-item>
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
<loading-button type="primary" html-type="button" :click="onClick">{{ t("certd.save") }}</loading-button>
</a-form-item>
</a-form>
</div>
</template>
<script setup lang="tsx">
import { computed, reactive, ref } from "vue";
import { merge } from "lodash-es";
@@ -69,105 +60,105 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
defineOptions({
name: "SettingSafe",
name: "SettingSafe",
});
const settingsStore = useSettingStore();
const api = {
async SettingGet() {
return await request({
url: "/sys/settings/safe/get",
method: "post",
});
},
async SettingSave(data: any) {
return await request({
url: "/sys/settings/safe/save",
method: "post",
data,
});
},
async HiddenImmediate() {
return await request({
url: "/sys/settings/safe/hidden",
method: "post",
});
},
async SettingGet() {
return await request({
url: "/sys/settings/safe/get",
method: "post",
});
},
async SettingSave(data: any) {
return await request({
url: "/sys/settings/safe/save",
method: "post",
data,
});
},
async HiddenImmediate() {
return await request({
url: "/sys/settings/safe/hidden",
method: "post",
});
},
};
const defaultState = {
hidden: {
enabled: false,
autoHiddenTimes: 5,
hiddenOpenApi: false,
},
hidden: {
enabled: false,
autoHiddenTimes: 5,
hiddenOpenApi: false,
},
};
const formRef = ref<any>(defaultState);
type SiteHidden = {
enabled: boolean;
openPath?: string;
autoHiddenTimes?: number;
openPassword?: string;
hiddenOpenApi?: boolean;
enabled: boolean;
openPath?: string;
autoHiddenTimes?: number;
openPassword?: string;
hiddenOpenApi?: boolean;
};
const formState = reactive<
Partial<{
hidden: SiteHidden;
}>
Partial<{
hidden: SiteHidden;
}>
>({
hidden: { enabled: false },
hidden: { enabled: false },
});
function changeOpenPath() {
formState.hidden.openPath = util.randomString(16);
formState.hidden.openPath = util.randomString(16);
}
async function loadSettings() {
const data: any = await api.SettingGet();
merge(formState, defaultState, formState, data);
if (!formState.hidden.openPath) {
changeOpenPath();
}
const data: any = await api.SettingGet();
merge(formState, defaultState, formState, data);
if (!formState.hidden.openPath) {
changeOpenPath();
}
}
loadSettings();
const openUrl = computed(() => {
const url = new URL(window.location.href);
url.pathname = `/api/unhidden/${formState.hidden?.openPath || ""}`;
//@ts-ignore
url.query = undefined;
url.hash = "";
return url.href;
const url = new URL(window.location.href);
url.pathname = `/api/unhidden/${formState.hidden?.openPath || ""}`;
//@ts-ignore
url.query = undefined;
url.hash = "";
return url.href;
});
const onClick = async () => {
const form = await formRef.value.validateFields();
//md5
// if (form.hidden?.openPassword) {
// form.hidden.openPassword = util.hash.md5(form.hidden.openPassword);
// }
await api.SettingSave(form);
await loadSettings();
notification.success({
message: t('certd.saveSuccess'),
});
const form = await formRef.value.validateFields();
//md5
// if (form.hidden?.openPassword) {
// form.hidden.openPassword = util.hash.md5(form.hidden.openPassword);
// }
await api.SettingSave(form);
await loadSettings();
notification.success({
message: t("certd.saveSuccess"),
});
};
async function doHiddenImmediate() {
Modal.confirm({
title: t('certd.confirmHideSiteTitle'),
content: t('certd.confirmHideSiteContent'),
async onOk() {
await api.HiddenImmediate();
notification.success({
message: t('certd.siteHiddenSuccess'),
});
},
});
Modal.confirm({
title: t("certd.confirmHideSiteTitle"),
content: t("certd.confirmHideSiteContent"),
async onOk() {
await api.HiddenImmediate();
notification.success({
message: t("certd.siteHiddenSuccess"),
});
},
});
}
</script>
<style lang="less">
.sys-settings-base {}
.sys-settings-base {
}
</style>
@@ -5,7 +5,7 @@ const apiPrefix = "/sys/site";
export async function SettingsGet(key: string) {
return await request({
url: apiPrefix + "/get",
method: "post"
method: "post",
});
}
@@ -13,6 +13,6 @@ export async function SettingsSave(setting: any) {
await request({
url: apiPrefix + "/save",
method: "post",
data: setting
data: setting,
});
}
@@ -9,7 +9,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -17,7 +17,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -25,7 +25,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -33,7 +33,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -41,7 +41,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -49,7 +49,7 @@ export async function GetDetail(id: any) {
return await request({
url: apiPrefix + "/detail",
method: "post",
params: { id }
params: { id },
});
}
@@ -57,7 +57,7 @@ export async function DeleteBatch(ids: any[]) {
return await request({
url: apiPrefix + "/deleteByIds",
method: "post",
data: { ids }
data: { ids },
});
}
@@ -65,7 +65,7 @@ export async function SetDefault(id: any) {
return await request({
url: apiPrefix + "/setDefault",
method: "post",
data: { id }
data: { id },
});
}
@@ -73,6 +73,6 @@ export async function SetDisabled(id: any, disabled: boolean) {
return await request({
url: apiPrefix + "/setDisabled",
method: "post",
data: { id, disabled }
data: { id, disabled },
});
}
@@ -7,330 +7,316 @@ import DurationPriceValue from "/@/views/sys/suite/product/duration-price-value.
import { useI18n } from "vue-i18n";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const emit = context.emit;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const { t } = useI18n();
const emit = context.emit;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }: EditReq) => {
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async ({ row }: DelReq) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
const addRequest = async ({ form }: AddReq) => {
const res = await api.AddObj(form);
return res;
};
return {
crudOptions: {
table: {
onRefreshed: () => {
emit("refreshed");
}
},
search: {
show: false
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
pagination: {
show: false,
pageSize: 999999
},
rowHandle: {
minWidth: 200,
fixed: "right"
},
form: {
group: {
groups: {
base: {
header: t('certd.basicInfo'),
columns: [
t('certd.titlea'),
t('certd.type'),
t('certd.disabled'),
t('certd.ordera'),
t('certd.supportBuy'),
t('certd.intro')
]
},
content: {
header: t('certd.packageContent'),
columns: [
t('certd.maxDomainCount'),
t('certd.maxPipelineCount'),
t('certd.maxDeployCount'),
t('certd.maxMonitorCount')
]
},
price: {
header: t('certd.price'),
columns: [
t('certd.durationPrices')
]
}
}
}
}
columns: {
// id: {
// title: "ID",
// key: "id",
// type: "number",
// column: {
// width: 100
// },
// form: {
// show: false
// }
// },
title: {
title: t('certd.packageName'),
type: "text",
search: {
show: true
},
form: {
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
width: 200
}
},
type: {
title: t('certd.type'),
type: "dict-select",
editForm: {
component: {
disabled: true
}
},
dict: dict({
data: [
{ label: t('certd.suite'), value: "suite" },
{ label: t('certd.addon'), value: "addon" }
]
}),
form: {
value: "suite",
rules: [{ required: true, message: t('certd.requiredField') }],
helper: t('certd.typeHelper')
},
column: {
width: 80,
align: "center"
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
if (row.durationPrices) {
row.durationPrices = JSON.parse(row.durationPrices);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
if (form.durationPrices) {
form.durationPrices = JSON.stringify(form.durationPrices);
}
}
},
"content.maxDomainCount": {
title: t('certd.domainCount'),
type: "text",
form: {
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unitCount')
},
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unitCount')
}
}
},
"content.maxPipelineCount": {
title: t('certd.pipelineCount'),
type: "text",
form: {
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unitPipeline')
},
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unitPipeline')
}
}
},
"content.maxDeployCount": {
title: t('certd.deployCount'),
type: "text",
form: {
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unitDeploy')
},
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unitDeploy')
}
}
},
"content.maxMonitorCount": {
title: t('certd.monitorCount'),
type: "text",
form: {
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unitCount')
},
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unitCount')
}
}
},
durationPrices: {
title: t('certd.durationPriceTitle'),
type: "text",
form: {
title: t('certd.selectDuration'),
component: {
name: PriceEdit,
vModel: "modelValue",
edit: true,
style: {
minHeight: "120px"
}
},
col: {
span: 24
},
rules: [{ required: true, message: t('certd.requiredField') }]
},
column: {
component: {
name: DurationPriceValue,
vModel: "modelValue"
},
width: 350
}
},
supportBuy: {
title: t('certd.supportBuy'),
type: "dict-switch",
dict: dict({
data: [
{ label: t('certd.supportPurchase'), value: true, color: "success" },
{ label: t('certd.cannotPurchase'), value: false, color: "gray" }
]
}),
form: {
value: true
},
column: {
width: 120
}
},
disabled: {
title: t('certd.shelfStatus'),
type: "dict-radio",
dict: dict({
data: [
{ value: false, label: t('certd.onShelf'), color: "green" },
{ value: true, label: t('certd.offShelf'), color: "gray" }
]
}),
form: {
value: false
},
column: {
width: 100
}
},
order: {
title: t('certd.ordera'),
type: "number",
form: {
helper: t('certd.orderHelper'),
value: 0
},
column: {
width: 100
}
},
intro: {
title: t('certd.description'),
type: "textarea",
column: {
width: 200
}
},
createTime: {
title: t('certd.createTime'),
type: "datetime",
form: {
show: false
},
column: {
sorter: true,
width: 160,
align: "center"
}
},
updateTime: {
title: t('certd.updateTime'),
type: "datetime",
form: {
show: false
},
column: {
show: true,
width: 160
}
}
}
}
};
return {
crudOptions: {
table: {
onRefreshed: () => {
emit("refreshed");
},
},
search: {
show: false,
},
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
pagination: {
show: false,
pageSize: 999999,
},
rowHandle: {
minWidth: 200,
fixed: "right",
},
form: {
group: {
groups: {
base: {
header: t("certd.basicInfo"),
columns: [t("certd.titlea"), t("certd.type"), t("certd.disabled"), t("certd.ordera"), t("certd.supportBuy"), t("certd.intro")],
},
content: {
header: t("certd.packageContent"),
columns: [t("certd.maxDomainCount"), t("certd.maxPipelineCount"), t("certd.maxDeployCount"), t("certd.maxMonitorCount")],
},
price: {
header: t("certd.price"),
columns: [t("certd.durationPrices")],
},
},
},
},
columns: {
// id: {
// title: "ID",
// key: "id",
// type: "number",
// column: {
// width: 100
// },
// form: {
// show: false
// }
// },
title: {
title: t("certd.packageName"),
type: "text",
search: {
show: true,
},
form: {
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 200,
},
},
type: {
title: t("certd.type"),
type: "dict-select",
editForm: {
component: {
disabled: true,
},
},
dict: dict({
data: [
{ label: t("certd.suite"), value: "suite" },
{ label: t("certd.addon"), value: "addon" },
],
}),
form: {
value: "suite",
rules: [{ required: true, message: t("certd.requiredField") }],
helper: t("certd.typeHelper"),
},
column: {
width: 80,
align: "center",
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
if (row.durationPrices) {
row.durationPrices = JSON.parse(row.durationPrices);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
if (form.durationPrices) {
form.durationPrices = JSON.stringify(form.durationPrices);
}
},
},
"content.maxDomainCount": {
title: t("certd.domainCount"),
type: "text",
form: {
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unitCount"),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unitCount"),
},
},
},
"content.maxPipelineCount": {
title: t("certd.pipelineCount"),
type: "text",
form: {
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unitPipeline"),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unitPipeline"),
},
},
},
"content.maxDeployCount": {
title: t("certd.deployCount"),
type: "text",
form: {
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unitDeploy"),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unitDeploy"),
},
},
},
"content.maxMonitorCount": {
title: t("certd.monitorCount"),
type: "text",
form: {
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unitCount"),
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unitCount"),
},
},
},
durationPrices: {
title: t("certd.durationPriceTitle"),
type: "text",
form: {
title: t("certd.selectDuration"),
component: {
name: PriceEdit,
vModel: "modelValue",
edit: true,
style: {
minHeight: "120px",
},
},
col: {
span: 24,
},
rules: [{ required: true, message: t("certd.requiredField") }],
},
column: {
component: {
name: DurationPriceValue,
vModel: "modelValue",
},
width: 350,
},
},
supportBuy: {
title: t("certd.supportBuy"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.supportPurchase"), value: true, color: "success" },
{ label: t("certd.cannotPurchase"), value: false, color: "gray" },
],
}),
form: {
value: true,
},
column: {
width: 120,
},
},
disabled: {
title: t("certd.shelfStatus"),
type: "dict-radio",
dict: dict({
data: [
{ value: false, label: t("certd.onShelf"), color: "green" },
{ value: true, label: t("certd.offShelf"), color: "gray" },
],
}),
form: {
value: false,
},
column: {
width: 100,
},
},
order: {
title: t("certd.ordera"),
type: "number",
form: {
helper: t("certd.orderHelper"),
value: 0,
},
column: {
width: 100,
},
},
intro: {
title: t("certd.description"),
type: "textarea",
column: {
width: 200,
},
},
createTime: {
title: t("certd.createTime"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.updateTime"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
width: 160,
},
},
},
},
};
}
@@ -13,7 +13,7 @@ import PriceInput from "./price-input.vue";
import { durationDict } from "../../../certd/suite/api";
defineOptions({
name: "DurationPriceValue"
name: "DurationPriceValue",
});
const props = withDefaults(
@@ -23,7 +23,7 @@ const props = withDefaults(
{
modelValue: () => {
return [];
}
},
}
);
</script>
@@ -6,7 +6,7 @@
import { durationDict } from "/@/views/certd/suite/api";
defineOptions({
name: "DurationValue"
name: "DurationValue",
});
const props = defineProps<{
modelValue: number;
@@ -27,7 +27,7 @@ const props = withDefaults(
{
modelValue: () => {
return [];
}
},
}
);
@@ -41,14 +41,14 @@ function doEmit(value: PriceItem[]) {
}
function isActive(item: any) {
return props.modelValue.some((v) => v.duration === item.value);
return props.modelValue.some(v => v.duration === item.value);
}
function onDurationClicked(item: any) {
const has = props.modelValue.some((v) => v.duration === item.value);
const has = props.modelValue.some(v => v.duration === item.value);
if (has) {
// remove
const newValue = props.modelValue.filter((v) => v.duration !== item.value);
const newValue = props.modelValue.filter(v => v.duration !== item.value);
doEmit(newValue);
} else {
// add
@@ -72,7 +72,7 @@ function onDurationClicked(item: any) {
.duration-item {
border: 1px solid #eee;
padding: 2px;
width: 35px;
width: 45px;
text-align: center;
cursor: pointer;
@@ -24,13 +24,13 @@ const target = computed(() => {
return {
value: -1,
label: "无限制",
color: "green"
color: "green",
};
} else if (props.modelValue === 0) {
return {
value: 0,
label: "0" + (props.unit || ""),
color: "red"
color: "red",
};
} else {
let color = "blue";
@@ -40,7 +40,7 @@ const target = computed(() => {
return {
value: props.modelValue,
label: props.modelValue + (props.unit || ""),
color: color
color: color,
};
}
});
@@ -49,23 +49,23 @@ import ProductManager from "/@/views/sys/suite/product/index.vue";
import { useSettingStore } from "/@/store/settings";
defineOptions({
name: "SettingsSuite"
name: "SettingsSuite",
});
const api = {
async SuiteSettingGet() {
return await request({
url: "/sys/settings/suite/get",
method: "post"
method: "post",
});
},
async SuiteSettingSave(data: any) {
return await request({
url: "/sys/settings/suite/save",
method: "post",
data
data,
});
}
},
};
const formRef = ref<any>(null);
@@ -93,7 +93,7 @@ const onClick = async () => {
await loadSettings();
await settingsStore.loadSysSettings();
notification.success({
message: "保存成功"
message: "保存成功",
});
};
@@ -8,7 +8,7 @@ import { dict } from "@fast-crud/fast-crud";
import { request } from "/@/api/service";
defineOptions({
name: "SuiteDurationSelector"
name: "SuiteDurationSelector",
});
const props = defineProps<{
@@ -22,13 +22,13 @@ const suiteDictRef = dict({
async getData() {
const res = await request({
url: "/sys/suite/product/list",
method: "post"
method: "post",
});
const options: any = [
{
value: "",
label: "不赠送"
}
label: "不赠送",
},
];
res.forEach((item: any) => {
const durationPrices = JSON.parse(item.durationPrices);
@@ -39,13 +39,13 @@ const suiteDictRef = dict({
value: value,
target: {
productId: item.id,
duration: dp.duration
}
duration: dp.duration,
},
});
}
});
return options;
}
},
});
const selectedValue = ref();
@@ -53,7 +53,7 @@ watch(
() => {
return props.modelValue;
},
(value) => {
value => {
if (value && value.productId && value.duration) {
selectedValue.value = value.productId + "_" + value.duration;
} else {
@@ -61,7 +61,7 @@ watch(
}
},
{
immediate: true
immediate: true,
}
);
@@ -75,14 +75,14 @@ const onSelectedChange = (value: any) => {
const arr = value.value.split("_");
emit("update:modelValue", {
productId: parseInt(arr[0]),
duration: parseInt(arr[1])
duration: parseInt(arr[1]),
});
};
defineExpose({
refresh() {
suiteDictRef.reloadDict();
}
},
});
</script>
@@ -6,7 +6,7 @@ export async function GetList(query: any) {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
}
@@ -14,7 +14,7 @@ export async function AddObj(obj: any) {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
}
@@ -22,7 +22,7 @@ export async function UpdateObj(obj: any) {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
}
@@ -30,7 +30,7 @@ export async function DelObj(id: any) {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
}
@@ -38,7 +38,7 @@ export async function GetObj(id: any) {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
}
@@ -46,7 +46,7 @@ export async function GetDetail(id: any) {
return await request({
url: apiPrefix + "/detail",
method: "post",
params: { id }
params: { id },
});
}
@@ -54,7 +54,7 @@ export async function DeleteBatch(ids: any[]) {
return await request({
url: apiPrefix + "/deleteByIds",
method: "post",
data: { ids }
data: { ids },
});
}
@@ -62,7 +62,7 @@ export async function UpdatePaid(id: any) {
return await request({
url: apiPrefix + "/updatePaid",
method: "post",
data: { id }
data: { id },
});
}
@@ -70,6 +70,6 @@ export async function SyncStatus(id: any) {
return await request({
url: apiPrefix + "/syncStatus",
method: "post",
data: { id }
data: { id },
});
}
@@ -6,7 +6,7 @@ export const sysUserSuiteApi = {
return await request({
url: apiPrefix + "/page",
method: "post",
data: query
data: query,
});
},
@@ -14,7 +14,7 @@ export const sysUserSuiteApi = {
return await request({
url: apiPrefix + "/add",
method: "post",
data: obj
data: obj,
});
},
@@ -22,7 +22,7 @@ export const sysUserSuiteApi = {
return await request({
url: apiPrefix + "/update",
method: "post",
data: obj
data: obj,
});
},
@@ -30,7 +30,7 @@ export const sysUserSuiteApi = {
return await request({
url: apiPrefix + "/delete",
method: "post",
params: { id }
params: { id },
});
},
@@ -38,13 +38,13 @@ export const sysUserSuiteApi = {
return await request({
url: apiPrefix + "/info",
method: "post",
params: { id }
params: { id },
});
},
async ListAll() {
return await request({
url: apiPrefix + "/all",
method: "post"
method: "post",
});
},
@@ -52,14 +52,14 @@ export const sysUserSuiteApi = {
return await request({
url: "/sys/authority/user/getSimpleUserByIds",
method: "post",
data: { ids }
data: { ids },
});
},
async PresentSuite(form: any) {
return await request({
url: apiPrefix + "/presentSuite",
method: "post",
data: form
data: form,
});
}
},
};
@@ -8,397 +8,396 @@ import createCrudOptionsUser from "/@/views/sys/authority/user/crud";
import UserSuiteStatus from "/@/views/certd/suite/mine/user-suite-status.vue";
import SuiteDurationSelector from "../setting/suite-duration-selector.vue";
import dayjs from "dayjs";
import { useI18n } from "vue-i18n";
import { useI18n } from "/src/locales";
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
const { t } = useI18n();
const api = sysUserSuiteApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const { t } = useI18n();
const api = sysUserSuiteApi;
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
return await api.GetList(query);
};
const editRequest = async (req: EditReq) => {
const { form, row } = req;
form.id = row.id;
const res = await api.UpdateObj(form);
return res;
};
const delRequest = async (req: DelReq) => {
const { row } = req;
return await api.DelObj(row.id);
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.PresentSuite(form);
return res;
};
const addRequest = async (req: AddReq) => {
const { form } = req;
const res = await api.PresentSuite(form);
return res;
};
const router = useRouter();
const router = useRouter();
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px"
}
},
col: {
span: 22
},
wrapper: {
width: 600
}
},
actionbar: {
buttons: {
add: { text: t('certd.gift_package') }
}
},
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest,
},
form: {
labelCol: {
//固定label宽度
span: null,
style: {
width: "100px",
},
},
col: {
span: 22,
},
wrapper: {
width: 600,
},
},
actionbar: {
buttons: {
add: { text: t("certd.gift_package") },
},
},
toolbar: { show: false },
rowHandle: {
width: 200,
fixed: "right",
buttons: {
view: { show: true },
copy: { show: false },
edit: { show: false },
remove: { show: true }
// continue:{
// text:"续期",
// type:"link",
// click(){
// console.log("续期");
// }
// }
}
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false
},
column: {
width: 100,
editable: {
disabled: true
}
},
form: {
show: false
}
},
title: {
title: t('certd.package_name'),
type: "text",
search: {
show: true
},
form: {
show: false
},
column: {
width: 200
}
},
userId: {
title: t('certd.usera'),
type: "table-select",
search: {
show: true
},
dict: dict({
async getNodesByValues(ids: number[]) {
return await api.GetSimpleUserByIds(ids);
},
value: "id",
label: "nickName"
}),
form: {
component: {
crossPage: true,
multiple: false,
select: {
placeholder: t('certd.click_to_select')
},
createCrudOptions: createCrudOptionsUser
// crudOptionsOverride: crudOptionsOverride
}
}
},
//赠送
presentSuiteId: {
title: t('certd.gift_package'),
type: "dict-select",
column: { show: false },
addForm: {
show: true,
component: {
name: SuiteDurationSelector,
vModel: "modelValue"
},
rules: [
{
validator: async (rule, value) => {
if (value && value.productId) {
return true;
}
throw new Error(t('certd.please_select_package'));
}
}
]
},
valueResolve({ form, value }) {
if (value && value.productId) {
form.productId = value.productId;
form.duration = value.duration;
}
},
form: { show: false }
},
productType: {
title: t('certd.type'),
type: "dict-select",
editForm: {
component: {
disabled: true
}
},
dict: dict({
data: [
{ label: t('certd.package'), value: "suite", color: "green" },
{ label: t('certd.addon_package'), value: "addon", color: "blue" }
]
}),
form: {
show: false
},
column: {
width: 80,
align: "center"
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
}
},
"content.maxDomainCount": {
title: t('certd.domain_count'),
type: "text",
form: {
show: false,
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unit_count')
},
rules: [{ required: true, message: t('certd.field_required') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unit_count')
},
align: "center"
}
},
"content.maxPipelineCount": {
title: t('certd.pipeline_count'),
type: "text",
form: {
show: false,
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unit_item')
},
rules: [{ required: true, message: t('certd.field_required') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unit_item')
},
align: "center"
}
},
"content.maxDeployCount": {
title: t('certd.deploy_count'),
type: "text",
form: {
show: false,
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unit_times')
},
rules: [{ required: true, message: t('certd.field_required') }]
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unit_times'),
used: compute(({ row }) => {
return row.deployCountUsed;
})
},
align: "center"
}
},
"content.maxMonitorCount": {
title: t('certd.monitor_count'),
type: "text",
form: {
show: false,
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t('certd.unit_count')
},
rules: [{ required: true, message: t('certd.field_required') }]
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t('certd.unit_count')
},
align: "center"
}
},
duration: {
title: t('certd.duration'),
type: "text",
form: { show: false },
column: {
component: {
name: DurationValue,
vModel: "modelValue"
},
width: 100,
align: "center"
}
},
status: {
title: t('certd.status'),
type: "text",
form: { show: false },
column: {
width: 100,
align: "center",
component: {
name: UserSuiteStatus,
userSuite: compute(({ row }) => {
return row;
})
},
conditionalRender: {
match() {
return false;
}
}
}
},
activeTime: {
title: t('certd.active_time'),
type: "date",
column: {
width: 150
},
form: {
show: false
}
},
expiresTime: {
title: t('certd.expires_time'),
type: "date",
form: {
show: false
},
column: {
width: 150,
component: {
name: "expires-time-text",
vModel: "value",
mode: "tag",
title: compute(({ value }) => {
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
})
}
}
},
isPresent: {
title: t('certd.is_present'),
type: "dict-switch",
dict: dict({
data: [
{ label: t('certd.is_present_yes'), value: true, color: "success" },
{ label: t('certd.is_present_no'), value: false, color: "blue" }
]
}),
form: {
value: true,
show: false
},
column: {
width: 100,
align: "center"
}
},
createTime: {
title: t('certd.create_time'),
type: "datetime",
form: {
show: false
},
column: {
sorter: true,
width: 160,
align: "center"
}
},
updateTime: {
title: t('certd.update_time'),
type: "datetime",
form: {
show: false
},
column: {
show: true,
width: 160
}
}
}
}
};
toolbar: { show: false },
rowHandle: {
width: 200,
fixed: "right",
buttons: {
view: { show: true },
copy: { show: false },
edit: { show: false },
remove: { show: true },
// continue:{
// text:"续期",
// type:"link",
// click(){
// console.log("续期");
// }
// }
},
},
columns: {
id: {
title: "ID",
key: "id",
type: "number",
search: {
show: false,
},
column: {
width: 100,
editable: {
disabled: true,
},
},
form: {
show: false,
},
},
title: {
title: t("certd.package_name"),
type: "text",
search: {
show: true,
},
form: {
show: false,
},
column: {
width: 200,
},
},
userId: {
title: t("certd.usera"),
type: "table-select",
search: {
show: true,
},
dict: dict({
async getNodesByValues(ids: number[]) {
return await api.GetSimpleUserByIds(ids);
},
value: "id",
label: "nickName",
}),
form: {
component: {
crossPage: true,
multiple: false,
select: {
placeholder: t("certd.click_to_select"),
},
createCrudOptions: createCrudOptionsUser,
// crudOptionsOverride: crudOptionsOverride
},
},
},
//赠送
presentSuiteId: {
title: t("certd.gift_package"),
type: "dict-select",
column: { show: false },
addForm: {
show: true,
component: {
name: SuiteDurationSelector,
vModel: "modelValue",
},
rules: [
{
validator: async (rule, value) => {
if (value && value.productId) {
return true;
}
throw new Error(t("certd.please_select_package"));
},
},
],
},
valueResolve({ form, value }) {
if (value && value.productId) {
form.productId = value.productId;
form.duration = value.duration;
}
},
form: { show: false },
},
productType: {
title: t("certd.type"),
type: "dict-select",
editForm: {
component: {
disabled: true,
},
},
dict: dict({
data: [
{ label: t("certd.package"), value: "suite", color: "green" },
{ label: t("certd.addon_package"), value: "addon", color: "blue" },
],
}),
form: {
show: false,
},
column: {
width: 80,
align: "center",
},
valueBuilder: ({ row }) => {
if (row.content) {
row.content = JSON.parse(row.content);
}
},
valueResolve: ({ form }) => {
if (form.content) {
form.content = JSON.stringify(form.content);
}
},
},
"content.maxDomainCount": {
title: t("certd.domain_count"),
type: "text",
form: {
show: false,
key: ["content", "maxDomainCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unit_count"),
},
rules: [{ required: true, message: t("certd.field_required") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unit_count"),
},
align: "center",
},
},
"content.maxPipelineCount": {
title: t("certd.pipeline_count"),
type: "text",
form: {
show: false,
key: ["content", "maxPipelineCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unit_item"),
},
rules: [{ required: true, message: t("certd.field_required") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unit_item"),
},
align: "center",
},
},
"content.maxDeployCount": {
title: t("certd.deploy_count"),
type: "text",
form: {
show: false,
key: ["content", "maxDeployCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unit_times"),
},
rules: [{ required: true, message: t("certd.field_required") }],
},
column: {
width: 100,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unit_times"),
used: compute(({ row }) => {
return row.deployCountUsed;
}),
},
align: "center",
},
},
"content.maxMonitorCount": {
title: t("certd.monitor_count"),
type: "text",
form: {
show: false,
key: ["content", "maxMonitorCount"],
component: {
name: SuiteValueEdit,
vModel: "modelValue",
unit: t("certd.unit_count"),
},
rules: [{ required: true, message: t("certd.field_required") }],
},
column: {
width: 120,
component: {
name: SuiteValue,
vModel: "modelValue",
unit: t("certd.unit_count"),
},
align: "center",
},
},
duration: {
title: t("certd.duration"),
type: "text",
form: { show: false },
column: {
component: {
name: DurationValue,
vModel: "modelValue",
},
width: 100,
align: "center",
},
},
status: {
title: t("certd.status"),
type: "text",
form: { show: false },
column: {
width: 100,
align: "center",
component: {
name: UserSuiteStatus,
userSuite: compute(({ row }) => {
return row;
}),
},
conditionalRender: {
match() {
return false;
},
},
},
},
activeTime: {
title: t("certd.active_time"),
type: "date",
column: {
width: 150,
},
form: {
show: false,
},
},
expiresTime: {
title: t("certd.expires_time"),
type: "date",
form: {
show: false,
},
column: {
width: 150,
component: {
name: "expires-time-text",
vModel: "value",
mode: "tag",
title: compute(({ value }) => {
return dayjs(value).format("YYYY-MM-DD HH:mm:ss");
}),
},
},
},
isPresent: {
title: t("certd.is_present"),
type: "dict-switch",
dict: dict({
data: [
{ label: t("certd.is_present_yes"), value: true, color: "success" },
{ label: t("certd.is_present_no"), value: false, color: "blue" },
],
}),
form: {
value: true,
show: false,
},
column: {
width: 100,
align: "center",
},
},
createTime: {
title: t("certd.create_time"),
type: "datetime",
form: {
show: false,
},
column: {
sorter: true,
width: 160,
align: "center",
},
},
updateTime: {
title: t("certd.update_time"),
type: "datetime",
form: {
show: false,
},
column: {
show: true,
width: 160,
},
},
},
},
};
}