| | |
| | | VITE_OPEN=false |
| | | |
| | | # 请求路径 |
| | | VITE_BASE_URL='http://172.16.8.100:48080' |
| | | VITE_BASE_URL='http://localhost:8088' |
| | | |
| | | # 平台路径 |
| | | VITE_PLAT_URL='http://localhost:48080' |
| | | |
| | | # 接口地址 |
| | | VITE_API_URL=/admin-api |
| | | |
| | | # 平台接口地址 |
| | | VITE_PLAT_API_URL=/admin-api |
| | | |
| | | # 租户开关 |
| | | VITE_APP_TENANT_ENABLE=true |
| | | |
| | | # 验证码的开关 |
| | | VITE_APP_CAPTCHA_ENABLE=false |
| | | |
| | | # 文档地址的开关 |
| | | VITE_APP_DOCALERT_ENABLE=true |
| | |
| | | VITE_APP_DEFAULT_LOGIN_USERNAME = admin |
| | | VITE_APP_DEFAULT_LOGIN_PASSWORD = admin123 |
| | | |
| | | VITE_TENANT_ID=172 |
| | | |
| | | ## 平台授权URL |
| | | #VITE_AUTH2_LOGIN_URL='http://localhost:48080/admin-api/system/oauth2/token' |
| | | # |
| | | ## 平台授权AUTH2 clientId |
| | | #VITE_AUTH2_CLIENT_ID='shasteel' |
| | | # |
| | | ## 平台授权AUTH2 clientSecret |
| | | #VITE_AUTH2_CLIENT_SECRET='iailab2019' |
| | | VITE_AUTH2_LOGIN_URL='http://localhost:48080/admin-api/system/oauth2/token' |
| | | |
| | | # 平台授权AUTH2 clientId |
| | | VITE_AUTH2_CLIENT_ID='shasteel' |
| | | |
| | | # 平台授权AUTH2 clientSecret |
| | | VITE_AUTH2_CLIENT_SECRET='iailab2019' |
| | | |
| | | # 验证码的开关 |
| | | VITE_APP_CAPTCHA_ENABLE=false |
| | |
| | | # 开发环境:本地只启动前端项目,依赖开发环境(后端、APP) |
| | | NODE_ENV=production |
| | | NODE_ENV=development |
| | | |
| | | VITE_DEV=true |
| | | |
| | |
| | | VITE_SOURCEMAP=true |
| | | |
| | | # 打包路径 |
| | | VITE_BASE_PATH=/ |
| | | VITE_BASE_PATH=/energy |
| | | |
| | | # 输出路径 |
| | | VITE_OUT_DIR=dist |
| | |
| | | <div class="app-loading-wrap"> |
| | | <div class="app-loading-title"> |
| | | <img src="/logo.gif" class="app-loading-logo" alt="Logo" /> |
| | | <div class="app-loading-title">沙钢智慧能源平台</div> |
| | | <div class="app-loading-title">沙钢智慧能源系统</div> |
| | | </div> |
| | | <div class="app-loading-item"> |
| | | <div class="app-loading-outter"></div> |
| | |
| | | "dev-server": "vite --mode dev", |
| | | "ts:check": "vue-tsc --noEmit", |
| | | "build:local": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build", |
| | | "build:dev": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode dev", |
| | | "build:test": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode test", |
| | | "build:dev": "node --max_old_space_size=4096 ./node_modules/vite/bin/vite.js build --mode dev", |
| | | "build:test": "node --max_old_space_size=4096 ./node_modules/vite/bin/vite.js build --mode test", |
| | | "build:stage": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode stage", |
| | | "build:prod": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build --mode prod", |
| | | "serve:dev": "vite preview --mode dev", |
| | |
| | | |
| | | // 查询列表 |
| | | export const getDemoPage = (params: PageParam) => { |
| | | return request.get({ url: 'http://localhost:8088/admin-api/shasteel/demo/page', params }) |
| | | return request.get({ url: '/shasteel/demo/page', params }) |
| | | } |
| | | |
| | | // 获得 |
| | | export const getDemo = (id: number) => { |
| | | return request.get({ url: 'http://localhost:8088/admin-api/shasteel/demo/get?id=' + id }) |
| | | return request.get({ url: '/shasteel/demo/get?id=' + id }) |
| | | } |
| | | |
| | | // 查询应用列表 |
| | | export const getDemoList = () => { |
| | | return request.get({ url: 'http://localhost:8088/admin-api/shasteel/demo/list' }) |
| | | return request.get({ url: '/shasteel/demo/list' }) |
| | | } |
| | | |
| | | // 新增 |
| | | export const createDemo = (data: DemoVO) => { |
| | | return request.post({ url: 'http://localhost:8088/admin-api/shasteel/demo/create', data }) |
| | | return request.post({ url: '/shasteel/demo/create', data }) |
| | | } |
| | | |
| | | // 修改 |
| | | export const updateDemo = (data: DemoVO) => { |
| | | return request.put({ url: 'http://localhost:8088/admin-api/shasteel/demo/update', data }) |
| | | return request.put({ url: '/shasteel/demo/update', data }) |
| | | } |
| | | |
| | | // 删除 |
| | | export const deleteDemo = (id: number) => { |
| | | return request.delete({ url: 'http://localhost:8088/admin-api/shasteel/demo/delete?id=' + id }) |
| | | return request.delete({ url: '/shasteel/demo/delete?id=' + id }) |
| | | } |
| | | |
| | | // 导出 |
| | | export const exportDemo = (params: DemoVO) => { |
| | | return request.download({ url: 'http://localhost:8088/admin-api/shasteel/demo/export-excel', params }) |
| | | return request.download({ url: '/shasteel/demo/export-excel', params }) |
| | | } |
| | |
| | | import request from '@/config/axios' |
| | | import type { UserLoginVO } from './types' |
| | | import {Oauth2TokenVO, UserLoginVO} from './types' |
| | | import { config } from '@/config/axios/config' |
| | | |
| | | const { plat_url} = config |
| | | |
| | | export interface SmsCodeVO { |
| | | mobile: string |
| | |
| | | |
| | | // 登录 |
| | | export const login = (data: UserLoginVO) => { |
| | | return request.post({ url: '/system/auth/login', data }) |
| | | return request.post({ url: plat_url + '/system/auth/login', data }) |
| | | } |
| | | |
| | | // 密码授权登录 |
| | | export const oauth2Login = (data: Oauth2TokenVO) => { |
| | | return request.post({ url: plat_url + '/system/oauth2/token?' // 客户端 |
| | | + "client_id=" + data.clientId |
| | | + "&client_secret=" + data.clientSecret, data }) |
| | | } |
| | | |
| | | // 使用租户名,获得租户编号 |
| | | export const getTenantIdByName = (name: string) => { |
| | | return request.get({ url: '/system/tenant/get-id-by-name?name=' + name }) |
| | | return request.get({ url: plat_url + '/system/tenant/get-id-by-name?name=' + name }) |
| | | } |
| | | |
| | | // 登出 |
| | | export const loginOut = () => { |
| | | return request.post({ url: '/system/auth/logout' }) |
| | | return request.post({ url: plat_url + '/system/auth/logout' }) |
| | | } |
| | | |
| | | // 获取用户权限信息 |
| | | export const getInfo = () => { |
| | | return request.get({ url: '/system/auth/get-permission-info' }) |
| | | return request.get({ url: plat_url + '/system/auth/get-permission-info' }) |
| | | } |
| | | |
| | | // 获取验证图片以及 token |
| | | export const getCode = (data) => { |
| | | return request.postOriginal({ url: 'captcha/get', data }) |
| | | return request.postOriginal({ url: plat_url + '/system/captcha/get', data }) |
| | | } |
| | | |
| | | // 滑动或者点选验证 |
| | | export const reqCheck = (data) => { |
| | | return request.postOriginal({ url: 'captcha/check', data }) |
| | | return request.postOriginal({ url: plat_url + '/system/captcha/check', data }) |
| | | } |
| | | |
| | |
| | | socialState?: string |
| | | } |
| | | |
| | | export type Oauth2TokenVO = { |
| | | clientId: string |
| | | clientSecret: string |
| | | grantType: string |
| | | username: string |
| | | password: string |
| | | scope: string |
| | | } |
| | | |
| | | export type TokenType = { |
| | | id: number // 编号 |
| | | accessToken: string // 访问令牌 |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | import { config } from '@/config/axios/config' |
| | | |
| | | const { plat_url} = config |
| | | |
| | | export interface AppVO { |
| | | id: number |
| | | appCode: string |
| | |
| | | return request.get({ url: '/system/app/get?id=' + id }) |
| | | } |
| | | |
| | | // 查询应用列表 |
| | | // 查询所拥有应用列表 |
| | | export const getAppList = () => { |
| | | return request.get({ url: '/system/app/list' }) |
| | | return request.get({ url: plat_url + '/system/auth/get-app-permission' }) |
| | | } |
| | | |
| | | // 查询应用列表 |
| | | export const getAppMenuList = () => { |
| | | return request.get({ url: '/system/app-menu/list' }) |
| | | // 查询所拥有应用菜单列表 |
| | | export const getAppMenuList = (id) => { |
| | | return request.get({ url: plat_url + '/system/auth/get-app-menu-permission?id=' + id }) |
| | | } |
| | | |
| | | // 新增 |
| | |
| | | import request from '@/config/axios' |
| | | import {config} from "@/config/axios/config"; |
| | | const { plat_url } = config |
| | | |
| | | export type DictDataVO = { |
| | | id: number | undefined |
| | |
| | | |
| | | // 查询字典数据(精简)列表 |
| | | export const getSimpleDictDataList = () => { |
| | | return request.get({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/simple-list' }) |
| | | return request.get({ url: plat_url + '/system/dict-data/simple-list' }) |
| | | } |
| | | |
| | | // 查询字典数据列表 |
| | | export const getDictDataPage = (params: PageParam) => { |
| | | return request.get({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/page', params }) |
| | | return request.get({ url: plat_url + '/system/dict-data/page', params }) |
| | | } |
| | | |
| | | // 查询字典数据详情 |
| | | export const getDictData = (id: number) => { |
| | | return request.get({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/get?id=' + id }) |
| | | return request.get({ url: plat_url + '/system/dict-data/get?id=' + id }) |
| | | } |
| | | |
| | | // 新增字典数据 |
| | | export const createDictData = (data: DictDataVO) => { |
| | | return request.post({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/create', data }) |
| | | return request.post({ url: plat_url + '/system/dict-data/create', data }) |
| | | } |
| | | |
| | | // 修改字典数据 |
| | | export const updateDictData = (data: DictDataVO) => { |
| | | return request.put({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/update', data }) |
| | | return request.put({ url: plat_url + '/system/dict-data/update', data }) |
| | | } |
| | | |
| | | // 删除字典数据 |
| | | export const deleteDictData = (id: number) => { |
| | | return request.delete({ url: 'http://172.16.8.100:48080/admin-api/system/dict-data/delete?id=' + id }) |
| | | return request.delete({ url: plat_url + '/system/dict-data/delete?id=' + id }) |
| | | } |
| | | |
| | | // 导出字典类型数据 |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | import {config} from "@/config/axios/config"; |
| | | const { plat_url } = config |
| | | |
| | | export type DictTypeVO = { |
| | | id: number | undefined |
| | | name: string |
| | |
| | | |
| | | // 查询字典(精简)列表 |
| | | export const getSimpleDictTypeList = () => { |
| | | return request.get({ url: '/system/dict-type/list-all-simple' }) |
| | | return request.get({ url: plat_url + '/system/dict-type/list-all-simple' }) |
| | | } |
| | | |
| | | // 查询字典列表 |
| | | export const getDictTypePage = (params: PageParam) => { |
| | | return request.get({ url: '/system/dict-type/page', params }) |
| | | return request.get({ url: plat_url + '/system/dict-type/page', params }) |
| | | } |
| | | |
| | | // 查询字典详情 |
| | | export const getDictType = (id: number) => { |
| | | return request.get({ url: '/system/dict-type/get?id=' + id }) |
| | | return request.get({ url: plat_url + '/system/dict-type/get?id=' + id }) |
| | | } |
| | | |
| | | // 新增字典 |
| | | export const createDictType = (data: DictTypeVO) => { |
| | | return request.post({ url: '/system/dict-type/create', data }) |
| | | return request.post({ url: plat_url + '/system/dict-type/create', data }) |
| | | } |
| | | |
| | | // 修改字典 |
| | | export const updateDictType = (data: DictTypeVO) => { |
| | | return request.put({ url: '/system/dict-type/update', data }) |
| | | return request.put({ url: plat_url + '/system/dict-type/update', data }) |
| | | } |
| | | |
| | | // 删除字典 |
| | | export const deleteDictType = (id: number) => { |
| | | return request.delete({ url: '/system/dict-type/delete?id=' + id }) |
| | | return request.delete({ url: plat_url + '/system/dict-type/delete?id=' + id }) |
| | | } |
| | | // 导出字典类型 |
| | | export const exportDictType = (params) => { |
| | | return request.download({ url: '/system/dict-type/export', params }) |
| | | return request.download({ url: plat_url + '/system/dict-type/export', params }) |
| | | } |
| | |
| | | import request from '@/config/axios' |
| | | |
| | | import { config } from '@/config/axios/config' |
| | | |
| | | const { plat_url} = config |
| | | |
| | | export interface MenuVO { |
| | | id: number |
| | | name: string |
| | |
| | | |
| | | // 查询菜单(精简)列表 |
| | | export const getSimpleMenusList = () => { |
| | | return request.get({ url: '/system/menu/simple-list' }) |
| | | return request.get({ url: plat_url + '/system/menu/simple-list' }) |
| | | } |
| | | |
| | | // 查询应用菜单(精简)列表 |
| | | export const getSimpleAppMenusList = () => { |
| | | return request.get({ url: '/system/menu/simple-app-menus' }) |
| | | return request.get({ url: plat_url + '/system/menu/simple-app-menus' }) |
| | | } |
| | | |
| | | // 查询菜单列表 |
| | | export const getMenuList = (params) => { |
| | | return request.get({ url: '/system/menu/list', params }) |
| | | return request.get({ url: plat_url + '/system/menu/list', params }) |
| | | } |
| | | |
| | | // 查询应用菜单列表 |
| | | export const getAppMenuList = (params) => { |
| | | return request.get({ url: '/system/menu/app-menu-list', params }) |
| | | return request.get({ url: plat_url + '/system/menu/app-menu-list', params }) |
| | | } |
| | | |
| | | // 获取菜单详情 |
| | | export const getMenu = (id: number) => { |
| | | return request.get({ url: '/system/menu/get?id=' + id }) |
| | | return request.get({ url: plat_url + '/system/menu/get?id=' + id }) |
| | | } |
| | | |
| | | // 获取应用菜单详情 |
| | | export const getAppMenu = (id: number) => { |
| | | return request.get({ url: '/system/menu/getAppMenu?id=' + id }) |
| | | return request.get({ url: plat_url + '/system/menu/getAppMenu?id=' + id }) |
| | | } |
| | | |
| | | // 新增菜单 |
| | | export const createMenu = (data: MenuVO) => { |
| | | return request.post({ url: '/system/menu/create', data }) |
| | | return request.post({ url: plat_url + '/system/menu/create', data }) |
| | | } |
| | | |
| | | // 新增应用菜单 |
| | | export const createAppMenu = (data: MenuVO) => { |
| | | return request.post({ url: '/system/menu/createAppMenu', data }) |
| | | return request.post({ url: plat_url + '/system/menu/createAppMenu', data }) |
| | | } |
| | | |
| | | // 修改菜单 |
| | | export const updateMenu = (data: MenuVO) => { |
| | | return request.put({ url: '/system/menu/update', data }) |
| | | return request.put({ url: plat_url + '/system/menu/update', data }) |
| | | } |
| | | |
| | | // 修改应用菜单 |
| | | export const updateAppMenu = (data: MenuVO) => { |
| | | return request.put({ url: '/system/menu/updateAppMenu', data }) |
| | | return request.put({ url: plat_url + '/system/menu/updateAppMenu', data }) |
| | | } |
| | | |
| | | // 删除菜单 |
| | | export const deleteMenu = (id: number) => { |
| | | return request.delete({ url: '/system/menu/delete?id=' + id }) |
| | | return request.delete({ url: plat_url + '/system/menu/delete?id=' + id }) |
| | | } |
| | | |
| | | // 删除应用菜单 |
| | | export const deleteAppMenu = (id: number) => { |
| | | return request.delete({ url: '/system/menu/deleteAppMenu?id=' + id }) |
| | | return request.delete({ url: plat_url + '/system/menu/deleteAppMenu?id=' + id }) |
| | | } |
| | |
| | | const config: { |
| | | base_url: string |
| | | plat_url: string |
| | | result_code: number | string |
| | | default_headers: AxiosHeaders |
| | | request_timeout: number |
| | |
| | | */ |
| | | base_url: import.meta.env.VITE_BASE_URL + import.meta.env.VITE_API_URL, |
| | | /** |
| | | * 平台请求基础路径 |
| | | */ |
| | | plat_url: import.meta.env.VITE_PLAT_URL + import.meta.env.VITE_PLAT_API_URL, |
| | | /** |
| | | * 接口成功返回状态码 |
| | | */ |
| | | result_code: 200, |
| | |
| | | |
| | | const collapse = computed(() => appStore.getCollapse) |
| | | |
| | | const homePath = ref('/index') |
| | | |
| | | homePath.value = '/index' |
| | | |
| | | onMounted(() => { |
| | | if (unref(collapse)) show.value = false |
| | | }) |
| | |
| | | layout !== 'classic' ? `${prefixCls}__Top` : '', |
| | | 'flex !h-[var(--logo-height)] items-center cursor-pointer pl-8px relative decoration-none overflow-hidden' |
| | | ]" |
| | | to="/" |
| | | :to="homePath" |
| | | > |
| | | <img |
| | | class="h-[calc(var(--logo-height)-10px)] w-[calc(var(--logo-height)-10px)]" |
| | |
| | | // 路由不重定向白名单 |
| | | const whiteList = [ |
| | | '/login', |
| | | '/callback', |
| | | '/social-login', |
| | | '/auth-redirect', |
| | | '/bind', |
| | |
| | | |
| | | // 创建路由实例 |
| | | const router = createRouter({ |
| | | history: createWebHistory("/"), // createWebHashHistory URL带#,createWebHistory URL不带# |
| | | history: createWebHistory("/energy"), // createWebHashHistory URL带#,createWebHistory URL不带# |
| | | strict: true, |
| | | routes: remainingRouter as RouteRecordRaw[], |
| | | scrollBehavior: () => ({ left: 0, top: 0 }) |
| | | }) |
| | | |
| | | export const resetRouter = (): void => { |
| | | const resetWhiteNameList = ['Redirect', 'Login', 'NoFind', 'Root'] |
| | | const resetWhiteNameList = ['Redirect', 'Login', 'NoFind', 'Root', 'Callback'] |
| | | router.getRoutes().forEach((route) => { |
| | | const { name } = route |
| | | if (name && !resetWhiteNameList.includes(name as string)) { |
| | |
| | | } |
| | | }, |
| | | { |
| | | path: '/callback', |
| | | component: () => import('@/views/Login/Callback.vue'), |
| | | name: 'Callback', |
| | | meta: { |
| | | hidden: true, |
| | | noTagsView: true |
| | | } |
| | | }, |
| | | { |
| | | path: '/home2', |
| | | component: () => import('@/views/Home/Index2.vue'), |
| | | name: 'Home2', |
| | |
| | | ] |
| | | }, |
| | | { |
| | | path: '/user', |
| | | component: Layout, |
| | | name: 'UserInfo', |
| | | meta: { |
| | | hidden: true |
| | | }, |
| | | children: [ |
| | | { |
| | | path: 'profile', |
| | | component: () => import('@/views/Profile/Index.vue'), |
| | | name: 'Profile', |
| | | meta: { |
| | | canTo: true, |
| | | hidden: true, |
| | | noTagsView: false, |
| | | icon: 'ep:user', |
| | | title: t('common.profile') |
| | | } |
| | | }, |
| | | { |
| | | path: 'notify-message', |
| | | component: () => import('@/views/system/notify/my/index.vue'), |
| | | name: 'MyNotifyMessage', |
| | | meta: { |
| | | canTo: true, |
| | | hidden: true, |
| | | noTagsView: false, |
| | | icon: 'ep:message', |
| | | title: '我的站内信' |
| | | } |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/login', |
| | | component: () => import('@/views/Login/Login.vue'), |
| | | name: 'Login', |
| | |
| | | |
| | | const AccessTokenKey = 'ACCESS_TOKEN' |
| | | const RefreshTokenKey = 'REFRESH_TOKEN' |
| | | const TenantId = 'tenantId' |
| | | |
| | | // 获取token |
| | | export const getAccessToken = () => { |
| | |
| | | export const setToken = (token: TokenType) => { |
| | | wsCache.set(RefreshTokenKey, token.refreshToken) |
| | | wsCache.set(AccessTokenKey, token.accessToken) |
| | | wsCache.set(TenantId, import.meta.env.VITE_TENANT_ID) |
| | | } |
| | | |
| | | // 删除token |
| | |
| | | <template> |
| | | <div> |
| | | <h1>这里是应用首页</h1> |
| | | <h1>这里是主页</h1> |
| | | </div> |
| | | <!-- <div>--> |
| | | <!-- <h1>应用列表</h1>--> |
| | | <!-- </div>--> |
| | | <!-- <el-skeleton :loading="loading" animated>--> |
| | | <!-- <div id="app" v-for="(item, index) in appList" :key="`dynamics-${index}`">--> |
| | | <!-- <div class="card" @click="gotoApp(item)">--> |
| | | <!-- <img :src="item.icon" style="width: 100px; height: 100px" />--> |
| | | <!-- <div>--> |
| | | <!-- {{item.appName}}--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <!-- </el-skeleton>--> |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | |
| | | import * as AppApi from '@/api/system/app' |
| | | import {Apps} from "@/views/Home/types"; |
| | | import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; |
| | | |
| | | |
| | | defineOptions({ name: 'Home' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | |
| | | const loading = ref(true) |
| | | |
| | | // let appList = reactive<Apps[]>([]) |
| | | // |
| | | // const getAppList = async () => { |
| | | // const data = await AppApi.getAppList() |
| | | // appList = Object.assign(appList, data) |
| | | // } |
| | | // |
| | | // const getAppMenuList = async (id) => { |
| | | // const data = await AppApi.getAppMenuList(id) |
| | | // let userInfo = wsCache.get(CACHE_KEY.USER) |
| | | // let routers = wsCache.get(CACHE_KEY.ROLE_ROUTERS) |
| | | // console.log(userInfo) |
| | | // console.log(routers) |
| | | // userInfo.menus = data |
| | | // wsCache.set(CACHE_KEY.USER, userInfo) |
| | | // wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
| | | // window.location.href = '/energy/index' |
| | | // } |
| | | // |
| | | // const getAllApi = async () => { |
| | | // await Promise.all([ |
| | | // getAppList() |
| | | // ]) |
| | | // loading.value = false |
| | | // } |
| | | // |
| | | // // getAllApi() |
| | | // |
| | | // // 进入应用 |
| | | // const gotoApp = async (item) => { |
| | | // let id = item.id |
| | | // getAppMenuList(id) |
| | | // } |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | #app{ |
| | | width: 300px; |
| | | height: 200px; |
| | | display: inline-block; |
| | | background: transparent; |
| | | } |
| | | .card{ |
| | | border: thin dashed gainsboro; |
| | | width: 150px; |
| | | height: 100px; |
| | | padding: 30px; |
| | | text-align: center; |
| | | justify-content: center; |
| | | font-size: 15px; |
| | | font-weight: bolder; |
| | | color: blue; |
| | | background: aliceblue; |
| | | border-radius: 10px; |
| | | } |
| | | </style> |
| | |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <!-- <Verify--> |
| | | <!-- ref="verify"--> |
| | | <!-- :captchaType="captchaType"--> |
| | | <!-- :imgSize="{ width: '400px', height: '200px' }"--> |
| | | <!-- mode="pop"--> |
| | | <!-- @success="handleLogin"--> |
| | | <!-- />--> |
| | | <Verify |
| | | ref="verify" |
| | | :captchaType="captchaType" |
| | | :imgSize="{ width: '400px', height: '200px' }" |
| | | mode="pop" |
| | | @success="handleLogin" |
| | | /> |
| | | </el-row> |
| | | |
| | | <!-- <!– 统一身份登录–>--> |
| | | <!-- <el-divider content-position="center">统一身份登录</el-divider>--> |
| | | <!-- <el-col :span="24" style="padding-right: 10px; padding-left: 10px">--> |
| | | <!-- <el-form-item>--> |
| | | <!-- <el-row :gutter="10" justify="space-between" style="width: 100%">--> |
| | | <!-- <el-col :span="8">--> |
| | | <!-- <el-button type="primary" style="width: 100%;"--> |
| | | <!-- @click="ssoPasswordLogin">--> |
| | | <!-- {{ ssoLoginPasswordTitle }}--> |
| | | <!-- </el-button>--> |
| | | <!-- </el-col>--> |
| | | <!-- <el-col :span="8">--> |
| | | <!-- <el-button type="primary" style="width: 100%;"--> |
| | | <!-- @click="ssoCodeLogin">--> |
| | | <!-- {{ ssoLoginCodeTitle }}--> |
| | | <!-- </el-button>--> |
| | | <!-- </el-col>--> |
| | | <!-- </el-row>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | </el-form> |
| | | </template> |
| | | <script lang="ts" setup> |
| | |
| | | import * as authUtil from '@/utils/auth' |
| | | import * as LoginApi from '@/api/login' |
| | | import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' |
| | | // import axios from "axios"; |
| | | |
| | | defineOptions({ name: 'LoginForm' }) |
| | | |
| | |
| | | const { currentRoute, push } = useRouter() |
| | | const redirect = ref<string>('') |
| | | const loginLoading = ref(false) |
| | | // const ssoLoginPasswordTitle = ref('账号密码模式') |
| | | // const ssoLoginCodeTitle = ref('授权码模式') |
| | | const verify = ref() |
| | | const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 |
| | | |
| | | const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) |
| | | |
| | |
| | | password: import.meta.env.VITE_APP_DEFAULT_LOGIN_PASSWORD || '', |
| | | scope: 'user.read user.write', |
| | | grantType: 'password', |
| | | captchaVerification: '', |
| | | rememberMe: true // 默认记录我。如果不需要,可手动修改 |
| | | } |
| | | }) |
| | | |
| | | // const ssoLoginData = reactive({ |
| | | // loginParam: { |
| | | // username: '', |
| | | // password: '', |
| | | // token: '' |
| | | // } |
| | | // }) |
| | | // |
| | | // const oauth2Token = reactive({ |
| | | // oauthParam: { |
| | | // clientId: 'shasteel', |
| | | // clientSecret: 'shasteel111111111111111', |
| | | // grantType: 'password', |
| | | // username: '', |
| | | // password: '', |
| | | // scope: '' |
| | | // } |
| | | // }) |
| | | |
| | | // 获取验证码 |
| | | const getCode = async () => { |
| | | // 情况一,未开启:则直接登录 |
| | | if (loginData.captchaEnable === 'false') { |
| | | await handleLogin() |
| | | await handleLogin({}) |
| | | } else { |
| | | // 情况二,已开启:则展示验证码;只有完成验证码的情况,才进行登录 |
| | | // 弹出验证码 |
| | |
| | | |
| | | const loading = ref() // ElLoading.service 返回的实例 |
| | | // 登录 |
| | | const handleLogin = async () => { |
| | | const handleLogin = async (params) => { |
| | | loginLoading.value = true |
| | | try { |
| | | const data = await validForm() |
| | | if (!data) { |
| | | return |
| | | } |
| | | loginData.loginForm.captchaVerification = params.captchaVerification |
| | | const res = await LoginApi.login(loginData.loginForm) |
| | | if (!res) { |
| | | return |
| | |
| | | } |
| | | authUtil.setToken(res) |
| | | if (!redirect.value) { |
| | | redirect.value = '/' |
| | | redirect.value = '/index' |
| | | } |
| | | // 判断是否为SSO登录 |
| | | if (redirect.value.indexOf('sso') !== -1) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 自动登录 |
| | | // const autoLogin = async (appid, username) => { |
| | | // console.log(appid) |
| | | // console.log(username) |
| | | // loginLoading.value = true |
| | | // try { |
| | | // const res = await LoginApi.auth2Login(loginData.loginForm) |
| | | // if (!res) { |
| | | // return |
| | | // const ssoPasswordLogin = () => { |
| | | // // 发起请求 |
| | | // axios({ |
| | | // url: "http://localhost:48080/admin-api/system/oauth2/token?" |
| | | // // 客户端 |
| | | // + "client_id=" + oauth2Token.oauthParam.clientId |
| | | // + "&client_secret=" + oauth2Token.oauthParam.clientSecret |
| | | // // 密码模式的参数 |
| | | // + "&grant_type=" + oauth2Token.oauthParam.grantType |
| | | // + "&username=" + loginData.loginForm.username |
| | | // + "&password=" + loginData.loginForm.password |
| | | // + '&scope=user.read user.write', |
| | | // method: 'POST', |
| | | // headers: { |
| | | // 'tenant-id': '172', // 多租户编号,写死 |
| | | // } |
| | | // loading.value = ElLoading.service({ |
| | | // lock: true, |
| | | // text: '正在加载系统中...', |
| | | // background: 'rgba(0, 0, 0, 0.7)' |
| | | // }) |
| | | // if (loginData.loginForm.rememberMe) { |
| | | // authUtil.setLoginForm(loginData.loginForm) |
| | | // }).then((result) => { |
| | | // const res = result.data |
| | | // if (res.code !== 0) { |
| | | // alert('授权失败,原因:' + res.msg) |
| | | // return; |
| | | // } |
| | | // const auth_token = res.data.access_token |
| | | // // 设置token |
| | | // authUtil.setToken(res.data) |
| | | // // 提示登录成功 |
| | | // alert('授权成功!校验系统用户及权限'); |
| | | // ssoLoginData.loginParam.token = auth_token |
| | | // if (!!redirect.value) { |
| | | // location.href = decodeURIComponent(redirect.value); |
| | | // } else { |
| | | // authUtil.removeLoginForm() |
| | | // push({ path: '/index' }) |
| | | // } |
| | | // authUtil.setToken(res) |
| | | // if (!redirect.value) { |
| | | // redirect.value = '/' |
| | | // }).catch((e) => { |
| | | // ElMessage.error('授权失败:' + e.message); |
| | | // }); |
| | | // } |
| | | // console.log(permissionStore) |
| | | // // 判断是否为SSO登录 |
| | | // if (redirect.value.indexOf('sso') !== -1) { |
| | | // window.location.href = window.location.href.replace('/login?redirect=', '') |
| | | // } else { |
| | | // push({ path: redirect.value }) |
| | | // } |
| | | // } finally { |
| | | // loginLoading.value = false |
| | | // loading.value.close() |
| | | // } |
| | | |
| | | // const ssoCodeLogin = () => { |
| | | // alert('暂未开通'); |
| | | // // const clientId = 'shasteel'; |
| | | // // const redirectUri = encodeURIComponent('http://127.0.0.1:9000/callback'); |
| | | // // const responseType = 'code'; // 1)授权码模式,对应 code;2)简化模式,对应 token |
| | | // // window.location.href = 'http://localhost/sso?client_id=' + clientId |
| | | // // + '&redirect_uri=' + redirectUri |
| | | // // + '&response_type=' + responseType; |
| | | // } |
| | | |
| | | watch( |
| | |
| | | ) |
| | | onMounted(() => { |
| | | getLoginFormCache() |
| | | let params = new URLSearchParams(window.location.search); |
| | | console.log(params) |
| | | let appid = params.get('appid'); |
| | | let username = params.get('username'); |
| | | console.log(appid) |
| | | console.log(username) |
| | | // if(appid) { |
| | | // autoLogin(appid, username) |
| | | // } |
| | | }) |
| | | </script> |
| | | |
| | |
| | | readonly VITE_APP_DEFAULT_LOGIN_PASSWORD: string |
| | | readonly VITE_APP_DOCALERT_ENABLE: string |
| | | readonly VITE_BASE_URL: string |
| | | readonly VITE_PLAT_URL: string |
| | | readonly VITE_AUTH2_LOGIN_URL: string |
| | | readonly VITE_AUTH2_CLIENT_ID: string |
| | | readonly VITE_AUTH2_CLIENT_SECRET: string |
| | | readonly VITE_UPLOAD_URL: string |
| | | readonly VITE_API_URL: string |
| | | readonly VITE_PLAT_API_URL: string |
| | | readonly VITE_BASE_PATH: string |
| | | readonly VITE_DROP_DEBUGGER: string |
| | | readonly VITE_DROP_CONSOLE: string |
| | | readonly VITE_SOURCEMAP: string |
| | | readonly VITE_OUT_DIR: string |
| | | readonly VITE_TENANT_ID: string |
| | | } |
| | | |
| | | declare global { |
| | |
| | | rewrite: (path) => path.replace(new RegExp(`^/admin-api`), ''), |
| | | }, |
| | | }, |
| | | hmr: { |
| | | overlay: false |
| | | } |
| | | }, |
| | | // 项目使用的vite插件。 单独提取到build/vite/plugin中管理 |
| | | plugins: createVitePlugins(), |