🔨 修改 defineProps 规范.

This commit is contained in:
lijiahangmax
2024-04-06 23:11:30 +08:00
parent 812286a2e7
commit 3623e6bd4a
50 changed files with 300 additions and 394 deletions

View File

@@ -10,17 +10,15 @@
</template>
<script lang="ts" setup>
import type { PropType } from 'vue';
import { useRoute } from 'vue-router';
defineProps({
items: {
type: Array as PropType<string[]>,
default() {
return useRoute().matched
.map(s => s.meta?.locale)
.filter(Boolean) || [];
},
const props = withDefaults(defineProps<{
items?: Array<string>;
}>(), {
items: () => {
return useRoute().matched
.map(s => s.meta?.locale as string)
.filter(Boolean) || [];
},
});
</script>

View File

@@ -19,12 +19,11 @@
</template>
<script lang="ts" setup>
import type { PropType } from 'vue';
import type { RadioOption } from '@arco-design/web-vue/es/radio/interface';
import type { SelectOption } from '@arco-design/web-vue/es/select/interface';
import { useAppStore } from '@/store';
import FormWrapper from './form-wrapper.vue';
import { updatePreference } from '@/api/user/preference';
import FormWrapper from './form-wrapper.vue';
interface OptionsProps {
name: string;
@@ -36,13 +35,10 @@
margin?: string;
}
defineProps({
title: String,
options: {
type: Array as PropType<OptionsProps[]>,
default: () => []
},
});
defineProps<Partial<{
title: string;
options: Array<OptionsProps>;
}>>();
const appStore = useAppStore();

View File

@@ -30,29 +30,22 @@
</template>
<script lang="ts" setup>
import type { PropType } from 'vue';
import type { RadioOption } from '@arco-design/web-vue/es/radio/interface';
import type { SelectOption } from '@arco-design/web-vue/es/select/interface';
const props = defineProps({
type: {
type: String,
default: 'switch',
},
name: {
type: String,
default: '',
},
defaultValue: {
type: [String, Boolean, Number],
default: '',
},
options: {
type: Array as PropType<Array<RadioOption | SelectOption>>,
default: () => []
}
const props = withDefaults(defineProps<Partial<{
type: string;
name: string;
defaultValue: string | boolean | number;
options: Array<RadioOption | SelectOption>;
}>>(), {
type: 'switch',
name: '',
defaultValue: '',
options: () => []
});
const emit = defineEmits(['inputChange']);
const handleChange = (value: unknown) => {
emit('inputChange', {
value,

View File

@@ -16,11 +16,11 @@
@cancel="() => setVisible(false)">
<div class="preference-containers">
<!-- 布局设置 -->
<Block :options="layoutOpts" title="布局设置" />
<block :options="layoutOpts" title="布局设置" />
<!-- 数据设置 -->
<Block :options="dataOpts" title="数据设置" />
<block :options="dataOpts" title="数据设置" />
<!-- 页面视图 -->
<Block :options="viewsOpts" title="页面视图" />
<block :options="viewsOpts" title="页面视图" />
</div>
</a-drawer>
</template>
@@ -28,9 +28,9 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { useAppStore } from '@/store';
import Block from './block.vue';
import useVisible from '@/hooks/visible';
import { CardPageSizeOptions, TablePageSizeOptions } from '@/types/const';
import Block from './block.vue';
const appStore = useAppStore();
const { visible, setVisible } = useVisible();

View File

@@ -50,9 +50,8 @@
<script lang="ts" setup>
import type { TagProps } from '@/store/modules/tab-bar/types';
import type { PropType } from 'vue';
import { computed } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { useTabBarStore } from '@/store';
import { DEFAULT_ROUTE_NAME, REDIRECT_ROUTE_NAME } from '@/router/constants';
@@ -65,18 +64,10 @@
all = 'all',
}
const props = defineProps({
itemData: {
type: Object as PropType<TagProps>,
default: () => {
return {};
}
},
index: {
type: Number,
default: 0,
},
});
const props = defineProps<{
index: number;
itemData: TagProps;
}>();
const router = useRouter();
const route = useRoute();