Skip to content

Commit dfa0adc

Browse files
committed
feat: migrateSelectInput
1 parent 4e8a966 commit dfa0adc

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { readFileSync, writeFileSync } from 'node:fs';
2+
3+
function migrateUseSingle() {
4+
const filePath = 'src/select-input/useSingle.tsx';
5+
let content = readFileSync(filePath, 'utf8');
6+
if (content.includes('const instance = getCurrentInstance();')) {
7+
content = content.replace('const instance = getCurrentInstance();', 'const instance = getCurrentInstance().proxy;');
8+
content = content.replaceAll('instance.emit', 'instance.$emit');
9+
writeFileSync(filePath, content, 'utf8');
10+
}
11+
}
12+
function migrateUseOverlayInnerStyle() {
13+
const filePath = 'src/select-input/useOverlayInnerStyle.ts';
14+
let content = readFileSync(filePath, 'utf8');
15+
if (content.includes('const instance = getCurrentInstance();')) {
16+
content = content.replace('const instance = getCurrentInstance();', 'const instance = getCurrentInstance().proxy;');
17+
content = content.replaceAll('instance.emit', 'instance.$emit');
18+
writeFileSync(filePath, content, 'utf8');
19+
}
20+
}
21+
function migrateSelectInput() {
22+
const filePath = 'src/select-input/select-input.tsx';
23+
let content = readFileSync(filePath, 'utf8');
24+
if (content.includes('setup(props: TdSelectInputProps')) {
25+
content = content.replace('setup(props: TdSelectInputProps', 'setup(props');
26+
writeFileSync(filePath, content, 'utf8');
27+
}
28+
}
29+
30+
export default function () {
31+
migrateSelectInput();
32+
migrateUseSingle();
33+
migrateUseOverlayInnerStyle();
34+
}

script/migrate/migrateComponent.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import migrateUpload from './components/upload.mjs';
1313
import migrateTable from './components/table.mjs';
1414
import migrateSelect from './components/select.mjs';
1515
import migrateRangeInput from './components/range-input.mjs';
16+
import migrateSelectInput from './components/select-input.mjs';
1617

1718
function run() {
1819
migrateSingleFile();
@@ -24,6 +25,7 @@ function run() {
2425
migrateCard();
2526
migrateUpload();
2627
migrateSelect();
28+
migrateSelectInput();
2729
migrateTable();
2830
migrateTree();
2931
migrateRangeInput();

0 commit comments

Comments
 (0)