optimize whole environment

This commit is contained in:
2025-06-02 18:13:18 +09:00
parent 4fbf2a4e81
commit 3f85eb8338
15 changed files with 578 additions and 483 deletions

View File

@@ -5,8 +5,6 @@ import ErrorFallback from '../common/ErrorFallback';
import Loading from '../common/Loading';
import MenuPanel from './MenuPanel';
import '@shin-chan/kypes';
interface DesktopAppProps {
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
}

View File

@@ -10,12 +10,10 @@ import { saveAs } from 'file-saver';
import moize from 'moize';
import PizZip from 'pizzip';
import invariant from 'tiny-invariant';
import { DOCX_CONTENTTYPE, LANGUAGE, PLUGIN_ID } from '../common/global';
import { DOCX_CONTENT_TYPE, LANGUAGE, PLUGIN_ID } from '../common/global';
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
import KintonePluginButton from '../common/ui/KintonePluginButton';
import '@shin-chan/kypes';
interface TemplateData {
[key: string]: TemplateData | TemplateData[] | string | string[];
}
@@ -191,32 +189,32 @@ const MenuPanel: React.FC<MenuPanelProps> = (props) => {
if (template === '') {
return (
<KintonePluginAlert>
WORD output plugin: Template field is not set. Please configure the plugin.
Word output plugin: Template field is not set. Please configure the plugin.
</KintonePluginAlert>
);
}
const record = event.record[template];
if (record == null) {
return <KintonePluginAlert>WORD output plugin: Template field is not available in this app.</KintonePluginAlert>;
return <KintonePluginAlert>Word output plugin: Template field is not available in this app.</KintonePluginAlert>;
}
if (record.type !== 'FILE') {
return <KintonePluginAlert>WORD output plugin: Template field must be a file field.</KintonePluginAlert>;
return <KintonePluginAlert>Word output plugin: Template field must be a file field.</KintonePluginAlert>;
}
if (record.value.length === 0) {
return <KintonePluginAlert>WORD output plugin: Template field does not contain any files.</KintonePluginAlert>;
return <KintonePluginAlert>Word output plugin: Template field does not contain any files.</KintonePluginAlert>;
}
if (record.value.length > 1) {
return (
<KintonePluginAlert>
WORD output plugin: Template field contains multiple files. Please ensure it contains only one file.
Word output plugin: Template field contains multiple files. Please ensure it contains only one file.
</KintonePluginAlert>
);
}
const { fileKey, contentType } = record.value[0];
if (contentType !== DOCX_CONTENTTYPE) {
if (contentType !== DOCX_CONTENT_TYPE) {
return (
<KintonePluginAlert>
WORD output plugin: The template file must be a DOCX file. The current file type is {contentType}.
Word output plugin: The template file must be a DOCX file. The current file type is {contentType}.
</KintonePluginAlert>
);
}
@@ -233,18 +231,18 @@ const MenuPanel: React.FC<MenuPanelProps> = (props) => {
parser: expressionParser,
});
doc.render(record2data(properties, event.record));
const out = doc.getZip().generate({ type: 'blob', mimeType: DOCX_CONTENTTYPE });
const out = doc.getZip().generate({ type: 'blob', mimeType: DOCX_CONTENT_TYPE });
saveAs(out, 'output.docx');
})
.catch((error) => {
console.error('Error downloading file:', error);
alert('Failed to download the WORD template file.');
alert('Failed to download the Word template file.');
});
};
return (
<KintonePluginButton variant="normal" onClick={handleOnClickOutputButton}>
WORD出力
Word出力
</KintonePluginButton>
);
};

View File

@@ -4,8 +4,6 @@ import ReactDOM from 'react-dom/client';
import invariant from 'tiny-invariant';
import DesktopApp from './DesktopApp';
import '@shin-chan/kypes';
import '../common/ui/51-modern-default.css';
kintone.events.on(