feat: 优化细节

This commit is contained in:
wanchun 2022-01-04 14:05:50 +08:00
parent 7301bd9acb
commit 449312c146
25 changed files with 196 additions and 189 deletions

View File

@ -84,7 +84,7 @@ export default {
// 标题
title: "Fes.js",
// 底部文字
footer: 'Created by MumbelFe',
footer: 'Created by MumbleFE',
// 主题light
theme: 'dark'
// 是否开启 tabs
@ -183,13 +183,13 @@ export default {
- **path**:菜单的路径,可配置第三方地址。
- **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`locales` 中配置了 `title` ,则菜单的名称会根据语言自动切换
- **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`title`的值以`$`开头,则使用`$`后面的内容去匹配语言设置
- **icon**: 菜单的图标,只有一级标题展示图标。
- 图标使用[antv icon](https://www.antdv.com/components/icon-cn/)在这里使用组件type
- 图标使用[fes-design icon](https://fes-design-4gvn317r3b6bfe17-1254145788.ap-shanghai.app.tcloudbase.com/zh/components/icon.html),在这里使用组件名称
```js
{
icon: "user"
icon: "AppstoreOutlined"
}
```
- 图标使用本地或者远程svg图片。

View File

@ -106,7 +106,7 @@ pages
```
**需要注意的是,满足以下任意规则的文件不会被注册为路由**
- 不是 `.vue` 文件
- 不是 `.vue .jsx` 文件
- `components` 目录中的文件

View File

@ -84,7 +84,7 @@ export default {
// 标题
title: "Fes.js",
// 底部文字
footer: 'Created by MumbelFe',
footer: 'Created by MumbleFE',
// 主题light
theme: 'dark'
// 是否开启 tabs
@ -183,13 +183,13 @@ export default {
- **path**:菜单的路径,可配置第三方地址。
- **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`locales` 中配置了 `title` ,则菜单的名称会根据语言自动切换
- **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`title`的值以`$`开头,则使用`$`后面的内容去匹配语言设置
- **icon**: 菜单的图标,只有一级标题展示图标。
- 图标使用[antv icon](https://www.antdv.com/components/icon-cn/)在这里使用组件type
- 图标使用[fes-design icon](https://fes-design-4gvn317r3b6bfe17-1254145788.ap-shanghai.app.tcloudbase.com/zh/components/icon.html),在这里使用组件名称
```js
{
icon: "user"
icon: "AppstoreOutlined"
}
```
- 图标使用本地或者远程svg图片。

View File

@ -1,7 +1,7 @@
import { watch } from 'vue';
const cache = new WeakMap();
const setDispaly = (el, access) => {
const setDisplay = (el, access) => {
if (access.value) {
el.style.display = el._display;
} else {
@ -15,9 +15,9 @@ export default function createDirective(useAccess) {
ctx.watch = (path) => {
el._display = el._display || el.style.display;
const access = useAccess(path);
setDispaly(el, access);
setDisplay(el, access);
return watch(access, () => {
setDispaly(el, access);
setDisplay(el, access);
});
};
cache.set(el, ctx);

View File

@ -1,10 +1,13 @@
import { plugin } from '@@/core/coreExports';
export const transTitle = (name) => {
if (!/^\$\S+$/.test(name)) {
return name;
}
const sharedLocale = plugin.getShared('locale');
if (sharedLocale) {
const { t } = sharedLocale.useI18n();
return t(name);
return t(name.slice(1));
}
return name;
};
@ -13,7 +16,6 @@ export const transTitle = (name) => {
export const transform = menus => menus.map((menu) => {
const copy = {
...menu,
_label: menu.label,
label: transTitle(menu.label)
};
if (menu.children) {

View File

@ -2,11 +2,10 @@ import { reactive, defineComponent } from "vue";
import { plugin, ApplyPluginsType } from "@@/core/coreExports";
import BaseLayout from "./views/BaseLayout.vue";
const userConfig = reactive({{{REPLACE_USER_CONFIG}}});
const Layout = defineComponent({
name: 'Layout',
setup(){
const userConfig = reactive({{{REPLACE_USER_CONFIG}}});
const runtimeConfig = plugin.applyPlugins({
key: "layout",
type: ApplyPluginsType.modify,

View File

@ -33,7 +33,7 @@ export default {
if (AText.value) {
return (
<span
className={'fes-layout-icon anticon'}
className={'fes-layout-icon'}
innerHTML={AText.value}
></span>
);
@ -55,9 +55,6 @@ export default {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
min-width: 14px;
margin-right: 10px;
font-size: 14px;
transition: font-size 0.15s cubic-bezier(0.215, 0.61, 0.355, 1),
margin 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
</style>

View File

@ -0,0 +1,54 @@
{
"name": "app1",
"version": "2.0.0",
"description": "fes项目模版",
"scripts": {
"build": "fes build",
"prod": "FES_ENV=prod fes build",
"analyze": "ANALYZE=1 fes build",
"dev": "fes dev",
"test": "fes test"
},
"keywords": [
"管理端",
"fes",
"fast",
"easy",
"strong"
],
"files": [
".eslintrc.js",
".gitignore",
".fes.js",
".fes.prod.js",
"mock.js",
"package.json",
"README.md",
"tsconfig.json",
"/src",
"/config"
],
"repository": {
"type": "git",
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
"directory": "packages/fes-template"
},
"author": "harrywan",
"license": "MIT",
"bugs": {
"url": "https://github.com/WeBankFinTech/fes.js/issues"
},
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",
"vue": "^3.0.5",
"@fesjs/fes-design": "^0.1.9"
},
"private": true
}

View File

@ -9,15 +9,13 @@ export default {
},
layout: {
title: "Fes.js",
footer: 'Created by MumbelFe',
footer: 'Created by MumbleFE',
multiTabs: false,
navigation: 'mixin',
menus: [{
name: 'index',
icon: 'user'
}, {
title: "子应用1",
icon: 'user',
children: [{
name: 'app1-index'
},{

View File

@ -0,0 +1,54 @@
{
"name": "main",
"version": "2.0.0",
"description": "fes项目模版",
"scripts": {
"build": "fes build",
"prod": "FES_ENV=prod fes build",
"analyze": "ANALYZE=1 fes build",
"dev": "fes dev",
"test": "fes test"
},
"keywords": [
"管理端",
"fes",
"fast",
"easy",
"strong"
],
"files": [
".eslintrc.js",
".gitignore",
".fes.js",
".fes.prod.js",
"mock.js",
"package.json",
"README.md",
"tsconfig.json",
"/src",
"/config"
],
"repository": {
"type": "git",
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
"directory": "packages/fes-template"
},
"author": "harrywan",
"license": "MIT",
"bugs": {
"url": "https://github.com/WeBankFinTech/fes.js/issues"
},
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.3.1"
},
"dependencies": {
"@fesjs/fes": "^2.0.0",
"vue": "^3.0.5",
"@fesjs/fes-design": "^0.1.9"
},
"private": true
}

View File

@ -0,0 +1,3 @@
html, body {
margin: 0;
}

View File

@ -1,87 +1,74 @@
// .fes.js 只负责管理编译时配置只能使用plain Object
export default {
exportStatic: {},
// exportStatic: {},
define: {
__DEV__: false,
__DEV__: false
},
publicPath: "./",
publicPath: './',
html: {
title: "海贼王",
title: '海贼王'
},
router: {
mode: "history",
mode: 'history'
},
access: {
roles: {
admin: ["*"],
menuTest: ['/', '/onepiece', '/store'],
},
admin: ['*'],
menuTest: ['/']
}
},
request: {
dataField: "result",
dataField: 'result'
},
mock: {
prefix: "/v2",
prefix: '/v2'
},
proxy: {
"/v2": {
target: "https://api.douban.com/",
changeOrigin: true,
},
'/v2': {
target: 'https://api.douban.com/',
changeOrigin: true
}
},
layout: {
title: "Fes.js",
footer: "Created by MumbleFe",
title: 'Fes.js',
footer: 'Created by MumbleFE',
multiTabs: false,
navigation: "side",
navigation: 'side',
theme: 'dark',
menus: [
{
name: "index",
icon: "/wine-outline.svg",
name: 'index',
icon: '/wine-outline.svg'
},
{
name: "onepiece",
icon: "UserOutlined",
path: "https://www.baidu.com",
name: 'store'
},
{
title: "abcd",
children: [
{
name: "store",
},
],
},
{
name: "setting",
title: "setting",
children: [
{
name: "test",
},
],
},{
name: 'editor',
icon: "/wine-outline.svg"
}
],
icon: '/wine-outline.svg'
},
{
title: '$externalLink',
icon: 'UserOutlined',
path: 'https://www.baidu.com'
},
]
},
locale: {
legacy: true,
legacy: true
},
devServer: {
port: 8080,
port: 8080
},
enums: {
status: [
["0", "无效的"],
["1", "有效的"],
],
['0', '无效的'],
['1', '有效的']
]
},
vuex: {
strict: true,
strict: true
},
dynamicImport: true,
monacoEditor: {

View File

@ -1,11 +1,9 @@
import { access as accessApi, store, GETTER_TYPES } from '@fesjs/fes';
import { access as accessApi } from '@fesjs/fes';
import PageLoading from '@/components/PageLoading';
import UserCenter from '@/components/UserCenter';
console.log(store.getters[GETTER_TYPES.user.address]);
console.log(process.env.FES_APP_PUBLISH_ERROR_PAGE);
export const beforeRender = {
loading: <PageLoading />,
@ -13,9 +11,9 @@ export const beforeRender = {
const { setRole } = accessApi;
return new Promise((resolve) => {
setTimeout(() => {
setRole('menuTest');
setRole('admin');
resolve({
userName: 'harrywan'
userName: '李雷'
});
}, 1000);
});
@ -24,10 +22,4 @@ export const beforeRender = {
export const layout = {
customHeader: <UserCenter />
// unAccessHandler({ next }) {
// next(false);
// },
// noFoundHandler({ next }) {
// next(false);
// }
};

View File

@ -1,12 +1,7 @@
export default {
test: 'test',
home: 'home',
'navBar.lang': 'Languages',
'layout.user.link.help': 'Help',
'layout.user.link.privacy': 'Privacy',
'layout.user.link.terms': 'Terms',
'app.preview.down.block': 'Download this page to your local project',
'app.welcome.link.fetch-blocks': 'Get all block',
'app.welcome.link.block-list': 'Quickly build standard, pages based on `block` development'
store: 'store',
editor: 'editor',
externalLink: 'externalLink'
};

View File

@ -1,11 +0,0 @@
export default {
'navbar.lang': 'Bahasa',
'layout.user.link.help': 'Bantuan',
'layout.user.link.privacy': 'Privasi',
'layout.user.link.terms': 'Ketentuan',
'app.preview.down.block': 'Unduh halaman ini dalam projek lokal anda',
'app.welcome.link.fetch-blocks': 'Dapatkan semua blok',
'app.welcome.link.block-list':
'Buat standar dengan cepat, halaman-halaman berdasarkan pengembangan `block`'
};

View File

@ -1,8 +0,0 @@
export default {
'navBar.lang': 'Idiomas',
'layout.user.link.help': 'ajuda',
'layout.user.link.privacy': 'política de privacidade',
'layout.user.link.terms': 'termos de serviços',
'app.preview.down.block': 'Download this page to your local project'
};

View File

@ -1,12 +1,7 @@
export default {
test: '测试',
home: '首页',
'navBar.lang': '语言',
'layout.user.link.help': '帮助',
'layout.user.link.privacy': '隐私',
'layout.user.link.terms': '条款',
'app.preview.down.block': '下载此页面到本地项目',
'app.welcome.link.fetch-blocks': '获取全部区块',
'app.welcome.link.block-list': '基于 block 开发,快速构建标准页面'
store: '状态管理',
editor: '编辑器',
externalLink: '外部链接'
};

View File

@ -1,8 +0,0 @@
export default {
'navBar.lang': '語言',
'layout.user.link.help': '幫助',
'layout.user.link.privacy': '隱私',
'layout.user.link.terms': '條款',
'app.preview.down.block': '下載此頁面到本地項目'
};

View File

@ -1,8 +0,0 @@
<template>
<div>a/b</div>
</template>
<script>
export default {
};
</script>

View File

@ -1,8 +0,0 @@
<template>
<div>b</div>
</template>
<script>
export default {
};
</script>

View File

@ -11,7 +11,7 @@
<config>
{
"name": "editor",
"title": "monaco-editor"
"title": "$editor"
}
</config>
<script>

View File

@ -6,7 +6,7 @@
<config>
{
"name": "index",
"title": "home"
"title": "$home"
}
</config>
<script>

View File

@ -1,21 +0,0 @@
<template>
<div>{{fes}}</div>
</template>
<config>
{
"name": "onepiece",
"title": "onepiece"
}
</config>
<script>
import { ref } from 'vue';
export default {
setup() {
const fes = ref('fes upgrade to vue3');
return {
fes
};
}
};
</script>

View File

@ -1,16 +1,24 @@
<template>
<div class="haizekuo">
<div class="page">
<h4>Vuex</h4>
<div><button @click="increment">click me{{doubleCount}}</button></div>
<div><button :disabled="disabled" @click="login">async login</button></div>
<div><button @click="fooBarIncrement">foo/bar{{fooBarDoubleCount}}</button></div>
<div>
<button @click="increment">click me{{doubleCount}}</button>
</div>
<div>
<button :disabled="disabled" @click="login">async login</button>
</div>
<div>
<button @click="fooBarIncrement">
foo/bar{{fooBarDoubleCount}}
</button>
</div>
<div>{{address}}</div>
</div>
</template>
<config>
{
"name": "store",
"title": "vuex测试"
"title": "$store"
}
</config>
<script>
@ -25,7 +33,9 @@ export default {
const disabled = ref(false);
return {
address: computed(() => store.getters[GETTER_TYPES.user.address]),
doubleCount: computed(() => store.getters[GETTER_TYPES.counter.doubleCount]),
doubleCount: computed(
() => store.getters[GETTER_TYPES.counter.doubleCount]
),
disabled,
increment: () => store.commit(MUTATION_TYPES.counter.increment),
login: () => {
@ -37,14 +47,15 @@ export default {
});
},
fooBarIncrement: () => store.commit(MUTATION_TYPES.fooBar.increment),
fooBarDoubleCount: computed(() => store.getters[GETTER_TYPES.fooBar.doubleCount])
fooBarDoubleCount: computed(
() => store.getters[GETTER_TYPES.fooBar.doubleCount]
)
};
}
};
</script>
<style scoped>
.haizekuo {
/* background: url('../images/icon.png'); */
.page {
min-height: 100vh;
}
</style>

View File

@ -1,16 +0,0 @@
<template>
<div>test</div>
</template>
<config>
{
"name": "test",
"title": "侧事故"
}
</config>
<script>
import { } from '@fesjs/fes';
export default {
};
</script>