Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion amoro-web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import './utils/editor'
import './assets/icons'
import loginService from './services/login.service'
import { getQueryString } from './utils'
import { resetLoginTip } from './utils/request'
import SvgIcon from '@/components/svg-icon.vue'

import 'virtual:svg-icons-register'
Expand Down Expand Up @@ -72,11 +73,21 @@ RegisterComponents(app);
finally {
const store = useStore()
router.beforeEach((to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
// if no username in store and not go to login page, should redirect to login page
store.setHistoryPath({
path: from.path,
query: from.query,
})
if (to.path === '/login') {
resetLoginTip()
next()
return
}
if (!store.userInfo.userName && to.path !== '/login') {
next({
path: '/login',
})
return
}
next()
})

Expand Down
10 changes: 9 additions & 1 deletion amoro-web/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { message } from 'ant-design-vue'
import useStore from '@/store'
import router from '@/router'

let loginTipShown = false

// http://10.196.98.23:19111/
export const baseURL = import.meta.env.PROD ? '' : (import.meta.env.MODE === 'mock' ? '/mock' : '/')

Expand Down Expand Up @@ -161,8 +163,10 @@ const request: any = function (options: CustomAxiosRequestConfig) {
store.updateUserInfo({
userName: '',
})
if (requestConfig.handleError) {
const currentPath = router.currentRoute.value.path
if (requestConfig.handleError && currentPath !== '/login' && !loginTipShown) {
message.error(msg || 'need login')
loginTipShown = true
}
return router.push({
path: '/login',
Expand Down Expand Up @@ -259,4 +263,8 @@ export function downloadWithHeader(url: string, fileName: string = 'download', _
}


export function resetLoginTip() {
loginTipShown = false
}

export default request as WrapperRequest
4 changes: 2 additions & 2 deletions amoro-web/src/views/tables/components/TableExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ onBeforeMount(async () => {
flex-direction: column;

.table-explorer-header {
padding: 0 12px;
padding: 0 7px 0 8px;
margin-bottom: 8px;

.search-input {
Expand Down Expand Up @@ -656,7 +656,7 @@ onBeforeMount(async () => {
flex: 1;
min-height: 0;
overflow: auto;
padding: 0 12px;
padding: 0 7px 0 8px;

:deep(.ant-tree) {
background-color: #fff;
Expand Down
15 changes: 9 additions & 6 deletions amoro-web/src/views/tables/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default defineComponent({
const SIDEBAR_WIDTH_STORAGE_KEY = 'tables_sidebar_width'
const SIDEBAR_MIN_WIDTH = 320
const SIDEBAR_MAX_WIDTH = 800
const sidebarWidth = ref(512)
const sidebarWidth = ref(320)

let isResizing = false
let startX = 0
Expand All @@ -71,7 +71,7 @@ export default defineComponent({
const initSidebarWidth = () => {
const stored = localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY)
const parsed = stored ? Number.parseInt(stored, 10) : Number.NaN
const base = Number.isFinite(parsed) ? clampSidebarWidth(parsed) : 512
const base = Number.isFinite(parsed) ? clampSidebarWidth(parsed) : 320
sidebarWidth.value = base
startWidth = base
}
Expand Down Expand Up @@ -317,13 +317,16 @@ export default defineComponent({
display: flex;
height: 100%;
align-items: stretch;
margin-top: -12px;
margin-bottom: -12px;
}

.tables-sidebar {
flex: 0 0 auto;
height: 100%;
background-color: #fff;
position: relative;
padding-top: 12px;
}

.tables-main {
Expand All @@ -332,12 +335,13 @@ export default defineComponent({
flex-direction: column;
min-width: 0;
height: 100%;
padding-top: 12px;
}

.tables-divider {
position: relative;
flex: 0 0 8px;
width: 8px;
flex: 0 0 5px;
width: 5px;
height: 100%;
cursor: col-resize;
z-index: 2; // Ensure divider is above sidebar and main content so drag area is not blocked
Expand All @@ -348,9 +352,8 @@ export default defineComponent({
position: absolute;
top: 0;
bottom: 0;
left: 50%;
right: 2px;
width: 1px;
transform: translateX(-50%);
background: #e8e8f0;
}

Expand Down