fix format
This commit is contained in:
@@ -7,55 +7,53 @@ import { Button } from 'kintone-ui-component/lib/button';
|
|||||||
(function (PLUGIN_ID) {
|
(function (PLUGIN_ID) {
|
||||||
kintone.events.on('app.record.index.show', async () => {
|
kintone.events.on('app.record.index.show', async () => {
|
||||||
// 授权了才能使用
|
// 授权了才能使用
|
||||||
LicenseService.loadPluginIfAuthorized(PLUGIN_ID,
|
LicenseService.loadPluginIfAuthorized(PLUGIN_ID, async () => {
|
||||||
async () => {
|
// 获取当前应用ID
|
||||||
// 获取当前应用ID
|
const appIdNum = kintone.app.getId();
|
||||||
const appIdNum = kintone.app.getId();
|
if (!appIdNum) {
|
||||||
if (!appIdNum) {
|
return;
|
||||||
return;
|
}
|
||||||
|
const appId = appIdNum.toString();
|
||||||
|
|
||||||
|
// 从插件配置中读取设置信息
|
||||||
|
const setting: Setting = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||||
|
|
||||||
|
// 检查按钮是否已存在,防止翻页时重复添加
|
||||||
|
const btnId = 'template-btn-id';
|
||||||
|
if (document.getElementById(btnId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试 i18n
|
||||||
|
const { t } = i18n.global;
|
||||||
|
|
||||||
|
// 获取 Header 容器元素
|
||||||
|
const headerSpace = kintone.app.getHeaderMenuSpaceElement();
|
||||||
|
if (!headerSpace) {
|
||||||
|
throw new Error(t('error.noAreaError'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建按钮
|
||||||
|
const button = new Button({
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
const appId = appIdNum.toString();
|
});
|
||||||
|
headerSpace.appendChild(button);
|
||||||
// 从插件配置中读取设置信息
|
});
|
||||||
const setting: Setting = kintone.plugin.app.getConfig(PLUGIN_ID);
|
|
||||||
|
|
||||||
// 检查按钮是否已存在,防止翻页时重复添加
|
|
||||||
const btnId = 'template-btn-id';
|
|
||||||
if (document.getElementById(btnId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试 i18n
|
|
||||||
const { t } = i18n.global;
|
|
||||||
|
|
||||||
// 获取 Header 容器元素
|
|
||||||
const headerSpace = kintone.app.getHeaderMenuSpaceElement();
|
|
||||||
if (!headerSpace) {
|
|
||||||
throw new Error(t('error.noAreaError'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建按钮
|
|
||||||
const button = new Button({
|
|
||||||
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);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
})(kintone.$PLUGIN_ID);
|
})(kintone.$PLUGIN_ID);
|
||||||
|
|||||||
@@ -7,55 +7,53 @@ import { MobileButton } from 'kintone-ui-component/lib/mobile/button';
|
|||||||
(function (PLUGIN_ID) {
|
(function (PLUGIN_ID) {
|
||||||
kintone.events.on('mobile.app.record.index.show', () => {
|
kintone.events.on('mobile.app.record.index.show', () => {
|
||||||
// 授权了才能使用
|
// 授权了才能使用
|
||||||
LicenseService.loadPluginIfAuthorized(PLUGIN_ID,
|
LicenseService.loadPluginIfAuthorized(PLUGIN_ID, async () => {
|
||||||
async () => {
|
// 获取当前应用ID
|
||||||
// 获取当前应用ID
|
const appIdNum = kintone.mobile.app.getId();
|
||||||
const appIdNum = kintone.mobile.app.getId();
|
if (!appIdNum) {
|
||||||
if (!appIdNum) {
|
return;
|
||||||
return;
|
};
|
||||||
};
|
const appId = appIdNum.toString();
|
||||||
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';
|
const btnId = 'template-btn-id';
|
||||||
if (document.getElementById(btnId)) {
|
if (document.getElementById(btnId)) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 测试 i18n
|
// 测试 i18n
|
||||||
const { t } = i18n.global;
|
const { t } = i18n.global;
|
||||||
|
|
||||||
// 获取 Header 容器元素
|
// 获取 Header 容器元素
|
||||||
const headerSpace = kintone.mobile.app.getHeaderSpaceElement();
|
const headerSpace = kintone.mobile.app.getHeaderSpaceElement();
|
||||||
if (!headerSpace) {
|
if (!headerSpace) {
|
||||||
throw new Error(t('error.noAreaError'));
|
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);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// 创建按钮
|
headerSpace.appendChild(button);
|
||||||
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);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
})(kintone.$PLUGIN_ID);
|
})(kintone.$PLUGIN_ID);
|
||||||
Reference in New Issue
Block a user