重构代码.

This commit is contained in:
lijiahangmax
2023-09-24 23:28:02 +08:00
parent 6fa57c616c
commit 024a8b4596
21 changed files with 48 additions and 38 deletions

View File

@@ -22,9 +22,9 @@
const emits = defineEmits(['update:modelValue']);
const value = computed({
const value = computed<number>({
get() {
return props.modelValue;
return props.modelValue as number;
},
set(e) {
if (e) {

View File

@@ -22,9 +22,9 @@
const emits = defineEmits(['update:modelValue']);
const value = computed({
const value = computed<number>({
get() {
return props.modelValue;
return props.modelValue as number;
},
set(e) {
if (e) {

View File

@@ -3,7 +3,7 @@
v-if="type === 'number'"
:style="{ width: '80px' }"
size="small"
:default-value="defaultValue"
:default-value="defaultValue as number"
@change="handleChange"
/>
<a-switch

View File

@@ -82,7 +82,7 @@
async function readMessage(data: MessageListType) {
const ids = data.map((item) => item.id);
await setMessageStatus({ ids });
fetchSourceData();
await fetchSourceData();
}
const renderList = computed(() => {
@@ -101,6 +101,7 @@
};
const formatUnreadLength = (type: string) => {
const list = getUnreadList(type);
// FIXME
return list.length ? `(${list.length})` : ``;
};
const handleItemClick = (items: MessageListType) => {

View File

@@ -5,14 +5,14 @@
@select="actionSelect">
<span
class="arco-tag arco-tag-size-medium arco-tag-checked"
:class="{ 'link-activated': itemData.fullPath === $route.fullPath }"
@click="goto(itemData)">
:class="{ 'link-activated': itemData?.fullPath === $route.fullPath }"
@click="goto(itemData as TagProps)">
<span class="tag-link">
{{ itemData.title }}
</span>
<span
class="arco-icon-hover arco-tag-icon-hover arco-icon-hover-size-medium arco-tag-close-btn"
@click.stop="tagClose(itemData, index)">
@click.stop="tagClose(itemData as TagProps, index)">
<icon-close />
</span>
</span>

View File

@@ -2,7 +2,7 @@
<a-select v-model:model-value="value"
:placeholder="placeholder"
:options="optionData"
:limit=limit
:limit="limit as number"
@exceed-limit="onLimited"
multiple
:allow-create="allowCreate"
@@ -17,13 +17,13 @@
</script>
<script lang="ts" setup>
import { ref, computed } from 'vue';
import { ref, computed, PropType } from 'vue';
import { useCacheStore } from '@/store';
import { Message, SelectOptionData } from '@arco-design/web-vue';
import { createTag, TagCreateRequest, TagType } from '@/api/meta/tag';
import { createTag, TagCreateRequest } from '@/api/meta/tag';
const props = defineProps({
modelValue: Array,
modelValue: Array as PropType<Array<number>>,
placeholder: String,
limit: Number,
type: String,
@@ -32,9 +32,9 @@
const emits = defineEmits(['update:modelValue']);
const value = computed({
const value = computed<Array<number>>({
get() {
return props.modelValue;
return props.modelValue as Array<number>;
},
async set(e) {
await checkCreateTag(e as Array<any>);
@@ -103,7 +103,7 @@
// 超出限制
const onLimited = () => {
Message.warning(`最多选择${props.limit}个tag`);
Message.warning(`最多选择${ props.limit }个tag`);
};
</script>