refactor: Update public and API base URL functions in company and detail pages for improved clarity
This commit is contained in:
@@ -104,14 +104,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 反向代理子路径(如 /api/shihezi)下,依据当前页面路径推导 API 前缀,
|
||||
// 保证 /app/... 请求带上子路径,避免落到根路径 404。
|
||||
function apiBase() {
|
||||
// 页面和 API 使用不同的代理前缀:
|
||||
// 页面:/shihezi/h5/...
|
||||
// API:/api/shihezi/...
|
||||
function publicBase() {
|
||||
var path = window.location.pathname;
|
||||
var idx = path.indexOf('/h5/');
|
||||
return idx > 0 ? path.slice(0, idx) : '';
|
||||
}
|
||||
|
||||
function apiBase() {
|
||||
return '/api' + publicBase();
|
||||
}
|
||||
|
||||
function apiUrl() {
|
||||
if (deviceCode) {
|
||||
return apiBase() + '/app/outdoor-fair/company-page?deviceCode=' + encodeURIComponent(deviceCode);
|
||||
@@ -165,7 +170,7 @@
|
||||
'</section>' +
|
||||
'<div class="actions">' +
|
||||
'<button type="button" class="btn checkin" id="checkinBtn">签到</button>' +
|
||||
'<a class="btn" href="' + escapeHtml(apiBase() + '/h5/outdoor-fair/detail.html?fairId=' + pageFairId) + '">查看招聘会</a>' +
|
||||
'<a class="btn" href="' + escapeHtml(publicBase() + '/h5/outdoor-fair/detail.html?fairId=' + pageFairId) + '">查看招聘会</a>' +
|
||||
'</div>' +
|
||||
'<section class="section">' +
|
||||
'<h2>企业信息</h2>' +
|
||||
|
||||
@@ -88,14 +88,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 反向代理子路径(如 /api/shihezi)下,依据当前页面路径推导 API 前缀,
|
||||
// 保证 /app/... 请求带上子路径,避免落到根路径 404。
|
||||
function apiBase() {
|
||||
// 页面和 API 使用不同的代理前缀:
|
||||
// 页面:/shihezi/h5/...
|
||||
// API:/api/shihezi/...
|
||||
function publicBase() {
|
||||
var path = window.location.pathname;
|
||||
var idx = path.indexOf('/h5/');
|
||||
return idx > 0 ? path.slice(0, idx) : '';
|
||||
}
|
||||
|
||||
function apiBase() {
|
||||
return '/api' + publicBase();
|
||||
}
|
||||
|
||||
function render(data) {
|
||||
var fair = data.fair || {};
|
||||
pageFairId = (fair.id !== null && fair.id !== undefined) ? fair.id : fairId;
|
||||
|
||||
Reference in New Issue
Block a user