Commit 61a0fd88 by haojie

中控台更新

parent a065d056
......@@ -21,7 +21,7 @@
<script lang="ts" setup>
import Dialog from '@/components/Dialog.vue';
import { computed, onMounted, ref } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import FormItem from '@/componentsUsiness/formItem.vue';
import Input from '@/components/input/index.vue';
import Switch from '@/components/switch';
......@@ -47,6 +47,8 @@ const route = useRoute();
// 本地数据的key
const localKey = 'reply_random_play_';
// 最少间隔和默认间隔
const defaultInterval = 120;
const visible = computed({
get() {
......@@ -61,7 +63,7 @@ let interval = null;
let localInterval = null;
// 间隔
const inputValue = ref('');
const inputValue = ref(defaultInterval + '');
const switchValue = ref(false);
......@@ -119,7 +121,20 @@ const openLocalInterval = () => {
}, 5000);
};
const closeLocalIneterval = () => {
window.clearInterval(localInterval);
clearInterval(localInterval);
localInterval = null;
};
const onSave = () => {
if (switchValue.value) {
if (!inputValue.value || inputValue.value < defaultInterval) {
show_message('间隔不能低于2分钟');
return;
}
}
if (!route.query.id) {
show_message('禁止访问');
return;
......@@ -139,7 +154,7 @@ const onSave = () => {
// 数据存本地,根据id
cache.setCache(getCacheId(), {
interval: inputValue.value,
interval: inputValue.value < defaultInterval ? defaultInterval : inputValue.value,
status: switchValue.value,
});
visible.value = false;
......@@ -148,7 +163,7 @@ const onSave = () => {
const init = () => {
const data = cache.getCache(getCacheId());
if (data) {
inputValue.value = data.interval;
inputValue.value = data.interval + '';
switchValue.value = data.status;
}
// 打开随机播放
......@@ -161,6 +176,11 @@ onMounted(() => {
init();
openLocalInterval();
});
onBeforeUnmount(() => {
closeInterval();
closeLocalIneterval();
});
</script>
<style lang="less">
......
......@@ -8,7 +8,7 @@ const error_messaage = '请求错误';
const getBaseUrl = async () => {
if (isDev()) {
// return 'http://156.247.11.21:93';
return 'http://156.247.11.21:93';
return '';
}
// 默认线上地址
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment