chore: lib-server

This commit is contained in:
xiaojunnuo
2024-10-03 22:03:49 +08:00
parent a13203fb3f
commit a4e2cc54e6
101 changed files with 936 additions and 223 deletions
@@ -0,0 +1,43 @@
// @ts-ignore
import { request } from "/src/api/service";
const apiPrefix = "/sys/settings";
export const SettingKeys = {
SysPublic: "sys.public",
SysPrivate: "sys.private"
};
export async function SettingsGet(key: string) {
return await request({
url: apiPrefix + "/get",
method: "post",
params: {
key
}
});
}
export async function SettingsSave(key: string, setting: any) {
await request({
url: apiPrefix + "/save",
method: "post",
data: {
key,
setting: JSON.stringify(setting)
}
});
}
export async function PublicSettingsSave(setting: any) {
await request({
url: apiPrefix + "/savePublicSettings",
method: "post",
data: setting
});
}
export async function stopOtherUserTimer() {
await request({
url: apiPrefix + "/stopOtherUserTimer",
method: "post"
});
}
@@ -0,0 +1,92 @@
<template>
<fs-page class="page-sys-settings">
<template #header>
<div class="title">站点个性化设置</div>
</template>
<div class="sys-settings-form">
<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="开启自助注册" name="registerEnabled">
<a-switch v-model:checked="formState.registerEnabled" />
</a-form-item>
<a-form-item label="管理其他用户流水线" name="managerOtherUserPipeline">
<a-switch v-model:checked="formState.managerOtherUserPipeline" />
</a-form-item>
<!-- <a-form-item label="启动后触发流水线" name="triggerOnStartup">-->
<!-- <a-switch v-model:checked="formState.triggerOnStartup" />-->
<!-- <div class="helper">启动后自动触发一次所有已启用的流水线</div>-->
<!-- </a-form-item>-->
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
<a-button type="primary" html-type="submit">保存</a-button>
</a-form-item>
</a-form>
<!-- <a-descriptions label="系统维护操作">-->
<!-- <a-descriptions-item label="自动化任务">-->
<!-- <a-button @click="stopOtherUserTimer">停止所有其他用户的定时任务</a-button>-->
<!-- </a-descriptions-item>-->
<!-- </a-descriptions>-->
</div>
</fs-page>
</template>
<script setup lang="ts">
import { reactive } from "vue";
import * as api from "./api";
import { PublicSettingsSave, SettingKeys } from "./api";
import { notification } from "ant-design-vue";
import { useSettingStore } from "/src/store/modules/settings";
interface FormState {
title: string;
logo: string;
}
const formState = reactive<Partial<FormState>>({
registerEnabled: false,
managerOtherUserPipeline: false
});
async function loadSysPublicSettings() {
const data: any = await api.SettingsGet(SettingKeys.SysPublic);
const setting = JSON.parse(data.setting);
Object.assign(formState, setting);
}
loadSysPublicSettings();
const settingsStore = useSettingStore();
const onFinish = async (form: any) => {
await api.PublicSettingsSave(form);
await settingsStore.loadSysSettings();
notification.success({
message: "保存成功"
});
};
const onFinishFailed = (errorInfo: any) => {
// console.log("Failed:", errorInfo);
};
async function stopOtherUserTimer() {
await api.stopOtherUserTimer();
notification.success({
message: "停止成功"
});
}
</script>
<style lang="less">
.page-sys-settings {
.sys-settings-form {
width: 500px;
margin: 20px;
}
}
</style>