提交
This commit is contained in:
8
themeColor/index.js
Normal file
8
themeColor/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* 主题色 本项目样式中使用到该颜色的位置将会在切换主题色时
|
||||
* 修改本文件后请运行一次 npm run dev 以保证./index.scss文件生成正常
|
||||
* */
|
||||
|
||||
const themeColor = '#409EFF'
|
||||
// const themeColor = '#4451B2'
|
||||
module.exports = themeColor
|
||||
23
themeColor/index.scss
Normal file
23
themeColor/index.scss
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
// 本文件自动生成,请勿手动修改,如需修改请去./index.js和./themeColorPlugin.js文件中处理
|
||||
// 主题色
|
||||
$themeColor: #409EFF;
|
||||
/*
|
||||
主题色同色色系,序号0是当前颜色 1是当前色的rgb写法 2-12是浅色越大颜色越浅 13-14是比主题色更深的两种颜色
|
||||
切换主题色时,同色系颜色也会被对应的切换
|
||||
*/
|
||||
$themeColor-0: #409EFF;
|
||||
$themeColor-1: rgb(64,158,255);
|
||||
$themeColor-2: #53a8ff;
|
||||
$themeColor-3: #3a8ee6;
|
||||
$themeColor-4: #66b1ff;
|
||||
$themeColor-5: #337ecc;
|
||||
$themeColor-6: #79bbff;
|
||||
$themeColor-7: #2d6fb3;
|
||||
$themeColor-8: #8cc5ff;
|
||||
$themeColor-9: #265f99;
|
||||
$themeColor-10: #a0cfff;
|
||||
$themeColor-11: #204f80;
|
||||
$themeColor-12: #b3d8ff;
|
||||
$themeColor-13: #1a3f66;
|
||||
$themeColor-14: #c6e2ff;
|
||||
73
themeColor/themeColorPlugin.js
Normal file
73
themeColor/themeColorPlugin.js
Normal file
@@ -0,0 +1,73 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const forElementUI = require('webpack-theme-color-replacer/forElementUI')
|
||||
const themeColor = require('./index')
|
||||
|
||||
const resolve = (dir) => {
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
const matchColors = forElementUI.getElementUISeries(themeColor)
|
||||
|
||||
const scssTemplate = `
|
||||
// 本文件自动生成,请勿手动修改,如需修改请去./index.js和./themeColorPlugin.js文件中处理
|
||||
// 主题色
|
||||
$themeColor: ${themeColor};
|
||||
/*
|
||||
主题色同色色系,序号0是当前颜色 1是当前色的rgb写法 2-12是浅色越大颜色越浅 13-14是比主题色更深的两种颜色
|
||||
切换主题色时,同色系颜色也会被对应的切换
|
||||
*/
|
||||
$themeColor-0: ${matchColors[0]};
|
||||
$themeColor-1: rgb(${matchColors[1]});
|
||||
$themeColor-2: ${matchColors[2]};
|
||||
$themeColor-3: ${matchColors[3]};
|
||||
$themeColor-4: ${matchColors[4]};
|
||||
$themeColor-5: ${matchColors[5]};
|
||||
$themeColor-6: ${matchColors[6]};
|
||||
$themeColor-7: ${matchColors[7]};
|
||||
$themeColor-8: ${matchColors[8]};
|
||||
$themeColor-9: ${matchColors[9]};
|
||||
$themeColor-10: ${matchColors[10]};
|
||||
$themeColor-11: ${matchColors[11]};
|
||||
$themeColor-12: ${matchColors[12]};
|
||||
$themeColor-13: ${matchColors[13]};
|
||||
$themeColor-14: ${matchColors[14]};
|
||||
`
|
||||
|
||||
const writeThemeColorScssFile = (callback) => {
|
||||
const pathname = resolve('./index.scss')
|
||||
const write = () => {
|
||||
fs.writeFile(pathname, scssTemplate, 'utf8', function(error) {
|
||||
if (error) {
|
||||
//console.log('主题文件生成失败:')
|
||||
throw new Error(error)
|
||||
}
|
||||
//console.log('主题文件生成成功')
|
||||
callback()
|
||||
})
|
||||
}
|
||||
fs.readFile(pathname, function(error, data) {
|
||||
if (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
write()
|
||||
return
|
||||
}
|
||||
throw new Error(error)
|
||||
}
|
||||
if (data.toString() !== scssTemplate) {
|
||||
write()
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function themeColorPlugin(options) {}
|
||||
|
||||
themeColorPlugin.prototype.apply = function(compiler) {
|
||||
compiler.plugin('emit', function(compilation, callback) {
|
||||
writeThemeColorScssFile(callback)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = themeColorPlugin
|
||||
Reference in New Issue
Block a user