mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: use vite
This commit is contained in:
15 files changed
+588
-31
No files matched your search
@@ -13,14 +13,14 @@ import getLoader from 'prismjs/dependencies';
|
||||
import Notification from 'vj/components/notification/index';
|
||||
import { i18n } from 'vj/utils';
|
||||
import languageMeta from './meta';
|
||||
import langs from 'prismjs/components/index';
|
||||
|
||||
const files = require.context('prismjs/components/', true, /prism-[a-z0-9-]+\.js/);
|
||||
const loadedLanguages = new Set();
|
||||
function loadLanguages() {
|
||||
const languages = Object.keys(components.languages).filter((l) => l !== 'meta');
|
||||
const loaded = [...loadedLanguages, ...Object.keys(Prism.languages)];
|
||||
getLoader(components, languages, loaded).load((lang) => {
|
||||
files(`./prism-${lang}.js`);
|
||||
langs[lang]?.();
|
||||
loadedLanguages.add(lang);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ const onmessage = (msg) => {
|
||||
|
||||
const initWorkerMode = (endpoint) => {
|
||||
console.log('Messages: using SharedWorker');
|
||||
const worker = new SharedWorker('/messages-shared-worker.js', { name: 'HydroMessagesWorker' });
|
||||
const worker = new SharedWorker(new URL('./worker.ts?worker', import.meta.url), { name: 'HydroMessagesWorker' });
|
||||
worker.port.start();
|
||||
window.addEventListener('beforeunload', () => {
|
||||
worker.port.postMessage({ type: 'unload' });
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
|
||||
export default function DataInputComponent(props) {
|
||||
const {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
|
||||
export default function ToolbarComponent(props) {
|
||||
const {
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import $ from 'jquery';
|
||||
import * as timeago from 'timeago.js';
|
||||
import en_US from 'timeago.js/lib/lang/en_US';
|
||||
import ko from 'timeago.js/lib/lang/ko';
|
||||
import zh_CN from 'timeago.js/lib/lang/zh_CN';
|
||||
import zh_TW from 'timeago.js/lib/lang/zh_TW';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import { i18n } from 'vj/utils';
|
||||
|
||||
try {
|
||||
const locales = require.context('timeago.js/lib/lang', false, /\.js$/);
|
||||
let locale;
|
||||
try {
|
||||
locale = locales(`./${i18n('timeago_locale')}.js`).default;
|
||||
} catch (e) {
|
||||
locale = locales('./en_US.js').default;
|
||||
}
|
||||
const locales = {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
zh_CN, zh_TW, ko, en_US,
|
||||
};
|
||||
const locale = locales[i18n('timeago_locale')] || locales.en_US;
|
||||
timeago.register(i18n('timeago_locale'), locale);
|
||||
} catch (e) {
|
||||
console.error(`Cannot register timeago locale: ${i18n('timeago_locale')}`);
|
||||
console.error(`Cannot register timeago locale: ${i18n('timeago_locale')}`, e);
|
||||
}
|
||||
function runRelativeTime($container) {
|
||||
$container.find('span.time.relative[data-timestamp]').get().forEach((element) => {
|
||||
|
||||
Reference in new issue
Block a user