diff --git a/admin/package.json b/admin/package.json index a6681cf96205fe5548d3f92063982f3bb6271da3..25c05ad8488ef934f071e8c31ebb5bf1fb2360ce 100644 --- a/admin/package.json +++ b/admin/package.json @@ -55,6 +55,7 @@ "vite": "^3.0.0", "vite-plugin-style-import": "^2.0.0", "vite-plugin-svg-icons": "^2.0.1", + "vite-plugin-vue-setup-extend": "^0.4.0", "vue-tsc": "^0.38.1" } } diff --git a/admin/src/components/editor/index.vue b/admin/src/components/editor/index.vue index c2f8920a515e54b6cb31961a08b84ea6767404cd..831bbcd3cc7d851687a8646ea39eb6db40dae355 100644 --- a/admin/src/components/editor/index.vue +++ b/admin/src/components/editor/index.vue @@ -39,7 +39,7 @@ const props = withDefaults( }>(), { modelValue: '', - mode: 'simple', + mode: 'default', height: '100%', width: 'auto', toolbarConfig: () => ({ @@ -100,3 +100,34 @@ const handleCreated = (editor: any) => { editorRef.value = editor // 记录 editor 实例,重要! } + + diff --git a/admin/src/components/material/file.vue b/admin/src/components/material/file.vue index 1006b2cfedca9bd0f3c555cb679c271d3be84c53..a9f05003347ab54397926ba69eaa2cc87704264f 100644 --- a/admin/src/components/material/file.vue +++ b/admin/src/components/material/file.vue @@ -1,8 +1,14 @@ - + diff --git a/admin/src/config/index.ts b/admin/src/config/index.ts index ba205a411944571c2792afa163bb90ed05c2fc6e..7995c377af5e2ea439a4eea7480006cb02a4f25e 100644 --- a/admin/src/config/index.ts +++ b/admin/src/config/index.ts @@ -1,10 +1,10 @@ const config = { - terminal: 1, - title: '后台管理系统', - version: '1.1.6', - baseUrl: `${import.meta.env.VITE_APP_BASE_URL}/`, - urlPrefix: 'api', - timeout: 20 * 1000 + terminal: 1, //终端 + title: '后台管理系统', //网站默认标题 + version: '1.2.0', //版本号 + baseUrl: `${import.meta.env.VITE_APP_BASE_URL}/`, //请求接口域名 + urlPrefix: 'api', //请求默认前缀 + timeout: 10 * 1000 //请求超时时长 } export default config diff --git a/admin/src/config/setting.ts b/admin/src/config/setting.ts index 37461da3ea3df44363df84ec94e583282ae5ba15..f11a9372cbf4bff1c655f040a85db60cdd255695 100644 --- a/admin/src/config/setting.ts +++ b/admin/src/config/setting.ts @@ -1,13 +1,15 @@ const defaultSetting = { - sideWidth: 200, - sideTheme: 'light', - sideDarkColor: '#1d2124', - theme: '#4A5DFF', - openMultipleTabs: true, - successTheme: '#67c23a', - warningTheme: '#e6a23c', - dangerTheme: '#f56c6c', - errorTheme: '#f56c6c', - infoTheme: '#909399' + sideWidth: 200, //侧边栏宽度 + sideTheme: 'light', //侧边栏主题 + sideDarkColor: '#1d2124', //侧边栏深色主题颜色 + openMultipleTabs: true, // 是否开启多标签tab栏 + theme: '#4A5DFF', //主题色 + successTheme: '#67c23a', //成功主题色 + warningTheme: '#e6a23c', //警告主题色 + dangerTheme: '#f56c6c', //危险主题色 + errorTheme: '#f56c6c', //错误主题色 + infoTheme: '#909399' //信息主题色 } +//以上各种主题色分别对应element-plus的几种行为主题 + export default defaultSetting diff --git a/admin/src/hooks/useMultipleTabs.ts b/admin/src/hooks/useMultipleTabs.ts new file mode 100644 index 0000000000000000000000000000000000000000..02e1e43558c8f7d6dcecbef0d4cb83851e3bdac6 --- /dev/null +++ b/admin/src/hooks/useMultipleTabs.ts @@ -0,0 +1,47 @@ +import useTabsStore from '@/stores/modules/multipleTabs' +import useSettingStore from '@/stores/modules/setting' + +export default function useMultipleTabs() { + const router = useRouter() + const route = useRoute() + const tabsStore = useTabsStore() + const settingStore = useSettingStore() + + const tabsLists = computed(() => { + return tabsStore.getTabList + }) + + const currentTab = computed(() => { + return route.fullPath + }) + + const addTab = () => { + if (!settingStore.openMultipleTabs) return + tabsStore.addTab(router) + } + + const removeTab = (fullPath?: any) => { + if (!settingStore.openMultipleTabs) return + fullPath = fullPath ?? route.fullPath + tabsStore.removeTab(fullPath, router) + } + + const removeOtherTab = () => { + if (!settingStore.openMultipleTabs) return + tabsStore.removeOtherTab(route) + } + + const removeAllTab = () => { + if (!settingStore.openMultipleTabs) return + tabsStore.removeAllTab(router) + } + + return { + tabsLists, + currentTab, + addTab, + removeTab, + removeOtherTab, + removeAllTab + } +} diff --git a/admin/src/layout/default/components/header/multiple-tabs.vue b/admin/src/layout/default/components/header/multiple-tabs.vue index 2b6fb41b37cae961516f2ee36f01d6cf6b23cadd..16a5d48f7a6aba87ac8403b4c9ae22d5894584b0 100644 --- a/admin/src/layout/default/components/header/multiple-tabs.vue +++ b/admin/src/layout/default/components/header/multiple-tabs.vue @@ -3,12 +3,12 @@
- diff --git a/admin/src/layout/default/components/setting/drawer.vue b/admin/src/layout/default/components/setting/drawer.vue index 19bcc60ccb7fa52f8eda3ad664319e2089d54d0a..020f61598da317488efa4b3d9b302a58cd8b93ef 100644 --- a/admin/src/layout/default/components/setting/drawer.vue +++ b/admin/src/layout/default/components/setting/drawer.vue @@ -65,7 +65,6 @@ import theme_light from '@/assets/images/theme_white.png' import theme_dark from '@/assets/images/theme_black.png' const settingStore = useSettingStore() - const predefineColors = ref(['#409EFF', '#28C76F', '#EA5455', '#FF9F43', '#01CFE8', '#4A5DFF']) const sideThemeList = [ { diff --git a/admin/src/permission.ts b/admin/src/permission.ts index 346a911f328534d0923ebbe44d94467927228997..7b3f5dbdc10b8dd974bfc0494d5916d4c231dca9 100644 --- a/admin/src/permission.ts +++ b/admin/src/permission.ts @@ -11,6 +11,7 @@ import { INDEX_ROUTE, INDEX_ROUTE_NAME } from './router/routes' import { PageEnum } from './enums/pageEnum' import useTabsStore from './stores/modules/multipleTabs' import { clearAuthInfo } from './utils/auth' +import config from './config' // NProgress配置 NProgress.configure({ showSpinner: false }) @@ -22,6 +23,7 @@ const whiteList: string[] = [PageEnum.LOGIN, PageEnum.ERROR_403] router.beforeEach(async (to, from, next) => { // 开始 Progress Bar NProgress.start() + document.title = to.meta.title ?? config.title const userStore = useUserStore() const tabsStore = useTabsStore() if (userStore.token) { diff --git a/admin/src/router/index.ts b/admin/src/router/index.ts index 283e0f8ba7aaccee32c1c7ea1f175d4ef65aca10..91b6f8807d411253985e2d2f7e44a22f20afc9a8 100644 --- a/admin/src/router/index.ts +++ b/admin/src/router/index.ts @@ -86,8 +86,8 @@ export function findFirstValidRoute(routes: RouteRecordRaw[]): string | undefine } //通过权限字符查询路由路径 export function getRoutePath(perms: string) { - const router = useRouter() - return router.getRoutes().find((item) => item.meta?.perms == perms)?.path || '' + const routerObj = useRouter() || router + return routerObj.getRoutes().find((item) => item.meta?.perms == perms)?.path || '' } // 重置路由 diff --git a/admin/src/stores/modules/multipleTabs.ts b/admin/src/stores/modules/multipleTabs.ts index d063546aa9875a2572e2943936c93b117fdfa836..b14e36649d384d46055a976548a95f1533327b9b 100644 --- a/admin/src/stores/modules/multipleTabs.ts +++ b/admin/src/stores/modules/multipleTabs.ts @@ -11,6 +11,7 @@ import { PageEnum } from '@/enums/pageEnum' interface TabItem { name: RouteRecordName + fullPath: string path: string title?: string query?: LocationQuery @@ -24,8 +25,8 @@ interface TabsSate { indexRouteName: RouteRecordName } -const getHasTabIndex = (path: string, tabList: TabItem[]) => { - return tabList.findIndex((item) => item.path == path) +const getHasTabIndex = (fullPath: string, tabList: TabItem[]) => { + return tabList.findIndex((item) => item.fullPath == fullPath) } const isCannotAddRoute = (route: RouteLocationNormalized, router: Router) => { @@ -39,8 +40,12 @@ const isCannotAddRoute = (route: RouteLocationNormalized, router: Router) => { return false } -const findTabsIndex = (path: string, tabList: TabItem[]) => { - return tabList.findIndex((item) => item.path === path) +const findTabsIndex = (fullPath: string, tabList: TabItem[]) => { + return tabList.findIndex((item) => item.fullPath === fullPath) +} + +const getComponentName = (route: RouteLocationNormalized) => { + return route.matched.at(-1)?.components?.default?.name } export const getRouteParams = (tabItem: TabItem) => { @@ -63,45 +68,67 @@ const useTabsStore = defineStore({ getters: { getTabList(): TabItem[] { return this.tabList + }, + getCacheTabList(): string[] { + return Array.from(this.cacheTabList) } }, actions: { setRouteName(name: RouteRecordName) { this.indexRouteName = name }, + addCache(componentName?: string) { + if (componentName) this.cacheTabList.add(componentName) + }, + removeCache(componentName?: string) { + if (componentName && this.cacheTabList.has(componentName)) { + this.cacheTabList.delete(componentName) + } + console.log(this.cacheTabList) + }, + clearCache() { + this.cacheTabList.clear() + }, resetState() { this.cacheTabList = new Set() this.tabList = [] this.tasMap = {} this.indexRouteName = '' }, - addTab(route: RouteLocationNormalized, router: Router) { - const { name, path, query, meta, params } = route + addTab(router: Router) { + const route = unref(router.currentRoute) + const { name, query, meta, params, fullPath, path } = route if (isCannotAddRoute(route, router)) return - const hasTabIndex = getHasTabIndex(path!, this.tabList) - + const hasTabIndex = getHasTabIndex(fullPath!, this.tabList) + const componentName = getComponentName(route) const tabItem = { name: name!, path, + fullPath, title: meta?.title, query, params } - this.tasMap[path] = tabItem + this.tasMap[fullPath] = tabItem + if (meta?.keepAlive) { + this.addCache(componentName) + } if (hasTabIndex != -1) { - this.tabList.splice(hasTabIndex, 1, tabItem) return } + this.tabList.push(tabItem) }, - removeTab(path: string, router: Router) { + removeTab(fullPath: string, router: Router) { const { currentRoute, push } = router - const index = findTabsIndex(path, this.tabList) + const index = findTabsIndex(fullPath, this.tabList) // 移除tab if (this.tabList.length > 1) { index !== -1 && this.tabList.splice(index, 1) } - if (path !== currentRoute.value.path) { + const componentName = getComponentName(currentRoute.value) + this.removeCache(componentName) + if (fullPath !== currentRoute.value.fullPath) { return } // 删除选中的tab @@ -116,17 +143,24 @@ const useTabsStore = defineStore({ const toRoute = getRouteParams(toTab) push(toRoute) }, - removeOtherTab(path: string) { - this.tabList = this.tabList.filter((item) => item.path == path) + removeOtherTab(route: RouteLocationNormalized) { + this.tabList = this.tabList.filter((item) => item.fullPath == route.fullPath) + const componentName = getComponentName(route) + this.cacheTabList.forEach((name) => { + if (componentName !== name) { + this.removeCache(name) + } + }) }, removeAllTab(router: Router) { const { push, currentRoute } = router - const { path, name } = unref(currentRoute) + const { name } = unref(currentRoute) if (name == this.indexRouteName) { - this.removeOtherTab(path) + this.removeOtherTab(currentRoute.value) return } this.tabList = [] + this.clearCache() push(PageEnum.INDEX) } } diff --git a/admin/src/stores/modules/user.ts b/admin/src/stores/modules/user.ts index f84da3f62d2c9f2ae0c0906866e2ca933535e56c..8ac6a42afca6480b67fc232063db6407d1459186 100644 --- a/admin/src/stores/modules/user.ts +++ b/admin/src/stores/modules/user.ts @@ -28,12 +28,6 @@ const useUserStore = defineStore({ }), getters: {}, actions: { - resetState() { - this.token = '' - this.userInfo = {} - this.perms = [] - this.menu = [] - }, login(playload: any) { const { account, password } = playload return new Promise((resolve, reject) => { @@ -54,8 +48,9 @@ const useUserStore = defineStore({ logout() { return new Promise((resolve, reject) => { logout() - .then((data) => { - router.push(PageEnum.LOGIN) + .then(async (data) => { + this.token = '' + await router.push(PageEnum.LOGIN) clearAuthInfo() resolve(data) }) diff --git a/admin/src/styles/element.scss b/admin/src/styles/element.scss index 48c2c86d31801a7e63af5b43c0e8d976c1d6598b..2ff0e634de0ddb5e58fb89e3cfb714335414ae34 100644 --- a/admin/src/styles/element.scss +++ b/admin/src/styles/element.scss @@ -115,6 +115,9 @@ .el-image__error { font-size: 12px; } + .el-tabs__nav-wrap::after { + height: 1px; + } } @media (max-width: 768px) { .el-pagination > .el-pagination__jump { diff --git a/admin/src/utils/auth.ts b/admin/src/utils/auth.ts index abc6f922dfc14535084958fe3644dee3a213dc1c..cbcc51940ee19ee0d13d8bbfd86307d35474c1f4 100644 --- a/admin/src/utils/auth.ts +++ b/admin/src/utils/auth.ts @@ -11,8 +11,8 @@ export function getToken() { export function clearAuthInfo() { const userStore = useUserStore() const tabsStore = useTabsStore() - userStore.resetState() - tabsStore.resetState() + userStore.$reset() + tabsStore.$reset() cache.remove(TOKEN_KEY) resetRouter() } diff --git a/admin/src/utils/request/axios.ts b/admin/src/utils/request/axios.ts index 2b6c1a03e3f6fc8427b21186f9c501a88821116e..cb07fd5ebeda028dff285c4a105a38c2640a1401 100644 --- a/admin/src/utils/request/axios.ts +++ b/admin/src/utils/request/axios.ts @@ -71,7 +71,7 @@ export class Axios { this.removeCancelToken(err.config?.url!) } - if (err.code == AxiosError.ECONNABORTED) { + if (err.code == AxiosError.ECONNABORTED || err.code == AxiosError.ERR_NETWORK) { setTimeout(() => { console.log(err) this.retryRequest(err) diff --git a/admin/src/views/account/login.vue b/admin/src/views/account/login.vue index da518e74efe9007d6ae1eee025822a275449631c..199831972dce4de5de51affd7ef151ec0028cbb5 100644 --- a/admin/src/views/account/login.vue +++ b/admin/src/views/account/login.vue @@ -6,7 +6,7 @@
- diff --git a/admin/src/views/channel/h5.vue b/admin/src/views/channel/h5.vue index 5c75fc3de995ddc4e14eba9dc940662f5b6d9679..c884fea234f60006327ee6233cfb2bae411af045 100644 --- a/admin/src/views/channel/h5.vue +++ b/admin/src/views/channel/h5.vue @@ -32,7 +32,7 @@ - diff --git a/admin/src/views/decoration/pages/index.vue b/admin/src/views/decoration/pages/index.vue index 20057e44b3123eb4f3fbac282a7cda18ae986a77..4de9db57c8703c089c2939593610f662607ac0fc 100644 --- a/admin/src/views/decoration/pages/index.vue +++ b/admin/src/views/decoration/pages/index.vue @@ -12,7 +12,7 @@ - diff --git a/admin/src/views/material/index.vue b/admin/src/views/material/index.vue index 975a338b3a6168af4adef02c0a73101408aa01c2..3d7f8d116555f69af80b26bf7b3d3e214d03cff7 100644 --- a/admin/src/views/material/index.vue +++ b/admin/src/views/material/index.vue @@ -23,7 +23,7 @@ - diff --git a/admin/src/views/message/short_letter/index.vue b/admin/src/views/message/short_letter/index.vue index 8d890365e1cc5093f197b16f1a83c7ca31ad96f3..027267013d814c4407b63e1f8734a167a15a3412 100644 --- a/admin/src/views/message/short_letter/index.vue +++ b/admin/src/views/message/short_letter/index.vue @@ -26,7 +26,7 @@ - - + @@ -85,7 +85,7 @@ - + @@ -106,7 +106,7 @@ - +
diff --git a/server/like-admin/src/main/java/com/mdd/admin/controller/common/UploadController.java b/server/like-admin/src/main/java/com/mdd/admin/controller/common/UploadController.java index a4444391ef0897daf4555d4710fcd62ca0d51a96..aaa9fee43685e20af7bff6741ad87e2e76a70113 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/controller/common/UploadController.java +++ b/server/like-admin/src/main/java/com/mdd/admin/controller/common/UploadController.java @@ -106,6 +106,7 @@ public class UploadController { album.put("ext", map.get("ext").toString()); album.put("size", map.get("size").toString()); album.put("url", map.get("url").toString()); + album.put("name", map.get("name").toString()); Integer id = iAlbumService.albumAdd(album); map.put("id", id); diff --git a/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java b/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java index 68a5d4c3a168e437275016d2660074da637904a5..0817bbd798c85b1deb467c68b54967ce8a2ce717 100644 --- a/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java +++ b/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java @@ -136,7 +136,7 @@ public class LoginServiceImpl implements ILoginService { UserAuth auth = new UserAuth(); auth.setUserId(model.getId()); auth.setOpenid(openId); - auth.setUnionid(unionId); + auth.setUnionid(unionId.equals("0") ? "" : unionId); auth.setClient(client); auth.setCreateTime(System.currentTimeMillis() / 1000); auth.setUpdateTime(System.currentTimeMillis() / 1000); diff --git a/server/like-front/src/main/java/com/mdd/front/service/impl/UserServiceImpl.java b/server/like-front/src/main/java/com/mdd/front/service/impl/UserServiceImpl.java index 5f3119d30ed31c49829deb16fbf2851d37276e7d..e747055f62cb9a9ae6b8c5c38ef6a49b592a2807 100644 --- a/server/like-front/src/main/java/com/mdd/front/service/impl/UserServiceImpl.java +++ b/server/like-front/src/main/java/com/mdd/front/service/impl/UserServiceImpl.java @@ -6,14 +6,11 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mdd.common.config.GlobalConfig; -import com.mdd.common.entity.server.Sys; -import com.mdd.common.entity.system.SystemConfig; import com.mdd.common.entity.user.User; import com.mdd.common.entity.user.UserAuth; import com.mdd.common.enums.ClientEnum; import com.mdd.common.enums.NoticeEnum; import com.mdd.common.exception.OperateException; -import com.mdd.common.mapper.system.SystemConfigMapper; import com.mdd.common.mapper.user.UserAuthMapper; import com.mdd.common.mapper.user.UserMapper; import com.mdd.common.utils.*; @@ -27,7 +24,6 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import javax.annotation.Resource; -import java.util.LinkedHashMap; import java.util.Map; /** diff --git a/server/like-front/src/main/resources/static/shop_logo.png b/server/like-front/src/main/resources/static/shop_logo.png index 2e358b1602a653b98ba4890c6f723e504a47942a..58f780014ec52b50696c9a5787aafe231c091f31 100644 Binary files a/server/like-front/src/main/resources/static/shop_logo.png and b/server/like-front/src/main/resources/static/shop_logo.png differ