merge(sj_map_reduce): 合并 sa 1.2.6
This commit is contained in:
parent
03f6db667a
commit
6f6c00b0ae
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -3,7 +3,7 @@
|
|||||||
"source.fixAll.eslint": "explicit",
|
"source.fixAll.eslint": "explicit",
|
||||||
"source.organizeImports": "never"
|
"source.organizeImports": "never"
|
||||||
},
|
},
|
||||||
"eslint.experimental.useFlatConfig": true,
|
"eslint.useFlatConfig": true,
|
||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"eslint.validate": ["html", "css", "scss", "json", "jsonc"],
|
"eslint.validate": ["html", "css", "scss", "json", "jsonc"],
|
||||||
"i18n-ally.displayLanguage": "zh-cn",
|
"i18n-ally.displayLanguage": "zh-cn",
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from './proxy';
|
export * from './proxy';
|
||||||
|
export * from './time';
|
||||||
|
12
build/config/time.ts
Normal file
12
build/config/time.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import dayjs from 'dayjs';
|
||||||
|
import utc from 'dayjs/plugin/utc';
|
||||||
|
import timezone from 'dayjs/plugin/timezone';
|
||||||
|
|
||||||
|
export function getBuildTime() {
|
||||||
|
dayjs.extend(utc);
|
||||||
|
dayjs.extend(timezone);
|
||||||
|
|
||||||
|
const buildTime = dayjs.tz(Date.now(), 'Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|
||||||
|
return buildTime;
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="/favicon.svg" />
|
<link rel="icon" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<meta name="color-scheme" content="light dark" />
|
||||||
<title>%VITE_APP_TITLE%</title>
|
<title>%VITE_APP_TITLE%</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
42
package.json
42
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "snail-job",
|
"name": "snail-job",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "A flexible, reliable, and fast platform for distributed task retry and distributed task scheduling.",
|
"description": "A flexible, reliable, and fast platform for distributed task retry and distributed task scheduling.",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"homepage": "https://gitee.com/aizuda/snail-job",
|
"homepage": "https://gitee.com/aizuda/snail-job",
|
||||||
@ -56,7 +56,7 @@
|
|||||||
"@sa/hooks": "workspace:*",
|
"@sa/hooks": "workspace:*",
|
||||||
"@sa/materials": "workspace:*",
|
"@sa/materials": "workspace:*",
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"@vueuse/core": "10.10.0",
|
"@vueuse/core": "10.11.0",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"dayjs": "1.11.11",
|
"dayjs": "1.11.11",
|
||||||
"echarts": "5.5.0",
|
"echarts": "5.5.0",
|
||||||
@ -67,46 +67,46 @@
|
|||||||
"pinia": "2.1.7",
|
"pinia": "2.1.7",
|
||||||
"tailwind-merge": "^2.3.0",
|
"tailwind-merge": "^2.3.0",
|
||||||
"ts-md5": "1.3.1",
|
"ts-md5": "1.3.1",
|
||||||
"vue": "3.4.27",
|
"vue": "3.4.30",
|
||||||
"vue-codemirror6": "^1.3.0",
|
"vue-codemirror6": "^1.3.0",
|
||||||
"vue-drag-resize": "^1.5.4",
|
"vue-drag-resize": "^1.5.4",
|
||||||
"vue-draggable-plus": "0.5.0",
|
"vue-draggable-plus": "0.5.0",
|
||||||
"vue-i18n": "9.13.1",
|
"vue-i18n": "9.13.1",
|
||||||
"vue-router": "4.3.2",
|
"vue-router": "4.4.0",
|
||||||
"vue3-puzzle-vcode": "^1.1.7"
|
"vue3-puzzle-vcode": "^1.1.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@elegant-router/vue": "0.3.7",
|
"@elegant-router/vue": "0.3.7",
|
||||||
"@iconify/json": "2.2.217",
|
"@iconify/json": "2.2.221",
|
||||||
"@sa/scripts": "workspace:*",
|
"@sa/scripts": "workspace:*",
|
||||||
"@sa/uno-preset": "workspace:*",
|
"@sa/uno-preset": "workspace:*",
|
||||||
"@soybeanjs/eslint-config": "1.3.6",
|
"@soybeanjs/eslint-config": "1.3.7",
|
||||||
"@types/lodash-es": "4.17.12",
|
"@types/lodash-es": "4.17.12",
|
||||||
"@types/node": "20.14.2",
|
"@types/node": "20.14.8",
|
||||||
"@types/nprogress": "0.2.3",
|
"@types/nprogress": "0.2.3",
|
||||||
"@unocss/eslint-config": "0.60.4",
|
"@unocss/eslint-config": "0.61.0",
|
||||||
"@unocss/preset-icons": "0.60.4",
|
"@unocss/preset-icons": "0.61.0",
|
||||||
"@unocss/preset-uno": "0.60.4",
|
"@unocss/preset-uno": "0.61.0",
|
||||||
"@unocss/transformer-directives": "0.60.4",
|
"@unocss/transformer-directives": "0.61.0",
|
||||||
"@unocss/transformer-variant-group": "0.60.4",
|
"@unocss/transformer-variant-group": "0.61.0",
|
||||||
"@unocss/vite": "0.60.4",
|
"@unocss/vite": "0.61.0",
|
||||||
"@vitejs/plugin-vue": "5.0.5",
|
"@vitejs/plugin-vue": "5.0.5",
|
||||||
"@vitejs/plugin-vue-jsx": "4.0.0",
|
"@vitejs/plugin-vue-jsx": "4.0.0",
|
||||||
"eslint": "9.4.0",
|
"eslint": "9.5.0",
|
||||||
"eslint-plugin-vue": "9.26.0",
|
"eslint-plugin-vue": "9.26.0",
|
||||||
"lint-staged": "15.2.5",
|
"lint-staged": "15.2.7",
|
||||||
"sass": "1.77.4",
|
"sass": "1.77.6",
|
||||||
"simple-git-hooks": "2.11.1",
|
"simple-git-hooks": "2.11.1",
|
||||||
"tsx": "4.12.0",
|
"tsx": "4.15.7",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.5.2",
|
||||||
"unplugin-icons": "0.19.0",
|
"unplugin-icons": "0.19.0",
|
||||||
"unplugin-vue-components": "0.27.0",
|
"unplugin-vue-components": "0.27.0",
|
||||||
"vite": "5.2.12",
|
"vite": "5.3.1",
|
||||||
"vite-plugin-progress": "0.0.7",
|
"vite-plugin-progress": "0.0.7",
|
||||||
"vite-plugin-svg-icons": "2.0.1",
|
"vite-plugin-svg-icons": "2.0.1",
|
||||||
"vite-plugin-vue-devtools": "7.2.1",
|
"vite-plugin-vue-devtools": "7.3.4",
|
||||||
"vue-eslint-parser": "9.4.3",
|
"vue-eslint-parser": "9.4.3",
|
||||||
"vue-tsc": "2.0.19"
|
"vue-tsc": "2.0.22"
|
||||||
},
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
"commit-msg": "pnpm sa git-commit-verify",
|
"commit-msg": "pnpm sa git-commit-verify",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/axios",
|
"name": "@sa/axios",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"axios": "1.7.2",
|
"axios": "1.7.2",
|
||||||
"axios-retry": "4.4.0",
|
"axios-retry": "4.4.1",
|
||||||
"qs": "6.12.1"
|
"qs": "6.12.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
export const REQUEST_ID_KEY = 'X-Request-Id';
|
export const REQUEST_ID_KEY = 'X-Request-Id';
|
||||||
|
|
||||||
/** the backend error code key */
|
/** the backend error code key */
|
||||||
export const BACKEND_ERROR_CODE = '0';
|
export const BACKEND_ERROR_CODE = '-1';
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/color",
|
"name": "@sa/color",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/hooks",
|
"name": "@sa/hooks",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/materials",
|
"name": "@sa/materials",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sa/utils": "workspace:*",
|
"@sa/utils": "workspace:*",
|
||||||
"simplebar-vue": "2.3.4"
|
"simplebar-vue": "2.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typed-css-modules": "0.9.1"
|
"typed-css-modules": "0.9.1"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/fetch",
|
"name": "@sa/fetch",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/scripts",
|
"name": "@sa/scripts",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"bin": {
|
"bin": {
|
||||||
"sa": "./bin.ts"
|
"sa": "./bin.ts"
|
||||||
},
|
},
|
||||||
@ -15,11 +15,11 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@soybeanjs/changelog": "0.3.24",
|
"@soybeanjs/changelog": "0.3.24",
|
||||||
"bumpp": "9.4.1",
|
"bumpp": "9.4.1",
|
||||||
"c12": "1.10.0",
|
"c12": "1.11.1",
|
||||||
"cac": "6.7.14",
|
"cac": "6.7.14",
|
||||||
"consola": "3.2.3",
|
"consola": "3.2.3",
|
||||||
"enquirer": "2.4.1",
|
"enquirer": "2.4.1",
|
||||||
"execa": "9.2.0",
|
"execa": "9.3.0",
|
||||||
"kolorist": "1.8.0",
|
"kolorist": "1.8.0",
|
||||||
"npm-check-updates": "16.14.20",
|
"npm-check-updates": "16.14.20",
|
||||||
"rimraf": "5.0.7"
|
"rimraf": "5.0.7"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/uno-preset",
|
"name": "@sa/uno-preset",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@sa/utils",
|
"name": "@sa/utils",
|
||||||
"version": "1.2.1",
|
"version": "1.2.6",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./src/index.ts"
|
".": "./src/index.ts"
|
||||||
},
|
},
|
||||||
|
1768
pnpm-lock.yaml
1768
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -41,6 +41,7 @@ const icon = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ButtonIcon
|
<ButtonIcon
|
||||||
|
:key="String(collapsed)"
|
||||||
:tooltip-content="collapsed ? $t('icon.expand') : $t('icon.collapse')"
|
:tooltip-content="collapsed ? $t('icon.expand') : $t('icon.collapse')"
|
||||||
tooltip-placement="bottom-start"
|
tooltip-placement="bottom-start"
|
||||||
:z-index="zIndex"
|
:z-index="zIndex"
|
||||||
|
@ -160,6 +160,24 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
Object.assign(pagination, update);
|
Object.assign(pagination, update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get data by page number
|
||||||
|
*
|
||||||
|
* @param pageNum the page number. default is 1
|
||||||
|
*/
|
||||||
|
async function getDataByPage(pageNum: number = 1) {
|
||||||
|
updatePagination({
|
||||||
|
page: pageNum
|
||||||
|
});
|
||||||
|
|
||||||
|
updateSearchParams({
|
||||||
|
page: pageNum,
|
||||||
|
size: pagination.pageSize!
|
||||||
|
});
|
||||||
|
|
||||||
|
await getData();
|
||||||
|
}
|
||||||
|
|
||||||
scope.run(() => {
|
scope.run(() => {
|
||||||
watch(
|
watch(
|
||||||
() => appStore.locale,
|
() => appStore.locale,
|
||||||
@ -189,6 +207,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
mobilePagination,
|
mobilePagination,
|
||||||
updatePagination,
|
updatePagination,
|
||||||
getData,
|
getData,
|
||||||
|
getDataByPage,
|
||||||
searchParams,
|
searchParams,
|
||||||
updateSearchParams,
|
updateSearchParams,
|
||||||
resetSearchParams
|
resetSearchParams
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { LAYOUT_SCROLL_EL_ID } from '@sa/materials';
|
||||||
import { useAppStore } from '@/store/modules/app';
|
import { useAppStore } from '@/store/modules/app';
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { useRouteStore } from '@/store/modules/route';
|
import { useRouteStore } from '@/store/modules/route';
|
||||||
@ -24,6 +25,12 @@ const routeStore = useRouteStore();
|
|||||||
const tabStore = useTabStore();
|
const tabStore = useTabStore();
|
||||||
|
|
||||||
const transitionName = computed(() => (themeStore.page.animate ? themeStore.page.animateMode : ''));
|
const transitionName = computed(() => (themeStore.page.animate ? themeStore.page.animateMode : ''));
|
||||||
|
|
||||||
|
function resetScroll() {
|
||||||
|
const el = document.querySelector(`#${LAYOUT_SCROLL_EL_ID}`);
|
||||||
|
|
||||||
|
el?.scrollTo({ left: 0, top: 0 });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -32,6 +39,7 @@ const transitionName = computed(() => (themeStore.page.animate ? themeStore.page
|
|||||||
:name="transitionName"
|
:name="transitionName"
|
||||||
mode="out-in"
|
mode="out-in"
|
||||||
@before-leave="appStore.setContentXScrollable(true)"
|
@before-leave="appStore.setContentXScrollable(true)"
|
||||||
|
@after-leave="resetScroll"
|
||||||
@after-enter="appStore.setContentXScrollable(false)"
|
@after-enter="appStore.setContentXScrollable(false)"
|
||||||
>
|
>
|
||||||
<KeepAlive :include="routeStore.cacheRoutes">
|
<KeepAlive :include="routeStore.cacheRoutes">
|
||||||
|
@ -36,6 +36,7 @@ const local: App.I18n.Schema = {
|
|||||||
exportAll: 'Are you sure to export all?',
|
exportAll: 'Are you sure to export all?',
|
||||||
exportPar: 'Are you sure to export {num} pieces of data?',
|
exportPar: 'Are you sure to export {num} pieces of data?',
|
||||||
edit: 'Edit',
|
edit: 'Edit',
|
||||||
|
error: 'Error',
|
||||||
detail: 'Detail',
|
detail: 'Detail',
|
||||||
index: 'Index',
|
index: 'Index',
|
||||||
keywordSearch: 'Please enter keyword',
|
keywordSearch: 'Please enter keyword',
|
||||||
|
@ -36,6 +36,7 @@ const local: App.I18n.Schema = {
|
|||||||
exportAll: '确认导出列表中全部数据吗?',
|
exportAll: '确认导出列表中全部数据吗?',
|
||||||
exportPar: '确认导出{num}条数据吗?',
|
exportPar: '确认导出{num}条数据吗?',
|
||||||
edit: '编辑',
|
edit: '编辑',
|
||||||
|
error: '错误',
|
||||||
detail: '详情',
|
detail: '详情',
|
||||||
index: '序号',
|
index: '序号',
|
||||||
keywordSearch: '请输入关键词搜索',
|
keywordSearch: '请输入关键词搜索',
|
||||||
|
@ -3,11 +3,22 @@ import { NButton } from 'naive-ui';
|
|||||||
import { $t } from '../locales';
|
import { $t } from '../locales';
|
||||||
|
|
||||||
export function setupAppVersionNotification() {
|
export function setupAppVersionNotification() {
|
||||||
|
let isShow = false;
|
||||||
|
|
||||||
document.addEventListener('visibilitychange', async () => {
|
document.addEventListener('visibilitychange', async () => {
|
||||||
|
const preConditions = [!isShow, document.visibilityState === 'visible', !import.meta.env.DEV];
|
||||||
|
|
||||||
|
if (!preConditions.every(Boolean)) return;
|
||||||
|
|
||||||
const buildTime = await getHtmlBuildTime();
|
const buildTime = await getHtmlBuildTime();
|
||||||
|
|
||||||
const { VITE_UPDATE_NOTIFY } = import.meta.env;
|
const { VITE_UPDATE_NOTIFY } = import.meta.env;
|
||||||
if (buildTime !== BUILD_TIME && document.visibilityState === 'visible' && VITE_UPDATE_NOTIFY === 'Y') {
|
if (buildTime === BUILD_TIME && VITE_UPDATE_NOTIFY !== 'Y') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isShow = true;
|
||||||
|
|
||||||
const n = window.$notification?.create({
|
const n = window.$notification?.create({
|
||||||
title: $t('system.updateTitle'),
|
title: $t('system.updateTitle'),
|
||||||
content: $t('system.updateContent'),
|
content: $t('system.updateContent'),
|
||||||
@ -33,9 +44,11 @@ export function setupAppVersionNotification() {
|
|||||||
() => $t('system.updateConfirm')
|
() => $t('system.updateConfirm')
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
},
|
||||||
|
onClose() {
|
||||||
|
isShow = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import type {
|
|||||||
Router
|
Router
|
||||||
} from 'vue-router';
|
} from 'vue-router';
|
||||||
import type { RouteKey, RoutePath } from '@elegant-router/types';
|
import type { RouteKey, RoutePath } from '@elegant-router/types';
|
||||||
|
import { getRouteName } from '@/router/elegant/transform';
|
||||||
import { useAuthStore } from '@/store/modules/auth';
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
import { useRouteStore } from '@/store/modules/route';
|
import { useRouteStore } from '@/store/modules/route';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
@ -153,9 +154,7 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
|
|||||||
// initialize the auth route requires the user to be logged in, if not, redirect to the login page
|
// initialize the auth route requires the user to be logged in, if not, redirect to the login page
|
||||||
if (!isLogin) {
|
if (!isLogin) {
|
||||||
const loginRoute: RouteKey = 'login';
|
const loginRoute: RouteKey = 'login';
|
||||||
const redirect = to.fullPath;
|
const query = getRouteQueryOfLoginRoute(to, routeStore.routeHome);
|
||||||
|
|
||||||
const query: LocationQueryRaw = to.name !== loginRoute ? { redirect } : {};
|
|
||||||
|
|
||||||
const location: RouteLocationRaw = {
|
const location: RouteLocationRaw = {
|
||||||
name: loginRoute,
|
name: loginRoute,
|
||||||
@ -202,3 +201,20 @@ function handleRouteSwitch(to: RouteLocationNormalized, from: RouteLocationNorma
|
|||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRouteQueryOfLoginRoute(to: RouteLocationNormalized, routeHome: RouteKey) {
|
||||||
|
const loginRoute: RouteKey = 'login';
|
||||||
|
const redirect = to.fullPath;
|
||||||
|
const [redirectPath, redirectQuery] = redirect.split('?');
|
||||||
|
const redirectName = getRouteName(redirectPath as RoutePath);
|
||||||
|
|
||||||
|
const isRedirectHome = routeHome === redirectName;
|
||||||
|
|
||||||
|
const query: LocationQueryRaw = to.name !== loginRoute && !isRedirectHome ? { redirect } : {};
|
||||||
|
|
||||||
|
if (isRedirectHome && redirectQuery) {
|
||||||
|
query.redirect = `/?${redirectQuery}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { AxiosResponse } from 'axios';
|
import type { AxiosResponse } from 'axios';
|
||||||
import { createFlatRequest } from '@sa/axios';
|
import { BACKEND_ERROR_CODE, createFlatRequest } from '@sa/axios';
|
||||||
import { useAuthStore } from '@/store/modules/auth';
|
import { useAuthStore } from '@/store/modules/auth';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
@ -72,7 +72,7 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
|
|||||||
if (!request.state.isLogout) {
|
if (!request.state.isLogout) {
|
||||||
request.state.isLogout = true;
|
request.state.isLogout = true;
|
||||||
window.$dialog?.error({
|
window.$dialog?.error({
|
||||||
title: 'Error',
|
title: $t('common.error'),
|
||||||
content: $t('request.logoutWithModalMsg'),
|
content: $t('request.logoutWithModalMsg'),
|
||||||
positiveText: $t('common.confirm'),
|
positiveText: $t('common.confirm'),
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
@ -118,8 +118,10 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
|
|||||||
let backendErrorCode = '';
|
let backendErrorCode = '';
|
||||||
|
|
||||||
// get backend error message and code
|
// get backend error message and code
|
||||||
|
if (String(error.code) === BACKEND_ERROR_CODE) {
|
||||||
message = error.response?.data?.message || message;
|
message = error.response?.data?.message || message;
|
||||||
backendErrorCode = error.response?.data?.status?.toString() || '';
|
backendErrorCode = error.response?.data?.status || '';
|
||||||
|
}
|
||||||
|
|
||||||
// the error message is displayed in the modal
|
// the error message is displayed in the modal
|
||||||
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];
|
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];
|
||||||
|
@ -36,6 +36,9 @@ export function showErrorMsg(state: RequestInstanceState, message: string) {
|
|||||||
state.errMsgStack = [];
|
state.errMsgStack = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isExist = state.errMsgStack.includes(message);
|
||||||
|
|
||||||
|
if (!isExist) {
|
||||||
state.errMsgStack.push(message);
|
state.errMsgStack.push(message);
|
||||||
|
|
||||||
window.$message?.error(message, {
|
window.$message?.error(message, {
|
||||||
@ -47,4 +50,5 @@ export function showErrorMsg(state: RequestInstanceState, message: string) {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,13 @@ import { localStg } from '@/utils/storage';
|
|||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { roleTypeRecord } from '@/constants/business';
|
import { roleTypeRecord } from '@/constants/business';
|
||||||
import { useRouteStore } from '../route';
|
import { useRouteStore } from '../route';
|
||||||
|
import { useTabStore } from '../tab';
|
||||||
import { clearAuthStorage, getToken } from './shared';
|
import { clearAuthStorage, getToken } from './shared';
|
||||||
|
|
||||||
export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const routeStore = useRouteStore();
|
const routeStore = useRouteStore();
|
||||||
|
const tabStore = useTabStore();
|
||||||
const { toLogin, redirectFromLogin } = useRouterPush(false);
|
const { toLogin, redirectFromLogin } = useRouterPush(false);
|
||||||
const { loading: loginLoading, startLoading, endLoading } = useLoading();
|
const { loading: loginLoading, startLoading, endLoading } = useLoading();
|
||||||
|
|
||||||
@ -56,6 +58,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
|
|||||||
await toLogin();
|
await toLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tabStore.cacheTabs();
|
||||||
routeStore.resetStore();
|
routeStore.resetStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
/** Init auth route */
|
/** Init auth route */
|
||||||
async function initAuthRoute() {
|
async function initAuthRoute() {
|
||||||
if (authRouteMode.value === 'static') {
|
if (authRouteMode.value === 'static') {
|
||||||
await initStaticAuthRoute();
|
initStaticAuthRoute();
|
||||||
} else {
|
} else {
|
||||||
await initDynamicAuthRoute();
|
await initDynamicAuthRoute();
|
||||||
}
|
}
|
||||||
@ -228,7 +228,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Init static auth route */
|
/** Init static auth route */
|
||||||
async function initStaticAuthRoute() {
|
function initStaticAuthRoute() {
|
||||||
const { authRoutes: staticAuthRoutes } = createStaticRoutes();
|
const { authRoutes: staticAuthRoutes } = createStaticRoutes();
|
||||||
|
|
||||||
if (authStore.isStaticSuper) {
|
if (authStore.isStaticSuper) {
|
||||||
|
@ -290,6 +290,7 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
|||||||
resetTabLabel,
|
resetTabLabel,
|
||||||
isTabRetain,
|
isTabRetain,
|
||||||
updateTabsByLocale,
|
updateTabsByLocale,
|
||||||
getTabIdByRoute
|
getTabIdByRoute,
|
||||||
|
cacheTabs
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
1
src/typings/app.d.ts
vendored
1
src/typings/app.d.ts
vendored
@ -288,6 +288,7 @@ declare namespace App {
|
|||||||
exportAll: string;
|
exportAll: string;
|
||||||
exportPar: string;
|
exportPar: string;
|
||||||
edit: string;
|
edit: string;
|
||||||
|
error: string;
|
||||||
detail: string;
|
detail: string;
|
||||||
index: string;
|
index: string;
|
||||||
keywordSearch: string;
|
keywordSearch: string;
|
||||||
|
4
src/typings/env.d.ts
vendored
4
src/typings/env.d.ts
vendored
@ -108,3 +108,7 @@ declare namespace Env {
|
|||||||
readonly VITE_LOGIN_CODE?: string;
|
readonly VITE_LOGIN_CODE?: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: Env.ImportMeta;
|
||||||
|
}
|
||||||
|
23
src/typings/global.d.ts
vendored
23
src/typings/global.d.ts
vendored
@ -1,4 +1,7 @@
|
|||||||
interface Window {
|
export {};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
export interface Window {
|
||||||
/** NProgress instance */
|
/** NProgress instance */
|
||||||
NProgress?: import('nprogress').NProgress;
|
NProgress?: import('nprogress').NProgress;
|
||||||
/** Loading bar instance */
|
/** Loading bar instance */
|
||||||
@ -9,20 +12,18 @@ interface Window {
|
|||||||
$message?: import('naive-ui').MessageProviderInst;
|
$message?: import('naive-ui').MessageProviderInst;
|
||||||
/** Notification instance */
|
/** Notification instance */
|
||||||
$notification?: import('naive-ui').NotificationProviderInst;
|
$notification?: import('naive-ui').NotificationProviderInst;
|
||||||
|
/** Table loading */
|
||||||
$loading?: import('@sa/hooks').LoadingApiInst;
|
$loading?: import('@sa/hooks').LoadingApiInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ViewTransition {
|
interface ViewTransition {
|
||||||
ready: Promise<void>;
|
ready: Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Document {
|
export interface Document {
|
||||||
startViewTransition?: (callback: () => Promise<void> | void) => ViewTransition;
|
startViewTransition?: (callback: () => Promise<void> | void) => ViewTransition;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
/** Build time of the project */
|
||||||
readonly env: Env.ImportMeta;
|
export const BUILD_TIME: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build time of the project */
|
|
||||||
declare const BUILD_TIME: string;
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import { URL, fileURLToPath } from 'node:url';
|
import { URL, fileURLToPath } from 'node:url';
|
||||||
import { defineConfig, loadEnv } from 'vite';
|
import { defineConfig, loadEnv } from 'vite';
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import { setupVitePlugins } from './build/plugins';
|
import { setupVitePlugins } from './build/plugins';
|
||||||
import { createViteProxy } from './build/config';
|
import { createViteProxy, getBuildTime } from './build/config';
|
||||||
|
|
||||||
export default defineConfig(configEnv => {
|
export default defineConfig(configEnv => {
|
||||||
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta;
|
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as Env.ImportMeta;
|
||||||
|
|
||||||
const buildTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
const buildTime = getBuildTime();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: viteEnv.VITE_BASE_URL,
|
base: viteEnv.VITE_BASE_URL,
|
||||||
|
Loading…
Reference in New Issue
Block a user