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