diff --git a/.eslintrc.js b/.eslintrc.js index 45170813b..89c28d5d8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -11,7 +11,13 @@ module.exports = { parserOptions: { parser: 'babel-eslint', }, - extends: ['plugin:vue/vue3-recommended', 'prettier'], + extends: [ + 'plugin:vue/vue3-essential', + 'eslint:recommended', + '@vue/typescript/recommended', + '@vue/prettier', + '@vue/prettier/@typescript-eslint', + ], plugins: ['markdown', 'jest', '@typescript-eslint'], overrides: [ { @@ -52,24 +58,24 @@ module.exports = { camelcase: 'off', 'no-extra-boolean-cast': 'off', semi: ['error', 'always'], - 'vue/require-explicit-emits': 'off', - 'vue/require-prop-types': 'off', - 'vue/require-default-prop': 'off', - 'vue/no-reserved-keys': 'off', - 'vue/comment-directive': 'off', - 'vue/prop-name-casing': 'off', - 'vue/one-component-per-file': 'off', - 'vue/custom-event-name-casing': 'off', - 'vue/max-attributes-per-line': [ - 2, - { - singleline: 20, - multiline: { - max: 1, - allowFirstLine: false, - }, - }, - ], + // 'vue/require-explicit-emits': 'off', + // 'vue/require-prop-types': 'off', + // 'vue/require-default-prop': 'off', + // 'vue/no-reserved-keys': 'off', + // 'vue/comment-directive': 'off', + // 'vue/prop-name-casing': 'off', + // 'vue/one-component-per-file': 'off', + // 'vue/custom-event-name-casing': 'off', + // 'vue/max-attributes-per-line': [ + // 2, + // { + // singleline: 20, + // multiline: { + // max: 1, + // allowFirstLine: false, + // }, + // }, + // ], }, globals: { h: true, diff --git a/examples/App.vue b/examples/App.vue index d492b4115..4af4dd9be 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -5,7 +5,7 @@ diff --git a/vite.config.ts b/examples/vite.config.ts similarity index 85% rename from vite.config.ts rename to examples/vite.config.ts index 0637a8b7e..041d37ca0 100644 --- a/vite.config.ts +++ b/examples/vite.config.ts @@ -1,7 +1,7 @@ import path from 'path'; import vue from '@vitejs/plugin-vue'; -import md from './plugin/md'; -import docs from './plugin/docs'; +import md from '../plugin/md'; +import docs from '../plugin/docs'; import vueJsx from '@vitejs/plugin-vue-jsx'; /** @@ -11,7 +11,7 @@ export default { resolve: { alias: { vue: 'vue/dist/vue.esm-bundler.js', - 'ant-design-vue': path.resolve(__dirname, './components'), + 'ant-design-vue': path.resolve(__dirname, '../components'), }, }, plugins: [ diff --git a/index.html b/index.html deleted file mode 100644 index bbd8c2c00..000000000 --- a/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - Ant Design Vue - - - - - - - -
- - diff --git a/package.json b/package.json index 2d9772936..3526fb990 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "vetur" ], "scripts": { - "debugger": "vite", - "dev": "vite serve site", + "debugger": "vite serve examples", + "dev": "yarn routes && vite serve site", "test": "cross-env NODE_ENV=test WORKFLOW=true jest --config .jest.js", "test:dev": "cross-env NODE_ENV=test jest --config .jest.js", "compile": "node antd-tools/cli/run.js compile", @@ -43,7 +43,8 @@ "dist": "node --max_old_space_size=8192 antd-tools/cli/run.js dist", "lint": "eslint -c ./.eslintrc.js --fix --ext .jsx,.js,.ts,.tsx ./components", "lint:style": "stylelint \"{site,components}/**/*.less\" --syntax less", - "codecov": "codecov" + "codecov": "codecov", + "routes": "node site/scripts/genrateRoutes.js" }, "repository": { "type": "git", diff --git a/scripts/compact-vars.js b/scripts/compact-vars.js new file mode 100644 index 000000000..40093f975 --- /dev/null +++ b/scripts/compact-vars.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const path = require('path'); +const lessToJs = require('less-vars-to-js'); + +const stylePath = path.join(__dirname, '..', 'components', 'style'); +const compactLess = fs.readFileSync(path.join(stylePath, 'themes', 'compact.less'), 'utf8'); + +const compactPaletteLess = lessToJs(compactLess, { + stripPrefix: true, + resolveVariables: false, +}); + +module.exports = compactPaletteLess; diff --git a/site/scripts/genrateRoutes.js b/site/scripts/genrateRoutes.js index a5f040701..ae42914be 100644 --- a/site/scripts/genrateRoutes.js +++ b/site/scripts/genrateRoutes.js @@ -6,12 +6,12 @@ const matter = require('gray-matter'); const { CLIEngine } = require('eslint'); (async () => { - const paths = await globby('src/docs/*/index.*.md'); + const paths = await globby('components/*/index.*.md'); const components = {}; paths.forEach(path => { const content = fs.readFileSync(path).toString(); - const componentName = path.split('/')[2]; + const componentName = path.split('/')[1]; if (componentName !== 'color-picker') { const { data } = matter(content); @@ -25,7 +25,7 @@ export default [ { path: '${component}:lang(-cn)?', meta: ${JSON.stringify(components[component])}, - component: () => import('../docs/${component}/demo/index.vue'), + component: () => import('../../../components/${component}/demo/index.vue'), }`, )} ];`; @@ -38,5 +38,5 @@ export default [ const report = engine.executeOnText(TEMPLATE); - fs.writeFileSync('src/router/demoRoutes.js', report.results[0].output); + fs.writeFileSync('site/src/router/demoRoutes.js', report.results[0].output); })(); diff --git a/site/src/App.vue b/site/src/App.vue index a5fbc5dd7..6068a065b 100644 --- a/site/src/App.vue +++ b/site/src/App.vue @@ -10,8 +10,8 @@ import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import useMediaQuery from './hooks/useMediaQuery'; import { GLOBAL_CONFIG } from './SymbolKey'; -import enUS from 'ant-design-vue/es/locale/en_US'; -import zhCN from 'ant-design-vue/es/locale/zh_CN'; +import enUS from '../../components/locale/en_US'; +import zhCN from '../../components/locale/zh_CN'; import dayjs from 'dayjs'; import 'dayjs/locale/zh-cn'; function isZhCN(name: string) { diff --git a/site/src/components/DemoBox.vue b/site/src/components/DemoBox.vue index ed77a8b52..3e78ee85f 100644 --- a/site/src/components/DemoBox.vue +++ b/site/src/components/DemoBox.vue @@ -98,11 +98,7 @@ export default defineComponent({ const copied = ref(false); const sectionId = computed(() => { const relativePath = props.jsfiddle?.relativePath || ''; - return `components-${relativePath - .split('/docs/')[1] - .split('/') - .join('-') - .replace('.vue', '')}`; + return `${relativePath.split('/').join('-').replace('.vue', '')}`; }); const inIframe = inject('inIframe', false); const iframeHeight = computed(() => props.jsfiddle?.iframe); diff --git a/site/src/layouts/Demo.vue b/site/src/layouts/Demo.vue index 363813bd4..c7e54922d 100644 --- a/site/src/layouts/Demo.vue +++ b/site/src/layouts/Demo.vue @@ -1,5 +1,6 @@ diff --git a/site/src/main.js b/site/src/main.js index 823a020dc..8e4017513 100644 --- a/site/src/main.js +++ b/site/src/main.js @@ -1,4 +1,4 @@ -import 'ant-design-vue/dist/antd.less'; +import '../../components/style'; import 'docsearch.js/dist/cdn/docsearch.css'; import './index.less'; import 'nprogress/nprogress.css'; @@ -18,11 +18,11 @@ const app = createApp(App); app.use(Antd); app.use(clipboard); -app.component('transition', Transition); -app.component('transition-group', TransitionGroup); -app.component('demo-box', demoBox); -app.component('demo-container', demoContainer); -app.component('demo-sort', demoSort); +app.component('Transition', Transition); +app.component('TransitionGroup', TransitionGroup); +app.component('DemoBox', demoBox); +app.component('DemoContainer', demoContainer); +app.component('DemoSort', demoSort); app.component('VNodes', function (_, { attrs: { value } }) { return value; }); diff --git a/site/src/router/demoRoutes.js b/site/src/router/demoRoutes.js new file mode 100644 index 000000000..a635b17f8 --- /dev/null +++ b/site/src/router/demoRoutes.js @@ -0,0 +1,319 @@ + +export default [ + + { + path: 'affix:lang(-cn)?', + meta: {"category":"Components","type":"导航","title":"Affix","cover":"https://gw.alipayobjects.com/zos/alicdn/tX6-md4H6/Affix.svg","subtitle":"固钉"}, + component: () => import('../../../components/affix/demo/index.vue'), + }, + { + path: 'alert:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Alert","cover":"https://gw.alipayobjects.com/zos/alicdn/8emPa3fjl/Alert.svg","subtitle":"警告提示"}, + component: () => import('../../../components/alert/demo/index.vue'), + }, + { + path: 'anchor:lang(-cn)?', + meta: {"category":"Components","type":"其他","cols":2,"title":"Anchor","cover":"https://gw.alipayobjects.com/zos/alicdn/_1-C1JwsC/Anchor.svg","subtitle":"锚点"}, + component: () => import('../../../components/anchor/demo/index.vue'), + }, + { + path: 'avatar:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Avatar","cover":"https://gw.alipayobjects.com/zos/antfincdn/aBcnbw68hP/Avatar.svg","subtitle":"头像"}, + component: () => import('../../../components/avatar/demo/index.vue'), + }, + { + path: 'auto-complete:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","cols":2,"title":"AutoComplete","cover":"https://gw.alipayobjects.com/zos/alicdn/qtJm4yt45/AutoComplete.svg","subtitle":"自动完成"}, + component: () => import('../../../components/auto-complete/demo/index.vue'), + }, + { + path: 'badge:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Badge","cover":"https://gw.alipayobjects.com/zos/antfincdn/6%26GF9WHwvY/Badge.svg","subtitle":"徽标数"}, + component: () => import('../../../components/badge/demo/index.vue'), + }, + { + path: 'back-top:lang(-cn)?', + meta: {"category":"Components","type":"其他","title":"BackTop","cover":"https://gw.alipayobjects.com/zos/alicdn/tJZ5jbTwX/BackTop.svg","subtitle":"回到顶部"}, + component: () => import('../../../components/back-top/demo/index.vue'), + }, + { + path: 'button:lang(-cn)?', + meta: {"category":"Components","type":"通用","title":"Button","cover":"https://gw.alipayobjects.com/zos/alicdn/fNUKzY1sk/Button.svg","subtitle":"按钮"}, + component: () => import('../../../components/button/demo/index.vue'), + }, + { + path: 'breadcrumb:lang(-cn)?', + meta: {"category":"Components","type":"导航","title":"Breadcrumb","cover":"https://gw.alipayobjects.com/zos/alicdn/9Ltop8JwH/Breadcrumb.svg","subtitle":"面包屑"}, + component: () => import('../../../components/breadcrumb/demo/index.vue'), + }, + { + path: 'calendar:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Calendar","cover":"https://gw.alipayobjects.com/zos/antfincdn/dPQmLq08DI/Calendar.svg","subtitle":"日历"}, + component: () => import('../../../components/calendar/demo/index.vue'), + }, + { + path: 'card:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Card","cover":"https://gw.alipayobjects.com/zos/antfincdn/NqXt8DJhky/Card.svg","subtitle":"卡片"}, + component: () => import('../../../components/card/demo/index.vue'), + }, + { + path: 'carousel:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Carousel","cover":"https://gw.alipayobjects.com/zos/antfincdn/%24C9tmj978R/Carousel.svg","subtitle":"走马灯"}, + component: () => import('../../../components/carousel/demo/index.vue'), + }, + { + path: 'cascader:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Cascader","cover":"https://gw.alipayobjects.com/zos/alicdn/UdS8y8xyZ/Cascader.svg","subtitle":"级联选择"}, + component: () => import('../../../components/cascader/demo/index.vue'), + }, + { + path: 'checkbox:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Checkbox","cover":"https://gw.alipayobjects.com/zos/alicdn/8nbVbHEm_/CheckBox.svg","subtitle":"多选框"}, + component: () => import('../../../components/checkbox/demo/index.vue'), + }, + { + path: 'collapse:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Collapse","cover":"https://gw.alipayobjects.com/zos/alicdn/IxH16B9RD/Collapse.svg","subtitle":"折叠面板"}, + component: () => import('../../../components/collapse/demo/index.vue'), + }, + { + path: 'comment:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Comment","cover":"https://gw.alipayobjects.com/zos/alicdn/ILhxpGzBO/Comment.svg","subtitle":"评论"}, + component: () => import('../../../components/comment/demo/index.vue'), + }, + { + path: 'config-provider:lang(-cn)?', + meta: {"category":"Components","type":"其他","cols":1,"title":"ConfigProvider","cover":"https://gw.alipayobjects.com/zos/alicdn/kegYxl1wj/ConfigProvider.svg","subtitle":"全局化配置"}, + component: () => import('../../../components/config-provider/demo/index.vue'), + }, + { + path: 'date-picker:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"DatePicker","cover":"https://gw.alipayobjects.com/zos/alicdn/RT_USzA48/DatePicker.svg","subtitle":"日期选择框"}, + component: () => import('../../../components/date-picker/demo/index.vue'), + }, + { + path: 'descriptions:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Descriptions","cover":"https://gw.alipayobjects.com/zos/alicdn/MjtG9_FOI/Descriptions.svg","subtitle":"描述列表"}, + component: () => import('../../../components/descriptions/demo/index.vue'), + }, + { + path: 'divider:lang(-cn)?', + meta: {"category":"Components","type":"布局","title":"Divider","cover":"https://gw.alipayobjects.com/zos/alicdn/5swjECahe/Divider.svg","subtitle":"分割线"}, + component: () => import('../../../components/divider/demo/index.vue'), + }, + { + path: 'drawer:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Drawer","cover":"https://gw.alipayobjects.com/zos/alicdn/7z8NJQhFb/Drawer.svg","subtitle":"抽屉"}, + component: () => import('../../../components/drawer/demo/index.vue'), + }, + { + path: 'dropdown:lang(-cn)?', + meta: {"category":"Components","type":"导航","title":"Dropdown","cover":"https://gw.alipayobjects.com/zos/alicdn/eedWN59yJ/Dropdown.svg","subtitle":"下拉菜单"}, + component: () => import('../../../components/dropdown/demo/index.vue'), + }, + { + path: 'empty:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Empty","cover":"https://gw.alipayobjects.com/zos/alicdn/MNbKfLBVb/Empty.svg","subtitle":"空状态"}, + component: () => import('../../../components/empty/demo/index.vue'), + }, + { + path: 'form:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","cols":1,"title":"Form","cover":"https://gw.alipayobjects.com/zos/alicdn/ORmcdeaoO/Form.svg","subtitle":"表单"}, + component: () => import('../../../components/form/demo/index.vue'), + }, + { + path: 'grid:lang(-cn)?', + meta: {"category":"Components","type":"布局","cols":1,"title":"Grid","cover":"https://gw.alipayobjects.com/zos/alicdn/5rWLU27so/Grid.svg","subtitle":"栅格"}, + component: () => import('../../../components/grid/demo/index.vue'), + }, + { + path: 'icon:lang(-cn)?', + meta: {"category":"Components","type":"通用","title":"Icon","cover":"https://gw.alipayobjects.com/zos/alicdn/rrwbSt3FQ/Icon.svg","subtitle":"图标"}, + component: () => import('../../../components/icon/demo/index.vue'), + }, + { + path: 'image:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Image","cover":"https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg","subtitle":"图片"}, + component: () => import('../../../components/image/demo/index.vue'), + }, + { + path: 'input:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Input","cover":"https://gw.alipayobjects.com/zos/alicdn/xS9YEJhfe/Input.svg","subtitle":"输入框"}, + component: () => import('../../../components/input/demo/index.vue'), + }, + { + path: 'input-number:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"InputNumber","cover":"https://gw.alipayobjects.com/zos/alicdn/XOS8qZ0kU/InputNumber.svg","subtitle":"数字输入框"}, + component: () => import('../../../components/input-number/demo/index.vue'), + }, + { + path: 'layout:lang(-cn)?', + meta: {"category":"Components","type":"布局","cols":1,"title":"Layout","cover":"https://gw.alipayobjects.com/zos/alicdn/hzEndUVEx/Layout.svg","subtitle":"布局"}, + component: () => import('../../../components/layout/demo/index.vue'), + }, + { + path: 'list:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"List","cover":"https://gw.alipayobjects.com/zos/alicdn/5FrZKStG_/List.svg","subtitle":"列表"}, + component: () => import('../../../components/list/demo/index.vue'), + }, + { + path: 'mentions:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Mentions","cover":"https://gw.alipayobjects.com/zos/alicdn/jPE-itMFM/Mentions.svg","subtitle":"提及"}, + component: () => import('../../../components/mentions/demo/index.vue'), + }, + { + path: 'menu:lang(-cn)?', + meta: {"category":"Components","cols":1,"type":"导航","title":"Menu","cover":"https://gw.alipayobjects.com/zos/alicdn/3XZcjGpvK/Menu.svg","subtitle":"导航菜单"}, + component: () => import('../../../components/menu/demo/index.vue'), + }, + { + path: 'message:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Message","cover":"https://gw.alipayobjects.com/zos/alicdn/hAkKTIW0K/Message.svg","subtitle":"全局提示"}, + component: () => import('../../../components/message/demo/index.vue'), + }, + { + path: 'modal:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Modal","cover":"https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg","subtitle":"对话框"}, + component: () => import('../../../components/modal/demo/index.vue'), + }, + { + path: 'notification:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Notification","cover":"https://gw.alipayobjects.com/zos/alicdn/Jxm5nw61w/Notification.svg","subtitle":"通知提醒框"}, + component: () => import('../../../components/notification/demo/index.vue'), + }, + { + path: 'page-header:lang(-cn)?', + meta: {"category":"Components","type":"导航","title":"PageHeader","cols":1,"subtitle":"页头","cover":"https://gw.alipayobjects.com/zos/alicdn/6bKE0Cq0R/PageHeader.svg"}, + component: () => import('../../../components/page-header/demo/index.vue'), + }, + { + path: 'pagination:lang(-cn)?', + meta: {"category":"Components","type":"导航","title":"Pagination","cols":1,"cover":"https://gw.alipayobjects.com/zos/alicdn/1vqv2bj68/Pagination.svg","subtitle":"分页"}, + component: () => import('../../../components/pagination/demo/index.vue'), + }, + { + path: 'popconfirm:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Popconfirm","cover":"https://gw.alipayobjects.com/zos/alicdn/fjMCD9xRq/Popconfirm.svg","subtitle":"气泡确认框"}, + component: () => import('../../../components/popconfirm/demo/index.vue'), + }, + { + path: 'popover:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Popover","cover":"https://gw.alipayobjects.com/zos/alicdn/1PNL1p_cO/Popover.svg","subtitle":"气泡卡片"}, + component: () => import('../../../components/popover/demo/index.vue'), + }, + { + path: 'progress:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Progress","cover":"https://gw.alipayobjects.com/zos/alicdn/xqsDu4ZyR/Progress.svg","subtitle":"进度条"}, + component: () => import('../../../components/progress/demo/index.vue'), + }, + { + path: 'radio:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Radio","cover":"https://gw.alipayobjects.com/zos/alicdn/8cYb5seNB/Radio.svg","subtitle":"单选框"}, + component: () => import('../../../components/radio/demo/index.vue'), + }, + { + path: 'rate:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Rate","cover":"https://gw.alipayobjects.com/zos/alicdn/R5uiIWmxe/Rate.svg","subtitle":"评分"}, + component: () => import('../../../components/rate/demo/index.vue'), + }, + { + path: 'result:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Result","cover":"https://gw.alipayobjects.com/zos/alicdn/9nepwjaLa/Result.svg","subtitle":"结果"}, + component: () => import('../../../components/result/demo/index.vue'), + }, + { + path: 'select:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Select","cover":"https://gw.alipayobjects.com/zos/alicdn/_0XzgOis7/Select.svg","subtitle":"选择器"}, + component: () => import('../../../components/select/demo/index.vue'), + }, + { + path: 'skeleton:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Skeleton","cover":"https://gw.alipayobjects.com/zos/alicdn/KpcciCJgv/Skeleton.svg","subtitle":"骨架屏"}, + component: () => import('../../../components/skeleton/demo/index.vue'), + }, + { + path: 'slider:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Slider","cover":"https://gw.alipayobjects.com/zos/alicdn/HZ3meFc6W/Silder.svg","subtitle":"滑动输入条"}, + component: () => import('../../../components/slider/demo/index.vue'), + }, + { + path: 'space:lang(-cn)?', + meta: {"category":"Components","type":"布局","title":"Space","cols":1,"cover":"https://gw.alipayobjects.com/zos/antfincdn/wc6%263gJ0Y8/Space.svg","subtitle":"间距"}, + component: () => import('../../../components/space/demo/index.vue'), + }, + { + path: 'spin:lang(-cn)?', + meta: {"category":"Components","type":"反馈","title":"Spin","cover":"https://gw.alipayobjects.com/zos/alicdn/8emPa3fjl/Alert.svg","subtitle":"加载中"}, + component: () => import('../../../components/spin/demo/index.vue'), + }, + { + path: 'statistic:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Statistic","cover":"https://gw.alipayobjects.com/zos/antfincdn/rcBNhLBrKbE/Statistic.svg","subtitle":"统计数值"}, + component: () => import('../../../components/statistic/demo/index.vue'), + }, + { + path: 'steps:lang(-cn)?', + meta: {"category":"Components","type":"导航","cols":1,"title":"Steps","cover":"https://gw.alipayobjects.com/zos/antfincdn/UZYqMizXHaj/Steps.svg","subtitle":"步骤条"}, + component: () => import('../../../components/steps/demo/index.vue'), + }, + { + path: 'switch:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Switch","cover":"https://gw.alipayobjects.com/zos/alicdn/zNdJQMhfm/Switch.svg","subtitle":"开关"}, + component: () => import('../../../components/switch/demo/index.vue'), + }, + { + path: 'table:lang(-cn)?', + meta: {"category":"Components","cols":1,"type":"数据展示","title":"Table","cover":"https://gw.alipayobjects.com/zos/alicdn/f-SbcX2Lx/Table.svg","subtitle":"表格"}, + component: () => import('../../../components/table/demo/index.vue'), + }, + { + path: 'tabs:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Tabs","cover":"https://gw.alipayobjects.com/zos/antfincdn/lkI2hNEDr2V/Tabs.svg","subtitle":"标签页"}, + component: () => import('../../../components/tabs/demo/index.vue'), + }, + { + path: 'tag:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Tag","cover":"https://gw.alipayobjects.com/zos/alicdn/cH1BOLfxC/Tag.svg","subtitle":"标签"}, + component: () => import('../../../components/tag/demo/index.vue'), + }, + { + path: 'time-picker:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"TimePicker","cover":"https://gw.alipayobjects.com/zos/alicdn/h04Zsl98I/TimePicker.svg","subtitle":"时间选择框"}, + component: () => import('../../../components/time-picker/demo/index.vue'), + }, + { + path: 'timeline:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Timeline","cover":"https://gw.alipayobjects.com/zos/antfincdn/vJmo00mmgR/Timeline.svg","subtitle":"时间轴"}, + component: () => import('../../../components/timeline/demo/index.vue'), + }, + { + path: 'tooltip:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Tooltip","cover":"https://gw.alipayobjects.com/zos/alicdn/Vyyeu8jq2/Tooltp.svg","subtitle":"文字提示"}, + component: () => import('../../../components/tooltip/demo/index.vue'), + }, + { + path: 'transfer:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Transfer","cover":"https://gw.alipayobjects.com/zos/alicdn/QAXskNI4G/Transfer.svg","subtitle":"穿梭框"}, + component: () => import('../../../components/transfer/demo/index.vue'), + }, + { + path: 'tree:lang(-cn)?', + meta: {"category":"Components","type":"数据展示","title":"Tree","cover":"https://gw.alipayobjects.com/zos/alicdn/Xh-oWqg9k/Tree.svg","subtitle":"树形控件"}, + component: () => import('../../../components/tree/demo/index.vue'), + }, + { + path: 'tree-select:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"TreeSelect","cover":"https://gw.alipayobjects.com/zos/alicdn/Ax4DA0njr/TreeSelect.svg","subtitle":"树选择"}, + component: () => import('../../../components/tree-select/demo/index.vue'), + }, + { + path: 'typography:lang(-cn)?', + meta: {"category":"Components","type":"通用","title":"Typography","cols":1,"cover":"https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg","subtitle":"排版"}, + component: () => import('../../../components/typography/demo/index.vue'), + }, + { + path: 'upload:lang(-cn)?', + meta: {"category":"Components","type":"数据录入","title":"Upload","cover":"https://gw.alipayobjects.com/zos/alicdn/QaeBt_ZMg/Upload.svg","subtitle":"上传"}, + component: () => import('../../../components/upload/demo/index.vue'), + }, +]; \ No newline at end of file diff --git a/site/src/router/index.js b/site/src/router/index.js index b17bdb533..cf90fcc67 100644 --- a/site/src/router/index.js +++ b/site/src/router/index.js @@ -35,7 +35,7 @@ const routes = [ const hash = route.hash.replace('#', ''); return { iframeName: hash }; }, - component: () => import('../docs/layout/demo/index.vue'), + component: () => import('../../../components/layout/demo/index.vue'), }, ], }, diff --git a/site/src/theme/static/header.less b/site/src/theme/static/header.less index 4bd5aca63..398849dd8 100644 --- a/site/src/theme/static/header.less +++ b/site/src/theme/static/header.less @@ -1,4 +1,4 @@ -@import '../../../node_modules/ant-design-vue/es/style/themes/default.less'; +@import '../../../../components/style/themes/default.less'; #header { // ===================== Home Page ===================== diff --git a/site/src/theme/static/index.less b/site/src/theme/static/index.less index 2d8af5c9b..fc336796e 100644 --- a/site/src/theme/static/index.less +++ b/site/src/theme/static/index.less @@ -1,5 +1,5 @@ @import './reset.less'; -@import '../../../node_modules/ant-design-vue/es/style/themes/default.less'; +@import '../../../../components/style/themes/default.less'; @import './theme'; @import './common'; @import './header'; diff --git a/site/src/theme/static/responsive.less b/site/src/theme/static/responsive.less index bb3237386..b017dcf97 100644 --- a/site/src/theme/static/responsive.less +++ b/site/src/theme/static/responsive.less @@ -1,4 +1,4 @@ -@import "../../../node_modules/ant-design-vue/es/style/themes/default.less"; +@import '../../../../components/style/themes/default.less'; .nav-phone-icon { position: absolute; diff --git a/site/src/theme/static/theme.less b/site/src/theme/static/theme.less index 259d872a7..5bbadb83b 100644 --- a/site/src/theme/static/theme.less +++ b/site/src/theme/static/theme.less @@ -1,9 +1,8 @@ -@import '../../../node_modules/ant-design-vue/es/style/themes/default.less'; +@import '../../../../components/style/themes/default.less'; @import './colors.less'; @import './home.less'; - -@input-icon-hover-color: rgba(0,0,0,.85); +@input-icon-hover-color: rgba(0, 0, 0, 0.85); @site-heading-color: @heading-color; @site-text-color: @heading-color; diff --git a/site/themeConfig.ts b/site/themeConfig.ts new file mode 100644 index 000000000..10779385d --- /dev/null +++ b/site/themeConfig.ts @@ -0,0 +1,49 @@ +import less from 'less'; +// import { getThemeVariables } from 'ant-design-vue/dist/theme'; +const themeConfig = [ + { + theme: 'dark', + htmlThemeAttr: 'dark', + modifyVars: { + // ...getThemeVariables({ dark: true }), + 'text-color': 'fade(@white, 65%)', + 'gray-8': '@text-color', + 'background-color-base': '#555', + 'skeleton-color': 'rgba(0,0,0,0.8)', + }, + }, +]; +const additionalData = async (content: string, filename: string): Promise => { + const themePromises = themeConfig.map(async t => { + const { htmlThemeAttr, modifyVars = {} } = t; + const options = { + javascriptEnabled: true, + modifyVars, + relativeUrls: true, + filename, + }; + try { + const { css } = await less.render(content, options); + let res = ''; + if (htmlThemeAttr && css) { + res = ` + [data-doc-theme=${htmlThemeAttr}] { + ${css} + } + `; + } + return Promise.resolve(res); + } catch (error) { + return Promise.reject(content); + } + }); + let res = content; + for (const themePromise of themePromises) { + const theme = await themePromise; + res += theme; + } + return res; +}; + +export default themeConfig; +export { themeConfig, additionalData }; diff --git a/site/vite.config.ts b/site/vite.config.ts new file mode 100644 index 000000000..b46551604 --- /dev/null +++ b/site/vite.config.ts @@ -0,0 +1,46 @@ +import path from 'path'; +import vue from '@vitejs/plugin-vue'; +import md from '../plugin/md'; +import docs from '../plugin/docs'; +import vueJsx from '@vitejs/plugin-vue-jsx'; +// import { getThemeVariables } from 'ant-design-vue/dist/theme'; +import { additionalData } from './themeConfig'; +import defaultVar from '../scripts/default-vars'; +import compact from '../scripts/compact-vars'; +// import dark from '../scripts/dark-vars'; +/** + * @type {import('vite').UserConfig} + */ +export default { + resolve: { + alias: { + // moment: 'moment/dist/moment.js', + '@': path.join(__dirname, './src'), + vue: 'vue/dist/vue.esm-bundler.js', + 'ant-design-vue': path.resolve(__dirname, '../components'), + }, + }, + plugins: [ + vueJsx({ + // options are passed on to @vue/babel-plugin-jsx + }), + docs(), + md(), + vue({ + include: [/\.vue$/, /\.md$/], + }), + ], + optimizeDeps: { + include: ['fetch-jsonp', '@ant-design/icons-vue', 'lodash-es'], + }, + css: { + preprocessorOptions: { + less: { + modifyVars: { ...defaultVar }, + javascriptEnabled: true, + // includePaths: ["node_modules/"], + // additionalData, + }, + }, + }, +}; diff --git a/tsconfig.json b/tsconfig.json index 91c26f392..4b83e020b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,7 @@ "lib": ["dom", "es2017"], "skipLibCheck": true, "allowJs": true, - "importsNotUsedAsValues": "error" + "importsNotUsedAsValues": "preserve" }, "exclude": [ "node_modules",