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