fix i18n
This commit is contained in:
@@ -6,60 +6,55 @@ import { MobileButton } from 'kintone-ui-component/lib/mobile/button';
|
||||
|
||||
(function (PLUGIN_ID) {
|
||||
kintone.events.on('mobile.app.record.index.show', () => {
|
||||
// 授权了才能使用
|
||||
LicenseService.loadPluginIfAuthorized(PLUGIN_ID,
|
||||
async () => {
|
||||
// 获取当前应用ID
|
||||
const appIdNum = kintone.mobile.app.getId();
|
||||
if (!appIdNum) {
|
||||
return;
|
||||
};
|
||||
const appId = appIdNum.toString();
|
||||
// 授权了才能使用
|
||||
LicenseService.loadPluginIfAuthorized(PLUGIN_ID,
|
||||
async () => {
|
||||
// 获取当前应用ID
|
||||
const appIdNum = kintone.mobile.app.getId();
|
||||
if (!appIdNum) {
|
||||
return;
|
||||
};
|
||||
const appId = appIdNum.toString();
|
||||
|
||||
// 从插件配置中读取设置信息
|
||||
const setting: Setting = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||
// 从插件配置中读取设置信息
|
||||
const setting: Setting = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||
|
||||
// 检查按钮是否已存在,防止翻页时重复添加
|
||||
const btnId = 'template-btn-id';
|
||||
if (document.getElementById(btnId)) {
|
||||
return;
|
||||
};
|
||||
// 检查按钮是否已存在,防止翻页时重复添加
|
||||
const btnId = 'template-btn-id';
|
||||
if (document.getElementById(btnId)) {
|
||||
return;
|
||||
};
|
||||
|
||||
// 获取 Header 容器元素
|
||||
const headerSpace = kintone.mobile.app.getHeaderSpaceElement();
|
||||
if (!headerSpace) {
|
||||
throw new Error('このページではヘッダー要素が利用できません。');
|
||||
// 测试 i18n
|
||||
const { t } = i18n.global;
|
||||
|
||||
// 获取 Header 容器元素
|
||||
const headerSpace = kintone.mobile.app.getHeaderSpaceElement();
|
||||
if (!headerSpace) {
|
||||
throw new Error(t('error.noAreaError'));
|
||||
}
|
||||
|
||||
// 创建按钮
|
||||
const button = new MobileButton({
|
||||
text: setting.buttonName,
|
||||
type: 'submit',
|
||||
id: btnId,
|
||||
});
|
||||
button.addEventListener('click', async () => {
|
||||
try {
|
||||
// 测试 KintoneRestAPIClient,显示所有已启用的插件名
|
||||
const { plugins } = await client.app.getPlugins({
|
||||
app: appId,
|
||||
});
|
||||
const pluginsInfo = plugins.map((p) => p.name).join('、');
|
||||
|
||||
const message = t('hello') + "\n" + setting.message + '\n--------\n【Plugins】 ' + pluginsInfo;
|
||||
alert(message);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch plugins:', error);
|
||||
}
|
||||
|
||||
// 测试 i18n
|
||||
const { t } = i18n.global;
|
||||
|
||||
// 创建按钮
|
||||
const button = new MobileButton({
|
||||
text: setting.buttonName,
|
||||
type: 'submit',
|
||||
id: btnId,
|
||||
});
|
||||
button.addEventListener('click', async () => {
|
||||
try {
|
||||
// 测试 KintoneRestAPIClient,显示所有已启用的插件名
|
||||
const { plugins } = await client.app.getPlugins({
|
||||
app: appId,
|
||||
});
|
||||
const pluginsInfo = plugins.map((p) => p.name).join('、');
|
||||
|
||||
const message = t('hello') + "\n" + setting.message + '\n--------\n【Plugins】 ' + pluginsInfo;
|
||||
alert(message);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch plugins:', error);
|
||||
}
|
||||
});
|
||||
headerSpace.appendChild(button);
|
||||
},
|
||||
{
|
||||
expiryDialogTitle: '自定义插件到期提示',
|
||||
expiryDialogMessage: '您的自定义插件许可证已过期,请联系管理员购买新的许可证。',
|
||||
// warningDialogMessage: '您的自定义插件许可证还有3天就到期了,请及时续费。',
|
||||
});
|
||||
headerSpace.appendChild(button);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user