mirror of
https://github.com/certd/certd.git
synced 2026-05-15 04:27:31 +08:00
perf: 支持设置用户有效期
This commit is contained in:
@@ -3,6 +3,7 @@ import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq,
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
import dayjs from "dayjs";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
@@ -22,6 +23,10 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
const settingStore = useSettingStore();
|
||||
const userValidTimeEnabled = compute(() => {
|
||||
return settingStore.sysPublic.userValidTimeEnabled === true;
|
||||
});
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
@@ -213,20 +218,28 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
},
|
||||
validTime: {
|
||||
title: "有效期",
|
||||
type: ["date", "time-humanize"],
|
||||
type: "date",
|
||||
form: {
|
||||
show: userValidTimeEnabled,
|
||||
},
|
||||
column: {
|
||||
align: "center",
|
||||
sorter: true,
|
||||
width: 100,
|
||||
component: {
|
||||
title: compute(({ row }) => {
|
||||
return dayjs(row.validTime).format("YYYY-MM-DD");
|
||||
}),
|
||||
useFormatGreater: 30000000000,
|
||||
options: {
|
||||
largest: 1,
|
||||
units: ["y", "d", "h"],
|
||||
},
|
||||
show: userValidTimeEnabled,
|
||||
cellRender({ value }) {
|
||||
if (value == null || value === 0) {
|
||||
return "";
|
||||
}
|
||||
if (value < dayjs().valueOf()) {
|
||||
return <a-tag color={"red"}>已过期</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 }) {
|
||||
|
||||
@@ -11,6 +11,13 @@
|
||||
<a-form-item label="开启自助注册" :name="['public', 'registerEnabled']">
|
||||
<a-switch v-model:checked="formState.public.registerEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item label="开启用户有效期" :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">有效期内用户可正常使用,失效后流水线将被停用</div>
|
||||
</a-form-item>
|
||||
<template v-if="formState.public.registerEnabled">
|
||||
<a-form-item label="开启用户名注册" :name="['public', 'usernameRegisterEnabled']">
|
||||
<a-switch v-model:checked="formState.public.usernameRegisterEnabled" />
|
||||
@@ -154,6 +161,14 @@ async function loadSysSettings() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
const saveLoading = ref(false);
|
||||
|
||||
Reference in New Issue
Block a user