From 15c93eb80e17fdb15a926b0e2450a4bc57be93b7 Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Fri, 6 May 2022 15:02:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20layout/locale/editor/sass=E7=AD=89?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=85=BC=E5=AE=B9vite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-layout/src/index.js | 2 +- .../fes-plugin-layout/src/runtime/runtime.js | 36 ++--- .../src/runtime/views/BaseLayout.vue | 144 ++++++------------ .../src/runtime/views/Menu.vue | 62 ++++---- .../src/runtime/views/MenuIcon.vue | 13 +- packages/fes-plugin-locale/src/index.js | 5 +- .../fes-plugin-locale/src/runtime/core.tpl | 14 +- packages/fes-plugin-locale/src/utils/index.js | 24 +-- .../fes-plugin-monaco-editor/package.json | 3 +- .../fes-plugin-monaco-editor/src/index.js | 18 ++- .../src/runtime/core.tpl | 2 +- packages/fes-plugin-sass/src/index.js | 41 ++--- .../src/plugins/features/globalCSS.js | 2 +- packages/fes-template-vite1/.env | 1 + packages/fes-template-vite1/.env.prod | 1 + packages/fes-template-vite1/.eslintrc.js | 11 ++ packages/fes-template-vite1/.fes.js | 90 +++++++++++ packages/fes-template-vite1/.fes.local.js | 5 + packages/fes-template-vite1/.fes.prod.js | 6 + packages/fes-template-vite1/.gitignore | 11 ++ packages/fes-template-vite1/LICENSE | 21 +++ packages/fes-template-vite1/README.md | 12 ++ packages/fes-template-vite1/__tests__/add.js | 5 + packages/fes-template-vite1/index.html | 20 +++ packages/fes-template-vite1/mock.js | 143 +++++++++++++++++ packages/fes-template-vite1/package.json | 66 ++++++++ packages/fes-template-vite1/public/logo.png | Bin 0 -> 33821 bytes .../public/wine-outline.svg | 1 + packages/fes-template-vite1/src/app.jsx | 27 ++++ .../fes-template-vite1/src/common/service.js | 19 +++ .../src/components/PageLoading.vue | 30 ++++ .../src/components/UserCenter.vue | 20 +++ packages/fes-template-vite1/src/global.css | 0 packages/fes-template-vite1/src/global.scss | 5 + .../fes-template-vite1/src/images/icon.png | Bin 0 -> 5586 bytes .../fes-template-vite1/src/locales/en-US.js | 8 + .../fes-template-vite1/src/locales/zh-CN.js | 8 + .../fes-template-vite1/src/models/user.js | 8 + .../src/pages/cssModule.vue | 24 +++ .../fes-template-vite1/src/pages/editor.vue | 42 +++++ .../fes-template-vite1/src/pages/index.vue | 32 ++++ .../src/pages/menuTest/@id.vue | 30 ++++ .../src/pages/menuTest/index.vue | 26 ++++ .../src/pages/menuTest/layout.vue | 8 + .../fes-template-vite1/src/pages/mock.vue | 47 ++++++ .../fes-template-vite1/src/pages/pinia.vue | 31 ++++ .../src/pages/route/@id.vue | 23 +++ .../fes-template-vite1/src/pages/store.vue | 60 ++++++++ packages/fes-template-vite1/src/store/main.js | 21 +++ .../fes-template-vite1/src/stores/counter.js | 23 +++ .../fes-template-vite1/src/stores/foo/bar.js | 23 +++ .../src/stores/plugin-loger.js | 3 + .../fes-template-vite1/src/stores/user.js | 54 +++++++ packages/fes-template-vite1/src/utils/sum.js | 3 + packages/fes-template-vite1/tsconfig.json | 38 +++++ packages/fes-template/.eslintrc.js | 11 +- packages/fes-template/src/app.js | 14 +- packages/fes-template/src/pages/index.vue | 7 +- yarn.lock | 5 + 59 files changed, 1178 insertions(+), 231 deletions(-) create mode 100644 packages/fes-template-vite1/.env create mode 100644 packages/fes-template-vite1/.env.prod create mode 100644 packages/fes-template-vite1/.eslintrc.js create mode 100644 packages/fes-template-vite1/.fes.js create mode 100644 packages/fes-template-vite1/.fes.local.js create mode 100644 packages/fes-template-vite1/.fes.prod.js create mode 100644 packages/fes-template-vite1/.gitignore create mode 100644 packages/fes-template-vite1/LICENSE create mode 100644 packages/fes-template-vite1/README.md create mode 100644 packages/fes-template-vite1/__tests__/add.js create mode 100644 packages/fes-template-vite1/index.html create mode 100644 packages/fes-template-vite1/mock.js create mode 100644 packages/fes-template-vite1/package.json create mode 100644 packages/fes-template-vite1/public/logo.png create mode 100644 packages/fes-template-vite1/public/wine-outline.svg create mode 100644 packages/fes-template-vite1/src/app.jsx create mode 100644 packages/fes-template-vite1/src/common/service.js create mode 100644 packages/fes-template-vite1/src/components/PageLoading.vue create mode 100644 packages/fes-template-vite1/src/components/UserCenter.vue create mode 100644 packages/fes-template-vite1/src/global.css create mode 100644 packages/fes-template-vite1/src/global.scss create mode 100644 packages/fes-template-vite1/src/images/icon.png create mode 100644 packages/fes-template-vite1/src/locales/en-US.js create mode 100644 packages/fes-template-vite1/src/locales/zh-CN.js create mode 100644 packages/fes-template-vite1/src/models/user.js create mode 100644 packages/fes-template-vite1/src/pages/cssModule.vue create mode 100644 packages/fes-template-vite1/src/pages/editor.vue create mode 100644 packages/fes-template-vite1/src/pages/index.vue create mode 100644 packages/fes-template-vite1/src/pages/menuTest/@id.vue create mode 100644 packages/fes-template-vite1/src/pages/menuTest/index.vue create mode 100644 packages/fes-template-vite1/src/pages/menuTest/layout.vue create mode 100644 packages/fes-template-vite1/src/pages/mock.vue create mode 100644 packages/fes-template-vite1/src/pages/pinia.vue create mode 100644 packages/fes-template-vite1/src/pages/route/@id.vue create mode 100644 packages/fes-template-vite1/src/pages/store.vue create mode 100644 packages/fes-template-vite1/src/store/main.js create mode 100644 packages/fes-template-vite1/src/stores/counter.js create mode 100644 packages/fes-template-vite1/src/stores/foo/bar.js create mode 100644 packages/fes-template-vite1/src/stores/plugin-loger.js create mode 100644 packages/fes-template-vite1/src/stores/user.js create mode 100644 packages/fes-template-vite1/src/utils/sum.js create mode 100644 packages/fes-template-vite1/tsconfig.json diff --git a/packages/fes-plugin-layout/src/index.js b/packages/fes-plugin-layout/src/index.js index 8b464115..209e5988 100644 --- a/packages/fes-plugin-layout/src/index.js +++ b/packages/fes-plugin-layout/src/index.js @@ -24,7 +24,7 @@ export default (api) => { api.addRuntimePluginKey(() => 'layout'); - const absFilePath = join(namespace, 'index.js'); + const absFilePath = join(namespace, 'index.jsx'); const absRuntimeFilePath = join(namespace, 'runtime.js'); diff --git a/packages/fes-plugin-layout/src/runtime/runtime.js b/packages/fes-plugin-layout/src/runtime/runtime.js index c676984f..eaeb72f0 100644 --- a/packages/fes-plugin-layout/src/runtime/runtime.js +++ b/packages/fes-plugin-layout/src/runtime/runtime.js @@ -1,13 +1,11 @@ import { plugin, ApplyPluginsType } from '@@/core/coreExports'; // eslint-disable-next-line import/extensions import { access as accessApi } from '../plugin-access/core'; -import Exception404 from './views/404'; -import Exception403 from './views/403'; +import Exception404 from './views/404.vue'; +import Exception403 from './views/403.vue'; if (!accessApi) { - throw new Error( - '[plugin-layout]: pLugin-layout depends on plugin-access,please install plugin-access first!' - ); + throw new Error('[plugin-layout]: pLugin-layout depends on plugin-access,please install plugin-access first!'); } const handle = (type, router) => { @@ -16,7 +14,7 @@ const handle = (type, router) => { const name = `Exception${type}`; const components = { 404: Exception404, - 403: Exception403 + 403: Exception403, }; if (!accesssIds.includes(path)) { accessApi.setAccess(accesssIds.concat([path])); @@ -26,18 +24,19 @@ const handle = (type, router) => { } }; -export const access = memo => ({ - unAccessHandler({ - router, to, from, next - }) { +export const access = (memo) => ({ + unAccessHandler({ router, to, from, next }) { const runtimeConfig = plugin.applyPlugins({ key: 'layout', type: ApplyPluginsType.modify, - initialValue: {} + initialValue: {}, }); if (runtimeConfig.unAccessHandler && typeof runtimeConfig.unAccessHandler === 'function') { return runtimeConfig.unAccessHandler({ - router, to, from, next + router, + to, + from, + next, }); } if (to.path === '/404') { @@ -47,17 +46,18 @@ export const access = memo => ({ handle(403, router); next('/403'); }, - noFoundHandler({ - router, to, from, next - }) { + noFoundHandler({ router, to, from, next }) { const runtimeConfig = plugin.applyPlugins({ key: 'layout', type: ApplyPluginsType.modify, - initialValue: {} + initialValue: {}, }); if (runtimeConfig.noFoundHandler && typeof runtimeConfig.noFoundHandler === 'function') { return runtimeConfig.noFoundHandler({ - router, to, from, next + router, + to, + from, + next, }); } if (to.path === '/403') { @@ -67,5 +67,5 @@ export const access = memo => ({ handle(404, router); next('/404'); }, - ...memo + ...memo, }); diff --git a/packages/fes-plugin-layout/src/runtime/views/BaseLayout.vue b/packages/fes-plugin-layout/src/runtime/views/BaseLayout.vue index 83065240..a6f24beb 100644 --- a/packages/fes-plugin-layout/src/runtime/views/BaseLayout.vue +++ b/packages/fes-plugin-layout/src/runtime/views/BaseLayout.vue @@ -12,26 +12,12 @@ > - + - - + +
@@ -39,38 +25,23 @@
- + - {{footer}} + {{ footer }}
- + - {{footer}} + {{ footer }} + +{ + "name": "cssModule", + "title": "css Module 测试" +} + + + + diff --git a/packages/fes-template-vite1/src/pages/editor.vue b/packages/fes-template-vite1/src/pages/editor.vue new file mode 100644 index 00000000..6aed5d6b --- /dev/null +++ b/packages/fes-template-vite1/src/pages/editor.vue @@ -0,0 +1,42 @@ + + +{ + "name": "editor", + "title": "$editor", + "keep-alive": true +} + + diff --git a/packages/fes-template-vite1/src/pages/index.vue b/packages/fes-template-vite1/src/pages/index.vue new file mode 100644 index 00000000..b78e7fa2 --- /dev/null +++ b/packages/fes-template-vite1/src/pages/index.vue @@ -0,0 +1,32 @@ + + + + + + + +{ + "name": "index", + "title": "$home" +} + diff --git a/packages/fes-template-vite1/src/pages/menuTest/@id.vue b/packages/fes-template-vite1/src/pages/menuTest/@id.vue new file mode 100644 index 00000000..4977d60f --- /dev/null +++ b/packages/fes-template-vite1/src/pages/menuTest/@id.vue @@ -0,0 +1,30 @@ + + +{ + "title": "menuTest-详情" +} + + + + diff --git a/packages/fes-template-vite1/src/pages/menuTest/index.vue b/packages/fes-template-vite1/src/pages/menuTest/index.vue new file mode 100644 index 00000000..d3ce9c1b --- /dev/null +++ b/packages/fes-template-vite1/src/pages/menuTest/index.vue @@ -0,0 +1,26 @@ + + +{ + "title": "menuTest" +} + + + + diff --git a/packages/fes-template-vite1/src/pages/menuTest/layout.vue b/packages/fes-template-vite1/src/pages/menuTest/layout.vue new file mode 100644 index 00000000..6e323c0d --- /dev/null +++ b/packages/fes-template-vite1/src/pages/menuTest/layout.vue @@ -0,0 +1,8 @@ + diff --git a/packages/fes-template-vite1/src/pages/mock.vue b/packages/fes-template-vite1/src/pages/mock.vue new file mode 100644 index 00000000..aa4d72f4 --- /dev/null +++ b/packages/fes-template-vite1/src/pages/mock.vue @@ -0,0 +1,47 @@ + + +{ + "name": "mock", + "title": "$mock" +} + + diff --git a/packages/fes-template-vite1/src/pages/pinia.vue b/packages/fes-template-vite1/src/pages/pinia.vue new file mode 100644 index 00000000..f55fc856 --- /dev/null +++ b/packages/fes-template-vite1/src/pages/pinia.vue @@ -0,0 +1,31 @@ + + +{ + "name": "pinia", + "title": "pinia" +} + + + + diff --git a/packages/fes-template-vite1/src/pages/route/@id.vue b/packages/fes-template-vite1/src/pages/route/@id.vue new file mode 100644 index 00000000..0bb17929 --- /dev/null +++ b/packages/fes-template-vite1/src/pages/route/@id.vue @@ -0,0 +1,23 @@ + + +{ + "name": "activeRoute", + "title": "动态路由" +} + + diff --git a/packages/fes-template-vite1/src/pages/store.vue b/packages/fes-template-vite1/src/pages/store.vue new file mode 100644 index 00000000..63c9df2b --- /dev/null +++ b/packages/fes-template-vite1/src/pages/store.vue @@ -0,0 +1,60 @@ + + +{ + "name": "store", + "title": "$store" +} + + + diff --git a/packages/fes-template-vite1/src/store/main.js b/packages/fes-template-vite1/src/store/main.js new file mode 100644 index 00000000..0541aae9 --- /dev/null +++ b/packages/fes-template-vite1/src/store/main.js @@ -0,0 +1,21 @@ +import { defineStore } from 'pinia'; + +// useStore could be anything like useUser, useCart +// the first argument is a unique id of the store across your application +export const useStore = defineStore('main', { + // other options... + state: () => ({ + // all these properties will have their type inferred automatically + counter: 0, + name: 'Eduardo', + isAdmin: true + }), + actions: { + increment() { + this.counter++; + }, + randomizeCounter() { + this.counter = Math.round(100 * Math.random()); + } + } +}); diff --git a/packages/fes-template-vite1/src/stores/counter.js b/packages/fes-template-vite1/src/stores/counter.js new file mode 100644 index 00000000..78070ba3 --- /dev/null +++ b/packages/fes-template-vite1/src/stores/counter.js @@ -0,0 +1,23 @@ +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); + } + } +}; diff --git a/packages/fes-template-vite1/src/stores/foo/bar.js b/packages/fes-template-vite1/src/stores/foo/bar.js new file mode 100644 index 00000000..78070ba3 --- /dev/null +++ b/packages/fes-template-vite1/src/stores/foo/bar.js @@ -0,0 +1,23 @@ +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); + } + } +}; diff --git a/packages/fes-template-vite1/src/stores/plugin-loger.js b/packages/fes-template-vite1/src/stores/plugin-loger.js new file mode 100644 index 00000000..6b8a9826 --- /dev/null +++ b/packages/fes-template-vite1/src/stores/plugin-loger.js @@ -0,0 +1,3 @@ +import { createLogger } from 'vuex'; + +export default createLogger(); diff --git a/packages/fes-template-vite1/src/stores/user.js b/packages/fes-template-vite1/src/stores/user.js new file mode 100644 index 00000000..337bf8f8 --- /dev/null +++ b/packages/fes-template-vite1/src/stores/user.js @@ -0,0 +1,54 @@ +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); + }, + login() { + return new Promise((reslove) => { + setTimeout(() => { + console.log('login'); + reslove('OK'); + }, 1000); + }); + } + }, + modules: { + address: { + state: () => ({ + province: '广东省', + city: '深圳市', + zone: '南山区' + }), + getters: { + address(state) { + return state.province + state.city + state.zone; + } + } + }, + posts: { + namespaced: true, + state: () => ({}), + mutations: { + doSomething() {} + } + } + } +}; diff --git a/packages/fes-template-vite1/src/utils/sum.js b/packages/fes-template-vite1/src/utils/sum.js new file mode 100644 index 00000000..54b28e5a --- /dev/null +++ b/packages/fes-template-vite1/src/utils/sum.js @@ -0,0 +1,3 @@ +export default function sum(a, b) { + return a + b; +} diff --git a/packages/fes-template-vite1/tsconfig.json b/packages/fes-template-vite1/tsconfig.json new file mode 100644 index 00000000..b7fce5b7 --- /dev/null +++ b/packages/fes-template-vite1/tsconfig.json @@ -0,0 +1,38 @@ +{ + "compilerOptions": { + "outDir": "build/dist", + "module": "esnext", + "target": "esnext", + "lib": ["esnext", "dom"], + "sourceMap": true, + "baseUrl": ".", + "jsx": "preserve", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "allowJs": true, + "skipLibCheck": true, + "experimentalDecorators": true, + "strict": true, + "paths": { + "@/*": ["./src/*"], + "@@/*": ["./src/.fes/*"] + } + }, + "include": [ + "src/**/*", + "tests/**/*", + "test/**/*", + "__test__/**/*", + "typings/**/*", + "config/**/*", + ".eslintrc.js", + ".stylelintrc.js", + ".prettierrc.js", + "src/.fes/configType.d.ts" + ], + "exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"] +} diff --git a/packages/fes-template/.eslintrc.js b/packages/fes-template/.eslintrc.js index 6300816f..fa1e7f3b 100644 --- a/packages/fes-template/.eslintrc.js +++ b/packages/fes-template/.eslintrc.js @@ -2,13 +2,10 @@ module.exports = { extends: ['@webank/eslint-config-webank/vue.js'], overrides: [ { - files: [ - '**/__tests__/*.{j,t}s?(x)', - '**/tests/unit/**/*.spec.{j,t}s?(x)' - ] - } + files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'], + }, ], env: { - jest: true - } + jest: true, + }, }; diff --git a/packages/fes-template/src/app.js b/packages/fes-template/src/app.js index 167601b7..9e119776 100644 --- a/packages/fes-template/src/app.js +++ b/packages/fes-template/src/app.js @@ -1,8 +1,6 @@ - - import { access as accessApi, pinia } from '@fesjs/fes'; -import PageLoading from '@/components/PageLoading'; -import UserCenter from '@/components/UserCenter'; +import PageLoading from '@/components/PageLoading.vue'; +import UserCenter from '@/components/UserCenter.vue'; import { useStore } from '@/store/main'; export const beforeRender = { @@ -13,17 +11,17 @@ export const beforeRender = { setTimeout(() => { const store = useStore(pinia); store.$patch({ - userName: '李雷' + userName: '李雷', }); setRole('admin'); resolve({ - userName: '李雷' + userName: '李雷', }); }, 1000); }); - } + }, }; export const layout = { - customHeader: + customHeader: , }; diff --git a/packages/fes-template/src/pages/index.vue b/packages/fes-template/src/pages/index.vue index c8fb7f9b..5d9811a3 100644 --- a/packages/fes-template/src/pages/index.vue +++ b/packages/fes-template/src/pages/index.vue @@ -10,12 +10,11 @@ import { FButton } from '@fesjs/fes-design'; export default { components: { - FButton + FButton, }, setup() { - return { - }; - } + return {}; + }, }; diff --git a/yarn.lock b/yarn.lock index d36d4801..225a8556 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10607,6 +10607,11 @@ vite-plugin-html@^3.2.0: node-html-parser "^5.3.3" pathe "^0.2.0" +vite-plugin-monaco-editor@^1.0.10: + version "1.0.10" + resolved "https://registry.npmmirror.com/vite-plugin-monaco-editor/-/vite-plugin-monaco-editor-1.0.10.tgz#cd370f68d4121bced6f902c6284649cc8eca4170" + integrity sha512-7yTAFIE0SefjCmfnjrvXOl53wkxeSASc/ZIcB5tZeEK3vAmHhveV8y3f90Vp8b+PYdbUipjqf91mbFbSENkpcw== + vite-plugin-windicss@^1.8.3: version "1.8.3" resolved "https://registry.npmmirror.com/vite-plugin-windicss/-/vite-plugin-windicss-1.8.3.tgz#d5fe923ad60f5d80f153a4fae5f837d56caa25cb"