Skip to content

Commit

Permalink
upgrade to version 0.3.5 (#308)
Browse files Browse the repository at this point in the history
* style: 调整 ReuseTab 样式

* fix(*): named more normalized

* feat(reuse-tab): right key close tab

* fix(reuse): 取消文字选中

* feat(*): 前端文件命名统一

* fix: 解决大小写不敏感问题

* fix: handle case insensitive issue

* 权限组修改由弹窗改成page

* feat: 优化体验

* feat: edit permission page;

* feat(element-variable): 修改dialog样式,视觉上更加突出

* feat: upgrade to version 0.3.5

Co-authored-by: qiushiming <[email protected]>
Co-authored-by: gongjs <[email protected]>
Co-authored-by: JohnStream <[email protected]>
  • Loading branch information
4 people authored Apr 17, 2020
1 parent fa288c5 commit 8b4ef5b
Show file tree
Hide file tree
Showing 200 changed files with 1,167 additions and 536 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
plugins: ['vue'],
extends: ['plugin:vue/essential', '@vue/airbnb'],
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ QQ群搜索:林间有风 或 643205479

最新版本 `0.3.4`

### 0.3.5

1. `F` 统一前端规范,文件夹、文件名统一用单数和小写字母中划线形式
2. `A` 新增右键关闭历史记录
3. `F` 调整默认 dialog 样式

### 0.3.4

1. `U` 优化变量命名,升级 `element-ui` 版本,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "lin-cms",
"version": "0.3.4",
"version": "0.3.5",
"private": true,
"scripts": {
"serve": "node script/plugin-get-config.js && vue-cli-service serve",
"build": "node script/plugin-get-config.js && vue-cli-service build",
"lint": "vue-cli-service lint",
"commit": "git-cz",
"plugin-init": "node script/plugin-init.js",
"plugin-new": "node script/plugin-new.js",
"plugin-reconfig": "node script/plugin-get-config.js",
"plugin:init": "node script/plugin-init.js",
"plugin:new": "node script/plugin-new.js",
"plugin:reconfig": "node script/plugin-get-config.js",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
Expand Down
7 changes: 5 additions & 2 deletions script/lib/plugin-get-all.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require('fs-extra')
// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path')
const fs = require('fs-extra')
const chalk = require('chalk')
const { came } = require('./util')

// 验证是否是插件
function isPlugin(source) {
Expand Down Expand Up @@ -31,13 +33,14 @@ function getPlugins(source) {
const folders = fs.readdirSync(source)
const pluginsList = []

folders.forEach((item) => {
folders.forEach(item => {
const itemPath = path.join(source, item)
if (!isPlugin(itemPath)) {
return
}
const config = {}
config.name = item
config.camelCaseName = came(item)
config.path = path.resolve(__dirname, `../src/plugins/${item}/`)
config.packageCtx = JSON.parse(fs.readFileSync(path.resolve(itemPath, './package.json'), 'utf8'))
pluginsList.push(config)
Expand Down
8 changes: 8 additions & 0 deletions script/lib/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const came = str => `${str}`.replace(/-\D/g, match => match.charAt(1).toUpperCase())

const hyphenate = str => `${str}`.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)

module.exports = {
came,
hyphenate,
}
7 changes: 4 additions & 3 deletions script/plugin-get-config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const fs = require('fs-extra')
// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path')
const chalk = require('chalk')
const ejs = require('ejs')
const getAllPlugin = require('./lib/plugin-get-all')

const targetDir = path.resolve(__dirname, '../src/config/stage/plugins.js')
const pluginsPath = path.resolve(__dirname, '../src/plugins')
const targetDir = path.resolve(__dirname, '../src/config/stage/plugin.js')
const pluginsPath = path.resolve(__dirname, '../src/plugin')
const templatePath = path.resolve(__dirname, './template/plugin-stage-config.js.ejs')

// eslint-disable-next-line
console.log(chalk.green('配置插件...'));
console.log(chalk.green('配置插件...'))

const template = fs.readFileSync(templatePath, 'utf8')
const puginList = getAllPlugin(pluginsPath)
Expand Down
27 changes: 15 additions & 12 deletions script/plugin-init.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// 手动添加完插件后执行此脚本进行初始化动作
const fs = require('fs-extra')
// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path')
const chalk = require('chalk')
const shell = require('shelljs')
Expand All @@ -10,20 +11,20 @@ const installDep = require('./lib/install-dep')

const projectPackage = require('../package.json')

const pluginsPath = path.resolve(__dirname, '../src/plugins')
const pluginsPath = path.resolve(__dirname, '../src/plugin')
// 检测是否有插件文件夹
if (!fs.existsSync(pluginsPath)) {
console.log(chalk.red('未找到插件文件夹目录, 请确认 src 文件夹中是否有 plugins 目录'))
process.exit(1)
}

const puginList = getAllPlugin(pluginsPath)
const pluginList = getAllPlugin(pluginsPath)

// 将数组 forEach 异步化
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
// eslint-disable-next-line
await callback(array[index], index, array);
await callback(array[index], index, array)
}
}

Expand All @@ -34,12 +35,14 @@ if (!shell.which('npm')) {
}

async function handler() {
const questions = [{
type: 'checkbox',
name: 'plugins',
choices: puginList.map(item => ({ name: item.name, value: item })),
message: '请选择需要初始化的插件\n',
}]
const questions = [
{
type: 'checkbox',
name: 'plugin',
choices: pluginList.map(item => ({ name: item.name, value: item })),
message: '请选择需要初始化的插件\n',
},
]

const { plugins } = await inquirer.prompt(questions)

Expand All @@ -55,8 +58,8 @@ async function handler() {
const keys = ['dependencies', 'devDependencies']
let hasError = false

await asyncForEach(keys, async (key) => {
await asyncForEach(Object.keys(packageCtx[key]), async (pkg) => {
await asyncForEach(keys, async key => {
await asyncForEach(Object.keys(packageCtx[key]), async pkg => {
const v1 = packageCtx[key][pkg]
const v2 = projectPackage[key][pkg]
if (v1 && v2) {
Expand All @@ -65,7 +68,7 @@ async function handler() {
}
}
try {
await installDep(pkg, v1, projectPackage, (key === 'devDependencies'))
await installDep(pkg, v1, projectPackage, key === 'devDependencies')
} catch (e) {
hasError = true
console.log(chalk.red(e.message))
Expand Down
161 changes: 85 additions & 76 deletions script/plugin-new.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const fs = require('fs-extra')
// eslint-disable-next-line import/no-extraneous-dependencies
const path = require('path')
const inquirer = require('inquirer')
const ejs = require('ejs')
Expand All @@ -7,6 +8,9 @@ const yaml = require('js-yaml')
const dirTree = require('directory-tree')
const validatePName = require('validate-npm-package-name')
const semver = require('semver')
// const came = require('./lib/util')

const came = str => `${str}`.replace(/-\D/g, match => match.charAt(1).toUpperCase())

const questions = []

Expand All @@ -29,7 +33,7 @@ questions.push({
return
}

const filePath = path.resolve(__dirname, `../src/plugins/${value}`)
const filePath = path.resolve(__dirname, `../src/plugin/${value}`)
if (fs.existsSync(filePath)) {
done('项目中已存在该插件, 请更换其他插件名')
return
Expand Down Expand Up @@ -84,89 +88,94 @@ questions.push({
const cachePath = path.resolve(__dirname, './.cache')
const cachePluginPath = path.resolve(__dirname, './.cache/plugin')
const pluginTmpPath = path.resolve(__dirname, './template/plugin')
const pluginViewsPath = path.resolve(__dirname, './template/plugin/views')
const pluginViewsPath = path.resolve(__dirname, './template/plugin/view')
const pluginStrPos = __dirname.length + '/template/'.length
const pluginsPath = path.resolve(__dirname, '../src/plugins')
const pluginsPath = path.resolve(__dirname, '../src/plugin')

// 检测是否有插件文件夹
if (!fs.existsSync(pluginsPath)) {
fs.mkdirSync(pluginsPath)
}

inquirer.prompt(questions).then((answers) => {
const result = answers
result.camelCaseName = result.name
.split('-')
.map(str => (str.charAt(0).toUpperCase() + str.slice(1)))
.join('')
return result
}).then((answers) => {
const config = { ...answers }

// 创建缓存文件夹 .cache
if (!fs.existsSync(cachePath)) {
fs.mkdirSync(cachePath)
}
// 清空 plugin 文件夹
if (fs.existsSync(cachePluginPath)) {
fs.removeSync(cachePluginPath)
}
fs.mkdirSync(cachePluginPath)

dirTree(pluginTmpPath, {}, (item) => {
// 忽略隐藏文件
if (item.extension === '' || item.name[0] === '.') {
return
inquirer
.prompt(questions)
.then(answers => {
const result = answers
result.camelCaseName = came(result.name)
return result
})
.then(answers => {
const config = { ...answers }

// 创建缓存文件夹 .cache
if (!fs.existsSync(cachePath)) {
fs.mkdirSync(cachePath)
}
// 清空 plugin 文件夹
if (fs.existsSync(cachePluginPath)) {
fs.removeSync(cachePluginPath)
}
// 处理模板文件
if (item.extension === '.ejs') {
const template = fs.readFileSync(item.path, 'utf8')
const fileConfig = { ...config }
// 舞台 view 文件配置处理
if (item.path.slice(pluginStrPos).split(path.sep)[1] === 'views' && item.name.slice(-8) === '.vue.ejs') {
const viewConfig = {}
viewConfig.icon = 'iconfont icon-demo'
viewConfig.name = fileConfig.camelCaseName + item.name.slice(0, -8)
viewConfig.route = path.join(config.name, path.relative(pluginViewsPath, item.path)).split(path.sep).join('/')
viewConfig.route = `/${viewConfig.route.slice(0, -8)}`
viewConfig.order = null
viewConfig.inNav = true
viewConfig.title = '舞台页'
viewConfig.type = 'view'
viewConfig.auths = {
role: null,
right: null,
fs.mkdirSync(cachePluginPath)

dirTree(pluginTmpPath, {}, item => {
// 忽略隐藏文件
if (item.extension === '' || item.name[0] === '.') {
return
}
// 处理模板文件
if (item.extension === '.ejs') {
const template = fs.readFileSync(item.path, 'utf8')
const fileConfig = { ...config }
// 舞台 view 文件配置处理
if (item.path.slice(pluginStrPos).split(path.sep)[1] === 'view' && item.name.slice(-8) === '.vue.ejs') {
const viewConfig = {}
viewConfig.icon = 'iconfont icon-demo'
viewConfig.name = fileConfig.camelCaseName + item.name.slice(0, -8)
viewConfig.route = path
.join(config.name, path.relative(pluginViewsPath, item.path))
.split(path.sep)
.join('/')
viewConfig.route = `/${viewConfig.route.slice(0, -8)}`
viewConfig.order = null
viewConfig.inNav = true
viewConfig.title = '舞台页'
viewConfig.type = 'view'
viewConfig.auths = {
role: null,
permission: null,
}
viewConfig.needLogin = true
fileConfig.configYml = yaml.safeDump(viewConfig)
}
viewConfig.needLogin = true
fileConfig.configYml = yaml.safeDump(viewConfig)
const result = ejs.render(template, fileConfig)
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path).slice(0, -4))
fs.outputFileSync(targetPath1, result)
return
}
const result = ejs.render(template, fileConfig)
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path)
.slice(0, -4))
fs.outputFileSync(targetPath1, result)
return
}
// 拷贝其他文件
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path))
fs.copySync(item.path, targetPath1)
})
// 拷贝其他文件
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path))
fs.copySync(item.path, targetPath1)
})

return config
}).then((answers) => {
// 复制 .cache 到 plugin
const sourcePath = path.resolve(__dirname, './.cache/plugin')
const targetPath = path.resolve(__dirname, `../src/plugins/${answers.camelCaseName}`)
fs.copySync(sourcePath, targetPath)

console.log(chalk.green(`创建插件 ${answers.name}: ${targetPath}`))
// eslint-disable-next-line
}).then(() => {
// eslint-disable-next-line
require('./plugin-get-config.js');
// eslint-disable-next-line
}).catch((err) => {
// eslint-disable-next-line
console.log(chalk.red('创建插件失败'))
console.error(err)
process.exit(1)
})
return config
})
.then(answers => {
// 复制 .cache 到 plugin
const sourcePath = path.resolve(__dirname, './.cache/plugin')
const targetPath = path.resolve(__dirname, `../src/plugin/${answers.name}`)
fs.copySync(sourcePath, targetPath)

console.log(chalk.green(`创建插件 ${answers.name}: ${targetPath}`))
// eslint-disable-next-line
})
.then(() => {
// eslint-disable-next-line
require('./plugin-get-config.js')
// eslint-disable-next-line
})
.catch(err => {
// eslint-disable-next-line
console.log(chalk.red('创建插件失败'))
console.error(err)
process.exit(1)
})
4 changes: 2 additions & 2 deletions script/template/plugin-stage-config.js.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 本文件是自动生成, 请勿修改
<% plugins.forEach(function(plugin){ %>import <%= plugin.name %> from '@/plugins/<%= plugin.name %>/stage-config'
<% plugins.forEach(function(plugin){ %>import <%= plugin.camelCaseName %> from '@/plugin/<%= plugin.name %>/stage-config'
<% }); %>
const pluginsConfig = [
<% plugins.forEach(function(plugin){ %> <%= plugin.name %>,
<% plugins.forEach(function(plugin){ %> <%= plugin.camelCaseName %>,
<% }); %>]

export default pluginsConfig
4 changes: 2 additions & 2 deletions script/template/plugin/README.md.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 插件名: <%= title %>(<%= camelCaseName %>)
# 插件名: <%= title %>(<%= name %>)

插件描述, <%= title %> 用于处于xxx业务场景, 提供了xxx功能

## 舞台视口列表

### TestView

地址: `/<%= camelCaseName %>/test.vue`
地址: `/<%= name %>/test.vue`
显示xxx内容, 可进行xxx操作

## 自由视口列表
Expand Down
File renamed without changes
Loading

0 comments on commit 8b4ef5b

Please sign in to comment.