add submodule adn remote redirecto to login
This commit is contained in:
parent
cf543c7f1d
commit
2ee8ec7a29
4
.gitignore
vendored
4
.gitignore
vendored
@ -24,4 +24,6 @@ dist-ssr
|
|||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
tsconfig.app.tsbuildinfo
|
tsconfig.app.tsbuildinfo
|
||||||
tsconfig.node.tsbuildinfo
|
tsconfig.node.tsbuildinfo
|
||||||
|
|
||||||
|
.turbo
|
||||||
|
6
.gitmodules
vendored
Normal file
6
.gitmodules
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[submodule "submodules/query-login"]
|
||||||
|
path = submodules/query-login
|
||||||
|
url = git@git.xiongxiao.me:kevisual/kevsiual-query-login.git
|
||||||
|
[submodule "submodules/query-config"]
|
||||||
|
path = submodules/query-config
|
||||||
|
url = git@git.xiongxiao.me:kevisual/kevsiual-query-config.git
|
0
.submodules
Normal file
0
.submodules
Normal file
23
package.json
23
package.json
@ -10,32 +10,28 @@
|
|||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"prepub": "envision switch root",
|
"prepub": "envision switch root",
|
||||||
"pub": "envision deploy ./dist -k center -v 0.0.9 -u -o root"
|
"pub": "envision deploy ./dist -k center -v 0.0.9 -u -o root",
|
||||||
|
"turbo:dev": "turbo dev:lib",
|
||||||
|
"turbo:build": "turbo build --filter=submodules/**"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/icons": "^6.0.0",
|
"@ant-design/icons": "^6.0.0",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.0",
|
"@emotion/styled": "^11.14.0",
|
||||||
"@icon-park/react": "^1.4.2",
|
|
||||||
"@kevisual/center-components": "workspace:*",
|
"@kevisual/center-components": "workspace:*",
|
||||||
"@kevisual/codemirror": "workspace:*",
|
"@kevisual/codemirror": "workspace:*",
|
||||||
"@kevisual/container": "1.0.0",
|
"@kevisual/container": "1.0.0",
|
||||||
"@kevisual/query": "^0.0.13",
|
"@kevisual/query": "^0.0.14",
|
||||||
"@kevisual/query-config": "workspace:*",
|
"@kevisual/query-config": "workspace:*",
|
||||||
"@kevisual/query-login": "workspace:*",
|
"@kevisual/query-login": "workspace:*",
|
||||||
"@kevisual/resources": "workspace:*",
|
"@kevisual/resources": "workspace:*",
|
||||||
"@kevisual/system-ui": "^0.0.3",
|
|
||||||
"@kevisual/ui": "^0.0.2",
|
|
||||||
"@monaco-editor/react": "^4.7.0",
|
"@monaco-editor/react": "^4.7.0",
|
||||||
"@mui/material": "^6.4.8",
|
"@mui/material": "^6.4.8",
|
||||||
"@tailwindcss/vite": "^4.0.15",
|
"@tailwindcss/vite": "^4.0.15",
|
||||||
"@uiw/react-textarea-code-editor": "^3.1.0",
|
"@uiw/react-textarea-code-editor": "^3.1.0",
|
||||||
"@xyflow/react": "^12.4.4",
|
|
||||||
"antd": "^5.24.4",
|
"antd": "^5.24.4",
|
||||||
"classnames": "^2.5.1",
|
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"d3": "^7.9.0",
|
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"eventemitter3": "^5.0.1",
|
"eventemitter3": "^5.0.1",
|
||||||
"i18next": "^24.2.3",
|
"i18next": "^24.2.3",
|
||||||
@ -57,10 +53,7 @@
|
|||||||
"zustand": "^5.0.3"
|
"zustand": "^5.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.22.0",
|
"@eslint/js": "^9.23.0",
|
||||||
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
|
||||||
"@types/d3": "^7.4.3",
|
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/node": "^22.13.11",
|
"@types/node": "^22.13.11",
|
||||||
@ -71,7 +64,7 @@
|
|||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"autoprefixer": "^10.4.21",
|
"autoprefixer": "^10.4.21",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^9.22.0",
|
"eslint": "^9.23.0",
|
||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.19",
|
"eslint-plugin-react-refresh": "^0.4.19",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
@ -83,8 +76,10 @@
|
|||||||
"tailwind-merge": "^3.0.2",
|
"tailwind-merge": "^3.0.2",
|
||||||
"tailwindcss": "^4.0.15",
|
"tailwindcss": "^4.0.15",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
|
"turbo": "^2.4.4",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"typescript-eslint": "^8.27.0",
|
"typescript-eslint": "^8.27.0",
|
||||||
"vite": "^6.2.2"
|
"vite": "^6.2.2"
|
||||||
}
|
},
|
||||||
|
"packageManager": "pnpm@10.6.5"
|
||||||
}
|
}
|
@ -11,5 +11,5 @@ query.afterResponse = async (response) => {
|
|||||||
noMsg: true,
|
noMsg: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return response;
|
return response as any;
|
||||||
};
|
};
|
||||||
|
@ -1,24 +1,42 @@
|
|||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
// Custom message component
|
// Custom message component
|
||||||
const LoginMessage = () => {
|
const LoginMessage = (props: ToastLoginProps) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
const currentUrl = window.location.href;
|
const currentUrl = window.location.href;
|
||||||
console.log(currentUrl);
|
const redirect = encodeURIComponent(props?.redirectUrl || currentUrl);
|
||||||
const redirect = encodeURIComponent(currentUrl);
|
const loginUrl = props?.loginUrl || '/user/login/';
|
||||||
console.log('redirect', redirect);
|
const newUrl = location.origin + loginUrl + '?redirect=' + redirect;
|
||||||
const newUrl = location.origin + '/user/login/?redirect=' + redirect;
|
|
||||||
window.open(newUrl, '_self');
|
window.open(newUrl, '_self');
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='msg-container' onClick={handleClick} style={{ cursor: 'pointer' }}>
|
<div className='msg-container' onClick={handleClick} style={{ cursor: 'pointer' }}>
|
||||||
<p className='msg-title'>Please login</p>
|
<p className='msg-title'>{t('Please login')}</p>
|
||||||
<p className='msg-description'>Click here to go to the login page.</p>
|
<p className='msg-description'>{t('Click here to go to the login page.')}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
type ToastLoginProps = {
|
||||||
export const toastLogin = () => {
|
/**
|
||||||
toast.info(<LoginMessage />);
|
* 登录页面地址, /user/login
|
||||||
|
*/
|
||||||
|
loginUrl?: string;
|
||||||
|
/**
|
||||||
|
* 登录成功后跳转的地址, 默认是当前页面
|
||||||
|
*/
|
||||||
|
redirectUrl?: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 登录提示
|
||||||
|
* @param props
|
||||||
|
* @example
|
||||||
|
* toastLogin({
|
||||||
|
* loginUrl: '/user/login/',
|
||||||
|
* redirectUrl: window.location.href,
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
export const toastLogin = (props: ToastLoginProps = {}) => {
|
||||||
|
toast.info(<LoginMessage {...props} />);
|
||||||
};
|
};
|
||||||
|
870
pnpm-lock.yaml
generated
870
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,22 @@
|
|||||||
import { message } from '@kevisual/system-ui/dist/message';
|
import { toast } from 'react-toastify';
|
||||||
export { message };
|
|
||||||
|
export const message = {
|
||||||
|
success: (message: string) => {
|
||||||
|
toast.success(message);
|
||||||
|
},
|
||||||
|
error: (message: string) => {
|
||||||
|
toast.error(message);
|
||||||
|
},
|
||||||
|
warning: (message: string) => {
|
||||||
|
toast.warning(message);
|
||||||
|
},
|
||||||
|
info: (message: string) => {
|
||||||
|
toast.info(message);
|
||||||
|
},
|
||||||
|
loading: (message: string) => {
|
||||||
|
const toastId = toast.loading(message);
|
||||||
|
return () => {
|
||||||
|
toast.dismiss(toastId);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { QueryClient } from '@kevisual/query';
|
import { QueryClient } from '@kevisual/query';
|
||||||
import { modal } from './redirect-to-login';
|
|
||||||
import { create } from 'zustand';
|
import { create } from 'zustand';
|
||||||
import { message } from './message';
|
|
||||||
import { QueryLogin } from '@kevisual/query-login';
|
import { QueryLogin } from '@kevisual/query-login';
|
||||||
|
import { toastLogin } from '@kevisual/resources/pages/message/ToastLogin.tsx';
|
||||||
export const query = new QueryClient();
|
export const query = new QueryClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +39,7 @@ query.afterResponse = async (res, ctx) => {
|
|||||||
const queryLoginRes = await queryLogin.afterCheck401ToRefreshToken(res, ctx);
|
const queryLoginRes = await queryLogin.afterCheck401ToRefreshToken(res, ctx);
|
||||||
query.stop = false;
|
query.stop = false;
|
||||||
if (queryLoginRes.code === 401) {
|
if (queryLoginRes.code === 401) {
|
||||||
modal.setOpen(true);
|
toastLogin();
|
||||||
}
|
}
|
||||||
return queryLoginRes;
|
return queryLoginRes;
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
import { DialogModal } from '@kevisual/ui';
|
|
||||||
import '@kevisual/ui/dist/index.css';
|
|
||||||
import { basename } from './basename';
|
|
||||||
const content = document.createElement('div');
|
|
||||||
|
|
||||||
const loginHref = `${basename}/user/login`;
|
|
||||||
content.innerHTML = `
|
|
||||||
<div class="bg-white p-8 rounded-sm shadow-md w-full max-w-md text-center">
|
|
||||||
<h2 class="text-2xl font-bold mb-4">Token 无效</h2>
|
|
||||||
<p class="mb-6">您的登录凭证已失效,请重新登录。</p>
|
|
||||||
<a href="${loginHref}" class="inline-block bg-red-500 text-white py-2 px-4 rounded-sm hover:bg-red-600 transition duration-200">确定</a>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
export const modal = DialogModal.render(content, {
|
|
||||||
id: 'redirect-to-login',
|
|
||||||
contentStyle: {
|
|
||||||
width: 'unset',
|
|
||||||
},
|
|
||||||
dialogTitleStyle: {
|
|
||||||
display: 'none',
|
|
||||||
padding: '0',
|
|
||||||
},
|
|
||||||
dialogContentStyle: {
|
|
||||||
padding: '0',
|
|
||||||
},
|
|
||||||
mask: true,
|
|
||||||
open: false,
|
|
||||||
});
|
|
@ -109,17 +109,13 @@ export const useAppVersionStore = create<AppVersionStore>((set, get) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
publishVersion: async (data) => {
|
publishVersion: async (data) => {
|
||||||
const { getList } = get();
|
|
||||||
const loaded = message.loading('Publishing...', 0);
|
|
||||||
const res = await query.post({
|
const res = await query.post({
|
||||||
path: 'app',
|
path: 'app',
|
||||||
key: 'publish',
|
key: 'publish',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
setTimeout(loaded, 200);
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('Success');
|
message.success('Success');
|
||||||
// getList();
|
|
||||||
get().getApp(get().key, true);
|
get().getApp(get().key, true);
|
||||||
} else {
|
} else {
|
||||||
message.error(res.message || 'Request failed');
|
message.error(res.message || 'Request failed');
|
||||||
|
@ -54,9 +54,7 @@ export const useLoginStore = create<LoginStore>((set, get) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
set({ loading: true });
|
set({ loading: true });
|
||||||
const loaded = message.loading('loading...', 0);
|
|
||||||
const res = await queryLogin.login({ username, password });
|
const res = await queryLogin.login({ username, password });
|
||||||
setTimeout(loaded, 200);
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('Success');
|
message.success('Success');
|
||||||
set({ isLogin: true });
|
set({ isLogin: true });
|
||||||
@ -78,9 +76,7 @@ export const useLoginStore = create<LoginStore>((set, get) => {
|
|||||||
},
|
},
|
||||||
register: async () => {
|
register: async () => {
|
||||||
set({ loading: true });
|
set({ loading: true });
|
||||||
const loaded = message.loading('loading...', 0);
|
|
||||||
const res = await query.post({ path: 'user', key: 'register' });
|
const res = await query.post({ path: 'user', key: 'register' });
|
||||||
setTimeout(loaded, 200);
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
message.success('Success');
|
message.success('Success');
|
||||||
// 跳到某一个页面
|
// 跳到某一个页面
|
||||||
|
1
submodules/query-config
Submodule
1
submodules/query-config
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit f993b2466ec4680a0a6ef044ad524130a4c24c0a
|
1
submodules/query-login
Submodule
1
submodules/query-login
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit a457dbabe931327b3b644d88e07c41ce82af4e76
|
17
turbo.json
Normal file
17
turbo.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://turbo.build/schema.json",
|
||||||
|
"tasks": {
|
||||||
|
"build": {
|
||||||
|
"dependsOn": [
|
||||||
|
"^build"
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
"dist/**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"dev:lib": {
|
||||||
|
"persistent": true,
|
||||||
|
"cache": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user