Browse Source

refactor(架构调整): 引入组件改script lang 等于typescript等

gemercheung 2 years ago
parent
commit
9885196db2

+ 1 - 1
internal/build/src/tasks/modules.ts

@@ -21,7 +21,7 @@ export const buildModules = async () => {
             onlyFiles: true,
         })
     )
-    console.log('input', input)
+    // console.log('input', input)
     const bundle = await rollup({
         input,
         plugins: [

+ 1 - 0
internal/build/src/tasks/types-definitions.ts

@@ -89,6 +89,7 @@ async function addSourceFiles(project: Project) {
     const sourceFiles: SourceFile[] = []
     await Promise.all([
         ...filePaths.map(async file => {
+            console.log('file', file)
             if (file.endsWith('.vue')) {
                 const content = await readFile(file, 'utf-8')
                 const hasTsNoCheck = content.includes('@ts-nocheck')

+ 3 - 1
package.json

@@ -21,7 +21,9 @@
         "build": "pnpm run -C internal/build start",
         "build:theme": "pnpm run -C packages/theme-chalk build",
         "prepare": "husky install",
-        "postinstall": "pnpm stub && concurrently  \"pnpm run -C internal/metadata dev\""
+        "postinstall": "pnpm stub && concurrently  \"pnpm run -C internal/metadata dev\"",
+        "typecheck": "run-p typecheck:web",
+        "typecheck:web": "vue-tsc -p tsconfig.web.json --composite false --noEmit"
     },
     "peerDependencies": {
         "vue": "^3.2.0"

+ 4 - 4
packages/components/basic/cropper/cropper.vue

@@ -1,6 +1,6 @@
 <template>
     <div>
-        <Confirm :title="title" :func="clickHandler" :no-text="noText" :ok-text="okText">
+        <confirm :title="title" :func="clickHandler" :no-text="noText" :ok-text="okText">
             <template #content>
                 <div>
                     <div class="cropper-layer" :style="style">
@@ -12,14 +12,14 @@
                     </div>
                 </div>
             </template>
-        </Confirm>
+        </confirm>
     </div>
 </template>
 
-<script setup lang="ts">
+<script lang="ts" setup>
 import { computed, defineProps, nextTick, ref } from 'vue'
 import { VueCropper } from 'vue-cropper'
-import Confirm from '../dialog/confirm.vue'
+import confirm from '@kankan-components/components/basic/dialog/src/confirm.vue'
 import 'vue-cropper/dist/index.css'
 // import { useI18n } from '@/i18n'
 // const { t } = useI18n({ useScope: 'global' })

packages/components/basic/cropper/index.js → packages/components/basic/cropper/index.ts


+ 1 - 1
packages/components/basic/dialog/src/window.vue

@@ -16,7 +16,7 @@
         </template>
     </ui-dialog>
 </template>
-<script>
+<script lang="ts">
 import { defineComponent } from 'vue'
 export default defineComponent({
     name: 'UIWindow',

packages/components/basic/gate/constant.js → packages/components/basic/gate/constant.ts


+ 7 - 3
packages/components/basic/gate/content.vue

@@ -4,11 +4,15 @@
     </div>
 </template>
 
-<script setup>
+<script lang="ts" setup>
 // getCurrentInstance
 import { inject, onBeforeMount, onUnmounted, ref } from 'vue'
 import { Relation } from './constant'
 
+defineOptions({
+    name: 'UIGateContent',
+})
+
 const active = ref(false)
 const brotherInstances = inject(Relation).value
 
@@ -23,6 +27,6 @@ if (brotherInstances) {
 }
 </script>
 
-<script>
+<!-- <script>
 export default { name: 'UiGateContent' }
-</script>
+</script> -->

packages/components/basic/gate/index.js → packages/components/basic/gate/index.ts


+ 7 - 3
packages/components/basic/gate/layer.vue

@@ -13,12 +13,16 @@
     </div>
 </template>
 
-<script setup>
+<script lang="ts" setup>
 // watchEffect
 import { computed, defineProps, provide, ref, watch } from 'vue'
 import { normalizeUnitToStyle } from '@kankan-components/utils'
 import { Relation } from './constant'
 
+defineOptions({
+    name: 'UIGate',
+})
+
 const contentInstances = ref([])
 const props = defineProps({
     index: {
@@ -42,6 +46,6 @@ watch([contentInstances, slideIndex], () => {
 provide(Relation, contentInstances)
 </script>
 
-<script>
+<!-- <script>
 export default { name: 'UiGate' }
-</script>
+</script> -->

packages/components/basic/group/constant.js → packages/components/basic/group/constant.ts


packages/components/basic/group/index.js → packages/components/basic/group/index.ts


+ 6 - 3
packages/components/basic/group/ui-group-option.vue

@@ -7,12 +7,15 @@
     </div>
 </template>
 
-<script setup>
+<script lang="ts" setup>
 import { getCurrentInstance, inject, onBeforeMount, onUnmounted } from 'vue'
 import { Relation } from './constant'
 const props = defineProps({
     label: String,
 })
+defineOptions({
+    name: 'UIGroupOption',
+})
 
 const brotherInstances = inject(Relation)
 const instance = getCurrentInstance()
@@ -29,6 +32,6 @@ if (brotherInstances.value) {
 }
 </script>
 
-<script>
+<!-- <script>
 export default { name: 'UiGroupOption' }
-</script>
+</script> -->

+ 7 - 3
packages/components/basic/group/ui-group.vue

@@ -29,12 +29,16 @@
     </div>
 </template>
 
-<script setup>
+<script lang="ts" setup>
 import { computed, provide, ref, watch, watchEffect } from 'vue'
 import icon from '../icon'
 import UISizeAnimation from '../size-animation'
 import { Relation } from './constant'
 
+defineOptions({
+    name: 'UIGroup',
+})
+
 const animationRef = ref(null)
 const props = defineProps({
     title: String,
@@ -64,6 +68,6 @@ watch(contentInstances, () => {
 })
 </script>
 
-<script>
+<!-- <script>
 export default { name: 'UiGroup' }
-</script>
+</script> -->

+ 8 - 4
packages/components/basic/guide/index.vue

@@ -28,10 +28,14 @@
     <slot v-else name="content" :show="false" />
 </template>
 
-<script setup>
+<script lang="ts" setup>
 import { ref, watch } from 'vue'
+import UIFloating from '@kankan-components/components/basic/floating'
 import Bubble from '../bubble'
-import UIFloating from '../floating/index.vue'
+
+defineOptions({
+    name: 'UIGuide',
+})
 
 const props = defineProps({
     mark: {
@@ -70,6 +74,6 @@ if (props.mark) {
 const mount = ref(shouldShow.value)
 </script>
 
-<script>
+<!-- <script>
 export default { name: 'UiGuide' }
-</script>
+</script> -->

+ 1 - 1
packages/components/basic/input/src/switch/switch.ts

@@ -53,4 +53,4 @@ export const switchProps = buildProps({
     },
 })
 
-export type SelectProps = ExtractPropTypes<typeof selectProps>
+export type SwitchProps = ExtractPropTypes<typeof switchProps>

+ 1 - 1
packages/components/basic/message/message.vue

@@ -9,7 +9,7 @@
     </teleport>
 </template>
 
-<script setup lang="ts">
+<script lang="ts" setup>
 // import getZindex from '../../utils/zindex'
 import { defineProps, nextTick, onMounted, ref } from 'vue'
 import { useZIndex } from '@kankan-components/hooks'

+ 2 - 2
packages/kankan-components/component.ts

@@ -1,5 +1,5 @@
 import { UIAudio } from '@kankan-components/components/basic/audio'
-import { UIButton } from '@kankan-components/components/basic/button'
+// import { UIButton } from '@kankan-components/components/basic/button'
 import type { Plugin } from 'vue'
 
-export default [UIAudio, UIButton] as Plugin[]
+export default [UIAudio] as Plugin[]