diff --git a/index.html b/index.html index 654b3b6..16755a9 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - Vite + Vue3 + TS + 系统管理 diff --git a/src/App.vue b/src/App.vue index 741fbfd..6004ba4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,7 +15,16 @@ const userStore = useUserStore() const { language } = storeToRefs(userStore) - + function setCompanyFromUrl() { + const userStore = useUserStore() + const params = new URLSearchParams(window.location.search) + const companyid = params.get('corp_id') + const companyabbr = params.get('corp_abbr') + if (companyid) { + userStore.setCompany(companyid, companyabbr || '') + // 你也可以加 localStorage/sessionStorage 备份 + } + } const locales = { zh: zh, en: en @@ -23,6 +32,7 @@ onBeforeMount(() => { setThemeTransitionClass(true) + setCompanyFromUrl() useUserStore().restoreTokenTimer() }) diff --git a/src/api/menuApi.ts b/src/api/menuApi.ts index dc26481..811d1b6 100644 --- a/src/api/menuApi.ts +++ b/src/api/menuApi.ts @@ -11,15 +11,12 @@ export const menuService = { async getMenuList(delay = 300): Promise { try { const userStore = useUserStore() - // 验证用户登录状态 if (!userStore.isLogin) { throw new Error('用户未登录') } - // 模拟接口返回的菜单数据 const menuData = userStore.info.menu - // 验证菜单数据 if (!menuData || !Array.isArray(menuData) || menuData.length === 0) { ElMessage.error('暂无系统菜单权限') diff --git a/src/assets/img/login/bgx.png b/src/assets/img/login/bgx.png new file mode 100644 index 0000000..ae26215 Binary files /dev/null and b/src/assets/img/login/bgx.png differ diff --git a/src/components/core/layouts/art-header-bar/index.vue b/src/components/core/layouts/art-header-bar/index.vue index 0048ee9..2f0b3d2 100644 --- a/src/components/core/layouts/art-header-bar/index.vue +++ b/src/components/core/layouts/art-header-bar/index.vue @@ -100,7 +100,7 @@ -
+
@@ -145,8 +145,14 @@
- {{ userInfo.userName }} - + {{ userInfo.user.id }} + + + + {{ userInfo.user.phone }} +
    diff --git a/src/components/core/views/login/LoginLeftView.vue b/src/components/core/views/login/LoginLeftView.vue index 2312ab3..3f5fb2d 100644 --- a/src/components/core/views/login/LoginLeftView.vue +++ b/src/components/core/views/login/LoginLeftView.vue @@ -1,17 +1,16 @@ @@ -27,7 +26,7 @@ height: 100%; padding: 20px; overflow: hidden; - background: #f3f4fb; + // background: #f3f4fb; background-size: cover; .logo { diff --git a/src/config/index.ts b/src/config/index.ts index 045de05..82ce903 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -9,7 +9,7 @@ import { configImages } from './assets/images' const appConfig: SystemConfig = { // 系统信息 systemInfo: { - name: 'XYH系统管理' // 系统名称 + name: '总台系统服务' // 系统名称 }, // Element Plus 主题 elementPlusTheme: { diff --git a/src/locales/langs/en.json b/src/locales/langs/en.json index d024f8f..eddaba7 100644 --- a/src/locales/langs/en.json +++ b/src/locales/langs/en.json @@ -133,7 +133,8 @@ "placeholder": [ "Please enter your account", "Please enter your password", - "Please slide to verify" + "Please slide to verify", + "Please select a company" ], "sliderText": "Please slide to verify", "sliderSuccessText": "Verification successful", diff --git a/src/locales/langs/zh.json b/src/locales/langs/zh.json index dd51a4e..9a158b5 100644 --- a/src/locales/langs/zh.json +++ b/src/locales/langs/zh.json @@ -130,7 +130,7 @@ "admin": "管理员", "user": "普通用户" }, - "placeholder": ["请输入账号", "请输入密码", "请拖动滑块完成验证"], + "placeholder": ["请输入账号", "请输入密码", "请拖动滑块完成验证","请选择公司"], "sliderText": "按住滑块拖动", "sliderSuccessText": "验证成功", "rememberPwd": "记住密码", diff --git a/src/router/guards/beforeEach.ts b/src/router/guards/beforeEach.ts index 6621eb1..2e27d11 100644 --- a/src/router/guards/beforeEach.ts +++ b/src/router/guards/beforeEach.ts @@ -99,7 +99,10 @@ async function handleLoginStatus( ): Promise { if (!userStore.isLogin && to.path !== RoutesAlias.Login && !to.meta.noLogin) { userStore.logOut() - next(RoutesAlias.Login) + next({ + path: RoutesAlias.Login, + query: to.query // 保留原始参数 + }) return false } return true diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 1a7f160..a3b8024 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -87,7 +87,7 @@ export const useUserStore = defineStore( function scheduleTokenRefresh(expiresIn: number) { if (refreshTimeout) clearTimeout(refreshTimeout) // 提前1分钟刷新 - const refreshTime = (expiresIn - 60) * 1000 + const refreshTime = (expiresIn - 100) * 1000 if (refreshTime > 0) { refreshTimeout = setTimeout(refreshTokenAction, refreshTime) } @@ -103,6 +103,12 @@ export const useUserStore = defineStore( } const logOut = () => { + // 清空所有本地缓存 + localStorage.clear(); + sessionStorage.clear(); + + companyabbr.value = '' + companyid.value = '' info.value = {} isLogin.value = false isLock.value = false diff --git a/src/utils/http/index.ts b/src/utils/http/index.ts index 0de84a8..e32f9fe 100644 --- a/src/utils/http/index.ts +++ b/src/utils/http/index.ts @@ -87,7 +87,7 @@ axiosInstance.interceptors.response.use( logOut() throw new HttpError(msg || $t('httpMsg.unauthorized'), ApiStatus.unauthorized) default: - throw new HttpError(msg || $t('httpMsg.requestFailed'), code) + return Promise.reject(handleError(error)) } // return Promise.reject(handleError(error)) } diff --git a/src/views/auth/login/index.scss b/src/views/auth/login/index.scss index 3b0dc14..7057ea1 100644 --- a/src/views/auth/login/index.scss +++ b/src/views/auth/login/index.scss @@ -1,6 +1,8 @@ @use '@styles/variables.scss' as *; .login { + background: url('@imgs/login/bgx.png'); + background-size: 100% 100%; box-sizing: border-box; display: flex; width: 100%; @@ -66,9 +68,11 @@ .form { box-sizing: border-box; - height: 100%; - padding: 40px 0; + // height: 100%; widows: 100%; + padding: 40px 30px; + background: white; + border-radius: 18px; .title { margin-left: -2px; @@ -103,7 +107,7 @@ .drag-verify { position: relative; - padding-bottom: 20px; + // padding-bottom: 20px; margin-top: 25px; .drag-verify-content { diff --git a/src/views/auth/login/index.vue b/src/views/auth/login/index.vue index e607b46..076ff12 100644 --- a/src/views/auth/login/index.vue +++ b/src/views/auth/login/index.vue @@ -27,24 +27,6 @@ - -
    - 公司 -
    - -
@@ -58,9 +40,6 @@ 飞书登录
- - - - - + - + + + +
- -
- {{ - $t('login.rememberPwd') - }} - + -
- -
- -
- -
@@ -178,6 +151,7 @@ import { useI18n } from 'vue-i18n' import { HttpError } from '@/utils/http/error' import { onMounted, ref, watch, nextTick } from 'vue' + import { useRoute } from 'vue-router' defineOptions({ name: 'Login' }) @@ -185,40 +159,6 @@ import { useSettingStore } from '@/store/modules/setting' import type { FormInstance, FormRules } from 'element-plus' - type AccountKey = 'super' | 'admin' | 'user' - - export interface Account { - key: AccountKey - label: string - userName: string - password: string - roles: string[] - } - - const accounts = computed(() => [ - { - key: 'super', - label: t('login.roles.super'), - userName: 'Super', - password: '123456', - roles: ['R_SUPER'] - }, - { - key: 'admin', - label: t('login.roles.admin'), - userName: 'Admin', - password: '123456', - roles: ['R_ADMIN'] - }, - { - key: 'user', - label: t('login.roles.user'), - userName: 'User', - password: '123456', - roles: ['R_USER'] - } - ]) - const settingStore = useSettingStore() const { isDark, systemThemeType } = storeToRefs(settingStore) @@ -234,10 +174,15 @@ const systemName = AppConfig.systemInfo.name const formRef = ref() const companyid = ref('') + companyid.value = useUserStore().companyid const iscompany = ref(false) + const { companyabbr } = useUserStore() + //获取公司 getCompanyList + const companyList = ref() const feishuresponse=ref() const formData = reactive({ account: '', + company: Number(useUserStore().companyid), username: '', password: '', rememberPassword: true @@ -245,15 +190,57 @@ const rules = computed(() => ({ username: [{ required: true, message: t('login.placeholder[0]'), trigger: 'blur' }], - password: [{ required: true, message: t('login.placeholder[1]'), trigger: 'blur' }] + password: [{ required: true, message: t('login.placeholder[1]'), trigger: 'blur' }], + company: [{ required: true, message: t('login.placeholder[3]'), trigger: 'blur' }] })) const loading = ref(false) const { width } = useWindowSize() + const getcompanyList = async () => { + try { + // 这里调用获取品牌列表的接口 + const response = await UserService.getCompanyList() + companyList.value = response || [] + } catch (error) { } + } + // 切换语言 + const { locale } = useI18n() + + const changeLanguage = (lang: LanguageEnum) => { + if (locale.value === lang) return + locale.value = lang + userStore.setLanguage(lang) + } + + const getfeishuAppList = async () => { + try { + // 这里调用获取品牌列表的接口 + feishuresponse.value = await UserService.getfeishuAppList({ corp_id: companyid.value }) + if(activeLoginType.value=='qrcode'){ + feishulogin() + } + console.log(feishuresponse) + } catch (error) { } + } + //切换公司 + + const changeCompany = (company: any) => { + // if (companyid.value === company) return + const companyt = companyList.value.find((c: any) => c.id === company) + companyid.value = company + iscompany.value = company + userStore.setCompany(company,companyt?.abbr) + getfeishuAppList() + } + if(companyabbr!=''){ + iscompany.value = true + getfeishuAppList() + } + const feishulogin = async () => { userStore.setLoginType('feishu') if (isInFeishu) { - + feishuSubmit() // 飞书特定的逻辑 } else { // 普通浏览器的逻辑 @@ -392,46 +379,19 @@ }) }, 150) } + const route = useRoute() + onMounted(() => { getcompanyList() + // 自动读取 query 参数并存入 userStore + const companyid = Array.isArray(route.query.corp_id) ? route.query.corp_id[0] : route.query.corp_id + const companyabbr = Array.isArray(route.query.corp_abbr) ? route.query.corp_abbr[0] : route.query.corp_abbr + if (companyid) { + userStore.setCompany(companyid as string, (companyabbr as string) || '') + formData.company = Number(companyid) + } }) - // 切换语言 - const { locale } = useI18n() - - const changeLanguage = (lang: LanguageEnum) => { - if (locale.value === lang) return - locale.value = lang - userStore.setLanguage(lang) - } - //获取公司 getCompanyList - const companyList = ref() - const getcompanyList = async () => { - try { - // 这里调用获取品牌列表的接口 - const response = await UserService.getCompanyList() - companyList.value = response || [] - } catch (error) { } - } - //切换公司 - - const changeCompany = (company: any) => { - if (companyid.value === company) return - const companyt = companyList.value.find((c: any) => c.id === company) - companyid.value = company - iscompany.value = company - userStore.setCompany(company,companyt?.abbr) - getfeishuAppList() - } - const getfeishuAppList = async () => { - try { - // 这里调用获取品牌列表的接口 - feishuresponse.value = await UserService.getfeishuAppList({ corp_id: companyid.value }) - if(activeLoginType.value=='qrcode'){ - feishulogin() - } - console.log(feishuresponse) - } catch (error) { } - } + // 切换主题 import { useTheme } from '@/composables/useTheme' @@ -468,4 +428,11 @@ color: #888; } } + .login-bottom-row { + display: flex; + justify-content: space-between; + align-items: center; + font-size: 14px; + // margin-top: 16px; + } diff --git a/src/views/dashboard/console/index.vue b/src/views/dashboard/console/index.vue index a2e8784..e3f8be9 100644 --- a/src/views/dashboard/console/index.vue +++ b/src/views/dashboard/console/index.vue @@ -1,8 +1,11 @@ diff --git a/src/views/work/myOrder/index.vue b/src/views/work/myOrder/index.vue index 37e2f89..666e325 100644 --- a/src/views/work/myOrder/index.vue +++ b/src/views/work/myOrder/index.vue @@ -1,166 +1,171 @@ diff --git a/src/views/work/order/index.vue b/src/views/work/order/index.vue index ede71bb..0011f58 100644 --- a/src/views/work/order/index.vue +++ b/src/views/work/order/index.vue @@ -1,166 +1,170 @@ diff --git a/src/views/work/type/index.vue b/src/views/work/type/index.vue index 3c76792..372afd6 100644 --- a/src/views/work/type/index.vue +++ b/src/views/work/type/index.vue @@ -1,65 +1,70 @@ @@ -73,6 +78,8 @@ const dialogVisible = ref(false) const typeList = ref([]) const formRef = ref() + const { width } = useWindowSize() + const isMobile = computed(() => width.value < 500) const rules = reactive({ name: [ { required: true, message: '请输入分类名称', trigger: 'blur' }