mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: update polyfill
This commit is contained in:
7 files changed
+44
-13
No files matched your search
@@ -144,8 +144,18 @@ export async function apply(ctx: Context) {
|
|||||||
});
|
});
|
||||||
if (process.env.HYDRO_CLI) return;
|
if (process.env.HYDRO_CLI) return;
|
||||||
ctx.inject(['server'], ({ server, on }) => {
|
ctx.inject(['server'], ({ server, on }) => {
|
||||||
|
let endpoint = builtinConfig.file.endPoint;
|
||||||
|
if (builtinConfig.file.type === 's3' && !builtinConfig.file.pathStyle) {
|
||||||
|
try {
|
||||||
|
const parsed = new URL(builtinConfig.file.endPoint);
|
||||||
|
parsed.hostname = `${builtinConfig.file.bucket}.${parsed.hostname}`;
|
||||||
|
endpoint = parsed.toString();
|
||||||
|
} catch (e) {
|
||||||
|
logger.warn('Failed to parse file endpoint');
|
||||||
|
}
|
||||||
|
}
|
||||||
const proxyMiddleware = proxy('/fs', {
|
const proxyMiddleware = proxy('/fs', {
|
||||||
target: builtinConfig.file.endPoint,
|
target: endpoint,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (p) => p.replace('/fs', ''),
|
rewrite: (p) => p.replace('/fs', ''),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const {
|
|||||||
list,
|
list,
|
||||||
targets,
|
targets,
|
||||||
} = compat({
|
} = compat({
|
||||||
targets: '> 0.5%, chrome 80',
|
targets: '> 1%, chrome 70, firefox 60, safari 16, ios_saf 16, not ie 11, not op_mini all',
|
||||||
modules: [
|
modules: [
|
||||||
'core-js/stable',
|
'core-js/stable',
|
||||||
],
|
],
|
||||||
@@ -290,7 +290,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
|
|||||||
rewriteSources: (source) => source.replace('@hydrooj/ui-default/../../node_modules/', ''),
|
rewriteSources: (source) => source.replace('@hydrooj/ui-default/../../node_modules/', ''),
|
||||||
},
|
},
|
||||||
release: (process.env.CI && isNew) ? {
|
release: (process.env.CI && isNew) ? {
|
||||||
name: version,
|
name: `hydro-web@${version}`,
|
||||||
uploadLegacySourcemaps: root('public'),
|
uploadLegacySourcemaps: root('public'),
|
||||||
} : {},
|
} : {},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ const CustomSelectAutoComplete = React.forwardRef<any, any>((props, ref) => (
|
|||||||
<AutoComplete<DefaultProps>
|
<AutoComplete<DefaultProps>
|
||||||
ref={ref as any}
|
ref={ref as any}
|
||||||
fetchItems={(keys) => props.data.filter((i) => (i._id ? keys.includes(i._id) : keys.includes(i)))}
|
fetchItems={(keys) => props.data.filter((i) => (i._id ? keys.includes(i._id) : keys.includes(i)))}
|
||||||
queryItems={(query) => props.data.filter((i) => (i.name
|
queryItems={(query) => props.data.filter((i) => (i.name || i).toString().toLowerCase().includes(query.toLowerCase()))}
|
||||||
? i.name.toLowerCase().match(query.toLowerCase())
|
|
||||||
: i.toString().toLowerCase().match(query.toLowerCase())
|
|
||||||
))}
|
|
||||||
itemText={(item) => `${item.name || item}`}
|
itemText={(item) => `${item.name || item}`}
|
||||||
itemKey={(item) => `${item._id?.toString() || item.name || item}`}
|
itemKey={(item) => `${item._id?.toString() || item.name || item}`}
|
||||||
renderItem={(item) => `${item.name || item}`}
|
renderItem={(item) => `${item.name || item}`}
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ console.log(
|
|||||||
window.UiContext = JSON.parse(window.UiContext);
|
window.UiContext = JSON.parse(window.UiContext);
|
||||||
window.UserContext = JSON.parse(window.UserContext);
|
window.UserContext = JSON.parse(window.UserContext);
|
||||||
if (process.env.NODE_ENV === 'production' && !UiContext.sentry_disable) {
|
if (process.env.NODE_ENV === 'production' && !UiContext.sentry_disable) {
|
||||||
window.captureException = (e) => Sentry.captureException(e);
|
window.captureException = (e) => {
|
||||||
|
if (!e.isUserFacingError) Sentry.captureException(e);
|
||||||
|
};
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: UiContext.sentry_dsn || 'https://2f95d53751e08c74c1af1c4b93ccaff7@sentry.hydro.ac/2',
|
dsn: UiContext.sentry_dsn || 'https://2f95d53751e08c74c1af1c4b93ccaff7@sentry.hydro.ac/2',
|
||||||
release: process.env.VERSION,
|
release: `hydro-web@${process.env.VERSION}`,
|
||||||
integrations: [
|
integrations: [
|
||||||
Sentry.browserTracingIntegration(),
|
Sentry.browserTracingIntegration(),
|
||||||
Sentry.replayIntegration(),
|
Sentry.replayIntegration(),
|
||||||
|
|||||||
@@ -17,6 +17,18 @@ if (window.MediaQueryList && !MediaQueryList.prototype.addEventListener) {
|
|||||||
MediaQueryList.prototype.addListener(listener);
|
MediaQueryList.prototype.addListener(listener);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (typeof window['WeakRef'] === 'undefined') {
|
||||||
|
// @ts-ignore
|
||||||
|
window.WeakRef = (function (wm) {
|
||||||
|
function WeakRef(target) {
|
||||||
|
wm.set(this, target);
|
||||||
|
}
|
||||||
|
WeakRef.prototype.deref = function () {
|
||||||
|
return wm.get(this);
|
||||||
|
};
|
||||||
|
return WeakRef;
|
||||||
|
}(new WeakMap()));
|
||||||
|
}
|
||||||
if (!(window.matchMedia('all').addListener || window.matchMedia('all').addEventListener)) {
|
if (!(window.matchMedia('all').addListener || window.matchMedia('all').addEventListener)) {
|
||||||
const localMatchMedia = window.matchMedia;
|
const localMatchMedia = window.matchMedia;
|
||||||
const hasMediaQueries = localMatchMedia('only all').matches;
|
const hasMediaQueries = localMatchMedia('only all').matches;
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ export const zIndexManager = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const request = {
|
export const request = {
|
||||||
async ajax(options: Record<string, any>) {
|
ajax(options: Record<string, any>) {
|
||||||
|
const stack = new Error().stack;
|
||||||
return new Promise<any>((resolve, reject) => {
|
return new Promise<any>((resolve, reject) => {
|
||||||
$
|
$
|
||||||
.ajax({
|
.ajax({
|
||||||
@@ -96,9 +97,12 @@ export const request = {
|
|||||||
if (textStatus === 'abort') {
|
if (textStatus === 'abort') {
|
||||||
const err = new Error(i18n('Aborted')) as any;
|
const err = new Error(i18n('Aborted')) as any;
|
||||||
err.aborted = true;
|
err.aborted = true;
|
||||||
|
err.isUserFacingError = true;
|
||||||
reject(err);
|
reject(err);
|
||||||
} else if (jqXHR.readyState === 0) {
|
} else if (jqXHR.readyState === 0) {
|
||||||
reject(new Error(i18n('Network error')));
|
const err = new Error(i18n('Network error')) as any;
|
||||||
|
err.isUserFacingError = true;
|
||||||
|
reject(err);
|
||||||
} else if (typeof jqXHR.responseJSON === 'object' && jqXHR.responseJSON.error) {
|
} else if (typeof jqXHR.responseJSON === 'object' && jqXHR.responseJSON.error) {
|
||||||
const { error } = jqXHR.responseJSON;
|
const { error } = jqXHR.responseJSON;
|
||||||
if (error.params) {
|
if (error.params) {
|
||||||
@@ -117,6 +121,9 @@ export const request = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.done(resolve);
|
.done(resolve);
|
||||||
|
}).catch((e: Error) => {
|
||||||
|
e.stack = stack;
|
||||||
|
throw e;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,14 @@ declare global {
|
|||||||
|
|
||||||
const defaultDict = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
const defaultDict = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
||||||
|
|
||||||
String.random = function random(digit = 32, dict = defaultDict) {
|
export function randomstring(digit = 32, dict = defaultDict) {
|
||||||
let str = '';
|
let str = '';
|
||||||
for (let i = 1; i <= digit; i++) str += dict[Math.floor(Math.random() * dict.length)];
|
for (let i = 1; i <= digit; i++) str += dict[Math.floor(Math.random() * dict.length)];
|
||||||
return str;
|
return str;
|
||||||
};
|
}
|
||||||
|
try {
|
||||||
|
String.random = randomstring;
|
||||||
|
} catch (e) { } // Cannot add property random, object is not extensible
|
||||||
|
|
||||||
String.prototype.format ||= function formatStr(...args) {
|
String.prototype.format ||= function formatStr(...args) {
|
||||||
let result = this;
|
let result = this;
|
||||||
|
|||||||
Reference in new issue
Block a user