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", title: "Fes.js",
// 底部文字 // 底部文字
footer: 'Created by MumbelFe', footer: 'Created by MumbleFE',
// 主题light // 主题light
theme: 'dark' theme: 'dark'
// 是否开启 tabs // 是否开启 tabs
@ -183,13 +183,13 @@ export default {
- **path**:菜单的路径,可配置第三方地址。 - **path**:菜单的路径,可配置第三方地址。
- **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`locales` 中配置了 `title` ,则菜单的名称会根据语言自动切换 - **title**:菜单的标题,如果同时使用[国际化插件](./locale.md),而且`title`的值以`$`开头,则使用`$`后面的内容去匹配语言设置
- **icon**: 菜单的图标,只有一级标题展示图标。 - **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 ```js
{ {
icon: "user" icon: "AppstoreOutlined"
} }
``` ```
- 图标使用本地或者远程svg图片。 - 图标使用本地或者远程svg图片。

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ export default {
if (AText.value) { if (AText.value) {
return ( return (
<span <span
className={'fes-layout-icon anticon'} className={'fes-layout-icon'}
innerHTML={AText.value} innerHTML={AText.value}
></span> ></span>
); );
@ -55,9 +55,6 @@ export default {
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
min-width: 14px; min-width: 14px;
margin-right: 10px;
font-size: 14px; 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> </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: { layout: {
title: "Fes.js", title: "Fes.js",
footer: 'Created by MumbelFe', footer: 'Created by MumbleFE',
multiTabs: false, multiTabs: false,
navigation: 'mixin', navigation: 'mixin',
menus: [{ menus: [{
name: 'index', name: 'index',
icon: 'user'
}, { }, {
title: "子应用1", title: "子应用1",
icon: 'user',
children: [{ children: [{
name: 'app1-index' 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 // .fes.js 只负责管理编译时配置只能使用plain Object
export default { export default {
exportStatic: {}, // exportStatic: {},
define: { define: {
__DEV__: false, __DEV__: false
}, },
publicPath: "./", publicPath: './',
html: { html: {
title: "海贼王", title: '海贼王'
}, },
router: { router: {
mode: "history", mode: 'history'
}, },
access: { access: {
roles: { roles: {
admin: ["*"], admin: ['*'],
menuTest: ['/', '/onepiece', '/store'], menuTest: ['/']
}, }
}, },
request: { request: {
dataField: "result", dataField: 'result'
}, },
mock: { mock: {
prefix: "/v2", prefix: '/v2'
}, },
proxy: { proxy: {
"/v2": { '/v2': {
target: "https://api.douban.com/", target: 'https://api.douban.com/',
changeOrigin: true, changeOrigin: true
}, }
}, },
layout: { layout: {
title: "Fes.js", title: 'Fes.js',
footer: "Created by MumbleFe", footer: 'Created by MumbleFE',
multiTabs: false, multiTabs: false,
navigation: "side", navigation: 'side',
theme: 'dark', theme: 'dark',
menus: [ menus: [
{ {
name: "index", name: 'index',
icon: "/wine-outline.svg", icon: '/wine-outline.svg'
}, },
{ {
name: "onepiece", name: 'store'
icon: "UserOutlined",
path: "https://www.baidu.com",
}, },
{ {
title: "abcd",
children: [
{
name: "store",
},
],
},
{
name: "setting",
title: "setting",
children: [
{
name: "test",
},
],
},{
name: 'editor', name: 'editor',
icon: "/wine-outline.svg" icon: '/wine-outline.svg'
} },
], {
title: '$externalLink',
icon: 'UserOutlined',
path: 'https://www.baidu.com'
},
]
}, },
locale: { locale: {
legacy: true, legacy: true
}, },
devServer: { devServer: {
port: 8080, port: 8080
}, },
enums: { enums: {
status: [ status: [
["0", "无效的"], ['0', '无效的'],
["1", "有效的"], ['1', '有效的']
], ]
}, },
vuex: { vuex: {
strict: true, strict: true
}, },
dynamicImport: true, dynamicImport: true,
monacoEditor: { 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 PageLoading from '@/components/PageLoading';
import UserCenter from '@/components/UserCenter'; 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 = { export const beforeRender = {
loading: <PageLoading />, loading: <PageLoading />,
@ -13,9 +11,9 @@ export const beforeRender = {
const { setRole } = accessApi; const { setRole } = accessApi;
return new Promise((resolve) => { return new Promise((resolve) => {
setTimeout(() => { setTimeout(() => {
setRole('menuTest'); setRole('admin');
resolve({ resolve({
userName: 'harrywan' userName: '李雷'
}); });
}, 1000); }, 1000);
}); });
@ -24,10 +22,4 @@ export const beforeRender = {
export const layout = { export const layout = {
customHeader: <UserCenter /> customHeader: <UserCenter />
// unAccessHandler({ next }) {
// next(false);
// },
// noFoundHandler({ next }) {
// next(false);
// }
}; };

View File

@ -1,12 +1,7 @@
export default { export default {
test: 'test',
home: 'home', home: 'home',
'navBar.lang': 'Languages', store: 'store',
'layout.user.link.help': 'Help', editor: 'editor',
'layout.user.link.privacy': 'Privacy', externalLink: 'externalLink'
'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'
}; };

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

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> <config>
{ {
"name": "editor", "name": "editor",
"title": "monaco-editor" "title": "$editor"
} }
</config> </config>
<script> <script>

View File

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