Merge branch 'develop' into swn

This commit is contained in:
tamaina
2021-08-25 08:32:38 +09:00
25 changed files with 142 additions and 24 deletions

View File

@@ -149,6 +149,10 @@ export const meta = {
validator: $.optional.nullable.str,
},
deeplIsPro: {
validator: $.optional.bool,
},
enableTwitterIntegration: {
validator: $.optional.bool,
},
@@ -574,6 +578,10 @@ export default define(meta, async (ps, me) => {
}
}
if (ps.deeplIsPro !== undefined) {
set.deeplIsPro = ps.deeplIsPro;
}
await getConnection().transaction(async transactionalEntityManager => {
const meta = await transactionalEntityManager.findOne(Meta, {
order: {

View File

@@ -583,6 +583,8 @@ export default define(meta, async (ps, me) => {
response.objectStorageUseProxy = instance.objectStorageUseProxy;
response.objectStorageSetPublicRead = instance.objectStorageSetPublicRead;
response.objectStorageS3ForcePathStyle = instance.objectStorageS3ForcePathStyle;
response.deeplAuthKey = instance.deeplAuthKey;
response.deeplIsPro = instance.deeplIsPro;
}
}

View File

@@ -61,7 +61,9 @@ export default define(meta, async (ps, user) => {
params.append('text', note.text);
params.append('target_lang', targetLang);
const res = await fetch('https://api-free.deepl.com/v2/translate', {
const endpoint = instance.deeplIsPro ? 'https://api.deepl.com/v2/translate' : 'https://api-free.deepl.com/v2/translate';
const res = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',

View File

@@ -17,6 +17,10 @@ const _dirname = dirname(_filename);
// Init app
const app = new Koa();
app.use(cors());
app.use(async (ctx, next) => {
ctx.set('Content-Security-Policy', `default-src 'none'; style-src 'unsafe-inline'`);
await next();
});
// Init router
const router = new Router();

View File

@@ -10,6 +10,10 @@ import { proxyMedia } from './proxy-media';
// Init app
const app = new Koa();
app.use(cors());
app.use(async (ctx, next) => {
ctx.set('Content-Security-Policy', `default-src 'none'; style-src 'unsafe-inline'`);
await next();
});
// Init router
const router = new Router();

View File

@@ -60,8 +60,6 @@
? `?salt=${localStorage.getItem('salt')}`
: '';
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');
script.setAttribute('src', `/assets/app.${v}.js${salt}`);
script.setAttribute('async', 'true');
@@ -70,7 +68,7 @@
renderError('APP_FETCH_FAILED');
checkUpdate();
});
head.appendChild(script);
document.head.appendChild(script);
//#endregion
//#region Theme
@@ -111,7 +109,7 @@
if (customCss && customCss.length > 0) {
const style = document.createElement('style');
style.innerHTML = customCss;
head.appendChild(style);
document.head.appendChild(style);
}
// eslint-disable-next-line no-inner-declarations