feat: migration to compositionAPI

This commit is contained in:
pengYYYYY 2021-11-08 16:49:45 +08:00
parent 05ac28eb21
commit 0c7a82e173
6 changed files with 24 additions and 20 deletions

View File

@ -27,12 +27,18 @@ import { defineComponent, PropType, computed } from 'vue';
export default defineComponent({ export default defineComponent({
name: 'Card', name: 'Card',
props: { props: {
title: String as PropType<string>, title: {
type: String as PropType<string>,
default: '',
},
compact: { compact: {
type: Boolean as PropType<boolean>, type: Boolean as PropType<boolean>,
default: false, default: false,
}, },
describe: String as PropType<string>, describe: {
type: String as PropType<string>,
default: '',
},
size: { size: {
type: String as PropType<string>, type: String as PropType<string>,
default: 'default', default: 'default',
@ -86,9 +92,6 @@ export default defineComponent({
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
// position: absolute;
// top: 30px;
// right: 32px;
} }
&-container { &-container {

View File

@ -5,14 +5,14 @@
/> />
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent } from 'vue'; import { computed, defineComponent, PropType } from 'vue';
import { getBrandColor } from '@/config/color'; import { getBrandColor } from '@/config/color';
export default defineComponent({ export default defineComponent({
name: 'Color', name: 'Color',
props: { props: {
value: { value: {
type: String, type: String as PropType<string>,
default: 'default', default: 'default',
}, },
}, },
@ -23,7 +23,10 @@ export default defineComponent({
backgroundColor: getBrandColor(value)['@brand-color'], backgroundColor: getBrandColor(value)['@brand-color'],
}; };
}); });
return { style };
return {
style,
};
}, },
}); });
</script> </script>

View File

@ -5,17 +5,17 @@
> >
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from 'vue'; import { defineComponent, computed, PropType } from 'vue';
export default defineComponent({ export default defineComponent({
name: 'Thumbnail', name: 'Thumbnail',
props: { props: {
url: { url: {
type: String, type: String as PropType<string>,
default: '', default: '',
}, },
type: { type: {
type: String, type: String as PropType<string>,
default: 'layout', default: 'layout',
}, },
}, },

View File

@ -57,7 +57,10 @@ export default defineComponent({
type: [String, Number] as PropType<string | number>, type: [String, Number] as PropType<string | number>,
default: '', default: '',
}, },
isReverseColor: Boolean as PropType<boolean>, isReverseColor: {
type: Boolean as PropType<boolean>,
default: false,
},
}, },
setup(props) { setup(props) {
const containerCls = computed(() => { const containerCls = computed(() => {

View File

@ -3,13 +3,8 @@ import { createStore, Store } from 'vuex';
import user from './modules/user'; import user from './modules/user';
import notification from './modules/notification'; import notification from './modules/notification';
import setting from './modules/setting'; import setting from './modules/setting';
export interface State {
count: number
}
export const key: InjectionKey<Store<State>> = Symbol(); export const store = createStore({
export const store = createStore<State>({
modules: { modules: {
user, user,
setting, setting,

View File

@ -2,7 +2,7 @@ import { defineConfig } from 'vite';
import { viteMockServe } from 'vite-plugin-mock'; import { viteMockServe } from 'vite-plugin-mock';
import { viteThemePlugin } from 'vite-plugin-theme'; import { viteThemePlugin } from 'vite-plugin-theme';
import createVuePlugin from '@vitejs/plugin-vue'; import createVuePlugin from '@vitejs/plugin-vue';
import createSvgPlugin from 'vite-plugin-vue-svg'; import svgLoader from 'vite-svg-loader'
import vueJsx from '@vitejs/plugin-vue-jsx'; import vueJsx from '@vitejs/plugin-vue-jsx';
// import HttpProxyAgent from 'http-proxy-agent'; // import HttpProxyAgent from 'http-proxy-agent';
@ -44,7 +44,7 @@ export default defineConfig({
viteThemePlugin({ viteThemePlugin({
colorVariables: getColorList([getGreyColor(backgroundTheme), getBrandColor(brandTheme)]), colorVariables: getColorList([getGreyColor(backgroundTheme), getBrandColor(brandTheme)]),
}), }),
createSvgPlugin(), svgLoader()
], ],
server: { server: {