fix: 检测vue和@vue/compiler-sfc的版本,保证一致

This commit is contained in:
harrywan 2021-08-18 14:23:37 +08:00
parent 5cca84e35a
commit 8e39dcf2c2
10 changed files with 3693 additions and 3624 deletions

View File

@ -30,7 +30,7 @@
"@fesjs/utils": "^2.0.0" "@fesjs/utils": "^2.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@ant-design/icons-vue": "^5.1.6", "@ant-design/icons-vue": "^6.0.0",
"@fesjs/fes": "^2.0.0", "@fesjs/fes": "^2.0.0",
"ant-design-vue": "^2.2.0", "ant-design-vue": "^2.2.0",
"vue": "^3.0.5" "vue": "^3.0.5"

View File

@ -5,8 +5,9 @@
hide-add hide-add
type="editable-card" type="editable-card"
@tabClick="switchPage" @tabClick="switchPage"
@edit="onEdit"
> >
<a-tab-pane v-for="page in pageList" :key="page.path" closable> <a-tab-pane v-for="page in pageList" :key="page.path" :closable="route.path !== page.path">
<template #tab> <template #tab>
{{page.name}} {{page.name}}
<ReloadOutlined <ReloadOutlined
@ -100,6 +101,13 @@ export default {
}); });
} }
}; };
const onEdit = (targetKey, action) => {
if (action === 'remove') {
const selectedPage = findPage(targetKey);
const index = pageList.indexOf(selectedPage);
pageList.splice(index, 1);
}
};
const reloadPage = (path) => { const reloadPage = (path) => {
const selectedPage = findPage(path || unref(route.path)); const selectedPage = findPage(path || unref(route.path));
if (selectedPage) { if (selectedPage) {
@ -119,7 +127,6 @@ export default {
return ''; return '';
}; };
const handlerMore = ({ key }) => { const handlerMore = ({ key }) => {
console.log(key);
switch (key) { switch (key) {
case 'closeOtherPage': case 'closeOtherPage':
closeOtherPage(); closeOtherPage();
@ -136,7 +143,8 @@ export default {
getPageKey, getPageKey,
reloadPage, reloadPage,
switchPage, switchPage,
handlerMore handlerMore,
onEdit
}; };
} }
}; };

View File

@ -31,7 +31,7 @@
"vue-i18n": "^9.0.0" "vue-i18n": "^9.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@ant-design/icons-vue": "^5.1.6", "@ant-design/icons-vue": "^6.0.0",
"@fesjs/fes": "^2.0.0", "@fesjs/fes": "^2.0.0",
"ant-design-vue": "^2.2.0", "ant-design-vue": "^2.2.0",
"vue": "^3.0.5" "vue": "^3.0.5"

View File

@ -10,7 +10,7 @@ export default (api) => {
} = api; } = api;
api.chainWebpack((memo) => { api.chainWebpack((memo) => {
memo.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'); memo.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.esm-bundler.js');
}); });
api.describe({ api.describe({

View File

@ -70,5 +70,8 @@
"webpack-chain": "^6.5.1", "webpack-chain": "^6.5.1",
"webpack-dev-server": "^3.11.2", "webpack-dev-server": "^3.11.2",
"webpackbar": "^5.0.0-3" "webpackbar": "^5.0.0-3"
},
"peerDependencies": {
"@vue/compiler-sfc": "^3.0.5"
} }
} }

View File

@ -45,6 +45,7 @@ export default function () {
require.resolve('./plugins/features/mock'), require.resolve('./plugins/features/mock'),
require.resolve('./plugins/features/dynamicImport'), require.resolve('./plugins/features/dynamicImport'),
require.resolve('./plugins/features/runtimePublicPath'), require.resolve('./plugins/features/runtimePublicPath'),
require.resolve('./plugins/features/checkVuePackage'),
// misc // misc
require.resolve('./plugins/misc/route'), require.resolve('./plugins/misc/route'),

View File

@ -0,0 +1,30 @@
import { chalk, semver } from '@fesjs/utils';
export default (api) => {
api.describe({
key: 'checkVuePackage',
config: {
schema(joi) {
return joi.object();
},
default: {
}
}
});
api.onStart(() => {
// eslint-disable-next-line import/no-extraneous-dependencies
const vuePkg = require('vue/package.json');
const vueCompilerPkg = require('@vue/compiler-sfc/package.json');
if (
!semver.satisfies(vuePkg.version, vueCompilerPkg.version, { includePrerelease: true })
) {
console.log(
chalk.red(
`You are using vue@${vuePkg.version}, requires @vue/compiler-sfc@${vuePkg.version}.\nPlease upgrade your @vue/compiler-sfc@${vueCompilerPkg.version} version.`
)
);
process.exit(1);
}
});
};

View File

@ -49,7 +49,7 @@
"@fesjs/fes": "^2.0.0", "@fesjs/fes": "^2.0.0",
"@fesjs/plugin-access": "^2.0.0", "@fesjs/plugin-access": "^2.0.0",
"@fesjs/plugin-layout": "^2.0.0", "@fesjs/plugin-layout": "^2.0.0",
"@fesjs/plugin-locale": "^2.0.0", "@fesjs/plugin-locale": "^2.0.1",
"@fesjs/plugin-model": "^2.0.0", "@fesjs/plugin-model": "^2.0.0",
"@fesjs/plugin-enums": "^2.0.0", "@fesjs/plugin-enums": "^2.0.0",
"@fesjs/plugin-jest": "^2.0.0", "@fesjs/plugin-jest": "^2.0.0",

View File

@ -8,9 +8,11 @@ import Spin from 'ant-design-vue/lib/spin';
import 'ant-design-vue/lib/spin/style/css'; import 'ant-design-vue/lib/spin/style/css';
export default { export default {
components: {
Spin
},
setup() { setup() {
return { return {
Spin
}; };
} }
}; };

7257
yarn.lock

File diff suppressed because it is too large Load Diff