Skip to content

Commit 8b4ef5b

Browse files
vanoneangsmileShirmygongjslucienstar
authored
upgrade to version 0.3.5 (#308)
* 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]>
1 parent fa288c5 commit 8b4ef5b

File tree

200 files changed

+1167
-536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+1167
-536
lines changed

.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module.exports = {
22
root: true,
33
env: {
4+
browser: true,
5+
es6: true,
46
node: true,
7+
jest: true,
58
},
69
plugins: ['vue'],
710
extends: ['plugin:vue/essential', '@vue/airbnb'],

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ QQ群搜索:林间有风 或 643205479
9999

100100
最新版本 `0.3.4`
101101

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

104110
1. `U` 优化变量命名,升级 `element-ui` 版本,

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "lin-cms",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"private": true,
55
"scripts": {
66
"serve": "node script/plugin-get-config.js && vue-cli-service serve",
77
"build": "node script/plugin-get-config.js && vue-cli-service build",
88
"lint": "vue-cli-service lint",
99
"commit": "git-cz",
10-
"plugin-init": "node script/plugin-init.js",
11-
"plugin-new": "node script/plugin-new.js",
12-
"plugin-reconfig": "node script/plugin-get-config.js",
10+
"plugin:init": "node script/plugin-init.js",
11+
"plugin:new": "node script/plugin-new.js",
12+
"plugin:reconfig": "node script/plugin-get-config.js",
1313
"test:unit": "vue-cli-service test:unit"
1414
},
1515
"dependencies": {

script/lib/plugin-get-all.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const fs = require('fs-extra')
1+
// eslint-disable-next-line import/no-extraneous-dependencies
22
const path = require('path')
3+
const fs = require('fs-extra')
34
const chalk = require('chalk')
5+
const { came } = require('./util')
46

57
// 验证是否是插件
68
function isPlugin(source) {
@@ -31,13 +33,14 @@ function getPlugins(source) {
3133
const folders = fs.readdirSync(source)
3234
const pluginsList = []
3335

34-
folders.forEach((item) => {
36+
folders.forEach(item => {
3537
const itemPath = path.join(source, item)
3638
if (!isPlugin(itemPath)) {
3739
return
3840
}
3941
const config = {}
4042
config.name = item
43+
config.camelCaseName = came(item)
4144
config.path = path.resolve(__dirname, `../src/plugins/${item}/`)
4245
config.packageCtx = JSON.parse(fs.readFileSync(path.resolve(itemPath, './package.json'), 'utf8'))
4346
pluginsList.push(config)

script/lib/util.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const came = str => `${str}`.replace(/-\D/g, match => match.charAt(1).toUpperCase())
2+
3+
const hyphenate = str => `${str}`.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)
4+
5+
module.exports = {
6+
came,
7+
hyphenate,
8+
}

script/plugin-get-config.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
const fs = require('fs-extra')
2+
// eslint-disable-next-line import/no-extraneous-dependencies
23
const path = require('path')
34
const chalk = require('chalk')
45
const ejs = require('ejs')
56
const getAllPlugin = require('./lib/plugin-get-all')
67

7-
const targetDir = path.resolve(__dirname, '../src/config/stage/plugins.js')
8-
const pluginsPath = path.resolve(__dirname, '../src/plugins')
8+
const targetDir = path.resolve(__dirname, '../src/config/stage/plugin.js')
9+
const pluginsPath = path.resolve(__dirname, '../src/plugin')
910
const templatePath = path.resolve(__dirname, './template/plugin-stage-config.js.ejs')
1011

1112
// eslint-disable-next-line
12-
console.log(chalk.green('配置插件...'));
13+
console.log(chalk.green('配置插件...'))
1314

1415
const template = fs.readFileSync(templatePath, 'utf8')
1516
const puginList = getAllPlugin(pluginsPath)

script/plugin-init.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// 手动添加完插件后执行此脚本进行初始化动作
22
const fs = require('fs-extra')
3+
// eslint-disable-next-line import/no-extraneous-dependencies
34
const path = require('path')
45
const chalk = require('chalk')
56
const shell = require('shelljs')
@@ -10,20 +11,20 @@ const installDep = require('./lib/install-dep')
1011

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

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

20-
const puginList = getAllPlugin(pluginsPath)
21+
const pluginList = getAllPlugin(pluginsPath)
2122

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

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

3637
async function handler() {
37-
const questions = [{
38-
type: 'checkbox',
39-
name: 'plugins',
40-
choices: puginList.map(item => ({ name: item.name, value: item })),
41-
message: '请选择需要初始化的插件\n',
42-
}]
38+
const questions = [
39+
{
40+
type: 'checkbox',
41+
name: 'plugin',
42+
choices: pluginList.map(item => ({ name: item.name, value: item })),
43+
message: '请选择需要初始化的插件\n',
44+
},
45+
]
4346

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

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

58-
await asyncForEach(keys, async (key) => {
59-
await asyncForEach(Object.keys(packageCtx[key]), async (pkg) => {
61+
await asyncForEach(keys, async key => {
62+
await asyncForEach(Object.keys(packageCtx[key]), async pkg => {
6063
const v1 = packageCtx[key][pkg]
6164
const v2 = projectPackage[key][pkg]
6265
if (v1 && v2) {
@@ -65,7 +68,7 @@ async function handler() {
6568
}
6669
}
6770
try {
68-
await installDep(pkg, v1, projectPackage, (key === 'devDependencies'))
71+
await installDep(pkg, v1, projectPackage, key === 'devDependencies')
6972
} catch (e) {
7073
hasError = true
7174
console.log(chalk.red(e.message))

script/plugin-new.js

+85-76
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs-extra')
2+
// eslint-disable-next-line import/no-extraneous-dependencies
23
const path = require('path')
34
const inquirer = require('inquirer')
45
const ejs = require('ejs')
@@ -7,6 +8,9 @@ const yaml = require('js-yaml')
78
const dirTree = require('directory-tree')
89
const validatePName = require('validate-npm-package-name')
910
const semver = require('semver')
11+
// const came = require('./lib/util')
12+
13+
const came = str => `${str}`.replace(/-\D/g, match => match.charAt(1).toUpperCase())
1014

1115
const questions = []
1216

@@ -29,7 +33,7 @@ questions.push({
2933
return
3034
}
3135

32-
const filePath = path.resolve(__dirname, `../src/plugins/${value}`)
36+
const filePath = path.resolve(__dirname, `../src/plugin/${value}`)
3337
if (fs.existsSync(filePath)) {
3438
done('项目中已存在该插件, 请更换其他插件名')
3539
return
@@ -84,89 +88,94 @@ questions.push({
8488
const cachePath = path.resolve(__dirname, './.cache')
8589
const cachePluginPath = path.resolve(__dirname, './.cache/plugin')
8690
const pluginTmpPath = path.resolve(__dirname, './template/plugin')
87-
const pluginViewsPath = path.resolve(__dirname, './template/plugin/views')
91+
const pluginViewsPath = path.resolve(__dirname, './template/plugin/view')
8892
const pluginStrPos = __dirname.length + '/template/'.length
89-
const pluginsPath = path.resolve(__dirname, '../src/plugins')
93+
const pluginsPath = path.resolve(__dirname, '../src/plugin')
9094

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

96-
inquirer.prompt(questions).then((answers) => {
97-
const result = answers
98-
result.camelCaseName = result.name
99-
.split('-')
100-
.map(str => (str.charAt(0).toUpperCase() + str.slice(1)))
101-
.join('')
102-
return result
103-
}).then((answers) => {
104-
const config = { ...answers }
105-
106-
// 创建缓存文件夹 .cache
107-
if (!fs.existsSync(cachePath)) {
108-
fs.mkdirSync(cachePath)
109-
}
110-
// 清空 plugin 文件夹
111-
if (fs.existsSync(cachePluginPath)) {
112-
fs.removeSync(cachePluginPath)
113-
}
114-
fs.mkdirSync(cachePluginPath)
115-
116-
dirTree(pluginTmpPath, {}, (item) => {
117-
// 忽略隐藏文件
118-
if (item.extension === '' || item.name[0] === '.') {
119-
return
100+
inquirer
101+
.prompt(questions)
102+
.then(answers => {
103+
const result = answers
104+
result.camelCaseName = came(result.name)
105+
return result
106+
})
107+
.then(answers => {
108+
const config = { ...answers }
109+
110+
// 创建缓存文件夹 .cache
111+
if (!fs.existsSync(cachePath)) {
112+
fs.mkdirSync(cachePath)
113+
}
114+
// 清空 plugin 文件夹
115+
if (fs.existsSync(cachePluginPath)) {
116+
fs.removeSync(cachePluginPath)
120117
}
121-
// 处理模板文件
122-
if (item.extension === '.ejs') {
123-
const template = fs.readFileSync(item.path, 'utf8')
124-
const fileConfig = { ...config }
125-
// 舞台 view 文件配置处理
126-
if (item.path.slice(pluginStrPos).split(path.sep)[1] === 'views' && item.name.slice(-8) === '.vue.ejs') {
127-
const viewConfig = {}
128-
viewConfig.icon = 'iconfont icon-demo'
129-
viewConfig.name = fileConfig.camelCaseName + item.name.slice(0, -8)
130-
viewConfig.route = path.join(config.name, path.relative(pluginViewsPath, item.path)).split(path.sep).join('/')
131-
viewConfig.route = `/${viewConfig.route.slice(0, -8)}`
132-
viewConfig.order = null
133-
viewConfig.inNav = true
134-
viewConfig.title = '舞台页'
135-
viewConfig.type = 'view'
136-
viewConfig.auths = {
137-
role: null,
138-
right: null,
118+
fs.mkdirSync(cachePluginPath)
119+
120+
dirTree(pluginTmpPath, {}, item => {
121+
// 忽略隐藏文件
122+
if (item.extension === '' || item.name[0] === '.') {
123+
return
124+
}
125+
// 处理模板文件
126+
if (item.extension === '.ejs') {
127+
const template = fs.readFileSync(item.path, 'utf8')
128+
const fileConfig = { ...config }
129+
// 舞台 view 文件配置处理
130+
if (item.path.slice(pluginStrPos).split(path.sep)[1] === 'view' && item.name.slice(-8) === '.vue.ejs') {
131+
const viewConfig = {}
132+
viewConfig.icon = 'iconfont icon-demo'
133+
viewConfig.name = fileConfig.camelCaseName + item.name.slice(0, -8)
134+
viewConfig.route = path
135+
.join(config.name, path.relative(pluginViewsPath, item.path))
136+
.split(path.sep)
137+
.join('/')
138+
viewConfig.route = `/${viewConfig.route.slice(0, -8)}`
139+
viewConfig.order = null
140+
viewConfig.inNav = true
141+
viewConfig.title = '舞台页'
142+
viewConfig.type = 'view'
143+
viewConfig.auths = {
144+
role: null,
145+
permission: null,
146+
}
147+
viewConfig.needLogin = true
148+
fileConfig.configYml = yaml.safeDump(viewConfig)
139149
}
140-
viewConfig.needLogin = true
141-
fileConfig.configYml = yaml.safeDump(viewConfig)
150+
const result = ejs.render(template, fileConfig)
151+
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path).slice(0, -4))
152+
fs.outputFileSync(targetPath1, result)
153+
return
142154
}
143-
const result = ejs.render(template, fileConfig)
144-
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path)
145-
.slice(0, -4))
146-
fs.outputFileSync(targetPath1, result)
147-
return
148-
}
149-
// 拷贝其他文件
150-
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path))
151-
fs.copySync(item.path, targetPath1)
152-
})
155+
// 拷贝其他文件
156+
const targetPath1 = path.resolve(cachePluginPath, path.relative(pluginTmpPath, item.path))
157+
fs.copySync(item.path, targetPath1)
158+
})
153159

154-
return config
155-
}).then((answers) => {
156-
// 复制 .cache 到 plugin
157-
const sourcePath = path.resolve(__dirname, './.cache/plugin')
158-
const targetPath = path.resolve(__dirname, `../src/plugins/${answers.camelCaseName}`)
159-
fs.copySync(sourcePath, targetPath)
160-
161-
console.log(chalk.green(`创建插件 ${answers.name}: ${targetPath}`))
162-
// eslint-disable-next-line
163-
}).then(() => {
164-
// eslint-disable-next-line
165-
require('./plugin-get-config.js');
166-
// eslint-disable-next-line
167-
}).catch((err) => {
168-
// eslint-disable-next-line
169-
console.log(chalk.red('创建插件失败'))
170-
console.error(err)
171-
process.exit(1)
172-
})
160+
return config
161+
})
162+
.then(answers => {
163+
// 复制 .cache 到 plugin
164+
const sourcePath = path.resolve(__dirname, './.cache/plugin')
165+
const targetPath = path.resolve(__dirname, `../src/plugin/${answers.name}`)
166+
fs.copySync(sourcePath, targetPath)
167+
168+
console.log(chalk.green(`创建插件 ${answers.name}: ${targetPath}`))
169+
// eslint-disable-next-line
170+
})
171+
.then(() => {
172+
// eslint-disable-next-line
173+
require('./plugin-get-config.js')
174+
// eslint-disable-next-line
175+
})
176+
.catch(err => {
177+
// eslint-disable-next-line
178+
console.log(chalk.red('创建插件失败'))
179+
console.error(err)
180+
process.exit(1)
181+
})
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// 本文件是自动生成, 请勿修改
2-
<% plugins.forEach(function(plugin){ %>import <%= plugin.name %> from '@/plugins/<%= plugin.name %>/stage-config'
2+
<% plugins.forEach(function(plugin){ %>import <%= plugin.camelCaseName %> from '@/plugin/<%= plugin.name %>/stage-config'
33
<% }); %>
44
const pluginsConfig = [
5-
<% plugins.forEach(function(plugin){ %> <%= plugin.name %>,
5+
<% plugins.forEach(function(plugin){ %> <%= plugin.camelCaseName %>,
66
<% }); %>]
77

88
export default pluginsConfig

script/template/plugin/README.md.ejs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# 插件名: <%= title %>(<%= camelCaseName %>)
1+
# 插件名: <%= title %>(<%= name %>)
22

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

55
## 舞台视口列表
66

77
### TestView
88

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

1212
## 自由视口列表

0 commit comments

Comments
 (0)