Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/workflows/typos-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extend-exclude = [
"changelog.json",
"echarts.js",
"packages/components/locale/*",
"packages/uniapp-components/locale/*",
"packages/uniapp-components/npm/**/*",
"packages/uniapp-pro-components/chat/npm/**/*",
"packages/tdesign-uniapp/app/common/uni.css",
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/uni-mp-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: UNI_MP_PREVIEW

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [develop]

concurrency:
group: mp-preview-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: 小程序预览/上传
uses: novlan1/tencent-cos-and-cdn-action/mp-preview@master
with:
mini_app_id: ${{ secrets.TDESIGN_UNI_APP_ID }}
mini_app_private_key: ${{ secrets.TDESIGN_UNI_MINI_KEY }}
allowed_users: '{"novlan1":26,"anlyyao":27}'
install_command: 'pnpm install'
build_command: 'pnpm run uniapp -- run init && pnpm run uniapp -- run build:mp-weixin'
project_path: 'packages/tdesign-uniapp/example/dist/build/mp-weixin'
cos_secret_id: ${{ secrets.UNI_TENCENT_COS_SECRET_ID }}
cos_secret_key: ${{ secrets.UNI_TENCENT_COS_SECRET_KEY }}
cos_bucket: mike-1255355338
cos_region: ap-guangzhou
cos_remote_path: tdesign-uniapp/wx-mp-preview-qrcode.png
cdn_prefix: 'https://cdn.uwayfly.com/'
description_prefix: 'tdesign-uniapp'
21 changes: 21 additions & 0 deletions packages/tdesign-miniprogram/test/scripts/globalSetup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
const path = require('path');
const fs = require('fs');

/**
* 清理 uniapp 构建产物目录,避免 wcc 编译器扫描 packages/ 时
* 误编译 uniapp dist 中不兼容的 wxml 文件导致测试失败
*/
function cleanUniappDist() {
const distDirs = [
path.resolve(__dirname, '../../../tdesign-uniapp/example/dist'),
path.resolve(__dirname, '../../../tdesign-uniapp-chat/example/dist'),
];

distDirs.forEach((dir) => {
if (fs.existsSync(dir)) {
fs.rmSync(dir, { recursive: true, force: true });
}
});
}

module.exports = async () => {
process.env.TZ = 'Asia/Shanghai';
cleanUniappDist();
};
9 changes: 9 additions & 0 deletions packages/tdesign-uniapp/.changelog/pr-4350.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
pr_number: 4350
contributor: novlan1
---

- feat(ConfigProvider): 新增 `ConfigProvider` 全局特性配置组件 @novlan1 ([#4350](https://github.com/Tencent/tdesign-miniprogram/pull/4350))
- break(DateTimePicker): 废弃 `custom-locale` 属性,请用 `ConfigProvider` 替换该功能 @novlan1 ([#4350](https://github.com/Tencent/tdesign-miniprogram/pull/4350))
- fix(Form): 修复 `required-mark` 无效问题 @novlan1 ([#4350](https://github.com/Tencent/tdesign-miniprogram/pull/4350))
- fix(ColorPicker): 修复弹窗模式下预设颜色(swatch-colors)无法横向滚动 @novlan1 ([#4350](https://github.com/Tencent/tdesign-miniprogram/pull/4350))
9 changes: 8 additions & 1 deletion packages/tdesign-uniapp/app/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@
{
"path": "pages-more/watermark/watermark"
},
{
"path": "pages-more/config-provider/config-provider"
},
{
"path": "pages-more/action-sheet/action-sheet"
},
Expand Down Expand Up @@ -417,6 +420,10 @@
"name": "watermark",
"pathName": "pages-more/watermark/watermark"
},
{
"name": "config-provider",
"pathName": "pages-more/config-provider/config-provider"
},
{
"name": "action-sheet",
"pathName": "pages-more/action-sheet/action-sheet"
Expand Down Expand Up @@ -472,4 +479,4 @@
"^t-(.*)": "@/uni_modules/tdesign-uniapp/components/$1/$1.vue"
}
}
}
}
4 changes: 4 additions & 0 deletions packages/tdesign-uniapp/example/script/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const {
skylineUx,
chat,
skylineChat,
other,
skylineOther,
} = components;

const getComponentPages = (list, isSkyline) => list.reduce((acc, item) => [
Expand All @@ -42,6 +44,7 @@ function main() {
nav,
form,
display,
other,
];

const skylineList = SHOW_SKYLINE_PAGES ? [
Expand All @@ -51,6 +54,7 @@ function main() {
skylineForm,
skylineDisplay,
skylineUx,
skylineOther,
] : [];

const componentPages = getComponentPages(list, false);
Expand Down
75 changes: 60 additions & 15 deletions packages/tdesign-uniapp/example/script/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ const path = require('path');
const fs = require('fs');
const { writeFileSync } = require('t-comm');
const { toPascal } = require('../utils/utils');
const { PACKAGES_ROOT } = require('../release/config');
const { PACKAGES_ROOT, toGlobPattern } = require('../release/config');


// 基于 __dirname 推算项目根目录(脚本位于 packages/tdesign-uniapp/example/script/types/)
const PROJECT_ROOT = path.resolve(__dirname, '../../../../../');


const CONFIG = {
pkgJsonPath: path.resolve(PACKAGES_ROOT, 'uniapp-components/package.json'),
chatPkgJsonPath: path.resolve(__dirname, 'uniapp-pro-components/chat/package.json'),
chatPkgJsonPath: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/package.json'),

dtsDir: path.resolve(PACKAGES_ROOT, 'uniapp-components/types'),
chatDtsDir: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/types'),

indexPath: path.resolve(PACKAGES_ROOT, 'uniapp-components/types/index.d.ts'),
chatIndexPath: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/types/index.d.ts'),

globalDTSPath: path.resolve(PACKAGES_ROOT, 'uniapp-components/global.d.ts'),
chatGlobalDTSPath: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/global.d.ts'),
globalDTSPath: path.resolve(PACKAGES_ROOT, 'tdesign-uniapp/global.d.ts'),
chatGlobalDTSPath: path.resolve(PACKAGES_ROOT, 'tdesign-uniapp-chat/global.d.ts'),
filterTypes: ['form-item'],
};

Expand Down Expand Up @@ -49,6 +54,14 @@ const GLOBAL_DTS_TEMPLATE = `declare module 'vue' {
export {};
`;


function checkFileExists(filePath, label) {
if (!fs.existsSync(filePath)) {
console.error(`[types] 错误: ${label} 不存在: ${filePath}`);
process.exit(1);
}
}

async function genOnProject({
pkgGlob,
pkgJsonPath,
Expand All @@ -57,24 +70,47 @@ async function genOnProject({
globalDTSPath,
isChat,
}) {
const label = isChat ? 'chat' : 'base';
console.log(`[types][${label}] 开始生成, glob: ${pkgGlob}`);

checkFileExists(pkgJsonPath, 'package.json');
checkFileExists(path.dirname(globalDTSPath), 'global.d.ts 所在目录');

const list = glob.sync(pkgGlob);
if (list.length === 0) {
console.error(`[types][${label}] 错误: glob "${pkgGlob}" 未匹配到任何 .vue 文件`);
console.error(`[types][${label}] 当前 cwd: ${process.cwd()}`);
process.exit(1);
}

const filtered = list.filter((item) => {
const typeFile = path.resolve(item, '../type.ts');
return fs.existsSync(typeFile);
});

if (filtered.length === 0) {
console.error(`[types][${label}] 错误: 匹配到 ${list.length} 个 .vue 文件, 但没有组件包含 type.ts`);
process.exit(1);
}

const fileNames = filtered.map(item => item.split(path.sep)[item.split(path.sep).length - 2]);
fileNames.sort();

changePkgExports(fileNames, pkgJsonPath);
genDTS({ list: fileNames, dtsDir, isChat });
genIndexContent(fileNames, indexPath);
getGlobalDTS(fileNames, globalDTSPath);
console.log(`[types][${label}] 找到 ${fileNames.length} 个组件: ${fileNames.join(', ')}`);

changePkgExports(fileNames, pkgJsonPath, label);
genDTS({ list: fileNames, dtsDir, isChat, label });
genIndexContent(fileNames, indexPath, label);
getGlobalDTS(fileNames, globalDTSPath, isChat, label);

console.log(`[types][${label}] 生成完毕 ✅`);
}

async function main() {
console.log(`[types] PACKAGES_ROOT: ${PACKAGES_ROOT}`);

await genOnProject({
pkgGlob: 'packages/tdesign/*/*.vue',
pkgGlob: toGlobPattern(path.resolve(PROJECT_ROOT, 'packages/uniapp-components/*/*.vue')),
pkgJsonPath: CONFIG.pkgJsonPath,
dtsDir: CONFIG.dtsDir,
indexPath: CONFIG.indexPath,
Expand All @@ -83,7 +119,7 @@ async function main() {
});

await genOnProject({
pkgGlob: 'packages/tdesign-uniapp-chat/*/*.vue',
pkgGlob: toGlobPattern(path.resolve(PROJECT_ROOT, 'packages/uniapp-pro-components/chat/*/*.vue')),
pkgJsonPath: CONFIG.chatPkgJsonPath,
dtsDir: CONFIG.chatDtsDir,
indexPath: CONFIG.chatIndexPath,
Expand All @@ -93,7 +129,7 @@ async function main() {
}


function changePkgExports(fileNames, pkgJsonPath) {
function changePkgExports(fileNames, pkgJsonPath, label) {
const exportsType = fileNames.reduce((acc, item) => {
const key = `./${item}/${item}.vue`;
return {
Expand All @@ -111,32 +147,41 @@ function changePkgExports(fileNames, pkgJsonPath) {
const pkgJson = require(pkgJsonPath);
pkgJson.exports = exportsType;
writeFileSync(pkgJsonPath, `${JSON.stringify(pkgJson, null, 2)}\n`);
console.log(`[types][${label}] 更新 package.json exports: ${Object.keys(exportsType).length} 条`);
}


function genDTS({ list, dtsDir, isChat }) {
function genDTS({ list, dtsDir, isChat, label }) {
if (!fs.existsSync(dtsDir)) {
fs.mkdirSync(dtsDir, { recursive: true });
console.log(`[types][${label}] 创建目录: ${dtsDir}`);
}
list.forEach((item) => {
const fileName = path.resolve(dtsDir, `${item}.d.ts`);
const content = getDTSTemplate(isChat)
.replaceAll('{{Component}}', toPascal(item))
.replaceAll('{{component}}', item);
writeFileSync(fileName, content);
});
console.log(`[types][${label}] 生成 ${list.length} 个 .d.ts 文件到 ${dtsDir}`);
}

function genIndexContent(fileNames, indexPath) {
function genIndexContent(fileNames, indexPath, label) {
const content = Array.from(new Set(fileNames))
.filter(item => !CONFIG.filterTypes.includes(item))
.map(item => `export * from '../${item}/type';`);
writeFileSync(indexPath, `${content.join('\n')}\n`);
console.log(`[types][${label}] 生成 index.d.ts: ${content.length} 条 export`);
}

function getGlobalDTS(fileNames, globalDTSPath) {
function getGlobalDTS(fileNames, globalDTSPath, isChat, label) {
const pkgName = isChat ? '@tdesign/uniapp-chat' : '@tdesign/uniapp';
const content = Array.from(new Set(fileNames))
.map(item => `T${toPascal(item)}: typeof import('@tdesign/uniapp/${item}/${item}.vue').default;`);
.map(item => `T${toPascal(item)}: typeof import('${pkgName}/${item}/${item}.vue').default;`);

const result = GLOBAL_DTS_TEMPLATE.replace('{{CONTENT}}', content.join('\n '));
writeFileSync(globalDTSPath, result);
console.log(`[types][${label}] 生成 global.d.ts: ${content.length} 个组件 -> ${globalDTSPath}`);
}


Expand Down
3 changes: 3 additions & 0 deletions packages/tdesign-uniapp/example/script/utils/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { display, skylineDisplay } = require('../../src/pages/home/data/display.j
const { form, skylineForm } = require('../../src/pages/home/data/form.json');
const { ux, skylineUx } = require('../../src/pages/home/data/ux.json');
const { chat, skylineChat } = require('../../src/pages/home/data/chat.json');
const { other, skylineOther } = require('../../src/pages/home/data/other.json');


module.exports = {
Expand All @@ -20,5 +21,7 @@ module.exports = {
skylineUx,
chat,
skylineChat,
other,
skylineOther,
},
};
14 changes: 13 additions & 1 deletion packages/tdesign-uniapp/example/script/watch/helper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
const fs = require('fs');
const path = require('path');

const { config } = require('./config');
const { copy } = require('../release/core');

// 不同步到 vue3-hx 的文件黑名单
const VUE3_HX_BLACK_LIST = [
'package.json',
'tsconfig.eslint.json',
];

function isInVue3HxBlackList(relativePath) {
const fileName = path.basename(relativePath);
return VUE3_HX_BLACK_LIST.includes(fileName);
}


async function copyComponents({
relativePath,
Expand Down Expand Up @@ -54,7 +66,7 @@ async function copyComponents({
});
}

if (checkVue3HxExist()) {
if (checkVue3HxExist() && !isInVue3HxBlackList(relativePath)) {
await copy({
relativePath,
filePath,
Expand Down
3 changes: 3 additions & 0 deletions packages/tdesign-uniapp/example/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import TNavbar from '@tdesign/uniapp/navbar/navbar.vue';
import TDemoHeader from '@tdesign/uniapp/demo-header/demo-header.vue';
import TDemoNavbar from '@tdesign/uniapp/demo-navbar/demo-navbar.vue';

const chooseImage = uni.chooseImage || {};
// @ts-ignore
uni.chooseImage = chooseImage;

export function createApp() {
const app = createSSRApp(App);
Expand Down
7 changes: 7 additions & 0 deletions packages/tdesign-uniapp/example/src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
},
{
"path": "pages-more/watermark/watermark"
},
{
"path": "pages-more/config-provider/config-provider"
}
],
"subPackages": [
Expand Down Expand Up @@ -559,6 +562,10 @@
"name": "watermark",
"pathName": "pages-more/watermark/watermark"
},
{
"name": "config-provider",
"pathName": "pages-more/config-provider/config-provider"
},
{
"name": "action-sheet",
"pathName": "pages-more/action-sheet/action-sheet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import displayData from './display.json';
import formData from './form.json';
import uxData from './ux.json';
import chatData from './chat.json';
import otherData from './other.json';

const { base, skylineBase } = baseData;
const { nav, skylineNav } = navData;
const { display, skylineDisplay } = displayData;
const { form, skylineForm } = formData;
const { ux, skylineUx } = uxData;
const { chat } = chatData;
const { other, skylineOther } = otherData;

const list = [chat, base, nav, form, display, ux];
const list = [chat, base, nav, form, display, ux, other];

const skylineList = [skylineBase, skylineNav, skylineForm, skylineDisplay, skylineUx];
const skylineList = [skylineBase, skylineNav, skylineForm, skylineDisplay, skylineUx, skylineOther];

export { list, skylineList };
Loading
Loading