-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(auto-import-plugin): support functional components #2511
Open
mengqiuleo
wants to merge
1
commit into
opentiny:dev
Choose a base branch
from
mengqiuleo:fix-auto-import-plugin
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
// @ts-nocheck | ||
// noinspection JSUnusedGlobalSymbols | ||
// Generated by unplugin-auto-import | ||
// biome-ignore lint: disable | ||
export {} | ||
declare global { | ||
const TinyLoading: (typeof import('@opentiny/vue'))['TinyLoading'] | ||
const TinyModal: (typeof import('@opentiny/vue'))['TinyModal'] | ||
const TinyNotify: (typeof import('@opentiny/vue'))['TinyNotify'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
// @ts-nocheck | ||
// Generated by unplugin-vue-components | ||
// Read more: https://github.com/vuejs/core/pull/3399 | ||
export {} | ||
|
||
declare module 'vue' { | ||
export interface GlobalComponents { | ||
RouterLink: (typeof import('vue-router'))['RouterLink'] | ||
RouterView: (typeof import('vue-router'))['RouterView'] | ||
TinyButton: (typeof import('@opentiny/vue'))['Button'] | ||
TinyModal: (typeof import('@opentiny/vue'))['TinyModal'] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
{ | ||
"name": "my-vue-app", | ||
"version": "0.0.0", | ||
"description": "", | ||
"author": "", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@opentiny/vue": "~3.12.1", | ||
"@opentiny/vue-alert": "~3.13.0", | ||
"@opentiny/vue-button-group": "~3.13.0", | ||
"@opentiny/vue": "~3.18.0", | ||
"@opentiny/vue-icon": "^3.12.0", | ||
"vue": "^3.3.9" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^4.1.0", | ||
"vite": "link:../node_modules/vite", | ||
"unplugin-auto-import": "^0.18.3", | ||
"vite": "^4.3.8", | ||
"vite-plugin-inspect": "^0.8.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,72 @@ | ||
<template> | ||
<div> | ||
<tiny-button-group :data="groupData" v-model="checkedVal"></tiny-button-group> | ||
<span>当前选中值:{{ checkedVal }}</span> | ||
<tiny-alert description="type 为默认值 success"></tiny-alert> | ||
<tiny-button @click="closeLoading">close Loading</tiny-button> | ||
<div id="tiny-basic-loading1"></div> | ||
<tiny-button @click="handleClick" :reset-time="0">弹出提示框</tiny-button> | ||
|
||
<h2>函数式调用</h2> | ||
<div class="content"> | ||
<span>弹窗模式:</span> | ||
<tiny-button @click="baseClick"> 基本提示框 </tiny-button> | ||
<tiny-button @click="successClick"> 成功提示框 </tiny-button> | ||
<tiny-button @click="confirmClick"> 确认提示框 </tiny-button> | ||
</div> | ||
|
||
<h2>标签式调用</h2> | ||
<div class="content"> | ||
<tiny-modal v-model="show1" title="基本提示框" message="窗口内容1" show-footer> </tiny-modal> | ||
<tiny-modal v-model="show2" title="基本提示框" message="窗口内容2" status="success" show-footer> </tiny-modal> | ||
<tiny-button @click="show1 = true"> 打开弹窗1 </tiny-button> | ||
<tiny-button @click="show2 = true"> 打开弹窗2 </tiny-button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
checkedVal: 'Button1', | ||
groupData: [ | ||
{ text: 'Button1', value: 'Button1' }, | ||
{ text: 'Button2', value: 'Button2' }, | ||
{ text: 'Button3', value: 'Button3' } | ||
] | ||
} | ||
} | ||
<script setup> | ||
import { ref, onMounted } from 'vue' | ||
|
||
const loadingInstance = ref(null) | ||
|
||
const closeLoading = () => { | ||
loadingInstance.value.close() | ||
} | ||
|
||
onMounted(() => { | ||
loadingInstance.value = TinyLoading.service({ | ||
target: document.getElementById('tiny-basic-loading1') | ||
}) | ||
}) | ||
|
||
function handleClick() { | ||
TinyNotify({ | ||
type: 'info', | ||
title: '通知消息的标题', | ||
message: '通知消息的正文,通知消息的正文,通知消息的正文,通知消息的正文,通知消息的正文,通知消息的正文', | ||
position: 'top-right', | ||
duration: 5000, | ||
customClass: 'my-custom-cls' | ||
}) | ||
} | ||
|
||
const show1 = ref(false) | ||
const show2 = ref(false) | ||
|
||
function baseClick() { | ||
const modal = TinyModal.alert('基本提示框', '标题') | ||
setTimeout(() => modal.vm.close(), 3000) | ||
} | ||
|
||
function successClick() { | ||
TinyModal.alert({ message: '成功提示框', status: 'success' }) | ||
} | ||
|
||
function confirmClick() { | ||
TinyModal.confirm('您确定要删除吗?').then((res) => { | ||
TinyNotify({ | ||
type: 'info', | ||
title: '触发回调事件', | ||
message: `点击${res}按钮` | ||
}) | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,25 @@ const supportMap = { | |
'rspack': AutoRspack | ||
} | ||
|
||
export const TinyVueResolver = (componentName) => { | ||
const TinyVueFunc = ['TinyModal', 'TinyNotify', 'TinyLoading'] | ||
|
||
export const TinyVueAutoImportResolver = (componentName: string) => { | ||
if (TinyVueFunc.includes(componentName)) { | ||
return { | ||
name: componentName, | ||
from: '@opentiny/vue' | ||
} | ||
} | ||
|
||
if (componentName.startsWith('Tiny') && !componentName.startsWith('TinyIcon')) { | ||
return { | ||
name: componentName.slice(4), | ||
from: '@opentiny/vue' | ||
} | ||
} | ||
} | ||
|
||
export const TinyVueResolver = (componentName: string) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为了避免破坏性变更, 你是保留了 TinyVueResolver 的名字, 特意新加了一个TinyVueAutoImportResolver 变量。 但现在看来, TinyVueAutoImportResolver 变量的能力涵盖了 TinyVueResolver, 且都是一层函数了 |
||
if (componentName.startsWith('Tiny') && !componentName.startsWith('TinyIcon')) { | ||
return { | ||
name: componentName.slice(4), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个变量,都还使用 TinyVueResolver 这个名称即可