2024-08-07 08:57:56 +08:00
|
|
|
<script setup lang="ts">
|
2024-08-08 08:53:05 +08:00
|
|
|
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
2024-08-07 08:57:56 +08:00
|
|
|
|
2024-08-08 14:05:08 +08:00
|
|
|
import { Button, Card, Select } from 'ant-design-vue';
|
|
|
|
|
|
|
|
import { DictTag } from '#/components/Dict';
|
|
|
|
import { useDictStore } from '#/store/dict';
|
|
|
|
import { getDict, getDictOptions } from '#/utils/dict';
|
2024-08-07 08:57:56 +08:00
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
console.log('keepAlive测试 -> 挂载了');
|
|
|
|
});
|
2024-08-08 08:53:05 +08:00
|
|
|
|
|
|
|
const count = ref(0);
|
|
|
|
let intervalId: number = 0;
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
intervalId = setInterval(() => {
|
|
|
|
count.value++;
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
onBeforeUnmount(() => intervalId && clearInterval(intervalId));
|
2024-08-08 14:05:08 +08:00
|
|
|
|
|
|
|
const sexOptions = getDictOptions('sys_user_sex');
|
|
|
|
const disabledDict = getDict('sys_normal_disable');
|
|
|
|
|
|
|
|
const dictStore = useDictStore();
|
|
|
|
onMounted(() => {
|
|
|
|
console.log(dictStore.dictMap);
|
|
|
|
console.log(dictStore.dictOptionsMap);
|
|
|
|
});
|
2024-08-07 08:57:56 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-08-08 14:05:08 +08:00
|
|
|
<div class="m-[16px] flex flex-col gap-[16px]">
|
2024-08-08 08:53:05 +08:00
|
|
|
<Card title="测试keepAlive">
|
|
|
|
<template #extra>
|
|
|
|
<Button type="primary" v-access:code="['system:user:list']">
|
|
|
|
测试按钮权限system:user:list
|
|
|
|
</Button>
|
|
|
|
</template>
|
|
|
|
<p>当前计数: {{ count }}</p>
|
|
|
|
</Card>
|
2024-08-08 14:05:08 +08:00
|
|
|
<Card title="字典测试">
|
|
|
|
<div class="flex items-center gap-[16px]">
|
|
|
|
<Select
|
|
|
|
:options="sexOptions"
|
|
|
|
class="w-[200px]"
|
|
|
|
placeholder="请选择性别"
|
|
|
|
/>
|
|
|
|
<DictTag :dicts="disabledDict" value="0" />
|
|
|
|
<DictTag :dicts="disabledDict" value="1" />
|
|
|
|
</div>
|
|
|
|
</Card>
|
2024-08-07 08:57:56 +08:00
|
|
|
</div>
|
|
|
|
</template>
|