mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core&ui: add cdn_dynamic
This commit is contained in:
3 files changed
+6
-2
No files matched your search
@@ -24,7 +24,7 @@ for (const country of countries) {
|
||||
const tz = moment.tz.zonesForCountry(country);
|
||||
for (const t of tz) tzs.add(t);
|
||||
}
|
||||
const timezones = Array.from(tzs).sort().map((tz) => [tz, tz]) as [string, string][];
|
||||
const timezones = [...tzs].sort().map((tz) => [tz, tz]) as [string, string][];
|
||||
const langRange: Dictionary<string> = {};
|
||||
|
||||
export const FLAG_HIDDEN = 1;
|
||||
@@ -320,6 +320,7 @@ SystemSetting(Schema.object({
|
||||
url: Schema.string().default('/').description('Server BaseURL'),
|
||||
upload: Schema.string().default('256m').description('Max upload file size'),
|
||||
cdn: Schema.string().default('/').description('CDN Prefix'),
|
||||
cdn_dynamic: Schema.boolean().default(false).description('Dynamic CDN'),
|
||||
ws: Schema.string().default('/').description('WebSocket Prefix'),
|
||||
host: Schema.string().default('127.0.0.1').description('Listen host'),
|
||||
port: Schema.number().step(1).min(1).max(65535).default(8888).description('Server Port'),
|
||||
|
||||
@@ -8,11 +8,13 @@ import token from '../../model/token';
|
||||
|
||||
export interface UiContextBase {
|
||||
cdn_prefix: string;
|
||||
cdn_dynamic: boolean;
|
||||
url_prefix: string;
|
||||
ws_prefix: string;
|
||||
}
|
||||
export const UiContextBase: UiContextBase = {
|
||||
cdn_prefix: '/',
|
||||
cdn_dynamic: false,
|
||||
url_prefix: '/',
|
||||
ws_prefix: '/',
|
||||
};
|
||||
@@ -29,6 +31,7 @@ export default async (ctx: KoaContext, next: Next) => {
|
||||
if (UiContext.cdn_prefix.includes(',')) UiContext.cdn_prefix = randomPick(UiContext.cdn_prefix.split(','));
|
||||
UiContext.ws_prefix = system.get('server.ws');
|
||||
if (UiContext.ws_prefix.includes(',')) UiContext.ws_prefix = randomPick(UiContext.ws_prefix.split(','));
|
||||
UiContext.cdn_dynamic = system.get('server.cdn_dynamic');
|
||||
}
|
||||
UiContext.domainId = domainId;
|
||||
UiContext.domain = domainInfo;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</head>
|
||||
<body>
|
||||
{% if not isIE(handler.request.headers['user-agent']) and not handler.session.legacy %}
|
||||
<script type="text/javascript" src="/resource/{{ UiContext.constantVersion }}/entry.js"></script>
|
||||
<script type="text/javascript" src="{{ UiContext.cdn_prefix if UiContext.cdn_dynamic else '/' }}resource/{{ UiContext.constantVersion }}/entry.js"></script>
|
||||
<script type="text/javascript" src="{{ UiContext.cdn_prefix }}resource/{{ global.Hydro.version['ui-default'] }}/lang-{{ _('__id') }}.js"></script>
|
||||
<script type="text/javascript" src="{{ UiContext.cdn_prefix }}hydro-{{ global.Hydro.version['ui-default'] }}.js{% if process.env.DEV %}?version=dev{% endif %}"></script>
|
||||
{% endif %}
|
||||
|
||||
Reference in new issue
Block a user