feat(projects): 添加组件名称,调整vue文件里面的类型声明位置

This commit is contained in:
Soybean
2022-07-10 14:02:00 +08:00
parent b60db89801
commit f64bc91ce2
76 changed files with 223 additions and 70 deletions

View File

@ -26,6 +26,8 @@ import { computed, watch, nextTick, onUnmounted } from 'vue';
import { NETWORK_ERROR_MSG } from '@/config';
import { useBoolean } from '@/hooks';
defineOptions({ name: 'LoadingEmptyWrapper' });
interface Props {
/** 是否加载 */
loading: boolean;

View File

@ -9,11 +9,17 @@
<script setup lang="ts">
import { computed } from 'vue';
defineOptions({ name: 'LoginAgreement' });
interface Props {
/** 是否勾选 */
value?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
value: true
});
interface Emits {
(e: 'update:value', value: boolean): void;
/** 点击协议 */
@ -22,10 +28,6 @@ interface Emits {
(e: 'click-policy'): void;
}
const props = withDefaults(defineProps<Props>(), {
value: true
});
const emit = defineEmits<Emits>();
const checked = computed({

View File

@ -8,9 +8,12 @@
</template>
<script setup lang="ts">
defineOptions({ name: 'DarkModeContainer' });
interface Props {
inverted?: boolean;
}
withDefaults(defineProps<Props>(), {
inverted: false
});

View File

@ -8,19 +8,21 @@
<script setup lang="ts">
import { computed } from 'vue';
defineOptions({ name: 'DarkModeSwitch' });
interface Props {
/** 暗黑模式 */
dark?: boolean;
}
interface Emits {
(e: 'update:dark', darkMode: boolean): void;
}
const props = withDefaults(defineProps<Props>(), {
dark: false
});
interface Emits {
(e: 'update:dark', darkMode: boolean): void;
}
const emit = defineEmits<Emits>();
const darkMode = computed({

View File

@ -14,6 +14,8 @@
<script lang="ts" setup>
import { routeName } from '@/router';
defineOptions({ name: 'ExceptionBase' });
type ExceptionType = '403' | '404' | '500';
interface Props {

View File

@ -18,6 +18,8 @@
import { computed } from 'vue';
import type { PopoverPlacement } from 'naive-ui';
defineOptions({ name: 'HoverContainer' });
interface Props {
/** tooltip显示文本 */
tooltipContent?: string;
@ -28,6 +30,7 @@ interface Props {
/** 反转模式下 */
inverted?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
tooltipContent: '',
placement: 'bottom',

View File

@ -15,6 +15,8 @@
import { defineComponent, h } from 'vue';
import { useLoadingBar, useDialog, useMessage, useNotification } from 'naive-ui';
defineOptions({ name: 'NaiveProvider' });
// 挂载naive组件的方法至window, 以便在路由钩子函数和请求函数里面调用
function registerNaiveTools() {
window.$loadingBar = useLoadingBar();
@ -24,6 +26,7 @@ function registerNaiveTools() {
}
const NaiveProviderContent = defineComponent({
name: 'NaiveProviderContent',
setup() {
registerNaiveTools();
},

View File

@ -4,6 +4,8 @@
</template>
<script lang="ts" setup>
defineOptions({ name: 'SystemLogo' });
interface Props {
/** logo是否填充 */
fill?: boolean;

View File

@ -12,6 +12,8 @@ import { useElementSize } from '@vueuse/core';
import BScroll from '@better-scroll/core';
import type { Options } from '@better-scroll/core';
defineOptions({ name: 'BetterScroll' });
interface Props {
/** better-scroll的配置: https://better-scroll.github.io/docs/zh-CN/guide/base-scroll-options.html */
options: Options;

View File

@ -6,6 +6,8 @@ import { ref, computed, onMounted, watch, watchEffect } from 'vue';
import { useTransition, TransitionPresets } from '@vueuse/core';
import { isNumber } from '@/utils';
defineOptions({ name: 'CountTo' });
interface Props {
/** 初始值 */
startValue?: number;
@ -45,10 +47,12 @@ const props = withDefaults(defineProps<Props>(), {
transition: 'linear'
});
const emit = defineEmits<{
interface Emits {
(e: 'on-started'): void;
(e: 'on-finished'): void;
}>();
}
const emit = defineEmits<Emits>();
const source = ref(props.startValue);
let outputValue = useTransition(source);

View File

@ -5,6 +5,8 @@
<script setup lang="ts">
import WebSiteLink from './WebSiteLink.vue';
defineOptions({ name: 'GithubLink' });
interface Props {
/** github链接 */
link: string;

View File

@ -29,6 +29,8 @@ import { ref, computed } from 'vue';
import { Icon } from '@iconify/vue';
import { useThemeStore } from '@/store';
defineOptions({ name: 'IconSelect' });
interface Props {
/** 选中的图标 */
value: string;
@ -38,14 +40,14 @@ interface Props {
emptyIcon?: string;
}
interface Emits {
(e: 'update:value', val: string): void;
}
const props = withDefaults(defineProps<Props>(), {
emptyIcon: 'mdi:apps'
});
interface Emits {
(e: 'update:value', val: string): void;
}
const emit = defineEmits<Emits>();
const theme = useThemeStore();

View File

@ -8,18 +8,20 @@
import { watch } from 'vue';
import { useImageVerify } from '@/hooks';
defineOptions({ name: 'ImageVerify' });
interface Props {
code?: string;
}
interface Emits {
(e: 'update:code', code: string): void;
}
const props = withDefaults(defineProps<Props>(), {
code: ''
});
interface Emits {
(e: 'update:code', code: string): void;
}
const emit = defineEmits<Emits>();
const { domRef, imgCode, setImgCode, getImgCode } = useImageVerify();

View File

@ -7,6 +7,8 @@
<script setup lang="ts">
import { computed } from 'vue';
defineOptions({ name: 'SvgIcon' });
interface Props {
/** 前缀 */
prefix?: string;

View File

@ -8,6 +8,8 @@
</template>
<script setup lang="ts">
defineOptions({ name: 'WebSiteLink' });
interface Props {
/** 网址名称 */
label: string;