mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
support sub path
This commit is contained in:
+2
-2
@@ -22,9 +22,9 @@ function isMobileDevice(): boolean {
|
|||||||
|
|
||||||
function navigate(type: string): void {
|
function navigate(type: string): void {
|
||||||
if (__EZBOOKKEEPING_IS_PRODUCTION__) {
|
if (__EZBOOKKEEPING_IS_PRODUCTION__) {
|
||||||
window.location.replace(`${type}/`);
|
window.location.replace(`${type}#/`);
|
||||||
} else {
|
} else {
|
||||||
window.location.replace(`${type}.html`);
|
window.location.replace(`${type}.html#/`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-5
@@ -133,6 +133,7 @@ import {
|
|||||||
} from './server_settings.ts';
|
} from './server_settings.ts';
|
||||||
import { getTimezoneOffsetMinutes } from './datetime.ts';
|
import { getTimezoneOffsetMinutes } from './datetime.ts';
|
||||||
import { generateRandomUUID } from './misc.ts';
|
import { generateRandomUUID } from './misc.ts';
|
||||||
|
import { getBasePath } from './web.ts';
|
||||||
|
|
||||||
interface ApiRequestConfig extends AxiosRequestConfig {
|
interface ApiRequestConfig extends AxiosRequestConfig {
|
||||||
readonly headers: AxiosRequestHeaders;
|
readonly headers: AxiosRequestHeaders;
|
||||||
@@ -147,7 +148,7 @@ export type ApiResponsePromise<T> = Promise<AxiosResponse<ApiResponse<T>>>;
|
|||||||
let needBlockRequest = false;
|
let needBlockRequest = false;
|
||||||
const blockedRequests: ((token: string | undefined) => void)[] = [];
|
const blockedRequests: ((token: string | undefined) => void)[] = [];
|
||||||
|
|
||||||
axios.defaults.baseURL = BASE_API_URL_PATH;
|
axios.defaults.baseURL = getBasePath() + BASE_API_URL_PATH;
|
||||||
axios.defaults.timeout = DEFAULT_API_TIMEOUT;
|
axios.defaults.timeout = DEFAULT_API_TIMEOUT;
|
||||||
axios.interceptors.request.use((config: ApiRequestConfig) => {
|
axios.interceptors.request.use((config: ApiRequestConfig) => {
|
||||||
const token = getCurrentToken();
|
const token = getCurrentToken();
|
||||||
@@ -560,11 +561,11 @@ export default {
|
|||||||
} as ApiRequestConfig);
|
} as ApiRequestConfig);
|
||||||
},
|
},
|
||||||
generateQrCodeUrl: (qrCodeName: string): string => {
|
generateQrCodeUrl: (qrCodeName: string): string => {
|
||||||
return `${BASE_QRCODE_PATH}/${qrCodeName}.png`;
|
return `${getBasePath()}${BASE_QRCODE_PATH}/${qrCodeName}.png`;
|
||||||
},
|
},
|
||||||
generateMapProxyTileImageUrl: (mapProvider: string, language: string): string => {
|
generateMapProxyTileImageUrl: (mapProvider: string, language: string): string => {
|
||||||
const token = getCurrentToken();
|
const token = getCurrentToken();
|
||||||
let url = `${BASE_PROXY_URL_PATH}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
let url = `${getBasePath()}${BASE_PROXY_URL_PATH}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
url = url + `&language=${language}`;
|
url = url + `&language=${language}`;
|
||||||
@@ -574,7 +575,7 @@ export default {
|
|||||||
},
|
},
|
||||||
generateMapProxyAnnotationImageUrl: (mapProvider: string, language: string): string => {
|
generateMapProxyAnnotationImageUrl: (mapProvider: string, language: string): string => {
|
||||||
const token = getCurrentToken();
|
const token = getCurrentToken();
|
||||||
let url = `${BASE_PROXY_URL_PATH}/map/annotation/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
let url = `${getBasePath()}${BASE_PROXY_URL_PATH}/map/annotation/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
url = url + `&language=${language}`;
|
url = url + `&language=${language}`;
|
||||||
@@ -598,7 +599,7 @@ export default {
|
|||||||
return `${AMAP_JAVASCRIPT_URL}&key=${getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`;
|
return `${AMAP_JAVASCRIPT_URL}&key=${getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`;
|
||||||
},
|
},
|
||||||
generateAmapApiInternalProxyUrl: (): string => {
|
generateAmapApiInternalProxyUrl: (): string => {
|
||||||
return `${window.location.origin}${BASE_AMAP_API_PROXY_URL_PATH}`;
|
return `${window.location.origin}${getBasePath()}${BASE_AMAP_API_PROXY_URL_PATH}`;
|
||||||
},
|
},
|
||||||
getInternalAvatarUrlWithToken(avatarUrl: string, disableBrowserCache?: boolean | string): string {
|
getInternalAvatarUrlWithToken(avatarUrl: string, disableBrowserCache?: boolean | string): string {
|
||||||
if (!avatarUrl) {
|
if (!avatarUrl) {
|
||||||
|
|||||||
+6
-4
@@ -1,3 +1,5 @@
|
|||||||
|
import { getBasePath } from './web.ts';
|
||||||
|
|
||||||
export function isProduction(): boolean {
|
export function isProduction(): boolean {
|
||||||
return __EZBOOKKEEPING_IS_PRODUCTION__;
|
return __EZBOOKKEEPING_IS_PRODUCTION__;
|
||||||
}
|
}
|
||||||
@@ -28,15 +30,15 @@ export function getBuildTime(): string {
|
|||||||
|
|
||||||
export function getMobileVersionPath(): string {
|
export function getMobileVersionPath(): string {
|
||||||
if (isProduction()) {
|
if (isProduction()) {
|
||||||
return '../mobile';
|
return getBasePath() + '/mobile#/';
|
||||||
} else {
|
} else {
|
||||||
return 'mobile.html';
|
return getBasePath() + '/mobile.html#/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function getDesktopVersionPath(): string {
|
export function getDesktopVersionPath(): string {
|
||||||
if (isProduction()) {
|
if (isProduction()) {
|
||||||
return '../desktop';
|
return getBasePath() + '/desktop#/';
|
||||||
} else {
|
} else {
|
||||||
return 'desktop.html';
|
return getBasePath() + '/desktop.html#/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
export function getBasePath(): string {
|
||||||
|
const path = window.location.pathname;
|
||||||
|
const lastSlashIndex = path.lastIndexOf('/');
|
||||||
|
|
||||||
|
if (lastSlashIndex < 0) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path.substring(0, lastSlashIndex);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user