congmao-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/index.js +20 -0
- package/package.json +42 -0
- package/src/commands/create.js +171 -0
- package/src/commands/mcp.js +157 -0
- package/src/mcp/CURSOR_SETUP.md +259 -0
- package/src/mcp/README.md +134 -0
- package/src/mcp/USAGE_EXAMPLES.md +181 -0
- package/src/mcp/get-cursor-config.js +58 -0
- package/src/mcp/package.json +23 -0
- package/src/mcp/pnpm-lock.yaml +2441 -0
- package/src/mcp/src/handlers.js +211 -0
- package/src/mcp/src/http-server.js +332 -0
- package/src/mcp/src/index.js +195 -0
- package/src/mcp/src/schemas.js +54 -0
- package/src/mcp/test-create-project.js +49 -0
- package/src/mcp/test-mcp.js +89 -0
- package/src/mcp/test-show-tree.js +66 -0
- package/src/template/Uni-app/README.md +19 -0
- package/src/template/Uni-app/babel.config.js +81 -0
- package/src/template/Uni-app/package.json +107 -0
- package/src/template/Uni-app/postcss.config.js +27 -0
- package/src/template/Uni-app/public/index.html +25 -0
- package/src/template/Uni-app/shims-uni.d.ts +11 -0
- package/src/template/Uni-app/shims-vue.d.ts +4 -0
- package/src/template/Uni-app/src/App.vue +17 -0
- package/src/template/Uni-app/src/main.js +12 -0
- package/src/template/Uni-app/src/manifest.json +75 -0
- package/src/template/Uni-app/src/pages/index/index.vue +49 -0
- package/src/template/Uni-app/src/pages.json +16 -0
- package/src/template/Uni-app/src/static/logo.png +0 -0
- package/src/template/Uni-app/src/uni.promisify.adaptor.js +13 -0
- package/src/template/Uni-app/src/uni.scss +76 -0
- package/src/template/Uni-app/yarn.lock +11466 -0
- package/src/template/Vue2/.editorconfig +14 -0
- package/src/template/Vue2/.env +2 -0
- package/src/template/Vue2/.env.development +2 -0
- package/src/template/Vue2/.env.site +2 -0
- package/src/template/Vue2/.prettierrc.js +39 -0
- package/src/template/Vue2/.stylelintignore +8 -0
- package/src/template/Vue2/README-zh_CN.md +115 -0
- package/src/template/Vue2/commitlint.config.js +1 -0
- package/src/template/Vue2/docs/docs-starter.png +0 -0
- package/src/template/Vue2/docs/docs-startup.png +0 -0
- package/src/template/Vue2/docs/docs-structure.png +0 -0
- package/src/template/Vue2/globals.d.ts +13 -0
- package/src/template/Vue2/index.html +27 -0
- package/src/template/Vue2/jsx.d.ts +13 -0
- package/src/template/Vue2/mock/index.ts +147 -0
- package/src/template/Vue2/package.json +91 -0
- package/src/template/Vue2/package.json.ejs +91 -0
- package/src/template/Vue2/public/favicon.ico +0 -0
- package/src/template/Vue2/shims-vue.d.ts +5 -0
- package/src/template/Vue2/src/App.vue +19 -0
- package/src/template/Vue2/src/assets/assets-login-bg-black.png +0 -0
- package/src/template/Vue2/src/assets/assets-login-bg-white.png +0 -0
- package/src/template/Vue2/src/assets/assets-logo-full.svg +39 -0
- package/src/template/Vue2/src/assets/assets-product-1.svg +5 -0
- package/src/template/Vue2/src/assets/assets-product-2.svg +5 -0
- package/src/template/Vue2/src/assets/assets-product-3.svg +5 -0
- package/src/template/Vue2/src/assets/assets-product-4.svg +5 -0
- package/src/template/Vue2/src/assets/assets-result-403.svg +32 -0
- package/src/template/Vue2/src/assets/assets-result-404.svg +36 -0
- package/src/template/Vue2/src/assets/assets-result-500.svg +32 -0
- package/src/template/Vue2/src/assets/assets-result-ie.svg +33 -0
- package/src/template/Vue2/src/assets/assets-result-maintenance.svg +49 -0
- package/src/template/Vue2/src/assets/assets-result-wifi.svg +23 -0
- package/src/template/Vue2/src/assets/assets-setting-auto.svg +13 -0
- package/src/template/Vue2/src/assets/assets-setting-dark.svg +5 -0
- package/src/template/Vue2/src/assets/assets-setting-light.svg +13 -0
- package/src/template/Vue2/src/assets/assets-t-logo.svg +41 -0
- package/src/template/Vue2/src/assets/assets-tencent-logo.png +0 -0
- package/src/template/Vue2/src/components/color/index.vue +35 -0
- package/src/template/Vue2/src/components/product-card/index.vue +121 -0
- package/src/template/Vue2/src/components/result/index.vue +118 -0
- package/src/template/Vue2/src/components/thumbnail/index.vue +49 -0
- package/src/template/Vue2/src/components/trend/index.vue +105 -0
- package/src/template/Vue2/src/config/color.ts +30 -0
- package/src/template/Vue2/src/config/global.ts +2 -0
- package/src/template/Vue2/src/config/host.ts +26 -0
- package/src/template/Vue2/src/config/style.ts +14 -0
- package/src/template/Vue2/src/constants/index.ts +46 -0
- package/src/template/Vue2/src/interface.ts +39 -0
- package/src/template/Vue2/src/layouts/blank.vue +12 -0
- package/src/template/Vue2/src/layouts/components/Breadcrumb.vue +39 -0
- package/src/template/Vue2/src/layouts/components/Content.vue +43 -0
- package/src/template/Vue2/src/layouts/components/Footer.vue +27 -0
- package/src/template/Vue2/src/layouts/components/Header.vue +321 -0
- package/src/template/Vue2/src/layouts/components/LayoutContent.vue +168 -0
- package/src/template/Vue2/src/layouts/components/LayoutHeader.vue +52 -0
- package/src/template/Vue2/src/layouts/components/LayoutSidebar.vue +51 -0
- package/src/template/Vue2/src/layouts/components/MenuContent.vue +108 -0
- package/src/template/Vue2/src/layouts/components/Notice.vue +221 -0
- package/src/template/Vue2/src/layouts/components/Search.vue +134 -0
- package/src/template/Vue2/src/layouts/components/SideNav.vue +150 -0
- package/src/template/Vue2/src/layouts/index.vue +100 -0
- package/src/template/Vue2/src/layouts/setting.vue +404 -0
- package/src/template/Vue2/src/main.js +9 -0
- package/src/template/Vue2/src/main.jsx +51 -0
- package/src/template/Vue2/src/pages/dashboard/base/components/MiddleChart.vue +158 -0
- package/src/template/Vue2/src/pages/dashboard/base/components/OutputOverview.vue +189 -0
- package/src/template/Vue2/src/pages/dashboard/base/components/RankList.vue +111 -0
- package/src/template/Vue2/src/pages/dashboard/base/components/TopPanel.vue +246 -0
- package/src/template/Vue2/src/pages/dashboard/base/index.ts +702 -0
- package/src/template/Vue2/src/pages/dashboard/base/index.vue +44 -0
- package/src/template/Vue2/src/pages/dashboard/detail/index.ts +267 -0
- package/src/template/Vue2/src/pages/dashboard/detail/index.vue +242 -0
- package/src/template/Vue2/src/pages/detail/advanced/components/Product.vue +167 -0
- package/src/template/Vue2/src/pages/detail/advanced/index.less +74 -0
- package/src/template/Vue2/src/pages/detail/advanced/index.vue +219 -0
- package/src/template/Vue2/src/pages/detail/base/index.less +105 -0
- package/src/template/Vue2/src/pages/detail/base/index.vue +46 -0
- package/src/template/Vue2/src/pages/detail/deploy/index.ts +204 -0
- package/src/template/Vue2/src/pages/detail/deploy/index.vue +224 -0
- package/src/template/Vue2/src/pages/detail/secondary/index.less +71 -0
- package/src/template/Vue2/src/pages/detail/secondary/index.vue +131 -0
- package/src/template/Vue2/src/pages/form/base/index.less +57 -0
- package/src/template/Vue2/src/pages/form/base/index.vue +254 -0
- package/src/template/Vue2/src/pages/form/step/index.less +37 -0
- package/src/template/Vue2/src/pages/form/step/index.vue +259 -0
- package/src/template/Vue2/src/pages/frame/doc/index.vue +86 -0
- package/src/template/Vue2/src/pages/frame/tdesign/index.vue +86 -0
- package/src/template/Vue2/src/pages/list/base/index.vue +267 -0
- package/src/template/Vue2/src/pages/list/card/index.vue +221 -0
- package/src/template/Vue2/src/pages/list/components/CommonTable.vue +313 -0
- package/src/template/Vue2/src/pages/list/filter/index.vue +15 -0
- package/src/template/Vue2/src/pages/list/tree/index.vue +174 -0
- package/src/template/Vue2/src/pages/login/components/components-header.vue +74 -0
- package/src/template/Vue2/src/pages/login/components/components-login.vue +154 -0
- package/src/template/Vue2/src/pages/login/components/components-register.vue +144 -0
- package/src/template/Vue2/src/pages/login/index.less +202 -0
- package/src/template/Vue2/src/pages/login/index.vue +53 -0
- package/src/template/Vue2/src/pages/nest-menu/Index.vue +10 -0
- package/src/template/Vue2/src/pages/result/403/index.vue +14 -0
- package/src/template/Vue2/src/pages/result/404/index.vue +14 -0
- package/src/template/Vue2/src/pages/result/500/index.vue +14 -0
- package/src/template/Vue2/src/pages/result/browser-incompatible/index.vue +77 -0
- package/src/template/Vue2/src/pages/result/fail/index.vue +57 -0
- package/src/template/Vue2/src/pages/result/maintenance/index.vue +14 -0
- package/src/template/Vue2/src/pages/result/network-error/index.vue +24 -0
- package/src/template/Vue2/src/pages/result/success/index.vue +59 -0
- package/src/template/Vue2/src/pages/user/index.less +148 -0
- package/src/template/Vue2/src/pages/user/index.ts +157 -0
- package/src/template/Vue2/src/pages/user/index.vue +204 -0
- package/src/template/Vue2/src/permission.js +56 -0
- package/src/template/Vue2/src/router/index.js +43 -0
- package/src/template/Vue2/src/router/modules/base.ts +29 -0
- package/src/template/Vue2/src/router/modules/components.ts +175 -0
- package/src/template/Vue2/src/router/modules/others.ts +55 -0
- package/src/template/Vue2/src/service/service-advance.ts +233 -0
- package/src/template/Vue2/src/service/service-base.ts +205 -0
- package/src/template/Vue2/src/service/service-detail-base.ts +84 -0
- package/src/template/Vue2/src/service/service-detail-deploy.ts +234 -0
- package/src/template/Vue2/src/service/service-detail.ts +57 -0
- package/src/template/Vue2/src/service/service-user.ts +64 -0
- package/src/template/Vue2/src/store/index.ts +22 -0
- package/src/template/Vue2/src/store/modules/notification.ts +90 -0
- package/src/template/Vue2/src/store/modules/permission.ts +66 -0
- package/src/template/Vue2/src/store/modules/setting.ts +122 -0
- package/src/template/Vue2/src/store/modules/tab-router.ts +83 -0
- package/src/template/Vue2/src/store/modules/user.ts +98 -0
- package/src/template/Vue2/src/style/font-family.less +6 -0
- package/src/template/Vue2/src/style/index.less +5 -0
- package/src/template/Vue2/src/style/layout.less +201 -0
- package/src/template/Vue2/src/style/reset.less +78 -0
- package/src/template/Vue2/src/style/variables.less +27 -0
- package/src/template/Vue2/src/utils/charts.ts +38 -0
- package/src/template/Vue2/src/utils/color.ts +118 -0
- package/src/template/Vue2/src/utils/date.ts +12 -0
- package/src/template/Vue2/src/utils/request.ts +60 -0
- package/src/template/Vue2/stylelint.config.js +5 -0
- package/src/template/Vue2/tsconfig.json +26 -0
- package/src/template/Vue2/vite.config.js +58 -0
- package/src/template/Vue3/package.json.ejs +8 -0
- package/src/template/Vue3/pages.json +10 -0
- package/src/template/Vue3/src/main.js +7 -0
- package/src/utils/copy.js +17 -0
- package/src/utils/eslint.js +205 -0
- package/src/utils/logo.js +18 -0
- package/src/utils/render.js +20 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
body {
|
|
2
|
+
color: var(--td-text-color-secondary);
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Microsoft YaHei, Arial Regular;
|
|
4
|
+
font: var(--td-font-body-medium);
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
pre {
|
|
11
|
+
font-family: var(--td-font-family);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
ul,
|
|
15
|
+
dl,
|
|
16
|
+
li,
|
|
17
|
+
dd,
|
|
18
|
+
dt {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
list-style: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
figure,
|
|
25
|
+
h1,
|
|
26
|
+
h2,
|
|
27
|
+
h3,
|
|
28
|
+
h4,
|
|
29
|
+
h5,
|
|
30
|
+
h6,
|
|
31
|
+
p {
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
* {
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.t-button-link,
|
|
40
|
+
a {
|
|
41
|
+
color: var(--td-brand-color);
|
|
42
|
+
text-decoration: none;
|
|
43
|
+
margin-right: var(--td-comp-margin-xxl);
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
transition: color @anim-duration-base @anim-time-fn-easing;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
color: var(--td-brand-color-hover);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:active {
|
|
52
|
+
color: var(--td-brand-color-active);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&--active {
|
|
56
|
+
color: var(--td-brand-color-active);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:focus {
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:last-child {
|
|
64
|
+
margin-right: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:last-child {
|
|
68
|
+
margin-right: 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.container-base-margin-top {
|
|
73
|
+
margin-top: 16px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.card-date-picker-container {
|
|
77
|
+
width: 250px;
|
|
78
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** 公共前缀 */
|
|
2
|
+
@starter-prefix: tdesign-starter;
|
|
3
|
+
|
|
4
|
+
// 颜色、尺寸、阴影、圆角、字体 variables 请参考 https://tdesign.tencent.com/starter/docs/vue/design-token
|
|
5
|
+
|
|
6
|
+
// 响应式断点
|
|
7
|
+
@screen-sm: 768px;
|
|
8
|
+
@screen-md: 992px;
|
|
9
|
+
@screen-lg: 1200px;
|
|
10
|
+
@screen-xl: 1400px;
|
|
11
|
+
|
|
12
|
+
@screen-sm-min: @screen-sm;
|
|
13
|
+
@screen-md-min: @screen-md;
|
|
14
|
+
@screen-lg-min: @screen-lg;
|
|
15
|
+
@screen-xl-min: @screen-xl;
|
|
16
|
+
|
|
17
|
+
@screen-sm-max: (@screen-md-min - 1px);
|
|
18
|
+
@screen-md-max: (@screen-lg-min - 1px);
|
|
19
|
+
@screen-lg-max: (@screen-xl-min - 1px);
|
|
20
|
+
|
|
21
|
+
// 动画
|
|
22
|
+
@anim-time-fn-easing: cubic-bezier(0.38, 0, 0.24, 1);
|
|
23
|
+
@anim-time-fn-ease-out: cubic-bezier(0, 0, 0.15, 1);
|
|
24
|
+
@anim-time-fn-ease-in: cubic-bezier(0.82, 0, 1, 0.9);
|
|
25
|
+
@anim-duration-base: 0.2s;
|
|
26
|
+
@anim-duration-moderate: 0.24s;
|
|
27
|
+
@anim-duration-slow: 0.28s;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @export
|
|
5
|
+
* @param {string[]} dateTime
|
|
6
|
+
* @param {number} divideNum
|
|
7
|
+
* @returns {string[]}
|
|
8
|
+
*/
|
|
9
|
+
export function getDateArray(dateTime: string[] = [], divideNum = 10): string[] {
|
|
10
|
+
const timeArray: string[] = [];
|
|
11
|
+
if (dateTime.length > 0) {
|
|
12
|
+
for (let i = 0; i < divideNum; i++) {
|
|
13
|
+
const dateAbsTime: number = (new Date(dateTime[1]).getTime() - new Date(dateTime[0]).getTime()) / divideNum;
|
|
14
|
+
const enhandTime: number = new Date(dateTime[0]).getTime() + dateAbsTime * i;
|
|
15
|
+
timeArray.push(dayjs(enhandTime).format('YYYY-MM-DD'));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return timeArray;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 获取随机数
|
|
24
|
+
*
|
|
25
|
+
* @param {number} [num=100]
|
|
26
|
+
* @returns
|
|
27
|
+
*
|
|
28
|
+
* @memberOf DashboardBase
|
|
29
|
+
*/
|
|
30
|
+
export function getRandomArray(num = 100): number {
|
|
31
|
+
let resultNum = Number((Math.random() * num).toFixed(0));
|
|
32
|
+
|
|
33
|
+
if (resultNum <= 1) {
|
|
34
|
+
resultNum = 1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return resultNum;
|
|
38
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Color } from 'tvision-color';
|
|
2
|
+
import * as echarts from 'echarts/core';
|
|
3
|
+
import trim from 'lodash/trim';
|
|
4
|
+
import { TColorToken } from '@/config/color';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 依据主题类型获取颜色
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @param {string} theme
|
|
11
|
+
* @returns {}
|
|
12
|
+
*/
|
|
13
|
+
export function getColorFromTheme(): Array<string> {
|
|
14
|
+
const theme = trim(getComputedStyle(document.documentElement).getPropertyValue('--td-brand-color'));
|
|
15
|
+
const themeColorList = Color.getRandomPalette({
|
|
16
|
+
color: theme,
|
|
17
|
+
colorGamut: 'bright',
|
|
18
|
+
number: 8,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return themeColorList;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** 图表颜色 */
|
|
25
|
+
export function getChartListColor(): Array<string> {
|
|
26
|
+
const res = getColorFromTheme();
|
|
27
|
+
|
|
28
|
+
return res;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 更改图表主题颜色
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
* @param {Array<string>} chartsList
|
|
36
|
+
* @param {string} theme
|
|
37
|
+
*/
|
|
38
|
+
export function changeChartsTheme(chartsList: echarts.EChartsType[]): void {
|
|
39
|
+
if (chartsList && chartsList.length) {
|
|
40
|
+
const chartChangeColor = getChartListColor();
|
|
41
|
+
|
|
42
|
+
for (let index = 0; index < chartsList.length; index++) {
|
|
43
|
+
const elementChart = chartsList[index];
|
|
44
|
+
|
|
45
|
+
if (elementChart) {
|
|
46
|
+
const optionVal = elementChart.getOption();
|
|
47
|
+
|
|
48
|
+
// 更改主题颜色
|
|
49
|
+
optionVal.color = chartChangeColor;
|
|
50
|
+
|
|
51
|
+
elementChart.setOption(optionVal, true);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 根据当前主题色、模式等情景 计算最后生成的色阶
|
|
59
|
+
*/
|
|
60
|
+
export function generateColorMap(
|
|
61
|
+
theme: string,
|
|
62
|
+
colorPalette: Array<string>,
|
|
63
|
+
mode: 'light' | 'dark',
|
|
64
|
+
brandColorIdx: number,
|
|
65
|
+
) {
|
|
66
|
+
const isDarkMode = mode === 'dark';
|
|
67
|
+
|
|
68
|
+
if (isDarkMode) {
|
|
69
|
+
// eslint-disable-next-line no-use-before-define
|
|
70
|
+
colorPalette.reverse().map((color) => {
|
|
71
|
+
const [h, s, l] = Color.colorTransform(color, 'hex', 'hsl');
|
|
72
|
+
return Color.colorTransform([h, Number(s) - 4, l], 'hsl', 'hex');
|
|
73
|
+
});
|
|
74
|
+
brandColorIdx = 5;
|
|
75
|
+
colorPalette[0] = `${colorPalette[brandColorIdx]}20`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const colorMap = {
|
|
79
|
+
'--td-brand-color': colorPalette[brandColorIdx], // 主题色
|
|
80
|
+
'--td-brand-color-1': colorPalette[0], // light
|
|
81
|
+
'--td-brand-color-2': colorPalette[1], // focus
|
|
82
|
+
'--td-brand-color-3': colorPalette[2], // disabled
|
|
83
|
+
'--td-brand-color-4': colorPalette[3],
|
|
84
|
+
'--td-brand-color-5': colorPalette[4],
|
|
85
|
+
'--td-brand-color-6': colorPalette[5],
|
|
86
|
+
'--td-brand-color-7': brandColorIdx > 0 ? colorPalette[brandColorIdx - 1] : theme, // hover
|
|
87
|
+
'--td-brand-color-8': colorPalette[brandColorIdx], // 主题色
|
|
88
|
+
'--td-brand-color-9': brandColorIdx > 8 ? theme : colorPalette[brandColorIdx + 1], // click
|
|
89
|
+
'--td-brand-color-10': colorPalette[9],
|
|
90
|
+
};
|
|
91
|
+
return colorMap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 将生成的样式嵌入头部
|
|
96
|
+
*/
|
|
97
|
+
export function insertThemeStylesheet(theme: string, colorMap: TColorToken, mode: 'light' | 'dark') {
|
|
98
|
+
const isDarkMode = mode === 'dark';
|
|
99
|
+
const root = !isDarkMode ? `:root[theme-color='${theme}']` : `:root[theme-color='${theme}'][theme-mode='dark']`;
|
|
100
|
+
|
|
101
|
+
const styleSheet = document.createElement('style');
|
|
102
|
+
styleSheet.type = 'text/css';
|
|
103
|
+
styleSheet.innerText = `${root}{
|
|
104
|
+
--td-brand-color: ${colorMap['--td-brand-color']};
|
|
105
|
+
--td-brand-color-1: ${colorMap['--td-brand-color-1']};
|
|
106
|
+
--td-brand-color-2: ${colorMap['--td-brand-color-2']};
|
|
107
|
+
--td-brand-color-3: ${colorMap['--td-brand-color-3']};
|
|
108
|
+
--td-brand-color-4: ${colorMap['--td-brand-color-4']};
|
|
109
|
+
--td-brand-color-5: ${colorMap['--td-brand-color-5']};
|
|
110
|
+
--td-brand-color-6: ${colorMap['--td-brand-color-6']};
|
|
111
|
+
--td-brand-color-7: ${colorMap['--td-brand-color-7']};
|
|
112
|
+
--td-brand-color-8: ${colorMap['--td-brand-color-8']};
|
|
113
|
+
--td-brand-color-9: ${colorMap['--td-brand-color-9']};
|
|
114
|
+
--td-brand-color-10: ${colorMap['--td-brand-color-10']};
|
|
115
|
+
}`;
|
|
116
|
+
|
|
117
|
+
document.head.appendChild(styleSheet);
|
|
118
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// 获取常用时间
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
|
|
4
|
+
export const LAST_7_DAYS = [
|
|
5
|
+
dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
|
|
6
|
+
dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
export const LAST_30_DAYS = [
|
|
10
|
+
dayjs().subtract(30, 'day').format('YYYY-MM-DD'),
|
|
11
|
+
dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
|
|
12
|
+
];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import proxy from '../config/host';
|
|
3
|
+
|
|
4
|
+
const env = import.meta.env.MODE || 'development';
|
|
5
|
+
|
|
6
|
+
const API_HOST = env === 'mock' ? '/' : proxy[env].API; // 如果是mock模式 就不配置host 会走本地Mock拦截
|
|
7
|
+
|
|
8
|
+
const CODE = {
|
|
9
|
+
LOGIN_TIMEOUT: 1000,
|
|
10
|
+
REQUEST_SUCCESS: 0,
|
|
11
|
+
REQUEST_FOBID: 1001,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const instance = axios.create({
|
|
15
|
+
baseURL: API_HOST,
|
|
16
|
+
timeout: 1000,
|
|
17
|
+
withCredentials: true,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
// axios的retry ts类型有问题
|
|
23
|
+
instance.interceptors.retry = 3;
|
|
24
|
+
|
|
25
|
+
instance.interceptors.request.use((config) => config);
|
|
26
|
+
|
|
27
|
+
instance.interceptors.response.use(
|
|
28
|
+
(response) => {
|
|
29
|
+
if (response.status === 200) {
|
|
30
|
+
const { data } = response;
|
|
31
|
+
if (data.code === CODE.REQUEST_SUCCESS) {
|
|
32
|
+
return data;
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
(err) => {
|
|
38
|
+
const { config } = err;
|
|
39
|
+
|
|
40
|
+
if (!config || !config.retry) return Promise.reject(err);
|
|
41
|
+
|
|
42
|
+
config.retryCount = config.retryCount || 0;
|
|
43
|
+
|
|
44
|
+
if (config.retryCount >= config.retry) {
|
|
45
|
+
return Promise.reject(err);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
config.retryCount += 1;
|
|
49
|
+
|
|
50
|
+
const backoff = new Promise((resolve) => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
resolve({});
|
|
53
|
+
}, config.retryDelay || 1);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return backoff.then(() => instance(config));
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export default instance;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2015",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"lib": ["esnext", "dom"],
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"checkJs": false,
|
|
8
|
+
"noImplicitAny": false,
|
|
9
|
+
"isolatedModules": false,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"noImplicitThis": false,
|
|
13
|
+
"strictNullChecks": false,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"jsx": "preserve",
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"baseUrl": "./",
|
|
20
|
+
"paths": {
|
|
21
|
+
"@/*": ["./src/*"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"include": ["**/*.ts", "**/*.tsx"],
|
|
25
|
+
"compileOnSave": false
|
|
26
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { loadEnv } from 'vite';
|
|
2
|
+
import { viteMockServe } from 'vite-plugin-mock';
|
|
3
|
+
import { createVuePlugin } from 'vite-plugin-vue2';
|
|
4
|
+
import { createSvgPlugin } from 'vite-plugin-vue2-svg';
|
|
5
|
+
|
|
6
|
+
import path from 'path';
|
|
7
|
+
|
|
8
|
+
const CWD = process.cwd();
|
|
9
|
+
|
|
10
|
+
export default ({ mode }) => {
|
|
11
|
+
const { VITE_BASE_URL } = loadEnv(mode, CWD);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
base: VITE_BASE_URL,
|
|
15
|
+
resolve: {
|
|
16
|
+
alias: {
|
|
17
|
+
'~': path.resolve(__dirname, './'),
|
|
18
|
+
'@': path.resolve(__dirname, './src'),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
css: {
|
|
23
|
+
preprocessorOptions: {
|
|
24
|
+
less: {
|
|
25
|
+
modifyVars: {},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
plugins: [
|
|
31
|
+
createVuePlugin({
|
|
32
|
+
jsx: true,
|
|
33
|
+
}),
|
|
34
|
+
viteMockServe({
|
|
35
|
+
mockPath: 'mock',
|
|
36
|
+
localEnabled: true,
|
|
37
|
+
}),
|
|
38
|
+
createSvgPlugin(),
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
build: {
|
|
42
|
+
cssCodeSplit: false,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
server: {
|
|
46
|
+
host: '0.0.0.0',
|
|
47
|
+
port: 3001,
|
|
48
|
+
proxy: {
|
|
49
|
+
'/api': {
|
|
50
|
+
// 用于开发环境下的转发请求
|
|
51
|
+
// 更多请参考:https://vitejs.dev/config/#server-proxy
|
|
52
|
+
target: 'https://service-exndqyuk-1257786608.gz.apigw.tencentcs.com',
|
|
53
|
+
changeOrigin: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export default function copyDir(src, dest) {
|
|
5
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
6
|
+
|
|
7
|
+
for (const file of fs.readdirSync(src)) {
|
|
8
|
+
const srcPath = path.join(src, file);
|
|
9
|
+
const destPath = path.join(dest, file);
|
|
10
|
+
|
|
11
|
+
if (fs.statSync(srcPath).isDirectory()) {
|
|
12
|
+
copyDir(srcPath, destPath);
|
|
13
|
+
} else {
|
|
14
|
+
fs.copyFileSync(srcPath, destPath);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 根据模板类型获取 ESLint 配置
|
|
6
|
+
*/
|
|
7
|
+
function getESLintConfig(templateName) {
|
|
8
|
+
const configs = {
|
|
9
|
+
'Uni-app': {
|
|
10
|
+
extends: [
|
|
11
|
+
'plugin:vue/essential',
|
|
12
|
+
'eslint:recommended'
|
|
13
|
+
],
|
|
14
|
+
parserOptions: {
|
|
15
|
+
ecmaVersion: 2020,
|
|
16
|
+
sourceType: 'module'
|
|
17
|
+
},
|
|
18
|
+
env: {
|
|
19
|
+
node: true,
|
|
20
|
+
es6: true
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
'no-console': 'warn',
|
|
24
|
+
'no-debugger': 'warn'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
'Vue2': {
|
|
28
|
+
extends: [
|
|
29
|
+
'plugin:vue/essential',
|
|
30
|
+
'eslint:recommended'
|
|
31
|
+
],
|
|
32
|
+
parserOptions: {
|
|
33
|
+
ecmaVersion: 2020,
|
|
34
|
+
sourceType: 'module'
|
|
35
|
+
},
|
|
36
|
+
env: {
|
|
37
|
+
node: true,
|
|
38
|
+
browser: true,
|
|
39
|
+
es6: true
|
|
40
|
+
},
|
|
41
|
+
rules: {
|
|
42
|
+
'no-console': 'warn',
|
|
43
|
+
'no-debugger': 'warn',
|
|
44
|
+
'vue/multi-word-component-names': 'off'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
'Vue3': {
|
|
48
|
+
extends: [
|
|
49
|
+
'plugin:vue/vue3-essential',
|
|
50
|
+
'eslint:recommended'
|
|
51
|
+
],
|
|
52
|
+
parserOptions: {
|
|
53
|
+
ecmaVersion: 2020,
|
|
54
|
+
sourceType: 'module'
|
|
55
|
+
},
|
|
56
|
+
env: {
|
|
57
|
+
node: true,
|
|
58
|
+
browser: true,
|
|
59
|
+
es6: true
|
|
60
|
+
},
|
|
61
|
+
rules: {
|
|
62
|
+
'no-console': 'warn',
|
|
63
|
+
'no-debugger': 'warn',
|
|
64
|
+
'vue/multi-word-component-names': 'off'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return configs[templateName] || configs['Vue3'];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 获取 ESLint 依赖包
|
|
74
|
+
*/
|
|
75
|
+
function getESLintDependencies(templateName) {
|
|
76
|
+
const baseDeps = {
|
|
77
|
+
'eslint': '^8.57.0',
|
|
78
|
+
'eslint-plugin-vue': templateName === 'Vue3' ? '^9.23.0' : '^9.0.0'
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return baseDeps;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 创建 ESLint 配置文件
|
|
86
|
+
*/
|
|
87
|
+
function createESLintConfigFile(targetDir, templateName) {
|
|
88
|
+
const config = getESLintConfig(templateName);
|
|
89
|
+
const configPath = path.join(targetDir, '.eslintrc.js');
|
|
90
|
+
|
|
91
|
+
// 如果配置文件已存在,则不覆盖
|
|
92
|
+
if (fs.existsSync(configPath)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 格式化配置文件内容
|
|
97
|
+
const extendsStr = config.extends.map(ext => `'${ext}'`).join(',\n ');
|
|
98
|
+
const envStr = Object.entries(config.env)
|
|
99
|
+
.map(([key, value]) => ` ${key}: ${value}`)
|
|
100
|
+
.join(',\n');
|
|
101
|
+
const rulesStr = Object.entries(config.rules)
|
|
102
|
+
.map(([key, value]) => ` '${key}': ${typeof value === 'string' ? `'${value}'` : JSON.stringify(value)}`)
|
|
103
|
+
.join(',\n');
|
|
104
|
+
|
|
105
|
+
const formattedContent = `module.exports = {
|
|
106
|
+
extends: [
|
|
107
|
+
${extendsStr}
|
|
108
|
+
],
|
|
109
|
+
parserOptions: {
|
|
110
|
+
ecmaVersion: ${config.parserOptions.ecmaVersion},
|
|
111
|
+
sourceType: '${config.parserOptions.sourceType}'
|
|
112
|
+
},
|
|
113
|
+
env: {
|
|
114
|
+
${envStr}
|
|
115
|
+
},
|
|
116
|
+
rules: {
|
|
117
|
+
${rulesStr}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
fs.writeFileSync(configPath, formattedContent, 'utf8');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 更新 package.json,添加 ESLint 依赖和脚本
|
|
127
|
+
*/
|
|
128
|
+
function updatePackageJson(targetDir, templateName) {
|
|
129
|
+
const packageJsonPath = path.join(targetDir, 'package.json');
|
|
130
|
+
|
|
131
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
132
|
+
console.warn('package.json 不存在,跳过 ESLint 配置');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
137
|
+
const deps = getESLintDependencies(templateName);
|
|
138
|
+
|
|
139
|
+
// 添加 devDependencies(如果不存在)
|
|
140
|
+
if (!packageJson.devDependencies) {
|
|
141
|
+
packageJson.devDependencies = {};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 只添加不存在的依赖
|
|
145
|
+
Object.keys(deps).forEach(dep => {
|
|
146
|
+
if (!packageJson.devDependencies[dep]) {
|
|
147
|
+
packageJson.devDependencies[dep] = deps[dep];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// 添加 scripts(如果不存在)
|
|
152
|
+
if (!packageJson.scripts) {
|
|
153
|
+
packageJson.scripts = {};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 只添加不存在的脚本
|
|
157
|
+
if (!packageJson.scripts['lint']) {
|
|
158
|
+
packageJson.scripts['lint'] = 'eslint . --ext .js,.vue';
|
|
159
|
+
}
|
|
160
|
+
if (!packageJson.scripts['lint:fix']) {
|
|
161
|
+
packageJson.scripts['lint:fix'] = 'eslint . --ext .js,.vue --fix';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf8');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 创建 .eslintignore 文件
|
|
169
|
+
*/
|
|
170
|
+
function createESLintIgnore(targetDir) {
|
|
171
|
+
const ignorePath = path.join(targetDir, '.eslintignore');
|
|
172
|
+
|
|
173
|
+
// 如果文件已存在,则不覆盖
|
|
174
|
+
if (fs.existsSync(ignorePath)) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const ignoreContent = `node_modules/
|
|
179
|
+
dist/
|
|
180
|
+
build/
|
|
181
|
+
*.min.js
|
|
182
|
+
coverage/
|
|
183
|
+
`;
|
|
184
|
+
|
|
185
|
+
fs.writeFileSync(ignorePath, ignoreContent, 'utf8');
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 设置 ESLint 配置
|
|
190
|
+
*/
|
|
191
|
+
export default async function setupESLint(targetDir, templateName) {
|
|
192
|
+
try {
|
|
193
|
+
// 创建 ESLint 配置文件
|
|
194
|
+
createESLintConfigFile(targetDir, templateName);
|
|
195
|
+
|
|
196
|
+
// 创建 .eslintignore 文件
|
|
197
|
+
createESLintIgnore(targetDir);
|
|
198
|
+
|
|
199
|
+
// 更新 package.json
|
|
200
|
+
updatePackageJson(targetDir, templateName);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
throw new Error(`配置 ESLint 失败: ${error.message}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import gradient from 'gradient-string';
|
|
2
|
+
|
|
3
|
+
export function showLogo() {
|
|
4
|
+
if (!process.stdout.isTTY || process.env.CI) return;
|
|
5
|
+
|
|
6
|
+
const logo = `
|
|
7
|
+
██████╗ ███╗ ███╗ ██████╗ ██╗ ██╗
|
|
8
|
+
██╔════╝ ████╗ ████║ ██╔════╝ ██║ ██║
|
|
9
|
+
██║ ██╔████╔██║ ██║ ██║ ██║
|
|
10
|
+
██║ ██║╚██╔╝██║ ██║ ██║ ██║
|
|
11
|
+
╚██████╗ ██║ ╚═╝ ██║ ╚██████╗ ███████╗██║
|
|
12
|
+
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
console.log(
|
|
16
|
+
gradient(['#00FFFF', '#00CED1', '#00BFFF', '#00FF7F'])(logo)
|
|
17
|
+
);
|
|
18
|
+
}
|