feat: 优化模版

This commit is contained in:
winixt 2021-05-17 18:09:51 +08:00
parent 7642e6c990
commit a2e75ffd27
20 changed files with 8540 additions and 245 deletions

View File

@ -144,6 +144,21 @@ export default {
}
```
## extraBabelPlugins
- 类型: `array`
- 默认值: `[]`
- 详情:
配置额外的 babel 插件。
比如:
export default {
extraBabelPlugins: ['babel-plugin-react-require'],
};
## extraPostCSSPlugins
- 类型: `array`
@ -166,7 +181,14 @@ export default {
- 默认值: `{}`
- 详情:
设置 [less-loader 配置项](https://github.com/webpack-contrib/less-loader)。
- 示例:
```js
export default {
extraBabelPlugins: [
['import', { libraryName: 'ant-design-vue', libraryDirectory: 'es', style: 'css' }],
],
}
```
## mock

View File

@ -2,9 +2,6 @@
export default {
define: {
__DEV__: false
},
publicPath: './',
access: {
roles: {
@ -17,13 +14,8 @@ export default {
multiTabs: false,
menus: [{
name: 'index'
}, {
name: 'onepiece'
}]
},
locale: {
legacy: true
},
devServer: {
port: 8000
},

View File

@ -1,4 +1,5 @@
.DS_Store
.cache
# dependencies
/node_modules

View File

@ -1,5 +0,0 @@
import sum from '@/utils/sum';
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});

View File

@ -43,21 +43,16 @@
"access": "public"
},
"devDependencies": {
"@webank/eslint-config-webank": "0.2.10"
"@webank/eslint-config-webank": "0.3.0"
},
"dependencies": {
"@fesjs/fes": "^2.0.0-rc.0",
"@fesjs/plugin-access": "^2.0.0-rc.0",
"@fesjs/plugin-layout": "^2.0.0-rc.0",
"@fesjs/plugin-locale": "^2.0.0-rc.0",
"@fesjs/plugin-model": "^2.0.0-rc.0",
"@fesjs/plugin-enums": "^2.0.0-rc.0",
"@fesjs/plugin-jest": "^2.0.0-rc.0",
"@fesjs/plugin-vuex": "^2.0.0-rc.0",
"ant-design-vue": "^2.0.0",
"vue": "^3.0.5",
"vuex": "^4.0.0"
"vue": "^3.0.5"
},
"private": true
}
}

View File

@ -11,6 +11,7 @@ export const beforeRender = {
return new Promise((resolve) => {
setTimeout(() => {
setRole('admin');
// 初始化应用的全局状态,可以通过 useModel('@@initialState') 获取,具体用法看@/components/UserCenter 文件
resolve({
userName: 'harrywan'
});

View File

@ -0,0 +1 @@
// 放工具函数

View File

@ -1,11 +0,0 @@
export default {
test: 'test',
'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'
};

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,11 +0,0 @@
export default {
test: '测试',
'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 开发,快速构建标准页面'
};

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,100 +1,43 @@
<template>
<div class="haizekuo">
<div>国际化 {{t("test")}}</div>
fes & 拉夫德鲁 <br />
<access :id="accessId"> accessOnepicess1 <input /> </access>
<div v-access="accessId"> accessOnepicess2 <input /> </div>
<input />
<div style="padding: 32px;">
<h3>fes & 拉夫德鲁 </h3>
<h4>数据字典</h4>
<div v-for="item in enumsGet('status')" :key="item.key">{{item.value}}{{item.key}}</div>
<div v-for="item in roles" :key="item.key">{{item.name}}{{item.disabled}}</div>
<div>{{enumsGet('roles', '2', { dir: 'eName' })}}</div>
<h4>Vuex <button @click="increment">click me{{count}}</button></h4>
<section>
计数器
<button @click="increment">click me{{count}}</button>
</section>
</div>
</template>
<script>
import { ref } from 'vue';
import {
enums
} from '@fesjs/fes';
export default {
setup() {
const fes = ref('fes upgrade to vue3');
const count = ref(0);
const increment = () => {
count.value++;
};
return {
fes,
increment,
count,
enumsGet: enums.get
};
}
};
</script>
<config>
{
"name": "index",
"title": "首页"
}
</config>
<script>
import { ref, onMounted, computed } from 'vue';
import { useStore } from 'vuex';
import {
useAccess, useRouter, useI18n, locale, enums
} from '@fesjs/fes';
export default {
setup() {
const fes = ref('fes upgrade to vue3');
const accessOnepicess = useAccess('/onepiece1');
const localI18n = useI18n();
const router = useRouter();
const accessId = ref('/onepiece1');
enums.push('roles', [
{
id: '1',
cName: '系统管理员',
eName: 'System',
perm: ['1', '2', '3']
},
{
id: '2',
cName: '业务管理员',
eName: 'Business',
perm: ['1', '2']
},
{
id: '3',
cName: '普通用户',
eName: 'User',
perm: ['1']
}
], { keyName: 'id' });
const roles = enums.get('roles', {
extend: [
{
key: 'name',
dir: 'cName'
},
{
key: 'disabled',
transfer: item => item.value.perm.some(i => i >= 2)
}
]
});
console.log(roles);
const store = useStore();
console.log('store==>', store);
onMounted(() => {
console.log(router);
setTimeout(() => {
locale.setLocale({ lang: 'en-US' });
locale.addLocale({ lang: 'ja-JP', messages: { test: 'テスト' } });
console.log(locale.getAllLocales());
}, 2000);
setTimeout(() => {
accessId.value = '11';
}, 4000);
// router.push('/onepiece');
});
return {
accessId,
fes,
accessOnepicess,
t: localI18n.t,
enumsGet: enums.get,
roles,
count: computed(() => store.state.counter.count),
increment: () => store.commit('counter/increment')
};
}
};
</script>
<style scoped>
.haizekuo {
/* background: url('../images/icon.png'); */
}
</style>

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,10 +0,0 @@
<template>
<div>test</div>
</template>
<script>
import { } from '@fesjs/fes';
export default {
};
</script>

View File

@ -1,23 +0,0 @@
export default {
namespaced: true,
state: () => ({
count: 0
}),
mutations: {
increment(state) {
state.count++;
}
},
getters: {
doubleCount(state) {
return state.count * 2;
}
},
actions: {
asyncIncrement({ commit }) {
setTimeout(() => {
commit('increment');
}, 2000);
}
}
};

View File

@ -1,3 +0,0 @@
import { createLogger } from 'vuex';
export default createLogger();

View File

@ -1,25 +0,0 @@
export default {
namespaced: true,
state: () => ({
name: 'aring',
age: 20,
count: 0
}),
mutations: {
increment(state) {
state.count++;
}
},
getters: {
doubleCount(state) {
return state.count * 2;
}
},
actions: {
asyncIncrement({ commit }) {
setTimeout(() => {
commit('increment');
}, 2000);
}
}
};

View File

@ -1,3 +0,0 @@
export default function sum(a, b) {
return a + b;
}

File diff suppressed because it is too large Load Diff