refactor!: 重构多个子包

- 移除 unbuild --stub 模式
- faToast -> useFaToast
This commit is contained in:
Hooray
2026-05-17 03:54:49 +08:00
parent 40cab5efa3
commit 749c55edbc
372 changed files with 806 additions and 2265 deletions
+2 -2
View File
@@ -51,7 +51,7 @@ function handleError(error: any) {
useAppAccountStore().requestLogout()
}
else {
faToast.error('Error', {
useFaToast().error('Error', {
description: error.message,
})
}
@@ -70,7 +70,7 @@ api.interceptors.response.use(
if (typeof response.data === 'object') {
if (response.data.status === 1) {
if (response.data.error) {
faToast.warning('Warning', {
useFaToast().warning('Warning', {
description: response.data.error,
})
return Promise.reject(response.data)
@@ -32,7 +32,7 @@ const form = useForm({
const onSubmit = form.handleSubmit((values) => {
loading.value = true
appAccountStore.editPassword(values).then(async () => {
faToast.success('模拟修改成功,请重新登录')
useFaToast().success('模拟修改成功,请重新登录')
appAccountStore.logout()
}).finally(() => {
loading.value = false
+2 -2
View File
@@ -80,13 +80,13 @@ export function useAppTabbar() {
const index = appTabbarStore.list.findIndex(item => item.tabId === tabId)
if (index < 0) {
flag = false
!checkOnly && faToast.warning('关闭的标签页不存在', {
!checkOnly && useFaToast().warning('关闭的标签页不存在', {
position: 'top-center',
})
}
else if (appTabbarStore.list.length <= 1) {
flag = false
!checkOnly && faToast.warning('当前只有一个标签页,不可关闭', {
!checkOnly && useFaToast().warning('当前只有一个标签页,不可关闭', {
position: 'top-center',
})
}
@@ -72,13 +72,13 @@ watch(() => route, (val) => {
function tabbarScrollTip() {
if (tabContainerRef.value?.$el.clientWidth > (tabsRef.value?.ref?.$el.clientWidth ?? 0) && !localStorage.has('tabbarScrollTip')) {
localStorage.setItem('tabbarScrollTip', '')
const tips = faToast.info('温馨提示', {
const tips = useFaToast().info('温馨提示', {
description: '标签栏数量超过展示区域范围,可以将鼠标移到标签栏上,通过鼠标滚轮滑动浏览',
position: 'top-center',
duration: Infinity,
action: {
label: '知道了',
onClick: () => faToast.dismiss(tips),
onClick: () => useFaToast().dismiss(tips),
},
})
}
@@ -8,7 +8,7 @@ defineOptions({
const route = useRoute()
const { copy, copied } = useClipboard()
watch(copied, (val) => {
val && faToast.success('复制成功')
val && useFaToast().success('复制成功')
})
function open() {
+1 -2
View File
@@ -16,7 +16,6 @@ declare global {
const defineComponent: typeof import('vue').defineComponent
const defineStore: typeof import('pinia').defineStore
const effectScope: typeof import('vue').effectScope
const faToast: typeof import('@fantastic-admin/components').faToast
const getActivePinia: typeof import('pinia').getActivePinia
const getCurrentInstance: typeof import('vue').getCurrentInstance
const getCurrentScope: typeof import('vue').getCurrentScope
@@ -83,8 +82,8 @@ declare global {
const useCssVars: typeof import('vue').useCssVars
const useFaDrawer: typeof import('@fantastic-admin/components').useFaDrawer
const useFaImagePreview: typeof import('@fantastic-admin/components').useFaImagePreview
const useFaLoading: typeof import('@fantastic-admin/components').useFaLoading
const useFaModal: typeof import('@fantastic-admin/components').useFaModal
const useFaToast: typeof import('@fantastic-admin/components').useFaToast
const useId: typeof import('vue').useId
const useLink: typeof import('vue-router').useLink
const useModel: typeof import('vue').useModel
@@ -24,24 +24,24 @@ function goTest() {
}
function permissionCheck(permissions: string | string[]) {
if (auth(permissions)) {
faToast.success('校验通过', {
useFaToast().success('校验通过', {
position: 'top-center',
})
}
else {
faToast.error('校验不通过', {
useFaToast().error('校验不通过', {
position: 'top-center',
})
}
}
function permissionCheck2(permissions: string[]) {
if (authAll(permissions)) {
faToast.success('校验通过', {
useFaToast().success('校验通过', {
position: 'top-center',
})
}
else {
faToast.error('校验不通过', {
useFaToast().error('校验不通过', {
position: 'top-center',
})
}
@@ -1,6 +1,6 @@
<script setup lang="ts">
function handleClick(text: string) {
faToast(text)
useFaToast()(text)
}
</script>
@@ -1,6 +1,6 @@
<script setup lang="ts">
function handleClick(text: string) {
faToast(text)
useFaToast()(text)
}
</script>
@@ -1,6 +1,6 @@
<script setup lang="ts">
function handleClick(text: string) {
faToast(text)
useFaToast()(text)
}
</script>
@@ -1,6 +1,6 @@
<script setup lang="ts">
function handleClick(text: string) {
faToast(text)
useFaToast()(text)
}
</script>
@@ -2,7 +2,7 @@
const modal = shallowRef(false)
function handleClick(text: string) {
faToast(text)
useFaToast()(text)
}
const items = [
@@ -4,7 +4,7 @@ import type { FileItem } from '@fantastic-admin/components'
const files = ref<FileItem[]>([])
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
</script>
@@ -10,22 +10,22 @@ function beforeUpload(file: File) {
const isLt200K = file.size <= 200 * 1024
if (!isPng) {
faToast.error('只能上传 PNG 文件')
useFaToast().error('只能上传 PNG 文件')
return false
}
if (!isLt200K) {
faToast.error('文件大小不能超过 200KB')
useFaToast().error('文件大小不能超过 200KB')
return false
}
return true
}
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
function handleClick(fileItem: FileItem) {
faToast.info(fileItem.name, {
useFaToast().info(fileItem.name, {
description: fileItem.url,
})
}
@@ -4,7 +4,7 @@ import type { FileItem } from '@fantastic-admin/components'
const files = ref<FileItem[]>([])
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
</script>
@@ -15,7 +15,7 @@ async function httpRequest({ file, onProgress }: FileUploadRequestOptions) {
}
function handleSuccess() {
faToast.success('自定义上传完成')
useFaToast().success('自定义上传完成')
}
</script>
@@ -2,7 +2,7 @@
const files = ref<string[]>([])
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
</script>
@@ -2,7 +2,7 @@
const files = ref<string[]>(['https://fantastic-admin.hurui.me/logo.svg'])
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
</script>
@@ -3,18 +3,18 @@ const files = ref<string[]>([])
function beforeUpload(file: File) {
if (!file.type.startsWith('image/')) {
faToast.error('请选择图片文件')
useFaToast().error('请选择图片文件')
return false
}
if (file.size > 200 * 1024) {
faToast.error('图片大小不能超过 200KB')
useFaToast().error('图片大小不能超过 200KB')
return false
}
return true
}
function handleSuccess() {
faToast.success('模拟上传成功')
useFaToast().success('模拟上传成功')
}
</script>
@@ -15,7 +15,7 @@ async function httpRequest({ file, onProgress }: UploadRequestOptions) {
}
function handleSuccess() {
faToast.success('自定义上传完成')
useFaToast().success('自定义上传完成')
}
</script>
@@ -2,7 +2,7 @@
const input = ref('')
function handleComplete() {
faToast.info(input.value)
useFaToast().info(input.value)
}
</script>
@@ -4,7 +4,7 @@ function showModalInfo() {
title: '温馨提醒',
content: '这是 info 弹窗',
onConfirm: () => {
faToast.info('你点了确定')
useFaToast().info('你点了确定')
},
})
}
@@ -13,7 +13,7 @@ function showModalSuccess() {
title: '温馨提醒',
content: '这是 success 弹窗',
onConfirm: () => {
faToast.info('你点了确定')
useFaToast().info('你点了确定')
},
})
}
@@ -22,7 +22,7 @@ function showModalWarning() {
title: '温馨提醒',
content: '这是 warning 弹窗',
onConfirm: () => {
faToast.info('你点了确定')
useFaToast().info('你点了确定')
},
})
}
@@ -31,7 +31,7 @@ function showModalError() {
title: '温馨提醒',
content: '这是 confirm 弹窗',
onConfirm: () => {
faToast.info('你点了确定')
useFaToast().info('你点了确定')
},
})
}
@@ -40,7 +40,7 @@ function showModalConfirm() {
title: '温馨提醒',
content: '这是 confirm 弹窗',
onConfirm: () => {
faToast.info('你点了确定')
useFaToast().info('你点了确定')
},
})
}
@@ -80,11 +80,11 @@ function showModalPromiseConfirm() {
if (action === 'confirm') {
await new Promise(resolve => setTimeout(resolve, 1000))
if (Math.random() > 0.5) {
faToast.success('成功了!')
useFaToast().success('成功了!')
done()
}
else {
faToast.error('失败了!')
useFaToast().error('失败了!')
}
}
else {
@@ -9,7 +9,7 @@ const search = ref({
})
function onToggle(fold: boolean) {
faToast(fold ? '收起' : '展开')
useFaToast()(fold ? '收起' : '展开')
}
</script>
@@ -2,7 +2,7 @@
function showToast(type?: 'success' | 'error' | 'info' | 'warning' | 'action' | 'loading1' | 'loading2') {
if (type) {
if (type === 'loading1') {
faToast.promise(() => new Promise((resolve) => {
useFaToast().promise(() => new Promise((resolve) => {
setTimeout(resolve, 2000)
}), {
loading: '加载中',
@@ -13,13 +13,13 @@ function showToast(type?: 'success' | 'error' | 'info' | 'warning' | 'action' |
})
}
else if (type === 'loading2') {
const loading = faToast.loading('加载中', {
const loading = useFaToast().loading('加载中', {
position: 'top-right',
duration: Infinity,
})
setTimeout(() => {
faToast.dismiss(loading)
faToast('Fantastic-admin 杰出的管理系统框架', {
useFaToast().dismiss(loading)
useFaToast()('Fantastic-admin 杰出的管理系统框架', {
description: '开箱即用,提供舒适开发体验',
position: 'top-right',
duration: 3000,
@@ -27,20 +27,20 @@ function showToast(type?: 'success' | 'error' | 'info' | 'warning' | 'action' |
}, 2000)
}
else if (type === 'action') {
faToast('Fantastic-admin 杰出的管理系统框架', {
useFaToast()('Fantastic-admin 杰出的管理系统框架', {
description: '开箱即用,提供舒适开发体验',
position: 'top-right',
duration: 3000,
action: {
label: 'Undo',
onClick: () => {
faToast.success('操作成功')
useFaToast().success('操作成功')
},
},
})
}
else {
faToast[type]('Fantastic-admin 杰出的管理系统框架', {
useFaToast()[type]('Fantastic-admin 杰出的管理系统框架', {
description: '开箱即用,提供舒适开发体验',
position: 'top-right',
duration: 3000,
@@ -48,7 +48,7 @@ function showToast(type?: 'success' | 'error' | 'info' | 'warning' | 'action' |
}
}
else {
faToast('Fantastic-admin 杰出的管理系统框架', {
useFaToast()('Fantastic-admin 杰出的管理系统框架', {
description: '开箱即用,提供舒适开发体验',
position: 'top-right',
duration: 3000,
@@ -476,7 +476,7 @@ const dialog = ref({
})
watch(copied, (val) => {
val && faToast.success(`复制成功:${text.value}`)
val && useFaToast().success(`复制成功:${text.value}`)
})
function test(index: number) {
@@ -2,7 +2,7 @@
import { useClipboard, useDebounceFn, useThrottleFn } from '@vueuse/core'
function message() {
faToast.success('Toast')
useFaToast().success('Toast')
}
const debounce = useDebounceFn(() => {
@@ -16,7 +16,7 @@ const throttle = useThrottleFn(() => {
const input = ref('test')
const { text, copy, copied, isSupported } = useClipboard()
watch(copied, (val) => {
val && faToast.success(text.value)
val && useFaToast().success(text.value)
})
function open(url: string) {
@@ -7,7 +7,7 @@ const { copy, isSupported } = useClipboard()
function onCopy(iconName: string) {
if (isSupported.value) {
copy(`<FaIcon name="i-${iconName}" />`)
faToast.success('复制成功', {
useFaToast().success('复制成功', {
description: `<FaIcon name="i-${iconName}" />`,
})
}
@@ -114,7 +114,7 @@ const { copy, copied, isSupported } = useClipboard()
watch(copied, (val) => {
if (val) {
faToast.success('复制成功', {
useFaToast().success('复制成功', {
position: 'top-center',
})
}
@@ -22,7 +22,7 @@ function handleGenerate() {
esignRef.value.generate().then((res: string) => {
result.value = res
}).catch(() => {
faToast.warning('画板为空,无法生成图片')
useFaToast().warning('画板为空,无法生成图片')
})
}
function handleDownload() {
@@ -47,13 +47,13 @@ defineExpose({
if (valid) {
if (form.value.id === '') {
apiStandardModule.create(form.value).then(() => {
faToast.success('新增成功')
useFaToast().success('新增成功')
resolve()
})
}
else {
apiStandardModule.edit(form.value).then(() => {
faToast.success('编辑成功')
useFaToast().success('编辑成功')
resolve()
})
}
@@ -193,7 +193,7 @@ function onDel(row: any) {
onConfirm: () => {
apiStandardModule.delete(row.id).then(() => {
getDataList()
faToast.success('删除成功')
useFaToast().success('删除成功')
})
},
})
+4 -1
View File
@@ -48,7 +48,10 @@ export default defineConfig(({ mode, command }) => {
},
plugins: createVitePlugins(mode, command === 'build'),
optimizeDeps: {
exclude: ['@fantastic-admin/components'],
exclude: [
'@fantastic-admin/components',
'@fantastic-admin/composables',
],
},
resolve: {
alias: {
+2
View File
@@ -53,6 +53,7 @@ export default function createVitePlugins(mode: string, isBuild = false) {
FantasticAdminComposablesAutoImports,
],
dts: './src/types/auto-imports.d.ts',
dtsMode: 'overwrite',
dirs: [
'./src/store/modules/**/*',
'./src/composables/**/*',
@@ -65,6 +66,7 @@ export default function createVitePlugins(mode: string, isBuild = false) {
'src/components/*/index.vue',
],
dts: './src/types/components.d.ts',
syncMode: 'overwrite',
resolvers: [
FantasticAdminComponentsResolver(),
],