dynamic ttl and limit
This commit is contained in:
15
src/Root.vue
15
src/Root.vue
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<root-layout class="root diselect" author="夜雨" icp="粤ICP备2025368555号-1" domain="imyeyu.com" text>
|
||||
<root-layout v-if="ready" class="root diselect" author="夜雨" icp="粤ICP备2025368555号-1" domain="imyeyu.com" text>
|
||||
<router-view />
|
||||
<t-back-top class="to-top" size="small">
|
||||
<icon name="arrow_1_n" :scale="2" />
|
||||
@ -9,7 +9,18 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { RootLayout } from "../../timi-tdesign-pc";
|
||||
import { Icon } from "../../timi-web";
|
||||
import { Icon, SettingMapper } from "../../timi-web";
|
||||
|
||||
const ready = ref(false);
|
||||
onMounted(async () => {
|
||||
await SettingMapper.loadSetting(
|
||||
"TEMP_FILE_TTL_MIN",
|
||||
"TEMP_FILE_TTL_MAX",
|
||||
"TEMP_FILE_TTL_DEFAULT",
|
||||
"TEMP_FILE_LIMIT"
|
||||
);
|
||||
ready.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@ -35,10 +35,10 @@
|
||||
<div class="ttl-selector" @click.stop>
|
||||
<span class="label">缓存时长:</span>
|
||||
<t-radio-group v-model="ttl" variant="primary-filled" size="small">
|
||||
<t-radio-button :value="Time.H * 3">3 小时</t-radio-button>
|
||||
<t-radio-button :value="Time.H * 6">6 小时</t-radio-button>
|
||||
<t-radio-button :value="ttlMin" v-text="Time.toString(ttlMin)"></t-radio-button>
|
||||
<t-radio-button :value="Time.D">1 天</t-radio-button>
|
||||
<t-radio-button :value="Time.D * 3">3 天</t-radio-button>
|
||||
<t-radio-button :value="ttlDef" v-text="Time.toString(ttlDef)"></t-radio-button>
|
||||
<t-radio-button :value="ttlMax" v-text="Time.toString(ttlMax)"></t-radio-button>
|
||||
</t-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
@ -83,14 +83,17 @@ import { MessagePlugin } from "tdesign-vue-next";
|
||||
import TempFileAPI from "@/api/TempFileAPI.ts";
|
||||
import { useFileHistoryStore } from "@/store/fileHistory";
|
||||
import { type Item, Status } from "@/type/TempFile.ts";
|
||||
import { Icon, IOSize, Time } from "timi-web";
|
||||
import { Icon, IOSize, SettingMapper, Time } from "timi-web";
|
||||
|
||||
const fileHistoryStore = useFileHistoryStore();
|
||||
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
const isDragging = ref(false);
|
||||
const uploadList = ref<Item[]>([]);
|
||||
const ttl = ref(Time.H * 6); // 默认 6 小时
|
||||
const ttlMin = Time.parseToMS(SettingMapper.getValue("TEMP_FILE_TTL_MIN")!);
|
||||
const ttlMax = Time.parseToMS(SettingMapper.getValue("TEMP_FILE_TTL_MAX")!);
|
||||
const ttlDef = Time.parseToMS(SettingMapper.getValue("TEMP_FILE_TTL_DEFAULT")!);
|
||||
const ttl = ref(ttlDef);
|
||||
|
||||
/** 文件选择 */
|
||||
function triggerFileInput() {
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
<li v-text="'已上传文件仅自己可见,分享 ID 可直接下载'"></li>
|
||||
<li>
|
||||
<span>每个 IP 限制缓存</span>
|
||||
<strong class="word-space pink">10 GB</strong>
|
||||
<strong class="word-space pink" v-text="SettingMapper.getValue('TEMP_FILE_LIMIT')"></strong>
|
||||
<span>容量</span>
|
||||
</li>
|
||||
</ul>
|
||||
@ -31,7 +31,7 @@ import FileUpload from "@/components/FileUpload.vue";
|
||||
import FileDownload from "@/components/FileDownload.vue";
|
||||
import FileHistoryList from "@/components/FileHistoryList.vue";
|
||||
import { useFileHistoryStore } from "@/store/fileHistory.ts";
|
||||
import { Time } from "../../../timi-web";
|
||||
import { SettingMapper, Time } from "../../../timi-web";
|
||||
|
||||
const fileHistoryStore = useFileHistoryStore();
|
||||
onMounted(() => setInterval(fileHistoryStore.cleanExpiredFiles, Time.S));
|
||||
|
||||
Reference in New Issue
Block a user