-
Notifications
You must be signed in to change notification settings - Fork 266
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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'] | ||
} |
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'))['Modal'] | ||
} | ||
} |
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" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,76 @@ | ||
<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> | ||
<div class="content"> | ||
<span>消息模式:</span> | ||
<tiny-button @click="messageClick"> 消息提示 </tiny-button> | ||
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. Undefined function 'messageClick' referenced in the template The Apply this diff to add the missing +function messageClick() {
+ TinyNotify({
+ type: 'info',
+ title: '消息提示',
+ message: '这是一个消息提示。',
+ position: 'top-right',
+ duration: 5000
+ })
+}
|
||
</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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { defineConfig } from 'vite' | ||
import vue from '@vitejs/plugin-vue' | ||
import Inspect from 'vite-plugin-inspect' | ||
import autoImportPlugin from '../dist/index.js' | ||
import Components from 'unplugin-vue-components/vite' | ||
import AutoImport from 'unplugin-auto-import/vite' | ||
import { TinyVueResolver } from '../dist/index.js' | ||
Comment on lines
+4
to
+6
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. 💡 Codebase verification Build required: dist directory is missing and dependency setup needs attention
Please ensure to:
🔗 Analysis chainVerify dependencies and build requirements The new imports look good, but let's ensure the build setup is complete. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if the required packages are in dependencies
cat package.json | jq '.dependencies["unplugin-vue-components"], .dependencies["unplugin-auto-import"]'
# Verify if dist/index.js exists and is built
if [ -f "internals/unplugin-tiny-vue/dist/index.js" ]; then
echo "dist/index.js exists"
else
echo "Warning: dist/index.js not found. Build may be required."
fi
Length of output: 365 Script: #!/bin/bash
# Check package.json in the specific plugin directory
cat internals/unplugin-tiny-vue/package.json | jq '.dependencies, .devDependencies'
# Check if the dist directory exists and list its contents
ls -la internals/unplugin-tiny-vue/dist/
# Find example usage of these plugins in the codebase
rg -l "unplugin-vue-components|unplugin-auto-import" internals/unplugin-tiny-vue/
Length of output: 752 |
||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue(), Inspect(), autoImportPlugin()], | ||
plugins: [ | ||
vue(), | ||
Inspect(), | ||
Components({ | ||
resolvers: [TinyVueResolver()] | ||
}), | ||
AutoImport({ | ||
resolvers: [TinyVueResolver({ autoImport: true })] | ||
}) | ||
], | ||
define: { | ||
'process.env': { ...process.env, TINY_MODE: 'pc' } | ||
}, | ||
|
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.
Maintain consistency in configuration examples.
The Vite example uses
export default
while the Webpack example usesmodule.exports
. Additionally, the Vite example incorrectly usesconfigureWebpack
which is a Vue CLI concept, not a Vite concept.Apply this diff to fix the Vite configuration:
Also applies to: 111-124