mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: fix tpl
This commit is contained in:
6 files changed
+13
-14
No files matched your search
@@ -111,7 +111,7 @@ Hydro 用户群:1085853538
|
||||
<details>
|
||||
<summary><h2>更新日志(点击展开)</h2></summary>
|
||||
|
||||
### Hydro 4.14.0 / UI 4.53.0
|
||||
### Hydro 4.14.0 / UI 4.53.1
|
||||
- core: 修复能够越权查看隐藏题目的问题 [security]
|
||||
- ui: 优化提交记录详情富文本展示
|
||||
- ui: 支持头像缓存
|
||||
|
||||
@@ -44,7 +44,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
|
||||
loader: 'esbuild-loader',
|
||||
options: {
|
||||
loader: 'tsx',
|
||||
target: 'es2015',
|
||||
target: 'es6',
|
||||
sourcemap: true,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -109,9 +109,8 @@ export default class DomDialog extends DOMAttachedObject {
|
||||
}
|
||||
|
||||
show() {
|
||||
if (this.isShown || this.isAnimating) {
|
||||
return Promise.reject();
|
||||
}
|
||||
if (this.isShown) return Promise.reject(new Error('dialog isShown'));
|
||||
if (this.isAnimating) return Promise.reject(new Error('dialog isAnimating'));
|
||||
const promise = new Promise<string>((resolve) => {
|
||||
this._resolve = resolve;
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ if (process.env.NODE_ENV === 'production' && UiContext.sentry_dsn) {
|
||||
if (!e.isUserFacingError) window._sentryEvents.push(e);
|
||||
};
|
||||
const script = document.createElement('script');
|
||||
script.src = new URL('/sentry.js', __webpack_public_path__).href;
|
||||
script.src = new URL('/sentry.js', UiContext.cdn_prefix).href;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.53.0",
|
||||
"version": "4.53.1",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "index.ts",
|
||||
|
||||
@@ -2,6 +2,7 @@ import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import DOMServer from 'react-dom/server';
|
||||
|
||||
export function substitute(str: string, obj: any) {
|
||||
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
|
||||
@@ -37,13 +38,12 @@ export function tpl<T extends boolean = false>(node: React.ReactNode, reactive?:
|
||||
export function tpl(pieces: TemplateStringsArray, ...substitutions: Substitution[]): string;
|
||||
export function tpl(pieces: TemplateStringsArray | React.ReactNode, ...substitutions: Substitution[] | boolean[]) {
|
||||
if (React.isValidElement(pieces)) {
|
||||
const div = document.createElement('div');
|
||||
const root = ReactDOM.createRoot(div);
|
||||
root.render(pieces);
|
||||
if (substitutions[0]) return div;
|
||||
const html = div.innerHTML;
|
||||
root.unmount();
|
||||
return html;
|
||||
if (substitutions[0]) {
|
||||
const div = document.createElement('div');
|
||||
ReactDOM.createRoot(div).render(pieces);
|
||||
return div;
|
||||
}
|
||||
return DOMServer.renderToStaticMarkup(pieces);
|
||||
}
|
||||
let result = pieces[0];
|
||||
for (let i = 0; i < substitutions.length; ++i) {
|
||||
|
||||
Reference in new issue
Block a user