|
@@ -6,8 +6,9 @@ import NavBarNormal from "@/components/NavBarNormal/index";
|
|
|
import WemetaTextarea from "@/components/wemeta-textarea/index";
|
|
|
import WemetaInput from "@/components/wemeta-input/index";
|
|
|
import ButtonMain from "@/components/buttons/ButtonMain";
|
|
|
+import FormitemSingleImage from '@/components/Form/FormItemSingleImage'
|
|
|
+import IconDeleteGray16 from "@/components/icon/IconDeleteGray16";
|
|
|
|
|
|
-import editorStyle from "../editor.module.less";
|
|
|
import style from "./index.module.less";
|
|
|
|
|
|
import BottomBar from "@/components/BottomBar";
|
|
@@ -30,27 +31,9 @@ export default function Index() {
|
|
|
|
|
|
const [linkValue, setLinkValue] = useState(link ?? "");
|
|
|
const [linkText, setLinkText] = useState(text ?? "");
|
|
|
- const [linkPoster, setLinkPoster] = useState(poster ?? "");
|
|
|
+ const [linkPoster, setLinkPoster] = useState<string>(poster ?? "");
|
|
|
|
|
|
const [showPopup, setShowPopup] = useState(false);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- const handleAddPoster = () => {
|
|
|
- Taro.chooseImage({
|
|
|
- count: 1,
|
|
|
- sizeType: ["original", "compressed"],
|
|
|
- sourceType: ["album", "camera"],
|
|
|
- async success(chooseImageRes) {
|
|
|
- const tempFilePaths = chooseImageRes.tempFilePaths;
|
|
|
- const res = await uploadImage(tempFilePaths[0]);
|
|
|
- if (res?.publicUrl) {
|
|
|
- setLinkPoster(res.publicUrl);
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- };
|
|
|
|
|
|
// 选择知识库导入
|
|
|
const onPicked = (pickedArr?: TKnowledgeItem[]) => {
|
|
@@ -69,6 +52,7 @@ export default function Index() {
|
|
|
setShowPopup(true)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
const handleSubmit = async () => {
|
|
|
if(!data?.id){
|
|
|
return;
|
|
@@ -93,31 +77,7 @@ export default function Index() {
|
|
|
await saveComponent(c);
|
|
|
Taro.navigateBack();
|
|
|
};
|
|
|
-
|
|
|
|
|
|
- // 渲染封面
|
|
|
- const renderPoster = (src?: string) => {
|
|
|
- if (src) {
|
|
|
- return (
|
|
|
- <View className="w-full overflow-hidden">
|
|
|
- <Image className={style.cover} mode="widthFix" src={src}></Image>
|
|
|
- </View>
|
|
|
- );
|
|
|
- }
|
|
|
- return (
|
|
|
- <>
|
|
|
- <View>
|
|
|
- <Image
|
|
|
- src="https://cdn.wehome.cn/cmn/png/100/META-H8UKVHWU-KIGP3BIL7M5AYC6XHNUA2-VDZCWI2M-O91.png"
|
|
|
- className={style.iconAdd}
|
|
|
- ></Image>
|
|
|
- </View>
|
|
|
- <View className="text-gray-45 text-12 leading-20 text-center">
|
|
|
- 上传展示图
|
|
|
- </View>
|
|
|
- </>
|
|
|
- );
|
|
|
- };
|
|
|
|
|
|
|
|
|
|
|
@@ -126,49 +86,32 @@ export default function Index() {
|
|
|
<PageCustom>
|
|
|
<NavBarNormal>链接</NavBarNormal>
|
|
|
<View className="flex flex-col items-center w-full">
|
|
|
- <View className="px-16 w-full pb-120">
|
|
|
-
|
|
|
-
|
|
|
- <View className={editorStyle.formContainer}>
|
|
|
- <View className={editorStyle.formItem}>
|
|
|
- <View className={editorStyle.formItemLabel}>
|
|
|
- <View className="flex flex-1 items-center">
|
|
|
- <View className={editorStyle.formLabel}>链接地址</View>
|
|
|
- <View className={editorStyle.formLabelRequired}>*</View>
|
|
|
- </View>
|
|
|
- <View className="text-primary" onClick={showKnowlegePopup}>知识库导入</View>
|
|
|
+ <View className="flex flex-col items-center gap-16 w-full px-16 pb-120">
|
|
|
+ <View className="flex flex-col gap-6 w-full">
|
|
|
+ <View className="flex w-full items-center">
|
|
|
+ <View className="flex flex-1 items-center">
|
|
|
+ <View className="flex text-14 leading-28 font-medium flex-1">链接地址<Text className="text-red">*</Text></View>
|
|
|
</View>
|
|
|
- <WemetaTextarea
|
|
|
- value={linkValue}
|
|
|
- onInput={(value: string) => setLinkValue(value)}
|
|
|
- placeholder="请输入URL..."
|
|
|
- ></WemetaTextarea>
|
|
|
+ <View className="text-primary" onClick={showKnowlegePopup}>知识库导入</View>
|
|
|
</View>
|
|
|
- <View className={editorStyle.formItem}>
|
|
|
- <View className={editorStyle.formItemLabel}>
|
|
|
- <View>链接描述<Text className="text-gray-45">(选填)</Text></View>
|
|
|
- </View>
|
|
|
- <WemetaInput
|
|
|
- value={linkText}
|
|
|
- onInput={(value: string) => setLinkText(value)}
|
|
|
- placeholder="请输入..."
|
|
|
- maxlength={50}
|
|
|
- />
|
|
|
- </View>
|
|
|
- <View className={editorStyle.formItem}>
|
|
|
- <View className={editorStyle.formItemLabel}>
|
|
|
- <View className="flex-1">
|
|
|
- 封面图 <Text className="text-gray-45">(选填)</Text>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- <View
|
|
|
- className={`${style.coverContainer}`}
|
|
|
- onClick={handleAddPoster}
|
|
|
- >
|
|
|
- {renderPoster(linkPoster)}
|
|
|
- </View>
|
|
|
+ <WemetaTextarea
|
|
|
+ value={linkValue}
|
|
|
+ onInput={(value: string) => setLinkValue(value)}
|
|
|
+ placeholder="请输入URL..."
|
|
|
+ ></WemetaTextarea>
|
|
|
+ </View>
|
|
|
+ <View className="flex flex-col gap-6 w-full">
|
|
|
+ <View className="flex w-full items-center">
|
|
|
+ <View>链接描述</View>
|
|
|
</View>
|
|
|
+ <WemetaInput
|
|
|
+ value={linkText}
|
|
|
+ onInput={(value: string) => setLinkText(value)}
|
|
|
+ placeholder="请输入..."
|
|
|
+ maxlength={50}
|
|
|
+ />
|
|
|
</View>
|
|
|
+ <FormitemSingleImage url={linkPoster} setUrl={setLinkPoster} ></FormitemSingleImage>
|
|
|
</View>
|
|
|
<BottomBar>
|
|
|
<ButtonMain disabled={!linkValue.length} className="flex-1" onClick={handleSubmit}>保存</ButtonMain>
|