27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
// Ported from legacy henza_admin/src/utils/index.js
|
|||
|
|
//
|
||
|
|
// Legacy:
|
||
|
|
// export function isBranch(){
|
||
|
|
// console.log(process.env.NODE_ENV)
|
||
|
|
// return process.env.NODE_ENV=='branch'
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
// Vite has no process.env at runtime; the equivalent build-time switch is the
|
||
|
|
// --mode flag, exposed as import.meta.env.MODE. Run `pnpm dev:branch` for branch mode.
|
||
|
|
// The legacy console.log is intentionally not carried over (debug noise, no behaviour).
|
||
|
|
export function isBranch(): boolean {
|
||
|
|
return import.meta.env.MODE === 'branch';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Legacy stored the token under a different localStorage key per mode.
|
||
|
|
// See henza_admin/src/axios.js:6 and router.js:173-174,188.
|
||
|
|
/** آدرس همین پنل، با پیشوند /branch در حالت شعبه. */
|
||
|
|
export function iamAppUrl(path: string) {
|
||
|
|
const base = import.meta.env.BASE_URL || '/';
|
||
|
|
const prefix = base.endsWith('/') ? base : `${base}/`;
|
||
|
|
return `${window.location.origin}${prefix}${path.replace(/^\//, '')}`;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const tokenName = isBranch() ? 'branch_token' : 'token';
|
||
|
|
export const userName = isBranch() ? 'branch_user' : 'user';
|