diff --git a/src/Add-on/ShareView/Command_ShareView.ts b/src/Add-on/ShareView/Command_ShareView.ts index eedf3744f..bfdfaaf49 100644 --- a/src/Add-on/ShareView/Command_ShareView.ts +++ b/src/Add-on/ShareView/Command_ShareView.ts @@ -101,6 +101,8 @@ export class Command_ShareView implements Command formData.append("logo", GetCurrentViewPreViewImage() as Blob, "cover.jpg"); formData.append("file", deflate(f.ToString())); formData.append("props", props); + if (store.m_Option.expireDays) + formData.append("expire_days", store.m_Option.expireDays); fetch(CURRENT_HOST + "/CAD-viewerUpload", { method: "POST", diff --git a/src/Add-on/ShareView/ShareViewStore.ts b/src/Add-on/ShareView/ShareViewStore.ts index 345d88886..02e6087c7 100644 --- a/src/Add-on/ShareView/ShareViewStore.ts +++ b/src/Add-on/ShareView/ShareViewStore.ts @@ -1,6 +1,7 @@ import { observable, toJS } from "mobx"; import { Singleton } from "../../Common/Singleton"; +import { safeEval } from "../../Common/eval"; import { Board } from "../../DatabaseServices/Entity/Board"; import { DefaultShareBoardInfConfigurationOption } from "../../Editor/DefaultConfig"; import { IConfigOption } from "../../UI/Components/Board/UserConfigComponent"; @@ -48,6 +49,14 @@ export class ShareViewStore extends Singleton implements IConfigStore @observable viewUploadProps: ShareBoardInfConfigurationOption = DefaultShareBoardInfConfigurationOption; @observable configName = "默认"; + + HasInvailValue() + { + let val = safeEval(this.m_Option.expireDays); + if (this.m_Option.expireDays !== "" && (isNaN(val) || val != Math.floor(val) || val <= 0)) + return "有效天数必须是大于0的整数"; + return ""; + } SaveConfig() { //新的配置 @@ -63,6 +72,11 @@ export class ShareViewStore extends Singleton implements IConfigStore } UpdateOption(cof: IConfigOption) { + if (!cof.option.version) + { + cof.option.version = 1; + cof.option.expireDays = ""; + } Object.assign(this.m_Option, cof.option); } diff --git a/src/Add-on/ShareView/components/ColorSelect.tsx b/src/Add-on/ShareView/components/ColorSelect.tsx index 3ec6c580f..f7322f9a7 100644 --- a/src/Add-on/ShareView/components/ColorSelect.tsx +++ b/src/Add-on/ShareView/components/ColorSelect.tsx @@ -109,7 +109,7 @@ export function ColorSelect({ value, onChange, options }: SelectProps) setIsOpen(false); }} onMouseEnter={() => setHighlightedIndex(index)} - key={option.value} + key={option.label.toString()} className={`option ${isOptionSelected(index) ? "selected" : ""} ${index === highlightedIndex ? "highlighted" : ""}`} > {option.label}. diff --git a/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx b/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx index 497aea2c2..a4c3f2ea0 100644 --- a/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx +++ b/src/Add-on/ShareView/components/ShareBoardInfoConfiguration.tsx @@ -3,11 +3,12 @@ import { observer } from "mobx-react"; import React from "react"; import { begin } from "xaop"; import { app } from "../../../ApplicationServices/Application"; +import { CheckObjectType } from "../../../Common/CheckoutVaildValue"; import { ColorPalette } from "../../../Common/ColorPalette"; import { KeyBoard } from "../../../Common/KeyEnum"; import { BoardModalType } from "../../../UI/Components/Board/BoardModalType"; import { Config_ModalType, UserConfigComponent } from "../../../UI/Components/Board/UserConfigComponent"; -import { AppToaster } from "../../../UI/Components/Toaster"; +import { AppToaster, ToasterInput } from "../../../UI/Components/Toaster"; import { ViewAngleTypes, ViewStyleTypes } from "../ShareViewRules"; import { ShareViewStore } from "../ShareViewStore"; import { ColorSelect } from "./ColorSelect"; @@ -129,6 +130,12 @@ export class ShareBoardInfoConfiguration extends React.Component<{ store: ShareV onChange={(e) => { option.VisualStyle = parseInt(e.target.value); }} /> +
+ 有效天数: + +
@@ -137,7 +144,20 @@ export class ShareBoardInfoConfiguration extends React.Component<{ store: ShareV
diff --git a/src/Add-on/ShareView/components/ShareBoradModal.less b/src/Add-on/ShareView/components/ShareBoradModal.less index f2d2c5e35..66f634738 100644 --- a/src/Add-on/ShareView/components/ShareBoradModal.less +++ b/src/Add-on/ShareView/components/ShareBoradModal.less @@ -6,6 +6,13 @@ label{ width: fit-content; } + + .label { + .bp3-input.expire-days { + height: 28px; + width: 95px; + } + } } .bp3-dialog-footer{ diff --git a/src/Common/CheckoutVaildValue.ts b/src/Common/CheckoutVaildValue.ts index 23701bbfd..fd4d61e45 100644 --- a/src/Common/CheckoutVaildValue.ts +++ b/src/Common/CheckoutVaildValue.ts @@ -24,6 +24,7 @@ export enum CheckObjectType BF = "boardFind",//查找修改 CONF = "configuration",//配置 Modeling2Depth = "modeling2Depth",// 大于0且支持BH + ExpireDays = "expireDays", //过期天数 } export namespace CheckoutValid @@ -90,6 +91,7 @@ export namespace CheckoutValid } export function CheckOption(type: CheckObjectType, k: string, v: string) { + let val: number; switch (type) { case CheckObjectType.BR: @@ -133,7 +135,7 @@ export namespace CheckoutValid case CheckObjectType.SmoothEdge: if (!isNum(v)) return "数值不能为空且必须为数字"; - let val = safeEval(v); + val = safeEval(v); if (val < 0) return "数值不能小于0"; case CheckObjectType.Modeling2Depth: @@ -143,6 +145,10 @@ export namespace CheckoutValid return "表达式错误"; if (safeEval(v) < 0) return "数值不能小于0"; + case CheckObjectType.ExpireDays: + val = safeEval(v); + if (v !== "" && (isNaN(val) || val != Math.floor(val) || val <= 0)) + return "请输入大于0的整数"; default: return ""; } diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index 6178fcbb3..2fddadae4 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -1061,12 +1061,14 @@ export const DefaultChangeColorByBoardMaterialOption: ChangeColorByBoardMaterial Object.freeze(DefaultChangeColorByBoardMaterialOption); export const DefaultShareBoardInfConfigurationOption: ShareBoardInfConfigurationOption = { + version: 1, Physical2EdgeColor: 7, VisualStyle: RenderType.Conceptual, Viewport: ViewDirection.Southwest, IsExportBoard: true, IsExportHardware: true, showBom: true, + expireDays: "", }; Object.freeze(DefaultShareBoardInfConfigurationOption); diff --git a/src/UI/Store/OptionInterface/IOptionInterface.ts b/src/UI/Store/OptionInterface/IOptionInterface.ts index f5c1ac2cd..d2b7410a8 100644 --- a/src/UI/Store/OptionInterface/IOptionInterface.ts +++ b/src/UI/Store/OptionInterface/IOptionInterface.ts @@ -313,7 +313,7 @@ export interface ChangeColorByBoardMaterialOption accordMaterialColor: boolean; } -export interface ShareBoardInfConfigurationOption +export interface ShareBoardInfConfigurationOption extends IBaseOption { Physical2EdgeColor: number; //真实带线框颜色 VisualStyle: RenderType; //视觉样式 @@ -321,6 +321,7 @@ export interface ShareBoardInfConfigurationOption IsExportBoard: boolean; //是否导出板件 IsExportHardware: boolean; //是否导出五金 showBom: boolean; //是否展示物料明细 + expireDays: string; //有效天数 } export interface ProcessingGroupOption