提交 6a182a2c 作者: 方治民

style: 代码格式问题修复

上级 619016b3
...@@ -30,12 +30,7 @@ export function getThemeColors(color?: string) { ...@@ -30,12 +30,7 @@ export function getThemeColors(color?: string) {
return [...lightColors, ...modeColors] return [...lightColors, ...modeColors]
} }
export function generateColors({ export function generateColors({ color = primaryColor, mixLighten, mixDarken, tinycolor }: GenerateColorsParams) {
color = primaryColor,
mixLighten,
mixDarken,
tinycolor,
}: GenerateColorsParams) {
const arr = new Array(19).fill(0) const arr = new Array(19).fill(0)
const lightens = arr.map((_t, i) => { const lightens = arr.map((_t, i) => {
return mixLighten(color, i / 5) return mixLighten(color, i / 5)
......
import path from 'path' import path from 'node:path'
import fs from 'fs-extra' import fs from 'fs-extra'
import inquirer from 'inquirer' import inquirer from 'inquirer'
import colors from 'picocolors' import colors from 'picocolors'
...@@ -30,7 +30,7 @@ async function generateIcon() { ...@@ -30,7 +30,7 @@ async function generateIcon() {
{ {
type: 'list', type: 'list',
name: 'iconSet', name: 'iconSet',
choices: choices, choices,
message: 'Select the icon set that needs to be generated?', message: 'Select the icon set that needs to be generated?',
}, },
{ {
...@@ -51,25 +51,17 @@ async function generateIcon() { ...@@ -51,25 +51,17 @@ async function generateIcon() {
if (data) { if (data) {
const { prefix } = data const { prefix } = data
const isLocal = useType === 'local' const isLocal = useType === 'local'
const icons = Object.keys(data.icons).map( const icons = Object.keys(data.icons).map((item) => `${isLocal ? `${prefix}:` : ''}${item}`)
(item) => `${isLocal ? prefix + ':' : ''}${item}`,
)
await fs.writeFileSync( await fs.writeFileSync(
path.join(output, `icons.data.ts`), path.join(output, `icons.data.ts`),
`export default ${ `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`,
isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })
}`,
) )
prefixSet.push(prefix) prefixSet.push(prefix)
} }
} }
fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite')) fs.emptyDir(path.join(process.cwd(), 'node_modules/.vite'))
console.log( console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - Icon generated successfully:' + `[${prefixSet}]`)
`✨ ${colors.cyan(`[${pkg.name}]`)}` +
' - Icon generated successfully:' +
`[${prefixSet}]`,
)
}) })
} }
......
import fs from 'fs' import fs from 'node:fs'
import path from 'path' import path from 'node:path'
import dotenv from 'dotenv' import dotenv from 'dotenv'
export function isDevFn(mode: string): boolean { export function isDevFn(mode: string): boolean {
...@@ -50,7 +50,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv { ...@@ -50,7 +50,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
*/ */
function getConfFiles() { function getConfFiles() {
const script = process.env.npm_lifecycle_script const script = process.env.npm_lifecycle_script
const reg = new RegExp('--mode ([a-z_\\d]+)') const reg = /--mode ([a-z_\d]+)/
const result = reg.exec(script as string) as any const result = reg.exec(script as string) as any
if (result) { if (result) {
const mode = result[1] as string const mode = result[1] as string
......
...@@ -70,7 +70,7 @@ export function configStyleImportPlugin(_isBuild: boolean) { ...@@ -70,7 +70,7 @@ export function configStyleImportPlugin(_isBuild: boolean) {
return ignoreList.includes(name) return ignoreList.includes(name)
? '' ? ''
: replaceList.hasOwnProperty(name) : Object.prototype.hasOwnProperty.call(replaceList, name)
? `ant-design-vue/es/${replaceList[name]}/style/index` ? `ant-design-vue/es/${replaceList[name]}/style/index`
: `ant-design-vue/es/${name}/style/index` : `ant-design-vue/es/${name}/style/index`
}, },
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* https://github.com/anncwb/vite-plugin-svg-icons * https://github.com/anncwb/vite-plugin-svg-icons
*/ */
import path from 'node:path'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'path'
export function configSvgIconsPlugin(isBuild: boolean) { export function configSvgIconsPlugin(isBuild: boolean) {
const svgIconsPlugin = createSvgIconsPlugin({ const svgIconsPlugin = createSvgIconsPlugin({
......
...@@ -2,16 +2,10 @@ ...@@ -2,16 +2,10 @@
* Vite plugin for website theme color switching * Vite plugin for website theme color switching
* https://github.com/anncwb/vite-plugin-theme * https://github.com/anncwb/vite-plugin-theme
*/ */
import path from 'node:path'
import type { PluginOption } from 'vite' import type { PluginOption } from 'vite'
import path from 'path' import { antdDarkThemePlugin, mixDarken, mixLighten, tinycolor, viteThemePlugin } from 'vite-plugin-theme'
import { import { generateColors, getThemeColors } from '../../config/themeConfig'
viteThemePlugin,
antdDarkThemePlugin,
mixLighten,
mixDarken,
tinycolor,
} from 'vite-plugin-theme'
import { getThemeColors, generateColors } from '../../config/themeConfig'
import { generateModifyVars } from '../../generate/generateModifyVars' import { generateModifyVars } from '../../generate/generateModifyVars'
export function configThemePlugin(isBuild: boolean): PluginOption[] { export function configThemePlugin(isBuild: boolean): PluginOption[] {
...@@ -48,7 +42,7 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { ...@@ -48,7 +42,7 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] {
antdDarkThemePlugin({ antdDarkThemePlugin({
preloadFiles: [ preloadFiles: [
path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'), path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'),
//path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'), // path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'),
path.resolve(process.cwd(), 'src/design/index.less'), path.resolve(process.cwd(), 'src/design/index.less'),
], ],
filter: (id) => (isBuild ? !id.endsWith('antd.less') : true), filter: (id) => (isBuild ? !id.endsWith('antd.less') : true),
......
...@@ -22,7 +22,7 @@ export function createProxy(list: ProxyList = []) { ...@@ -22,7 +22,7 @@ export function createProxy(list: ProxyList = []) {
// https://github.com/http-party/node-http-proxy#options // https://github.com/http-party/node-http-proxy#options
ret[prefix] = { ret[prefix] = {
target: target, target,
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''), rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''),
......
// import * as Pont from 'pont-engine' // import * as Pont from 'pont-engine'
import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine' import type { BaseClass, Interface } from 'pont-engine'
import { CodeGenerator, Property } from 'pont-engine'
// 接口 API 前缀 // 接口 API 前缀
// 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同 // 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同
...@@ -38,7 +39,7 @@ export default class BasicGenerator extends CodeGenerator { ...@@ -38,7 +39,7 @@ export default class BasicGenerator extends CodeGenerator {
return `${requestParams.replace( return `${requestParams.replace(
'options?: any', 'options?: any',
`config?: http.RequestConfig<${ `config?: http.RequestConfig<${
bodyTypeDef ? bodyTypeDef : `Params${requestParams.includes('form') ? ' | FormData' : ''}` bodyTypeDef || `Params${requestParams.includes('form') ? ' | FormData' : ''}`
}>`, }>`,
)}, options?: http.RequestOptions` )}, options?: http.RequestOptions`
} }
......
import { StandardDataSource } from 'pont-engine' import type { StandardDataSource } from 'pont-engine'
export default function transform(dataSource: StandardDataSource): StandardDataSource { export default function transform(dataSource: StandardDataSource): StandardDataSource {
console.log(dataSource) console.log(dataSource)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论