Commit 61a0fd88 by haojie

中控台更新

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