Skip to content

Commit b763d39

Browse files
committed
fix: type export
1 parent be2df3b commit b763d39

17 files changed

+74
-160
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import fs from "fs"
2+
import path from "path"
3+
import { Plugin } from "vite"
4+
import chalk from "chalk"
5+
6+
function list(root: string): string[] {
7+
if (fs.lstatSync(root).isFile()) {
8+
return [path.resolve(root)]
9+
} else {
10+
return fs
11+
.readdirSync(root)
12+
.map((record) => list(path.join(root, record)))
13+
.reduce((arr, i) => [...arr, ...i], [] as string[])
14+
}
15+
}
16+
17+
const allFile = new Set<string>()
18+
19+
const current = path.resolve(".")
20+
21+
list("./src")
22+
.filter((record) => !record.includes("spec"))
23+
.filter((record) => !record.includes("demo"))
24+
.forEach((record) => allFile.add(record))
25+
26+
function log() {
27+
console.log(
28+
chalk.redBright(
29+
[...allFile.values()]
30+
.map((v, idx) => `[${idx}].${v.split(current).join("")}`)
31+
.join("\n")
32+
)
33+
)
34+
console.log(
35+
`${chalk.red("×")} ${chalk.dim.white(`${allFile.size} unused files`)}`
36+
)
37+
}
38+
39+
export default function unused(): Plugin {
40+
return {
41+
name: "find-unused-file",
42+
43+
load(id) {
44+
if (allFile.has(id)) {
45+
allFile.delete(id)
46+
}
47+
return null
48+
},
49+
50+
buildEnd() {
51+
log()
52+
},
53+
}
54+
}

packages/hexon-web/src/components/HNavList.vue

-145
This file was deleted.

packages/hexon-web/src/components/HSearchBar.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import HToolbar from "./HToolbar.vue"
3-
import HInput from "./ui/input/src/HInput.vue"
3+
import { HInput } from "./ui/input"
44
import { HButton } from "./ui/button"
55
import { HIcon } from "./ui/icon"
66
import { HIconName } from "./ui/icon"

packages/hexon-web/src/components/forms/HInstallForm.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ref } from "vue"
33
import { useTheme } from "@winwin/vue-global-theming"
44
import logo from "~/assets/logo-invert.svg"
55
import { HTheme } from "~/themes"
6-
import HInput from "@/ui/input/src/HInput.vue"
6+
import { HInput } from "@/ui/input"
77
import { HIcon } from "@/ui/icon"
88
import { HIconName } from "@/ui/icon"
99
import { HButton } from "@/ui/button"

packages/hexon-web/src/components/forms/HLoginForm.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { useTheme } from "@winwin/vue-global-theming"
44
import logo from "~/assets/logo.svg"
55
import { HTheme } from "~/themes"
66
import HImage from "@/HImage.vue"
7-
import HInput from "~/components/ui/input/src/HInput.vue"
7+
import { HInput } from "~/components/ui/input"
88
import { HIcon } from "~/components/ui/icon"
99
import { HButton } from "~/components/ui/button"
10-
import { HIconName } from "~/components/ui/icon/src/interface"
10+
import { HIconName } from "~/components/ui/icon"
1111
1212
const emits = defineEmits<{
1313
(e: "on-submit", payload: { username: string; password: string }): void

packages/hexon-web/src/components/others/HDialog.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { useTheme } from "@winwin/vue-global-theming"
33
import { DialogActionType, IDialog } from "~/lib/dialog"
44
import { HTheme } from "~/themes"
55
import HButton from "../ui/button/src/HButton.vue"
6+
import { HButtonType } from "../ui/button/src/interface"
67
const props = defineProps<{ data: IDialog }>()
7-
function transformType(type: DialogActionType) {
8+
function transformType(type: DialogActionType): HButtonType {
89
switch (type) {
910
case "info":
1011
return "primary"
11-
1212
default:
1313
return type
1414
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as HButton } from "./src/HButton.vue"
2+
export * from "./src/interface"
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export { createDialogPlugin, useDialog, type Dialog } from "./lib"
1+
export { createDialogPlugin, useDialog } from "./lib"
2+
export type { Dialog } from "./lib"
23
export { default as DialogContainer } from "./DialogContainer.vue"
34
export * from "./interface"
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
export { useNotification, createNotification, type Notification } from "./lib"
1+
export { useNotification, createNotification } from "./lib"
2+
export type { Notification } from "./lib"
23
export { default as Notifications } from "./Notification.vue"
4+
export * from "./interface"

packages/hexon-web/src/store/detail.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineStore } from "pinia"
22
import { api, Page, Post } from "~/api"
3-
import { PostOrPage } from "~/types"
3+
import { PostOrPage } from "~/interface"
44

55
interface IState {
66
article: Post | Page | null

packages/hexon-web/src/store/dispatcher.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineStore } from "pinia"
2-
import { IArticleIdentifier, PostOrPage } from "~/types"
2+
import { IArticleIdentifier } from "~/interface"
33
import { useDetailStore } from "./detail"
44
import { useMainStore } from "./main"
55

packages/hexon-web/src/store/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineStore } from "pinia"
22
import { list2Tree, TreeNode } from "~/lib/list2tree"
33
import { api, BriefPage, BriefPost, Category, Tag } from "~/api"
44
import { list2object, object2list } from "~/utils"
5-
import { PostOrPage } from "~/types"
5+
import { PostOrPage } from "~/interface"
66

77
export interface IState {
88
posts: {

packages/hexon-web/src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { computed, ComputedRef, defineAsyncComponent, ref } from "vue"
2-
import { INotificationType } from "./lib/notification/interface"
2+
import { INotificationType } from "./lib/notification"
33

44
export const forceReloadWindow = () => {
55
window.onbeforeunload = () => {}

packages/hexon-web/src/views/EditorView.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { HEditorToolbarActionPayload } from "@/types"
1212
import ErroredView from "./ErroredView.vue"
1313
import { useAsyncComponentWithLoading } from "~/utils"
1414
import { useDispatcher } from "~/store/dispatcher"
15-
import { PostOrPage } from "~/types"
15+
import { PostOrPage } from "~/interface"
1616
1717
const [HMonacoEditor, monacoLoading] = useAsyncComponentWithLoading(
1818
() => import("@/Editors/HMonacoEditor.vue")

packages/hexon-web/src/views/ViewerView.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import HViewerHeader from "@/HViewerHeader.vue"
1010
import { HViewerToolbarActionPayload } from "@/types"
1111
import ErroredView from "./ErroredView.vue"
1212
import { useDispatcher } from "~/store/dispatcher"
13-
import { PostOrPage } from "~/types"
13+
import { PostOrPage } from "~/interface"
1414
1515
//#region hooks
1616
const route = useRoute()

packages/hexon-web/vite.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import path from "path"
22
import { defineConfig } from "vite"
33
import vue from "@vitejs/plugin-vue"
44
import visualizer from "rollup-plugin-visualizer"
5+
import unused from "./find-unused-file-plugin"
56
const projectRootDir = path.resolve(__dirname)
67

78
// https://vitejs.dev/config/
89
export default defineConfig({
910
server: { port: 4000 },
10-
plugins: [vue()],
11+
plugins: [vue(), unused()],
1112
resolve: {
1213
alias: [
1314
{

0 commit comments

Comments
 (0)