mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-06-29 18:09:17 +08:00
style: format code
This commit is contained in:
parent
a3e931bacf
commit
f77566adcc
@ -2,6 +2,20 @@
|
|||||||
"name": "@fesjs/plugin-layout",
|
"name": "@fesjs/plugin-layout",
|
||||||
"version": "5.1.7",
|
"version": "5.1.7",
|
||||||
"description": "@fesjs/plugin-layout",
|
"description": "@fesjs/plugin-layout",
|
||||||
|
"author": "harrywan",
|
||||||
|
"license": "MIT",
|
||||||
|
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
||||||
|
"directory": "packages/fes-plugin-layout"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"fes"
|
||||||
|
],
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"lib",
|
"lib",
|
||||||
@ -10,31 +24,17 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
|
||||||
"directory": "packages/fes-plugin-layout"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"fes"
|
|
||||||
],
|
|
||||||
"author": "harrywan",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"@fesjs/utils": "^3.0.1"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@fesjs/fes": "^3.1.4",
|
"@fesjs/fes": "^3.1.4",
|
||||||
"@fesjs/fes-design": ">=0.7.0",
|
"@fesjs/fes-design": ">=0.7.0",
|
||||||
"vue": "^3.2.47",
|
"vue": "^3.2.47",
|
||||||
"vue-router": "^4.0.1"
|
"vue-router": "^4.0.1"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fesjs/utils": "^3.0.1"
|
||||||
|
},
|
||||||
"typings": "./types.d.ts"
|
"typings": "./types.d.ts"
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@ import { useRoute } from '@@/core/coreExports';
|
|||||||
|
|
||||||
const cache = reactive(new Map());
|
const cache = reactive(new Map());
|
||||||
|
|
||||||
export const getTitle = (path) => cache.get(path);
|
export const getTitle = path => cache.get(path);
|
||||||
|
|
||||||
export const deleteTitle = (patch) => cache.delete(patch);
|
export const deleteTitle = patch => cache.delete(patch);
|
||||||
|
|
||||||
export const useTabTitle = (title) => {
|
export function useTabTitle(title) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const titleRef = ref(title);
|
const titleRef = ref(title);
|
||||||
const path = route.path;
|
const path = route.path;
|
||||||
@ -15,4 +15,4 @@ export const useTabTitle = (title) => {
|
|||||||
cache.set(path, titleRef);
|
cache.set(path, titleRef);
|
||||||
|
|
||||||
return titleRef;
|
return titleRef;
|
||||||
};
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<template v-if="multiTabs">
|
<template v-if="multiTabs">
|
||||||
<FTabs
|
<FTabs
|
||||||
:modelValue="route.path"
|
:model-value="route.path"
|
||||||
closable
|
closable
|
||||||
:tabsPadding="24"
|
:tabs-padding="24"
|
||||||
type="card"
|
type="card"
|
||||||
class="layout-content-tabs"
|
class="layout-content-tabs"
|
||||||
@close="handleCloseTab"
|
@close="handleCloseTab"
|
||||||
@ -21,17 +21,18 @@
|
|||||||
</FDropdown>
|
</FDropdown>
|
||||||
</template>
|
</template>
|
||||||
</FTabs>
|
</FTabs>
|
||||||
<Page ref="pageRef" :pageKey="getPageKey" isAllKeepAlive />
|
<Page ref="pageRef" :page-key="getPageKey" is-all-keep-alive />
|
||||||
</template>
|
</template>
|
||||||
<Page v-else />
|
<Page v-else />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, unref, ref } from 'vue';
|
import { computed, ref, unref } from 'vue';
|
||||||
import { FTabs, FTabPane, FDropdown } from '@fesjs/fes-design';
|
import { FDropdown, FTabPane, FTabs } from '@fesjs/fes-design';
|
||||||
import { ReloadOutlined, MoreOutlined } from '@fesjs/fes-design/icon';
|
import { MoreOutlined, ReloadOutlined } from '@fesjs/fes-design/icon';
|
||||||
import { useRouter, useRoute } from '@@/core/coreExports';
|
import { useRoute, useRouter } from '@@/core/coreExports';
|
||||||
import { transTitle } from '../helpers/pluginLocale';
|
import { transTitle } from '../helpers/pluginLocale';
|
||||||
import { getTitle, deleteTitle } from '../useTitle';
|
import { deleteTitle, getTitle } from '../useTitle';
|
||||||
import Page from './page.vue';
|
import Page from './page.vue';
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
@ -78,15 +79,16 @@ export default {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const findPage = (path) => pageList.value.find((item) => unref(item.path) === unref(path));
|
const findPage = path => pageList.value.find(item => unref(item.path) === unref(path));
|
||||||
|
|
||||||
router.beforeEach((to) => {
|
router.beforeEach((to) => {
|
||||||
const page = findPage(to.path);
|
const page = findPage(to.path);
|
||||||
if (!page) {
|
if (!page)
|
||||||
pageList.value = [...pageList.value, createPage(to)];
|
pageList.value = [...pageList.value, createPage(to)];
|
||||||
} else {
|
|
||||||
|
else
|
||||||
page.route = to;
|
page.route = to;
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,13 +109,13 @@ export default {
|
|||||||
const index = list.indexOf(selectedPage);
|
const index = list.indexOf(selectedPage);
|
||||||
if (route.path === selectedPage.path) {
|
if (route.path === selectedPage.path) {
|
||||||
if (list.length > 1) {
|
if (list.length > 1) {
|
||||||
if (list.length - 1 === index) {
|
if (list.length - 1 === index)
|
||||||
await switchPage(list[index - 1].path);
|
await switchPage(list[index - 1].path);
|
||||||
} else {
|
|
||||||
|
else
|
||||||
await switchPage(list[index + 1].path);
|
await switchPage(list[index + 1].path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
list.splice(index, 1);
|
list.splice(index, 1);
|
||||||
pageList.value = list;
|
pageList.value = list;
|
||||||
pageRef.value.removeKeepAlive(selectedPage.name);
|
pageRef.value.removeKeepAlive(selectedPage.name);
|
||||||
@ -121,9 +123,8 @@ export default {
|
|||||||
};
|
};
|
||||||
const reloadPage = (path) => {
|
const reloadPage = (path) => {
|
||||||
const selectedPage = findPage(path || unref(route.path));
|
const selectedPage = findPage(path || unref(route.path));
|
||||||
if (selectedPage) {
|
if (selectedPage)
|
||||||
selectedPage.key = getKey();
|
selectedPage.key = getKey();
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const closeOtherPage = (path) => {
|
const closeOtherPage = (path) => {
|
||||||
const selectedPage = findPage(path || unref(route.path));
|
const selectedPage = findPage(path || unref(route.path));
|
||||||
@ -132,9 +133,9 @@ export default {
|
|||||||
};
|
};
|
||||||
const getPageKey = (_route) => {
|
const getPageKey = (_route) => {
|
||||||
const selectedPage = findPage(_route.path);
|
const selectedPage = findPage(_route.path);
|
||||||
if (selectedPage) {
|
if (selectedPage)
|
||||||
return selectedPage.key;
|
return selectedPage.key;
|
||||||
}
|
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
const handlerMore = (key) => {
|
const handlerMore = (key) => {
|
||||||
@ -163,6 +164,7 @@ export default {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
.layout-content-tabs {
|
.layout-content-tabs {
|
||||||
background: rgb(255, 255, 255);
|
background: rgb(255, 255, 255);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user