Skip to content

Commit 640f9c1

Browse files
fix(auto-import-resolver): fix auto import ChatReasoning invalid (#5818)
* chore(auto-import-resolver): use common constants * chore(auto-import-resolver): use common constants * chore(auto-import-resolver): use common constants * chore: fix build * chore: update common * chore: update common * docs: update readme * chore: update common --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 8546500 commit 640f9c1

File tree

5 files changed

+18
-159
lines changed

5 files changed

+18
-159
lines changed

packages/auto-import-resolver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Components({
220220
Components({
221221
resolvers: [
222222
TDesignResolver({
223-
exclude: ['Button'],
223+
exclude: ['TButton'],
224224
}),
225225
],
226226
});

packages/auto-import-resolver/src/components.ts

Lines changed: 0 additions & 145 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
export * from './components';
21
export * from './resolver';
32
export * from './utils';

packages/auto-import-resolver/src/resolver.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ComponentResolver } from 'unplugin-vue-components';
22
import type { FilterPattern } from 'unplugin-utils';
3-
import { chatComponentMap, mobileComponentMap, webComponentMap } from './components';
3+
import { WEB_COMPONENT_MAP, MOBILE_COMPONENT_MAP, CHAT_COMPONENT_MAP } from '@tdesign/common-js/components';
4+
45
import icons from './icons.json';
56
import { isExclude } from './utils';
67

@@ -47,16 +48,7 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
4748
from: `${resolveIconPkg(library)}${importFrom}`,
4849
};
4950
}
50-
let componentMap: Record<string, string[]> = {};
51-
if (['vue', 'vue-next'].includes(library)) {
52-
componentMap = webComponentMap;
53-
}
54-
if (library === 'mobile-vue') {
55-
componentMap = mobileComponentMap;
56-
}
57-
if (library === 'chat') {
58-
componentMap = chatComponentMap;
59-
}
51+
const componentMap = resolveComponentMap(library);
6052

6153
let isTDesignComponent = false;
6254
const importName = resolveImportName(name);
@@ -109,3 +101,16 @@ function resolveComponentPkg(library: TDesignLibrary): string {
109101
}
110102
return `tdesign-${library}`;
111103
}
104+
105+
function resolveComponentMap(library: TDesignLibrary): Record<string, string[]> {
106+
if (['vue', 'vue-next'].includes(library)) {
107+
return WEB_COMPONENT_MAP;
108+
}
109+
if (library === 'mobile-vue') {
110+
return MOBILE_COMPONENT_MAP;
111+
}
112+
if (library === 'chat') {
113+
return CHAT_COMPONENT_MAP;
114+
}
115+
return;
116+
}

0 commit comments

Comments
 (0)