fix ts
This commit is contained in:
@@ -106,15 +106,18 @@ export class SelfKintoneClient {
|
||||
| Awaited<AppCustomizeResponse>["desktop"]["js"][number]
|
||||
| Awaited<AppCustomizeResponse>["desktop"]["css"][number],
|
||||
): JSFileConfig | CSSFileConfig {
|
||||
if (resource.type === "FILE") {
|
||||
return {
|
||||
type: "FILE",
|
||||
file: {
|
||||
fileKey: resource.file.fileKey,
|
||||
name: resource.file.name,
|
||||
size: parseInt(resource.file.size, 10),
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: resource.type,
|
||||
file: resource.file
|
||||
? {
|
||||
fileKey: resource.file.fileKey,
|
||||
name: resource.file.name,
|
||||
size: parseInt(resource.file.size, 10),
|
||||
}
|
||||
: undefined,
|
||||
type: "URL",
|
||||
url: resource.url,
|
||||
};
|
||||
}
|
||||
@@ -122,20 +125,19 @@ export class SelfKintoneClient {
|
||||
private buildCustomizeSection(
|
||||
js?: JSFileConfig[],
|
||||
css?: CSSFileConfig[],
|
||||
): Parameters<KintoneClient["app"]["updateAppCustomize"]>[0] | undefined {
|
||||
): Parameters<KintoneClient["app"]["updateAppCustomize"]>[0]["desktop"] {
|
||||
if (!js && !css) return undefined;
|
||||
|
||||
const mapItem = (item: JSFileConfig | CSSFileConfig) => {
|
||||
if (item.type === "FILE" && item.file) {
|
||||
return { type: "FILE" as const, file: { fileKey: item.file.fileKey } };
|
||||
}
|
||||
return { type: "URL" as const, url: item.url || "" };
|
||||
};
|
||||
|
||||
return {
|
||||
js: js?.map((item) => ({
|
||||
type: item.type,
|
||||
file: item.file ? { fileKey: item.file.fileKey } : undefined,
|
||||
url: item.url,
|
||||
})),
|
||||
css: css?.map((item) => ({
|
||||
type: item.type,
|
||||
file: item.file ? { fileKey: item.file.fileKey } : undefined,
|
||||
url: item.url,
|
||||
})),
|
||||
js: js?.map(mapItem),
|
||||
css: css?.map(mapItem),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -259,10 +261,14 @@ export class SelfKintoneClient {
|
||||
return this.withErrorHandling(async () => {
|
||||
await this.client.app.updateAppCustomize({
|
||||
app: appId,
|
||||
...this.buildCustomizeSection(
|
||||
desktop: this.buildCustomizeSection(
|
||||
config.javascript?.pc,
|
||||
config.stylesheet?.pc,
|
||||
),
|
||||
mobile: this.buildCustomizeSection(
|
||||
config.javascript?.mobile,
|
||||
config.stylesheet?.mobile,
|
||||
),
|
||||
scope: "ALL",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,32 +2,37 @@ import { contextBridge, ipcRenderer } from "electron";
|
||||
import { electronAPI } from "@electron-toolkit/preload";
|
||||
import type { SelfAPI } from "./index.d";
|
||||
|
||||
// Generic invoke helper - reduces boilerplate
|
||||
const invoke = <T>(channel: string, arg?: unknown): Promise<T> =>
|
||||
ipcRenderer.invoke(channel, arg);
|
||||
|
||||
// Custom APIs for renderer - bridges to IPC handlers
|
||||
const api: SelfAPI = {
|
||||
// Platform detection
|
||||
platform: process.platform,
|
||||
|
||||
// ==================== Domain Management ====================
|
||||
getDomains: () => ipcRenderer.invoke("getDomains"),
|
||||
createDomain: (params) => ipcRenderer.invoke("createDomain", params),
|
||||
updateDomain: (params) => ipcRenderer.invoke("updateDomain", params),
|
||||
deleteDomain: (id) => ipcRenderer.invoke("deleteDomain", id),
|
||||
testConnection: (id) => ipcRenderer.invoke("testConnection", id),
|
||||
testDomainConnection: (params) => ipcRenderer.invoke("testDomainConnection", params),
|
||||
// Domain management
|
||||
getDomains: () => invoke("getDomains"),
|
||||
createDomain: (params) => invoke("createDomain", params),
|
||||
updateDomain: (params) => invoke("updateDomain", params),
|
||||
deleteDomain: (id) => invoke("deleteDomain", id),
|
||||
testConnection: (id) => invoke("testConnection", id),
|
||||
testDomainConnection: (params) => invoke("testDomainConnection", params),
|
||||
|
||||
// ==================== Browse ====================
|
||||
getApps: (params) => ipcRenderer.invoke("getApps", params),
|
||||
// Browse
|
||||
getApps: (params) => invoke("getApps", params),
|
||||
getAppDetail: (params) => invoke("getAppDetail", params),
|
||||
getFileContent: (params) => invoke("getFileContent", params),
|
||||
|
||||
// ==================== Deploy ====================
|
||||
deploy: (params) => ipcRenderer.invoke("deploy", params),
|
||||
// Deploy
|
||||
deploy: (params) => invoke("deploy", params),
|
||||
|
||||
// ==================== Download ====================
|
||||
download: (params) => ipcRenderer.invoke("download", params),
|
||||
// Download
|
||||
download: (params) => invoke("download", params),
|
||||
|
||||
// ==================== Version Management ====================
|
||||
getVersions: (params) => ipcRenderer.invoke("getVersions", params),
|
||||
deleteVersion: (id) => ipcRenderer.invoke("deleteVersion", id),
|
||||
rollback: (params) => ipcRenderer.invoke("rollback", params),
|
||||
// Version management
|
||||
getVersions: (params) => invoke("getVersions", params),
|
||||
deleteVersion: (id) => invoke("deleteVersion", id),
|
||||
rollback: (params) => invoke("rollback", params),
|
||||
};
|
||||
|
||||
// Use `contextBridge` APIs to expose Electron APIs to
|
||||
|
||||
@@ -82,6 +82,9 @@ const useStyles = createStyles(({ token, css }) => ({
|
||||
color: ${token.colorTextSecondary};
|
||||
font-size: 12px;
|
||||
`,
|
||||
clockIcon: css`
|
||||
color: ${token.colorTextSecondary};
|
||||
`,
|
||||
}));
|
||||
|
||||
const AppList: React.FC = () => {
|
||||
@@ -208,9 +211,7 @@ const AppList: React.FC = () => {
|
||||
width: 180,
|
||||
render: (createdAt: string) => (
|
||||
<Space size={4}>
|
||||
<ClockCircleOutlined
|
||||
style={{ color: (token) => token.colorTextSecondary }}
|
||||
/>
|
||||
<ClockCircleOutlined className={styles.clockIcon} />
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{new Date(createdAt).toLocaleString("zh-CN")}
|
||||
</Text>
|
||||
|
||||
@@ -55,6 +55,8 @@ export interface GetSpacesParams {
|
||||
export interface GetAppsParams {
|
||||
domainId: string;
|
||||
spaceId?: string;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface GetAppDetailParams {
|
||||
|
||||
@@ -7,8 +7,11 @@
|
||||
"src/renderer/**/*",
|
||||
"src/shared/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*.d.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["electron-vite/node"],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user