diff --git a/.eslintrc.mjs b/.eslintrc.js
similarity index 60%
rename from .eslintrc.mjs
rename to .eslintrc.js
index 95e1ce4..a714deb 100644
--- a/.eslintrc.mjs
+++ b/.eslintrc.js
@@ -1,7 +1,9 @@
/* eslint-env node */
-export default {
+module.exports = {
root: true,
- 'extends': [
+ extends: [
+ 'plugin:vue/vue3-essential',
+ 'eslint:recommended',
'plugin:vue/vue3-recommended',
'eslint:recommended',
'@vue/eslint-config-standard'
@@ -10,6 +12,6 @@ export default {
ecmaVersion: 'latest'
},
rules: {
- 'vue/multi-word-component-names': "off"
+ 'vue/multi-word-component-names': 'off'
}
}
diff --git a/src/components/common-form-control/index.vue b/src/components/common-form-control/index.vue
new file mode 100644
index 0000000..49e6cd3
--- /dev/null
+++ b/src/components/common-form-control/index.vue
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/common-form-input/index.vue b/src/components/common-form-input/index.vue
deleted file mode 100644
index 15e3178..0000000
--- a/src/components/common-form-input/index.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
diff --git a/src/components/common-menu-item/index.vue b/src/components/common-menu-item/index.vue
index cac144f..2b6d580 100644
--- a/src/components/common-menu-item/index.vue
+++ b/src/components/common-menu-item/index.vue
@@ -2,7 +2,26 @@
import { computed } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
-
+/**
+ * @typedef {Object} CommonMenuItem 菜单对象
+ * @property {boolean} isDropdown 是否是下拉Dropdown样式
+ * @property {boolean} isSplit 是否是分割元素
+ * @property {string} menuCls 自定义样式
+ * @property {string} index 路由地址
+ * @property {Object} route 路由
+ * @property {string} icon 图标
+ * @property {number} iconSize 图标大小
+ * @property {string} label 菜单显示名称
+ * @property {string} labelKey 菜单显示名称的Key,国际化需要
+ * @method iconIf 图标计算函数
+ * @method click 点击事件
+ * @property {[CommonMenuItem]} children 子菜单
+ */
+/**
+ * @type {Object}
+ * @property {CommonMenuItem} menuItem 菜单对象
+ * @property index 序号
+ */
const props = defineProps({
menuItem: {
type: Object,
@@ -81,7 +100,7 @@ const dropdownClick = menuItem => {
:class="menuCls"
@click="menuItem.click&&menuItem.click()"
>
-
+
{
diff --git a/src/components/common-tabs-view/index.vue b/src/components/common-tabs-view/index.vue
index 675c071..1e77a34 100644
--- a/src/components/common-tabs-view/index.vue
+++ b/src/components/common-tabs-view/index.vue
@@ -31,12 +31,22 @@ const selectHistoryTab = path => {
}
const removeHistoryTab = path => {
- const lastTab = tabsViewStore.removeHistoryTab(path)
+ const lastTab = tabsViewStore.removeHistoryTab({ path })
if (lastTab) {
selectHistoryTab(lastTab)
}
}
+const refreshHistoryTab = tab => {
+ const time = new Date().getTime()
+ router.push(`${tab.path}?${time}`)
+}
+
+const removeOtherHistoryTabs = tab => {
+ tabsViewStore.removeOtherHistoryTabs(tab)
+ selectHistoryTab(tab.path)
+}
+
@@ -52,6 +62,9 @@ const removeHistoryTab = path => {
diff --git a/src/components/common-tabs-view/tabs-view-item.vue b/src/components/common-tabs-view/tabs-view-item.vue
index 05523bc..5e9d7fe 100644
--- a/src/components/common-tabs-view/tabs-view-item.vue
+++ b/src/components/common-tabs-view/tabs-view-item.vue
@@ -6,10 +6,16 @@ import { useTabsViewStore } from '@/stores/TabsViewStore'
const tabsViewStore = useTabsViewStore()
const props = defineProps({
+ /**
+ * @type RouteRecordRaw
+ */
tabItem: {
type: Object,
required: true
- }
+ },
+ removeHistoryTab: Function,
+ removeOtherHistoryTabs: Function,
+ refreshHistoryTab: Function
})
const menuName = computed(() => {
@@ -26,13 +32,33 @@ const menuInfo = computed(() => {
:name="tabItem.path"
>
-
-
- {{ menuName }}
-
+
+
+
+ {{ menuName }}
+
+
+
+
+
+ {{ $t('common.label.refresh') }}
+
+
+
+ {{ $t('common.label.close') }}
+
+
+
+ {{ $t('common.label.closeOther') }}
+
+
+
+
diff --git a/src/components/index.js b/src/components/index.js
index dcff11e..83ae7d7 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -1,5 +1,5 @@
import CommonIcon from '@/components/common-icon/index.vue'
-import CommonInput from '@/components/common-form-input/index.vue'
+import CommonFormControl from '@/components/common-form-control/index.vue'
import CommonMenu from '@/components/common-menu/index.vue'
import CommonMenuItem from '@/components/common-menu-item/index.vue'
import CommonTabsView from '@/components/common-tabs-view/index.vue'
@@ -13,7 +13,7 @@ export default {
*/
install (Vue) {
Vue.component('CommonIcon', CommonIcon)
- Vue.component('CommonInput', CommonInput)
+ Vue.component('CommonFormControl', CommonFormControl)
Vue.component('CommonMenu', CommonMenu)
Vue.component('CommonMenuItem', CommonMenuItem)
Vue.component('CommonTabsView', CommonTabsView)
diff --git a/src/messages/common_cn.js b/src/messages/common_cn.js
index 6ace0d1..87f9fd9 100644
--- a/src/messages/common_cn.js
+++ b/src/messages/common_cn.js
@@ -6,6 +6,8 @@ common.label.login = '登录'
common.label.index = '首页'
common.label.settings = '设置'
common.label.close = '关闭'
+common.label.refresh = '刷新'
+common.label.closeOther = '关闭其他'
common.label.langCn = '中文'
common.label.langEn = 'English'
common.label.language = '语言'
diff --git a/src/messages/common_en.js b/src/messages/common_en.js
index 3e4c64f..57c5219 100644
--- a/src/messages/common_en.js
+++ b/src/messages/common_en.js
@@ -6,6 +6,8 @@ common.label.login = 'Login'
common.label.index = 'Home'
common.label.settings = 'Settings'
common.label.close = 'Close'
+common.label.refresh = 'Refresh'
+common.label.closeOther = 'Close Others'
common.label.langCn = '中文'
common.label.langEn = 'English'
common.label.language = 'Language'
diff --git a/src/stores/TabsViewStore.js b/src/stores/TabsViewStore.js
index 0c65ff1..b454c8d 100644
--- a/src/stores/TabsViewStore.js
+++ b/src/stores/TabsViewStore.js
@@ -1,21 +1,35 @@
import { ref } from 'vue'
import { defineStore } from 'pinia'
+/**
+ * @typedef {Object} TabsViewStore
+ * @property {boolean} isTabMode 是否开启tab模式
+ * @property {boolean} isCachedTabMode 是否开启tab缓存
+ * @property {boolean} isShowTabIcon 是否显示tab的图标
+ * @property {[import('vue-router').RouteRecordRaw]} historyTabs 历史tab列表
+ * @property {[string]} cachedTabs 缓存的tab列表
+ * @method removeHistoryTab
+ */
+/**
+ * @return {TabsViewStore}
+ */
export const useTabsViewStore = defineStore('tabsView', () => {
const isTabMode = ref(true)
const isCachedTabMode = ref(true)
const isShowTabIcon = ref(true)
+ /**
+ * @type {{value: [import('vue-router').RouteRecordRaw]}}
+ */
const historyTabs = ref([])
+ /**
+ * @type {{value: [string]}}
+ */
const cachedTabs = ref([])
const clearHistoryTabs = () => {
if (historyTabs.value.length) {
const tab = historyTabs.value[0]
- historyTabs.value = [tab]
- cachedTabs.value = []
- if (isCachedTabMode.value && tab.name) {
- cachedTabs.value = [tab.name]
- }
+ removeOtherHistoryTabs(tab)
}
}
@@ -26,21 +40,28 @@ export const useTabsViewStore = defineStore('tabsView', () => {
}
}
- const addHistoryTab = tab => {
+ const addHistoryTab = (tab, insertIdx) => {
// 添加tab
if (isTabMode.value) {
const idx = historyTabs.value.findIndex(v => v.path === tab.path)
if (idx < 0) {
- historyTabs.value.push(Object.assign({}, tab)) // 可能是Proxy,需要解析出来
+ if (insertIdx !== undefined) {
+ historyTabs.value.splice(insertIdx, 0, tab)
+ } else {
+ historyTabs.value.push(Object.assign({}, tab)) // 可能是Proxy,需要解析出来
+ }
if (isCachedTabMode.value && tab.name) {
- cachedTabs.value.push(tab.name)
+ console.info('=======================add tab', tab.name)
+ if (!cachedTabs.value.includes(tab.name)) {
+ cachedTabs.value.push(tab.name)
+ }
}
}
}
}
- const removeHistoryTab = path => {
+ const removeHistoryTab = tab => {
if (historyTabs.value.length > 1) {
- const idx = historyTabs.value.findIndex(v => v.path === path)
+ const idx = historyTabs.value.findIndex(v => v.path === tab.path)
if (idx > -1) {
removeCachedTab(historyTabs.value[idx])
// 删除tab
@@ -59,6 +80,14 @@ export const useTabsViewStore = defineStore('tabsView', () => {
}
}
+ const removeOtherHistoryTabs = tab => {
+ historyTabs.value = [tab]
+ cachedTabs.value = []
+ if (isCachedTabMode.value && tab.name) {
+ cachedTabs.value = [tab.name]
+ }
+ }
+
return {
isTabMode,
isCachedTabMode,
@@ -81,6 +110,7 @@ export const useTabsViewStore = defineStore('tabsView', () => {
isShowTabIcon.value = !isShowTabIcon.value
},
removeHistoryTab,
+ removeOtherHistoryTabs,
clearHistoryTabs,
findHistoryTab,
addHistoryTab
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 25c57ad..f380635 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -35,7 +35,10 @@ const showLeftMenu = computed(() => {
name="slide-fade"
mode="out-in"
>
-
+
{
-
+
diff --git a/src/views/components/global/GlobalSettings.vue b/src/views/components/global/GlobalSettings.vue
index 292d7e6..27090c4 100644
--- a/src/views/components/global/GlobalSettings.vue
+++ b/src/views/components/global/GlobalSettings.vue
@@ -5,7 +5,7 @@ const globalConfigStore = useGlobalConfigStore()
-
+
{{ $t('common.label.settings') }}