| | |
| | | "license": "MIT",
|
| | | "scripts": {
|
| | | "dev": "vite",
|
| | | "build:prod": "vite build",
|
| | | "build:prod": "vite build",
|
| | | "build:stage": "vite build --mode staging",
|
| | | "preview": "vite preview"
|
| | | },
|
| | |
| | | "js-cookie": "3.0.1",
|
| | | "jsencrypt": "3.2.1",
|
| | | "nprogress": "0.2.0",
|
| | | "pinia": "2.0.14",
|
| | | "vue": "3.2.31",
|
| | | "vue-cropper": "1.0.3",
|
| | | "vue-router": "4.0.14",
|
| | | "vuex": "4.0.2"
|
| | | "vue-router": "4.0.14"
|
| | | },
|
| | | "devDependencies": {
|
| | | "@vitejs/plugin-vue": "2.3.3",
|
| | |
| | | import Fuse from 'fuse.js'
|
| | | import { getNormalPath } from '@/utils/ruoyi'
|
| | | import { isHttp } from '@/utils/validate'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | const search = ref('');
|
| | | const options = ref([]);
|
| | |
| | | const show = ref(false);
|
| | | const fuse = ref(undefined);
|
| | | const headerSearchSelectRef = ref(null);
|
| | | const store = useStore();
|
| | | const router = useRouter();
|
| | | const routes = computed(() => store.getters.permission_routes);
|
| | | const routes = computed(() => usePermissionStore().routes);
|
| | |
|
| | | function click() {
|
| | | show.value = !show.value
|
| | |
| | | </template>
|
| | |
|
| | | <script setup>
|
| | | import { ElMessage } from 'element-plus'
|
| | | import useAppStore from "@/store/modules/app";
|
| | |
|
| | | const store = useStore();
|
| | | const size = computed(() => store.getters.size);
|
| | | const appStore = useAppStore();
|
| | | const size = computed(() => appStore.size);
|
| | | const route = useRoute();
|
| | | const router = useRouter();
|
| | | const {proxy} = getCurrentInstance();
|
| | | const { proxy } = getCurrentInstance();
|
| | | const sizeOptions = ref([
|
| | | { label: 'è¾å¤§', value: 'large' },
|
| | | { label: 'é»è®¤', value: 'default' },
|
| | | { label: 'ç¨å°', value: 'small' },
|
| | | ])
|
| | | { label: "è¾å¤§", value: "large" },
|
| | | { label: "é»è®¤", value: "default" },
|
| | | { label: "ç¨å°", value: "small" },
|
| | | ]);
|
| | |
|
| | | function refreshView() {
|
| | | // In order to make the cached page re-rendered
|
| | | store.dispatch('tagsView/delAllCachedViews', route)
|
| | |
|
| | | const { fullPath } = route
|
| | |
|
| | | nextTick(() => {
|
| | | router.replace({
|
| | | path: '/redirect' + fullPath
|
| | | })
|
| | | })
|
| | | }
|
| | | function handleSetSize(size) {
|
| | | proxy.$modal.loading("æ£å¨è®¾ç½®å¸å±å¤§å°ï¼è¯·ç¨å...");
|
| | | store.dispatch('app/setSize', size)
|
| | | setTimeout("window.location.reload()", 1000)
|
| | | };
|
| | | appStore.setSize(size);
|
| | | setTimeout("window.location.reload()", 1000);
|
| | | }
|
| | | </script>
|
| | |
|
| | | <style lang='scss' scoped>
|
| | |
| | | <script setup>
|
| | | import { constantRoutes } from "@/router"
|
| | | import { isHttp } from '@/utils/validate'
|
| | | import useAppStore from '@/store/modules/app'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | // 顶鍿 åå§æ°
|
| | | const visibleNumber = ref(null);
|
| | |
| | | // éèä¾§è¾¹æ è·¯ç±
|
| | | const hideList = ['/index', '/user/profile'];
|
| | |
|
| | | const store = useStore();
|
| | | const appStore = useAppStore()
|
| | | const settingsStore = useSettingsStore()
|
| | | const permissionStore = usePermissionStore()
|
| | | const route = useRoute();
|
| | | const router = useRouter();
|
| | |
|
| | | // 主é¢é¢è²
|
| | | const theme = computed(() => store.state.settings.theme);
|
| | | const theme = computed(() => settingsStore.theme);
|
| | | // ææçè·¯ç±ä¿¡æ¯
|
| | | const routers = computed(() => store.state.permission.topbarRouters);
|
| | | const routers = computed(() => permissionStore.topbarRouters);
|
| | |
|
| | | // 顶鍿¾ç¤ºèå
|
| | | const topMenus = computed(() => {
|
| | |
| | | if (path !== undefined && path.lastIndexOf("/") > 0 && hideList.indexOf(path) === -1) {
|
| | | const tmpPath = path.substring(1, path.length);
|
| | | activePath = "/" + tmpPath.substring(0, tmpPath.indexOf("/"));
|
| | | store.dispatch('app/toggleSideBarHide', false);
|
| | | appStore.toggleSideBarHide(false);
|
| | | } else if(!route.children) {
|
| | | activePath = path;
|
| | | store.dispatch('app/toggleSideBarHide', true);
|
| | | appStore.toggleSideBarHide(true);
|
| | | }
|
| | | activeRoutes(activePath);
|
| | | return activePath;
|
| | |
| | | } else if (!route || !route.children) {
|
| | | // 没æåè·¯ç±è·¯å¾å
鍿å¼
|
| | | router.push({ path: key });
|
| | | store.dispatch('app/toggleSideBarHide', true);
|
| | | appStore.toggleSideBarHide(true);
|
| | | } else {
|
| | | // æ¾ç¤ºå·¦ä¾§èå¨èå
|
| | | activeRoutes(key);
|
| | | store.dispatch('app/toggleSideBarHide', false);
|
| | | appStore.toggleSideBarHide(false);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | });
|
| | | }
|
| | | if(routes.length > 0) {
|
| | | store.commit("SET_SIDEBAR_ROUTERS", routes);
|
| | | permissionStore.setSidebarRouters(routes);
|
| | | }
|
| | | return routes;
|
| | | }
|
| | |
| | | * Copyright (c) 2019 ruoyi
|
| | | */
|
| | |
|
| | | import store from '@/store'
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | export default {
|
| | | mounted(el, binding, vnode) {
|
| | | const { value } = binding
|
| | | const all_permission = "*:*:*";
|
| | | const permissions = store.getters && store.getters.permissions
|
| | | const permissions = useUserStore().permissions
|
| | |
|
| | | if (value && value instanceof Array && value.length > 0) {
|
| | | const permissionFlag = value
|
| | |
| | | * Copyright (c) 2019 ruoyi
|
| | | */
|
| | |
|
| | | import store from '@/store'
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | export default {
|
| | | mounted(el, binding, vnode) {
|
| | | const { value } = binding
|
| | | const super_admin = "admin";
|
| | | const roles = store.getters && store.getters.roles
|
| | | const roles = useUserStore().roles
|
| | |
|
| | | if (value && value instanceof Array && value.length > 0) {
|
| | | const roleFlag = value
|
| | |
| | | </template>
|
| | |
|
| | | <script setup>
|
| | | let store = useStore()
|
| | | import useTagsViewStore from '@/store/modules/tagsview'
|
| | |
|
| | | const tagsViewStore = useTagsViewStore()
|
| | | const route = useRoute()
|
| | | store.dispatch('tagsView/addCachedView', route)
|
| | | tagsViewStore.addCachedView(route)
|
| | | const cachedViews = computed(() => {
|
| | | return store.state.tagsView.cachedViews
|
| | | return tagsViewStore.cachedViews
|
| | | })
|
| | | </script>
|
| | |
|
| | |
| | | <template>
|
| | | <div class="navbar">
|
| | | <hamburger id="hamburger-container" :is-active="getters.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
| | | <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!$store.state.settings.topNav" />
|
| | | <top-nav id="topmenu-container" class="topmenu-container" v-if="$store.state.settings.topNav" />
|
| | | <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
| | | <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!settingsStore.topNav" />
|
| | | <top-nav id="topmenu-container" class="topmenu-container" v-if="settingsStore.topNav" />
|
| | |
|
| | | <div class="right-menu">
|
| | | <template v-if="getters.device !== 'mobile'">
|
| | | <template v-if="appStore.device !== 'mobile'">
|
| | | <header-search id="header-search" class="right-menu-item" />
|
| | |
|
| | | <el-tooltip content="æºç å°å" effect="dark" placement="bottom">
|
| | |
| | | <div class="avatar-container">
|
| | | <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
|
| | | <div class="avatar-wrapper">
|
| | | <img :src="getters.avatar" class="user-avatar" />
|
| | | <img :src="userStore.avatar" class="user-avatar" />
|
| | | <el-icon><caret-bottom /></el-icon>
|
| | | </div>
|
| | | <template #dropdown>
|
| | |
| | | import HeaderSearch from '@/components/HeaderSearch'
|
| | | import RuoYiGit from '@/components/RuoYi/Git'
|
| | | import RuoYiDoc from '@/components/RuoYi/Doc'
|
| | | import useAppStore from '@/store/modules/app'
|
| | | import useUserStore from '@/store/modules/user'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | |
|
| | | const store = useStore();
|
| | | const getters = computed(() => store.getters);
|
| | | const appStore = useAppStore()
|
| | | const userStore = useUserStore()
|
| | | const settingsStore = useSettingsStore()
|
| | |
|
| | | function toggleSideBar() {
|
| | | store.dispatch('app/toggleSideBar')
|
| | | appStore.toggleSideBar()
|
| | | }
|
| | |
|
| | | function handleCommand(command) {
|
| | |
| | | cancelButtonText: 'åæ¶',
|
| | | type: 'warning'
|
| | | }).then(() => {
|
| | | store.dispatch('LogOut').then(() => {
|
| | | userStore.logOut().then(() => {
|
| | | location.href = '/index';
|
| | | })
|
| | | }).catch(() => { });
|
| | |
| | | import axios from 'axios'
|
| | | import { ElLoading, ElMessage } from 'element-plus'
|
| | | import { useDynamicTitle } from '@/utils/dynamicTitle'
|
| | | import useAppStore from '@/store/modules/app'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | const { proxy } = getCurrentInstance();
|
| | | const store = useStore();
|
| | | const appStore = useAppStore()
|
| | | const settingsStore = useSettingsStore()
|
| | | const permissionStore = usePermissionStore()
|
| | | const showSettings = ref(false);
|
| | | const theme = ref(store.state.settings.theme);
|
| | | const sideTheme = ref(store.state.settings.sideTheme);
|
| | | const storeSettings = computed(() => store.state.settings);
|
| | | const theme = ref(settingsStore.theme);
|
| | | const sideTheme = ref(settingsStore.sideTheme);
|
| | | const storeSettings = computed(() => settingsStore);
|
| | | const predefineColors = ref(["#409EFF", "#ff4500", "#ff8c00", "#ffd700", "#90ee90", "#00ced1", "#1e90ff", "#c71585"]);
|
| | |
|
| | | /** æ¯å¦éè¦topnav */
|
| | | const topNav = computed({
|
| | | get: () => storeSettings.value.topNav,
|
| | | set: (val) => {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'topNav',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'topNav', value: val })
|
| | | if (!val) {
|
| | | store.dispatch('app/toggleSideBarHide', false);
|
| | | store.commit("SET_SIDEBAR_ROUTERS", store.state.permission.defaultRoutes);
|
| | | appStore.toggleSideBarHide(false);
|
| | | permissionStore.setSidebarRouters(permissionStore.defaultRoutes);
|
| | | }
|
| | | }
|
| | | })
|
| | |
| | | const tagsView = computed({
|
| | | get: () => storeSettings.value.tagsView,
|
| | | set: (val) => {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'tagsView',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'tagsView', value: val })
|
| | | }
|
| | | })
|
| | | /**æ¯å¦éè¦åºå®å¤´é¨ */
|
| | | const fixedHeader = computed({
|
| | | get: () => storeSettings.value.fixedHeader,
|
| | | set: (val) => {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'fixedHeader',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'fixedHeader', value: val })
|
| | | }
|
| | | })
|
| | | /**æ¯å¦éè¦ä¾§è¾¹æ çlogo */
|
| | | const sidebarLogo = computed({
|
| | | get: () => storeSettings.value.sidebarLogo,
|
| | | set: (val) => {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'sidebarLogo',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'sidebarLogo', value: val })
|
| | | }
|
| | | })
|
| | | /**æ¯å¦éè¦ä¾§è¾¹æ ç卿ç½é¡µçtitle */
|
| | | const dynamicTitle = computed({
|
| | | get: () => storeSettings.value.dynamicTitle,
|
| | | set: (val) => {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'dynamicTitle',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'dynamicTitle', value: val })
|
| | | // å¨æè®¾ç½®ç½é¡µæ é¢
|
| | | useDynamicTitle()
|
| | | }
|
| | | })
|
| | |
|
| | | function themeChange(val) {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'theme',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'theme', value: val })
|
| | | theme.value = val;
|
| | | }
|
| | | function handleTheme(val) {
|
| | | store.dispatch('settings/changeSetting', {
|
| | | key: 'sideTheme',
|
| | | value: val
|
| | | })
|
| | | settingsStore.changeSetting({ key: 'sideTheme', value: val })
|
| | | sideTheme.value = val;
|
| | | }
|
| | | function saveSetting() {
|
| | |
| | | <script setup>
|
| | | import variables from '@/assets/styles/variables.module.scss'
|
| | | import logo from '@/assets/logo/logo.png'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | |
|
| | | defineProps({
|
| | | collapse: {
|
| | |
| | | })
|
| | |
|
| | | const title = ref('è¥ä¾ç®¡çç³»ç»');
|
| | | const store = useStore();
|
| | | const sideTheme = computed(() => store.state.settings.sideTheme);
|
| | | const settingsStore = useSettingsStore();
|
| | | const sideTheme = computed(() => settingsStore.sideTheme);
|
| | | </script>
|
| | |
|
| | | <style lang="scss" scoped>
|
| | |
| | | import Logo from './Logo'
|
| | | import SidebarItem from './SidebarItem'
|
| | | import variables from '@/assets/styles/variables.module.scss'
|
| | | import useAppStore from '@/store/modules/app'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | const route = useRoute();
|
| | | const store = useStore();
|
| | | const appStore = useAppStore()
|
| | | const settingsStore = useSettingsStore()
|
| | | const permissionStore = usePermissionStore()
|
| | |
|
| | | const sidebarRouters = computed(() => store.getters.sidebarRouters);
|
| | | const showLogo = computed(() => store.state.settings.sidebarLogo);
|
| | | const sideTheme = computed(() => store.state.settings.sideTheme);
|
| | | const theme = computed(() => store.state.settings.theme);
|
| | | const isCollapse = computed(() => !store.state.app.sidebar.opened);
|
| | | const sidebarRouters = computed(() => permissionStore.sidebarRouters);
|
| | | const showLogo = computed(() => settingsStore.sidebarLogo);
|
| | | const sideTheme = computed(() => settingsStore.sideTheme);
|
| | | const theme = computed(() => settingsStore.theme);
|
| | | const isCollapse = computed(() => !appStore.sidebar.opened);
|
| | |
|
| | | const activeMenu = computed(() => {
|
| | | const { meta, path } = route;
|
| | |
| | | </template>
|
| | |
|
| | | <script setup>
|
| | | import useTagsViewStore from '@/store/modules/tagsview'
|
| | |
|
| | | const tagAndTagSpacing = ref(4);
|
| | | const { proxy } = getCurrentInstance();
|
| | |
|
| | |
| | | emits('scroll')
|
| | | }
|
| | |
|
| | | const store = useStore();
|
| | | const visitedViews = computed(() => store.state.tagsView.visitedViews);
|
| | | const tagsViewStore = useTagsViewStore()
|
| | | const visitedViews = computed(() => tagsViewStore.visitedViews);
|
| | |
|
| | | function moveToTarget(currentTag) {
|
| | | const $container = proxy.$refs.scrollContainer.$el
|
| | |
| | | <script setup>
|
| | | import ScrollPane from './ScrollPane'
|
| | | import { getNormalPath } from '@/utils/ruoyi'
|
| | | import useTagsViewStore from '@/store/modules/tagsview'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | const visible = ref(false);
|
| | | const top = ref(0);
|
| | |
| | | const scrollPaneRef = ref(null);
|
| | |
|
| | | const { proxy } = getCurrentInstance();
|
| | | const store = useStore();
|
| | | const route = useRoute();
|
| | | const router = useRouter();
|
| | |
|
| | | const visitedViews = computed(() => store.state.tagsView.visitedViews);
|
| | | const routes = computed(() => store.state.permission.routes);
|
| | | const theme = computed(() => store.state.settings.theme);
|
| | | const visitedViews = computed(() => useTagsViewStore().visitedViews);
|
| | | const routes = computed(() => usePermissionStore().routes);
|
| | | const theme = computed(() => useSettingsStore().theme);
|
| | |
|
| | | watch(route, () => {
|
| | | addTags()
|
| | |
| | | for (const tag of res) {
|
| | | // Must have tag name
|
| | | if (tag.name) {
|
| | | store.dispatch('tagsView/addVisitedView', tag)
|
| | | useTagsViewStore().addVisitedView(tag)
|
| | | }
|
| | | }
|
| | | }
|
| | | function addTags() {
|
| | | const { name } = route
|
| | | if (name) {
|
| | | store.dispatch('tagsView/addView', route)
|
| | | useTagsViewStore().addView(route)
|
| | | }
|
| | | return false
|
| | | }
|
| | |
| | | scrollPaneRef.value.moveToTarget(r);
|
| | | // when query is different then update
|
| | | if (r.fullPath !== route.fullPath) {
|
| | | store.dispatch('tagsView/updateVisitedView', route)
|
| | | useTagsViewStore().updateVisitedView(route)
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import { AppMain, Navbar, Settings, TagsView } from './components'
|
| | | import defaultSettings from '@/settings'
|
| | |
|
| | | const store = useStore();
|
| | | const theme = computed(() => store.state.settings.theme);
|
| | | const sideTheme = computed(() => store.state.settings.sideTheme);
|
| | | const sidebar = computed(() => store.state.app.sidebar);
|
| | | const device = computed(() => store.state.app.device);
|
| | | const needTagsView = computed(() => store.state.settings.tagsView);
|
| | | const fixedHeader = computed(() => store.state.settings.fixedHeader);
|
| | | import useAppStore from '@/store/modules/app'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | |
|
| | | const settingsStore = useSettingsStore()
|
| | | const theme = computed(() => settingsStore.theme);
|
| | | const sideTheme = computed(() => settingsStore.sideTheme);
|
| | | const sidebar = computed(() => useAppStore().sidebar);
|
| | | const device = computed(() => useAppStore().device);
|
| | | const needTagsView = computed(() => settingsStore.tagsView);
|
| | | const fixedHeader = computed(() => settingsStore.fixedHeader);
|
| | |
|
| | | const classObj = computed(() => ({
|
| | | hideSidebar: !sidebar.value.opened,
|
| | |
| | |
|
| | | watchEffect(() => {
|
| | | if (device.value === 'mobile' && sidebar.value.opened) {
|
| | | store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
| | | useAppStore().closeSideBar({ withoutAnimation: false })
|
| | | }
|
| | | if (width.value - 1 < WIDTH) {
|
| | | store.dispatch('app/toggleDevice', 'mobile')
|
| | | store.dispatch('app/closeSideBar', { withoutAnimation: true })
|
| | | useAppStore().toggleDevice('mobile')
|
| | | useAppStore().closeSideBar({ withoutAnimation: true })
|
| | | } else {
|
| | | store.dispatch('app/toggleDevice', 'desktop')
|
| | | useAppStore().toggleDevice('desktop')
|
| | | }
|
| | | })
|
| | |
|
| | | function handleClickOutside() {
|
| | | store.dispatch('app/closeSideBar', { withoutAnimation: false })
|
| | | useAppStore().closeSideBar({ withoutAnimation: false })
|
| | | }
|
| | |
|
| | | const settingRef = ref(null);
|
| | |
| | | import router from './router'
|
| | | import store from './store'
|
| | | import { ElMessage } from 'element-plus'
|
| | | import NProgress from 'nprogress'
|
| | | import 'nprogress/nprogress.css'
|
| | | import { getToken } from '@/utils/auth'
|
| | | import { isHttp } from '@/utils/validate'
|
| | | import { isRelogin } from '@/utils/request'
|
| | | import useUserStore from '@/store/modules/user'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | | import usePermissionStore from '@/store/modules/permission'
|
| | |
|
| | | NProgress.configure({ showSpinner: false });
|
| | |
|
| | |
| | | router.beforeEach((to, from, next) => {
|
| | | NProgress.start()
|
| | | if (getToken()) {
|
| | | to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
| | | to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
| | | /* has token*/
|
| | | if (to.path === '/login') {
|
| | | next({ path: '/' })
|
| | | NProgress.done()
|
| | | } else {
|
| | | if (store.getters.roles.length === 0) {
|
| | | if (useUserStore().roles.length === 0) {
|
| | | isRelogin.show = true
|
| | | // 夿å½åç¨æ·æ¯å¦å·²æåå®user_infoä¿¡æ¯
|
| | | store.dispatch('GetInfo').then(() => {
|
| | | useUserStore().getInfo().then(() => {
|
| | | isRelogin.show = false
|
| | | store.dispatch('GenerateRoutes').then(accessRoutes => {
|
| | | usePermissionStore().generateRoutes().then(accessRoutes => {
|
| | | // æ ¹æ®rolesæéçæå¯è®¿é®çè·¯ç±è¡¨
|
| | | accessRoutes.forEach(route => {
|
| | | if (!isHttp(route.path)) {
|
| | |
| | | next({ ...to, replace: true }) // hackæ¹æ³ ç¡®ä¿addRoutes已宿
|
| | | })
|
| | | }).catch(err => {
|
| | | store.dispatch('LogOut').then(() => {
|
| | | useUserStore().logOut().then(() => {
|
| | | ElMessage.error(err)
|
| | | next({ path: '/' })
|
| | | })
|
| | |
| | | import store from '@/store'
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | function authPermission(permission) {
|
| | | const all_permission = "*:*:*";
|
| | | const permissions = store.getters && store.getters.permissions
|
| | | const permissions = useUserStore().permissions
|
| | | if (permission && permission.length > 0) {
|
| | | return permissions.some(v => {
|
| | | return all_permission === v || v === permission
|
| | |
| | |
|
| | | function authRole(role) {
|
| | | const super_admin = "admin";
|
| | | const roles = store.getters && store.getters.roles
|
| | | const roles = useUserStore().roles
|
| | | if (role && role.length > 0) {
|
| | | return roles.some(v => {
|
| | | return super_admin === v || v === role
|
| | |
| | | import store from '@/store'
|
| | | import useTagsViewStore from '@/store/modules/tagsview'
|
| | | import router from '@/router'
|
| | |
|
| | | export default {
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | | return store.dispatch('tagsView/delCachedView', obj).then(() => {
|
| | | return useTagsViewStore().delCachedView(obj).then(() => {
|
| | | const { path, query } = obj
|
| | | router.replace({
|
| | | path: '/redirect' + path,
|
| | |
| | | },
|
| | | // å
³éå½åtab页ç¾ï¼æå¼æ°é¡µç¾
|
| | | closeOpenPage(obj) {
|
| | | store.dispatch("tagsView/delView", router.currentRoute.value);
|
| | | useTagsViewStore().delView(router.currentRoute.value);
|
| | | if (obj !== undefined) {
|
| | | return router.push(obj);
|
| | | }
|
| | |
| | | // å
³éæå®tab页ç¾
|
| | | closePage(obj) {
|
| | | if (obj === undefined) {
|
| | | return store.dispatch('tagsView/delView', router.currentRoute.value).then(({ lastPath }) => {
|
| | | return useTagsViewStore().delView(router.currentRoute.value).then(({ lastPath }) => {
|
| | | return router.push(lastPath || '/index');
|
| | | });
|
| | | }
|
| | | return store.dispatch('tagsView/delView', obj);
|
| | | return useTagsViewStore().delView(obj);
|
| | | },
|
| | | // å
³éæætab页ç¾
|
| | | closeAllPage() {
|
| | | return store.dispatch('tagsView/delAllViews');
|
| | | return useTagsViewStore().delAllViews();
|
| | | },
|
| | | // å
³é左侧tab页ç¾
|
| | | closeLeftPage(obj) {
|
| | | return store.dispatch('tagsView/delLeftTags', obj || router.currentRoute.value);
|
| | | return useTagsViewStore().delLeftTags(obj || router.currentRoute.value);
|
| | | },
|
| | | // å
³éå³ä¾§tab页ç¾
|
| | | closeRightPage(obj) {
|
| | | return store.dispatch('tagsView/delRightTags', obj || router.currentRoute.value);
|
| | | return useTagsViewStore().delRightTags(obj || router.currentRoute.value);
|
| | | },
|
| | | // å
³éå
¶ä»tab页ç¾
|
| | | closeOtherPage(obj) {
|
| | | return store.dispatch('tagsView/delOthersViews', obj || router.currentRoute.value);
|
| | | return useTagsViewStore().delOthersViews(obj || router.currentRoute.value);
|
| | | },
|
| | | // æå¼tab页ç¾
|
| | | openPage(url) {
|
| | |
| | | },
|
| | | // ä¿®æ¹tab页ç¾
|
| | | updatePage(obj) {
|
| | | return store.dispatch('tagsView/updateVisitedView', obj);
|
| | | return useTagsViewStore().updateVisitedView(obj);
|
| | | }
|
| | | }
|
| | |
| | | import { createStore } from 'vuex'
|
| | | import app from './modules/app'
|
| | | import user from './modules/user'
|
| | | import tagsView from './modules/tagsView'
|
| | | import permission from './modules/permission'
|
| | | import settings from './modules/settings'
|
| | | import getters from './getters'
|
| | |
|
| | | const store = createStore({
|
| | | modules: {
|
| | | app,
|
| | | user,
|
| | | tagsView,
|
| | | permission,
|
| | | settings
|
| | | },
|
| | | getters
|
| | | });
|
| | |
|
| | | const store = createPinia()
|
| | |
|
| | | export default store |
| | |
| | | import Cookies from 'js-cookie'
|
| | |
|
| | | const state = {
|
| | | sidebar: {
|
| | | opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
|
| | | withoutAnimation: false,
|
| | | hide: false
|
| | | },
|
| | | device: 'desktop',
|
| | | size: Cookies.get('size') || 'default'
|
| | | }
|
| | |
|
| | | const mutations = {
|
| | | TOGGLE_SIDEBAR: state => {
|
| | | if (state.sidebar.hide) {
|
| | | return false;
|
| | | const useAppStore = defineStore(
|
| | | 'app',
|
| | | {
|
| | | state: () => ({
|
| | | sidebar: {
|
| | | opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
|
| | | withoutAnimation: false,
|
| | | hide: false
|
| | | },
|
| | | device: 'desktop',
|
| | | size: Cookies.get('size') || 'default'
|
| | | }),
|
| | | actions: {
|
| | | toggleSideBar(withoutAnimation) {
|
| | | if (this.sidebar.hide) {
|
| | | return false;
|
| | | }
|
| | | this.sidebar.opened = !this.sidebar.opened
|
| | | this.sidebar.withoutAnimation = withoutAnimation
|
| | | if (this.sidebar.opened) {
|
| | | Cookies.set('sidebarStatus', 1)
|
| | | } else {
|
| | | Cookies.set('sidebarStatus', 0)
|
| | | }
|
| | | },
|
| | | closeSideBar(withoutAnimation) {
|
| | | Cookies.set('sidebarStatus', 0)
|
| | | this.sidebar.opened = false
|
| | | this.sidebar.withoutAnimation = withoutAnimation
|
| | | },
|
| | | toggleDevice(device) {
|
| | | this.device = device
|
| | | },
|
| | | setSize(size) {
|
| | | this.size = size;
|
| | | Cookies.set('size', size)
|
| | | },
|
| | | toggleSideBarHide(status) {
|
| | | this.sidebar.hide = status
|
| | | }
|
| | | }
|
| | | state.sidebar.opened = !state.sidebar.opened
|
| | | state.sidebar.withoutAnimation = false
|
| | | if (state.sidebar.opened) {
|
| | | Cookies.set('sidebarStatus', 1)
|
| | | } else {
|
| | | Cookies.set('sidebarStatus', 0)
|
| | | }
|
| | | },
|
| | | CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
| | | Cookies.set('sidebarStatus', 0)
|
| | | state.sidebar.opened = false
|
| | | state.sidebar.withoutAnimation = withoutAnimation
|
| | | },
|
| | | TOGGLE_DEVICE: (state, device) => {
|
| | | state.device = device
|
| | | },
|
| | | SET_SIZE: (state, size) => {
|
| | | state.size = size
|
| | | Cookies.set('size', size)
|
| | | },
|
| | | SET_SIDEBAR_HIDE: (state, status) => {
|
| | | state.sidebar.hide = status
|
| | | }
|
| | | }
|
| | | })
|
| | |
|
| | | const actions = {
|
| | | toggleSideBar({ commit }) {
|
| | | commit('TOGGLE_SIDEBAR')
|
| | | },
|
| | | closeSideBar({ commit }, { withoutAnimation }) {
|
| | | commit('CLOSE_SIDEBAR', withoutAnimation)
|
| | | },
|
| | | toggleDevice({ commit }, device) {
|
| | | commit('TOGGLE_DEVICE', device)
|
| | | },
|
| | | setSize({ commit }, size) {
|
| | | commit('SET_SIZE', size)
|
| | | },
|
| | | toggleSideBarHide({ commit }, status) {
|
| | | commit('SET_SIDEBAR_HIDE', status)
|
| | | }
|
| | | }
|
| | |
|
| | | export default {
|
| | | namespaced: true,
|
| | | state,
|
| | | mutations,
|
| | | actions
|
| | | }
|
| | | export default useAppStore
|
| | |
| | | // å¹é
viewsé颿æç.vueæä»¶
|
| | | const modules = import.meta.glob('./../../views/**/*.vue')
|
| | |
|
| | | const permission = {
|
| | | state: {
|
| | | routes: [],
|
| | | addRoutes: [],
|
| | | defaultRoutes: [],
|
| | | topbarRouters: [],
|
| | | sidebarRouters: []
|
| | | },
|
| | | mutations: {
|
| | | SET_ROUTES: (state, routes) => {
|
| | | state.addRoutes = routes
|
| | | state.routes = constantRoutes.concat(routes)
|
| | | },
|
| | | SET_DEFAULT_ROUTES: (state, routes) => {
|
| | | state.defaultRoutes = constantRoutes.concat(routes)
|
| | | },
|
| | | SET_TOPBAR_ROUTES: (state, routes) => {
|
| | | state.topbarRouters = routes
|
| | | },
|
| | | SET_SIDEBAR_ROUTERS: (state, routes) => {
|
| | | state.sidebarRouters = routes
|
| | | },
|
| | | },
|
| | | actions: {
|
| | | // çæè·¯ç±
|
| | | GenerateRoutes({ commit }) {
|
| | | return new Promise(resolve => {
|
| | | // åå端请æ±è·¯ç±æ°æ®
|
| | | getRouters().then(res => {
|
| | | const sdata = JSON.parse(JSON.stringify(res.data))
|
| | | const rdata = JSON.parse(JSON.stringify(res.data))
|
| | | const defaultData = JSON.parse(JSON.stringify(res.data))
|
| | | const sidebarRoutes = filterAsyncRouter(sdata)
|
| | | const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
| | | const defaultRoutes = filterAsyncRouter(defaultData)
|
| | | commit('SET_ROUTES', rewriteRoutes)
|
| | | commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes))
|
| | | commit('SET_DEFAULT_ROUTES', sidebarRoutes)
|
| | | commit('SET_TOPBAR_ROUTES', defaultRoutes)
|
| | | resolve(rewriteRoutes)
|
| | | const usePermissionStore = defineStore(
|
| | | 'permission',
|
| | | {
|
| | | state: () => ({
|
| | | routes: [],
|
| | | addRoutes: [],
|
| | | defaultRoutes: [],
|
| | | topbarRouters: [],
|
| | | sidebarRouters: []
|
| | | }),
|
| | | actions: {
|
| | | setRoutes(routes) {
|
| | | this.addRoutes = routes
|
| | | this.routes = constantRoutes.concat(routes)
|
| | | },
|
| | | setDefaultRoutes(routes) {
|
| | | this.defaultRoutes = constantRoutes.concat(routes)
|
| | | },
|
| | | setTopbarRoutes(routes) {
|
| | | this.topbarRouters = routes
|
| | | },
|
| | | setSidebarRouters(routes) {
|
| | | this.sidebarRouters = routes
|
| | | },
|
| | | generateRoutes(roles) {
|
| | | return new Promise(resolve => {
|
| | | // åå端请æ±è·¯ç±æ°æ®
|
| | | getRouters().then(res => {
|
| | | const sdata = JSON.parse(JSON.stringify(res.data))
|
| | | const rdata = JSON.parse(JSON.stringify(res.data))
|
| | | const defaultData = JSON.parse(JSON.stringify(res.data))
|
| | | const sidebarRoutes = filterAsyncRouter(sdata)
|
| | | const rewriteRoutes = filterAsyncRouter(rdata, false, true)
|
| | | const defaultRoutes = filterAsyncRouter(defaultData)
|
| | | this.setRoutes(rewriteRoutes)
|
| | | this.setSidebarRouters(constantRoutes.concat(sidebarRoutes))
|
| | | this.setDefaultRoutes(sidebarRoutes)
|
| | | this.setTopbarRoutes(defaultRoutes)
|
| | | resolve(rewriteRoutes)
|
| | | })
|
| | | })
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | })
|
| | |
|
| | | // éååå°ä¼ æ¥çè·¯ç±å符串ï¼è½¬æ¢ä¸ºç»ä»¶å¯¹è±¡
|
| | | function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
|
| | |
| | | return res;
|
| | | }
|
| | |
|
| | | export default permission
|
| | | export default usePermissionStore
|
| | |
| | | const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo, dynamicTitle } = defaultSettings
|
| | |
|
| | | const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
|
| | | const state = {
|
| | | title: '',
|
| | | theme: storageSetting.theme || '#409EFF',
|
| | | sideTheme: storageSetting.sideTheme || sideTheme,
|
| | | showSettings: showSettings,
|
| | | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,
|
| | | tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
| | | fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
| | | sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
| | | dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
|
| | | }
|
| | | const mutations = {
|
| | | CHANGE_SETTING: (state, { key, value }) => {
|
| | | if (state.hasOwnProperty(key)) {
|
| | | state[key] = value
|
| | |
|
| | | const useSettingsStore = defineStore(
|
| | | 'settings',
|
| | | {
|
| | | state: () => ({
|
| | | title: '',
|
| | | theme: storageSetting.theme || '#409EFF',
|
| | | sideTheme: storageSetting.sideTheme || sideTheme,
|
| | | showSettings: showSettings,
|
| | | topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav,
|
| | | tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView,
|
| | | fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader,
|
| | | sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo,
|
| | | dynamicTitle: storageSetting.dynamicTitle === undefined ? dynamicTitle : storageSetting.dynamicTitle
|
| | | }),
|
| | | actions: {
|
| | | // ä¿®æ¹å¸å±è®¾ç½®
|
| | | changeSetting(data) {
|
| | | const { key, value } = data
|
| | | if (this.hasOwnProperty(key)) {
|
| | | this[key] = value
|
| | | }
|
| | | },
|
| | | // 设置ç½é¡µæ é¢
|
| | | setTitle(title) {
|
| | | this.title = title
|
| | | useDynamicTitle();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | })
|
| | |
|
| | | const actions = {
|
| | | // ä¿®æ¹å¸å±è®¾ç½®
|
| | | changeSetting({ commit }, data) {
|
| | | commit('CHANGE_SETTING', data)
|
| | | },
|
| | | // 设置ç½é¡µæ é¢
|
| | | setTitle({ commit }, title) {
|
| | | state.title = title
|
| | | useDynamicTitle();
|
| | | }
|
| | | }
|
| | |
|
| | | export default {
|
| | | namespaced: true,
|
| | | state,
|
| | | mutations,
|
| | | actions
|
| | | }
|
| | |
|
| | | export default useSettingsStore
|
| | |
| | | const state = {
|
| | | visitedViews: [],
|
| | | cachedViews: []
|
| | | }
|
| | |
|
| | | const mutations = {
|
| | | ADD_VISITED_VIEW: (state, view) => {
|
| | | if (state.visitedViews.some(v => v.path === view.path)) return
|
| | | state.visitedViews.push(
|
| | | Object.assign({}, view, {
|
| | | title: view.meta.title || 'no-name'
|
| | | })
|
| | | )
|
| | | },
|
| | | ADD_CACHED_VIEW: (state, view) => {
|
| | | if (state.cachedViews.includes(view.name)) return
|
| | | if (!view.meta.noCache) {
|
| | | state.cachedViews.push(view.name)
|
| | | }
|
| | | },
|
| | |
|
| | | DEL_VISITED_VIEW: (state, view) => {
|
| | | for (const [i, v] of state.visitedViews.entries()) {
|
| | | if (v.path === view.path) {
|
| | | state.visitedViews.splice(i, 1)
|
| | | break
|
| | | const useTagsViewStore = defineStore(
|
| | | 'tags-view',
|
| | | {
|
| | | state: () => ({
|
| | | visitedViews: [],
|
| | | cachedViews: []
|
| | | }),
|
| | | actions: {
|
| | | addView(view) {
|
| | | this.addVisitedView(view)
|
| | | this.addCachedView(view)
|
| | | },
|
| | | addVisitedView(view) {
|
| | | if (this.visitedViews.some(v => v.path === view.path)) return
|
| | | this.visitedViews.push(
|
| | | Object.assign({}, view, {
|
| | | title: view.meta.title || 'no-name'
|
| | | })
|
| | | )
|
| | | },
|
| | | addCachedView(view) {
|
| | | if (this.cachedViews.includes(view.name)) return
|
| | | if (!view.meta.noCache) {
|
| | | this.cachedViews.push(view.name)
|
| | | }
|
| | | },
|
| | | delView(view) {
|
| | | return new Promise(resolve => {
|
| | | this.delVisitedView(view)
|
| | | this.delCachedView(view)
|
| | | resolve({
|
| | | visitedViews: [...this.visitedViews],
|
| | | cachedViews: [...this.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delVisitedView(view) {
|
| | | return new Promise(resolve => {
|
| | | for (const [i, v] of this.visitedViews.entries()) {
|
| | | if (v.path === view.path) {
|
| | | this.visitedViews.splice(i, 1)
|
| | | break
|
| | | }
|
| | | }
|
| | | resolve([...this.visitedViews])
|
| | | })
|
| | | },
|
| | | delCachedView(view) {
|
| | | return new Promise(resolve => {
|
| | | const index = this.cachedViews.indexOf(view.name)
|
| | | index > -1 && this.cachedViews.splice(index, 1)
|
| | | resolve([...this.cachedViews])
|
| | | })
|
| | | },
|
| | | delOthersViews(view) {
|
| | | return new Promise(resolve => {
|
| | | this.delOthersVisitedViews(view)
|
| | | this.delOthersCachedViews(view)
|
| | | resolve({
|
| | | visitedViews: [...this.visitedViews],
|
| | | cachedViews: [...this.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delOthersVisitedViews(view) {
|
| | | return new Promise(resolve => {
|
| | | this.visitedViews = this.visitedViews.filter(v => {
|
| | | return v.meta.affix || v.path === view.path
|
| | | })
|
| | | resolve([...this.visitedViews])
|
| | | })
|
| | | },
|
| | | delOthersCachedViews(view) {
|
| | | return new Promise(resolve => {
|
| | | const index = this.cachedViews.indexOf(view.name)
|
| | | if (index > -1) {
|
| | | this.cachedViews = this.cachedViews.slice(index, index + 1)
|
| | | } else {
|
| | | this.cachedViews = []
|
| | | }
|
| | | resolve([...this.cachedViews])
|
| | | })
|
| | | },
|
| | | delAllViews(view) {
|
| | | return new Promise(resolve => {
|
| | | this.delAllVisitedViews(view)
|
| | | this.delAllCachedViews(view)
|
| | | resolve({
|
| | | visitedViews: [...this.visitedViews],
|
| | | cachedViews: [...this.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delAllVisitedViews(view) {
|
| | | return new Promise(resolve => {
|
| | | const affixTags = this.visitedViews.filter(tag => tag.meta.affix)
|
| | | this.visitedViews = affixTags
|
| | | resolve([...this.visitedViews])
|
| | | })
|
| | | },
|
| | | delAllCachedViews(view) {
|
| | | return new Promise(resolve => {
|
| | | this.cachedViews = []
|
| | | resolve([...this.cachedViews])
|
| | | })
|
| | | },
|
| | | updateVisitedView(view) {
|
| | | for (let v of this.visitedViews) {
|
| | | if (v.path === view.path) {
|
| | | v = Object.assign(v, view)
|
| | | break
|
| | | }
|
| | | }
|
| | | },
|
| | | delRightTags(view) {
|
| | | return new Promise(resolve => {
|
| | | const index = this.visitedViews.findIndex(v => v.path === view.path)
|
| | | if (index === -1) {
|
| | | return
|
| | | }
|
| | | this.visitedViews = this.visitedViews.filter((item, idx) => {
|
| | | if (idx <= index || (item.meta && item.meta.affix)) {
|
| | | return true
|
| | | }
|
| | | const i = this.cachedViews.indexOf(item.name)
|
| | | if (i > -1) {
|
| | | this.cachedViews.splice(i, 1)
|
| | | }
|
| | | return false
|
| | | })
|
| | | resolve([...this.visitedViews])
|
| | | })
|
| | | },
|
| | | delLeftTags(view) {
|
| | | const index = this.visitedViews.findIndex(v => v.path === view.path)
|
| | | if (index === -1) {
|
| | | return
|
| | | }
|
| | | this.visitedViews = this.visitedViews.filter((item, idx) => {
|
| | | if (idx >= index || (item.meta && item.meta.affix)) {
|
| | | return true
|
| | | }
|
| | | const i = this.cachedViews.indexOf(item.name)
|
| | | if (i > -1) {
|
| | | this.cachedViews.splice(i, 1)
|
| | | }
|
| | | return false
|
| | | })
|
| | | }
|
| | | }
|
| | | },
|
| | | DEL_CACHED_VIEW: (state, view) => {
|
| | | const index = state.cachedViews.indexOf(view.name)
|
| | | index > -1 && state.cachedViews.splice(index, 1)
|
| | | },
|
| | | })
|
| | |
|
| | | DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
| | | state.visitedViews = state.visitedViews.filter(v => {
|
| | | return v.meta.affix || v.path === view.path
|
| | | })
|
| | | },
|
| | | DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
| | | const index = state.cachedViews.indexOf(view.name)
|
| | | if (index > -1) {
|
| | | state.cachedViews = state.cachedViews.slice(index, index + 1)
|
| | | } else {
|
| | | state.cachedViews = []
|
| | | }
|
| | | },
|
| | |
|
| | | DEL_ALL_VISITED_VIEWS: state => {
|
| | | // keep affix tags
|
| | | const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
|
| | | state.visitedViews = affixTags
|
| | | },
|
| | | DEL_ALL_CACHED_VIEWS: state => {
|
| | | state.cachedViews = []
|
| | | },
|
| | |
|
| | | UPDATE_VISITED_VIEW: (state, view) => {
|
| | | for (let v of state.visitedViews) {
|
| | | if (v.path === view.path) {
|
| | | v = Object.assign(v, view)
|
| | | break
|
| | | }
|
| | | }
|
| | | },
|
| | | |
| | | DEL_RIGHT_VIEWS: (state, view) => {
|
| | | const index = state.visitedViews.findIndex(v => v.path === view.path)
|
| | | if (index === -1) {
|
| | | return
|
| | | }
|
| | | state.visitedViews = state.visitedViews.filter((item, idx) => {
|
| | | if (idx <= index || (item.meta && item.meta.affix)) {
|
| | | return true
|
| | | }
|
| | | const i = state.cachedViews.indexOf(item.name)
|
| | | if (i > -1) {
|
| | | state.cachedViews.splice(i, 1)
|
| | | }
|
| | | return false
|
| | | })
|
| | | },
|
| | |
|
| | | DEL_LEFT_VIEWS: (state, view) => {
|
| | | const index = state.visitedViews.findIndex(v => v.path === view.path)
|
| | | if (index === -1) {
|
| | | return
|
| | | }
|
| | | state.visitedViews = state.visitedViews.filter((item, idx) => {
|
| | | if (idx >= index || (item.meta && item.meta.affix)) {
|
| | | return true
|
| | | }
|
| | | const i = state.cachedViews.indexOf(item.name)
|
| | | if (i > -1) {
|
| | | state.cachedViews.splice(i, 1)
|
| | | }
|
| | | return false
|
| | | })
|
| | | }
|
| | | }
|
| | |
|
| | | const actions = {
|
| | | addView({ dispatch }, view) {
|
| | | dispatch('addVisitedView', view)
|
| | | dispatch('addCachedView', view)
|
| | | },
|
| | | addVisitedView({ commit }, view) {
|
| | | commit('ADD_VISITED_VIEW', view)
|
| | | },
|
| | | addCachedView({ commit }, view) {
|
| | | commit('ADD_CACHED_VIEW', view)
|
| | | },
|
| | |
|
| | | delView({ dispatch, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | dispatch('delVisitedView', view)
|
| | | dispatch('delCachedView', view)
|
| | | resolve({
|
| | | visitedViews: [...state.visitedViews],
|
| | | cachedViews: [...state.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delVisitedView({ commit, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_VISITED_VIEW', view)
|
| | | resolve([...state.visitedViews])
|
| | | })
|
| | | },
|
| | | delCachedView({ commit, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_CACHED_VIEW', view)
|
| | | resolve([...state.cachedViews])
|
| | | })
|
| | | },
|
| | |
|
| | | delOthersViews({ dispatch, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | dispatch('delOthersVisitedViews', view)
|
| | | dispatch('delOthersCachedViews', view)
|
| | | resolve({
|
| | | visitedViews: [...state.visitedViews],
|
| | | cachedViews: [...state.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delOthersVisitedViews({ commit, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_OTHERS_VISITED_VIEWS', view)
|
| | | resolve([...state.visitedViews])
|
| | | })
|
| | | },
|
| | | delOthersCachedViews({ commit, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_OTHERS_CACHED_VIEWS', view)
|
| | | resolve([...state.cachedViews])
|
| | | })
|
| | | },
|
| | |
|
| | | delAllViews({ dispatch, state }, view) {
|
| | | return new Promise(resolve => {
|
| | | dispatch('delAllVisitedViews', view)
|
| | | dispatch('delAllCachedViews', view)
|
| | | resolve({
|
| | | visitedViews: [...state.visitedViews],
|
| | | cachedViews: [...state.cachedViews]
|
| | | })
|
| | | })
|
| | | },
|
| | | delAllVisitedViews({ commit, state }) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_ALL_VISITED_VIEWS')
|
| | | resolve([...state.visitedViews])
|
| | | })
|
| | | },
|
| | | delAllCachedViews({ commit, state }) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_ALL_CACHED_VIEWS')
|
| | | resolve([...state.cachedViews])
|
| | | })
|
| | | },
|
| | |
|
| | | updateVisitedView({ commit }, view) {
|
| | | commit('UPDATE_VISITED_VIEW', view)
|
| | | },
|
| | |
|
| | | delRightTags({ commit }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_RIGHT_VIEWS', view)
|
| | | resolve([...state.visitedViews])
|
| | | })
|
| | | },
|
| | |
|
| | | delLeftTags({ commit }, view) {
|
| | | return new Promise(resolve => {
|
| | | commit('DEL_LEFT_VIEWS', view)
|
| | | resolve([...state.visitedViews])
|
| | | })
|
| | | },
|
| | | }
|
| | |
|
| | | export default {
|
| | | namespaced: true,
|
| | | state,
|
| | | mutations,
|
| | | actions
|
| | | }
|
| | | export default useTagsViewStore
|
| | |
| | | import { getToken, setToken, removeToken } from '@/utils/auth'
|
| | | import defAva from '@/assets/images/profile.jpg'
|
| | |
|
| | | const user = {
|
| | | state: {
|
| | | token: getToken(),
|
| | | name: '',
|
| | | avatar: '',
|
| | | roles: [],
|
| | | permissions: []
|
| | | },
|
| | | const useUserStore = defineStore(
|
| | | 'user',
|
| | | {
|
| | | state: () => ({
|
| | | token: getToken(),
|
| | | name: '',
|
| | | avatar: '',
|
| | | roles: [],
|
| | | permissions: []
|
| | | }),
|
| | | actions: {
|
| | | // ç»å½
|
| | | login(userInfo) {
|
| | | const username = userInfo.username.trim()
|
| | | const password = userInfo.password
|
| | | const code = userInfo.code
|
| | | const uuid = userInfo.uuid
|
| | | return new Promise((resolve, reject) => {
|
| | | login(username, password, code, uuid).then(res => {
|
| | | setToken(res.token)
|
| | | this.token = res.token
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | },
|
| | | // è·åç¨æ·ä¿¡æ¯
|
| | | getInfo() {
|
| | | return new Promise((resolve, reject) => {
|
| | | getInfo().then(res => {
|
| | | const user = res.user
|
| | | const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar;
|
| | |
|
| | | mutations: {
|
| | | SET_TOKEN: (state, token) => {
|
| | | state.token = token
|
| | | },
|
| | | SET_NAME: (state, name) => {
|
| | | state.name = name
|
| | | },
|
| | | SET_AVATAR: (state, avatar) => {
|
| | | state.avatar = avatar
|
| | | },
|
| | | SET_ROLES: (state, roles) => {
|
| | | state.roles = roles
|
| | | },
|
| | | SET_PERMISSIONS: (state, permissions) => {
|
| | | state.permissions = permissions
|
| | | if (res.roles && res.roles.length > 0) { // éªè¯è¿åçrolesæ¯å¦æ¯ä¸ä¸ªé空æ°ç»
|
| | | this.roles = res.roles
|
| | | this.permissions = res.permissions
|
| | | } else {
|
| | | this.setRoutes = ['ROLE_DEFAULT']
|
| | | }
|
| | | this.name = user.userName
|
| | | this.avatar = avatar;
|
| | | resolve(res)
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | },
|
| | | // éåºç³»ç»
|
| | | logOut() {
|
| | | return new Promise((resolve, reject) => {
|
| | | logout(this.token).then(() => {
|
| | | this.token = ''
|
| | | this.roles = []
|
| | | this.permissions = []
|
| | | removeToken()
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | }
|
| | | }
|
| | | },
|
| | | })
|
| | |
|
| | | actions: {
|
| | | // ç»å½
|
| | | Login({ commit }, userInfo) {
|
| | | const username = userInfo.username.trim()
|
| | | const password = userInfo.password
|
| | | const code = userInfo.code
|
| | | const uuid = userInfo.uuid
|
| | | return new Promise((resolve, reject) => {
|
| | | login(username, password, code, uuid).then(res => {
|
| | | setToken(res.token)
|
| | | commit('SET_TOKEN', res.token)
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | },
|
| | |
|
| | | // è·åç¨æ·ä¿¡æ¯
|
| | | GetInfo({ commit, state }) {
|
| | | return new Promise((resolve, reject) => {
|
| | | getInfo().then(res => {
|
| | | const user = res.user
|
| | | const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar;
|
| | |
|
| | | if (res.roles && res.roles.length > 0) { // éªè¯è¿åçrolesæ¯å¦æ¯ä¸ä¸ªé空æ°ç»
|
| | | commit('SET_ROLES', res.roles)
|
| | | commit('SET_PERMISSIONS', res.permissions)
|
| | | } else {
|
| | | commit('SET_ROLES', ['ROLE_DEFAULT'])
|
| | | }
|
| | | commit('SET_NAME', user.userName)
|
| | | commit('SET_AVATAR', avatar)
|
| | | resolve(res)
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | },
|
| | |
|
| | | // éåºç³»ç»
|
| | | LogOut({ commit, state }) {
|
| | | return new Promise((resolve, reject) => {
|
| | | logout(state.token).then(() => {
|
| | | commit('SET_TOKEN', '')
|
| | | commit('SET_ROLES', [])
|
| | | commit('SET_PERMISSIONS', [])
|
| | | removeToken()
|
| | | resolve()
|
| | | }).catch(error => {
|
| | | reject(error)
|
| | | })
|
| | | })
|
| | | },
|
| | |
|
| | | // å端 ç»åº
|
| | | FedLogOut({ commit }) {
|
| | | return new Promise(resolve => {
|
| | | commit('SET_TOKEN', '')
|
| | | removeToken()
|
| | | resolve()
|
| | | })
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | export default user
|
| | | export default useUserStore
|
| | |
| | | import store from '@/store'
|
| | | import defaultSettings from '@/settings'
|
| | | import useSettingsStore from '@/store/modules/settings'
|
| | |
|
| | | /**
|
| | | * å¨æä¿®æ¹æ é¢
|
| | | */
|
| | | export function useDynamicTitle() {
|
| | | if (store.state.settings.dynamicTitle) {
|
| | | document.title = store.state.settings.title + ' - ' + defaultSettings.title;
|
| | | const settingsStore = useSettingsStore();
|
| | | if (settingsStore.dynamicTitle) {
|
| | | document.title = settingsStore.title + ' - ' + defaultSettings.title;
|
| | | } else {
|
| | | document.title = defaultSettings.title;
|
| | | }
|
| | |
| | | import store from '@/store'
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | /**
|
| | | * å符æéæ ¡éª
|
| | |
| | | */
|
| | | export function checkPermi(value) {
|
| | | if (value && value instanceof Array && value.length > 0) {
|
| | | const permissions = store.getters && store.getters.permissions
|
| | | const permissions = useUserStore().permissions
|
| | | const permissionDatas = value
|
| | | const all_permission = "*:*:*";
|
| | |
|
| | |
| | | */
|
| | | export function checkRole(value) {
|
| | | if (value && value instanceof Array && value.length > 0) {
|
| | | const roles = store.getters && store.getters.roles
|
| | | const roles = useUserStore().roles
|
| | | const permissionRoles = value
|
| | | const super_admin = "admin";
|
| | |
|
| | |
| | | import axios from 'axios'
|
| | | import { ElNotification , ElMessageBox, ElMessage, ElLoading } from 'element-plus'
|
| | | import store from '@/store'
|
| | | import { getToken } from '@/utils/auth'
|
| | | import errorCode from '@/utils/errorCode'
|
| | | import { tansParams, blobValidate } from '@/utils/ruoyi'
|
| | | import cache from '@/plugins/cache'
|
| | | import { saveAs } from 'file-saver'
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | let downloadLoadingInstance;
|
| | | // æ¯å¦æ¾ç¤ºéæ°ç»å½
|
| | |
| | | }
|
| | | ).then(() => {
|
| | | isRelogin.show = false;
|
| | | store.dispatch('LogOut').then(() => {
|
| | | useUserStore().logOut().then(() => {
|
| | | location.href = '/index';
|
| | | })
|
| | | }).catch(() => {
|
| | |
| | | import { getCodeImg } from "@/api/login";
|
| | | import Cookies from "js-cookie";
|
| | | import { encrypt, decrypt } from "@/utils/jsencrypt";
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | const store = useStore();
|
| | | const userStore = useUserStore()
|
| | | const router = useRouter();
|
| | | const { proxy } = getCurrentInstance();
|
| | |
|
| | |
| | | Cookies.remove("rememberMe");
|
| | | }
|
| | | // è°ç¨actionçç»å½æ¹æ³
|
| | | store.dispatch("Login", loginForm.value).then(() => {
|
| | | userStore.login(loginForm.value).then(() => {
|
| | | router.push({ path: redirect.value || "/" });
|
| | | }).catch(() => {
|
| | | loading.value = false;
|
| | |
| | | import "vue-cropper/dist/index.css";
|
| | | import { VueCropper } from "vue-cropper";
|
| | | import { uploadAvatar } from "@/api/system/user";
|
| | | import useUserStore from '@/store/modules/user'
|
| | |
|
| | | const store = useStore();
|
| | | const userStore = useUserStore()
|
| | | const { proxy } = getCurrentInstance();
|
| | |
|
| | | const open = ref(false);
|
| | |
| | |
|
| | | //å¾çè£åªæ°æ®
|
| | | const options = reactive({
|
| | | img: store.getters.avatar, // è£åªå¾ççå°å
|
| | | img: userStore.avatar, // è£åªå¾ççå°å
|
| | | autoCrop: true, // æ¯å¦é»è®¤çææªå¾æ¡
|
| | | autoCropWidth: 200, // é»è®¤çææªå¾æ¡å®½åº¦
|
| | | autoCropHeight: 200, // é»è®¤çææªå¾æ¡é«åº¦
|
| | |
| | | uploadAvatar(formData).then(response => {
|
| | | open.value = false;
|
| | | options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
| | | store.commit("SET_AVATAR", options.img);
|
| | | userStore.avatar = options.img;
|
| | | proxy.$modal.msgSuccess("ä¿®æ¹æå");
|
| | | visible.value = false;
|
| | | });
|
| | |
| | | };
|
| | | /** å
³éçªå£ */
|
| | | function closeDialog() {
|
| | | options.img = store.getters.avatar;
|
| | | options.img = userStore.avatar;
|
| | | options.visible = false;
|
| | | };
|
| | | </script>
|
| | |
| | | imports: [
|
| | | 'vue',
|
| | | 'vue-router',
|
| | | {
|
| | | 'vuex': ['useStore']
|
| | | }
|
| | | 'pinia'
|
| | | ],
|
| | | dts: false
|
| | | })
|