Skip to content

Let's use AI to Earn!

feat: 【账户选择】添加选择所有平台账户功能

gaoSir9c1dfceb84fb
diff --git a/electron/main/index.ts b/electron/main/index.ts
index 41948880..9fdbc9bd 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -59,7 +59,7 @@ async function createWindow() {
webPreferences: {
preload,
webviewTag: true,
- webSecurity: false,
+ webSecurity: true,
nodeIntegration: false,
contextIsolation: true,
},
diff --git a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
index a73f2240..39de02f5 100644
--- a/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
+++ b/src/views/publish/children/videoPage/components/CommonPubSetting.tsx
@@ -55,7 +55,12 @@ const CommonPubSetting = memo(
<p className="commonPubSetting-tip">
支持常用图片格式上传,暂不支持 GIF,上传后图片将按平台要求自动裁剪
</p>
- <h2>标题</h2>
+ <h2>
+ 标题
+ <Tooltip title="更多详情中单独设置的话题和描述中带的话题都是有效的,发布时将合并去重处理">
+ <ExclamationCircleOutlined />
+ </Tooltip>
+ </h2>
<Input
showCount
maxLength={30}
@@ -81,7 +86,7 @@ const CommonPubSetting = memo(
}}
/>
<p className="commonPubSetting-tip">
- 描述中可带话题,以‘#’开头、‘空格’结尾,{' '}
+ 描述中可带话题,以‘#’开头、‘空格’结尾,
<Tooltip title="更多详情中单独设置的话题和描述中带的话题都是有效的,发布时将合并去重处理">
<span style={{ color: 'rgb(250, 173, 20)' }}>
<ExclamationCircleOutlined style={{ marginRight: '3px' }} />
diff --git a/src/views/publish/children/videoPage/page.tsx b/src/views/publish/children/videoPage/page.tsx
index 87d01693..249c0f26 100644
--- a/src/views/publish/children/videoPage/page.tsx
+++ b/src/views/publish/children/videoPage/page.tsx
@@ -67,7 +67,8 @@ export default function Page() {
<ChooseAccountModule
disableAllSelect={
- accountChooseType.current === AccountChooseType.Radio
+ accountChooseType.current === AccountChooseType.Radio ||
+ accountChooseType.current === AccountChooseType.Replace
}
open={chooseAccountOpen}
onClose={setChooseAccountOpen}
diff --git a/src/views/publish/children/videoPage/useVideoPageStore.ts b/src/views/publish/children/videoPage/useVideoPageStore.ts
index 1c4d4660..58a42545 100644
--- a/src/views/publish/children/videoPage/useVideoPageStore.ts
+++ b/src/views/publish/children/videoPage/useVideoPageStore.ts
@@ -246,9 +246,9 @@ export const useVideoPageStore = create(
// 清空所有数据
clear() {
store.commonPubParams.cover = undefined;
- set({
- ...store,
- });
+ // set({
+ // ...store,
+ // });
},
// 删除某个视频
diff --git a/src/views/publish/children/videoPage/video.module.scss b/src/views/publish/children/videoPage/video.module.scss
index fd16df88..02a3acdf 100644
--- a/src/views/publish/children/videoPage/video.module.scss
+++ b/src/views/publish/children/videoPage/video.module.scss
@@ -408,6 +408,9 @@
font-size: var(--fs-md);
margin-bottom: 5px;
margin-top: 20px;
+ .anticon {
+ margin-left: 3px;
+ }
}
&-tip {
font-size: var(--fs-sm);
diff --git a/src/views/publish/components/ChooseAccountModule/chooseAccountModule.module.scss b/src/views/publish/components/ChooseAccountModule/chooseAccountModule.module.scss
index 3ba7e7ea..1feb1b43 100644
--- a/src/views/publish/components/ChooseAccountModule/chooseAccountModule.module.scss
+++ b/src/views/publish/components/ChooseAccountModule/chooseAccountModule.module.scss
@@ -2,19 +2,25 @@
display: flex;
:global {
- .ant-segmented {
- margin-right: 20px;
- .ant-segmented-item {
+ .platChoose-platSelect {
+ .ant-checkbox-wrapper {
margin-bottom: 5px;
- padding: 3px 60px 3px 0;
}
- .ant-segmented-item-label {
- display: flex;
- align-items: center;
- .ant-segmented-item-icon {
+ .ant-segmented {
+ margin-right: 20px;
+ .ant-segmented-item {
+ margin-bottom: 5px;
+ padding: 3px 60px 3px 0;
+ }
+
+ .ant-segmented-item-label {
display: flex;
align-items: center;
+ .ant-segmented-item-icon {
+ display: flex;
+ align-items: center;
+ }
}
}
}
diff --git a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
index 6090857e..5ece1d95 100644
--- a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
+++ b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx
@@ -69,6 +69,24 @@ const PlatChoose = memo(
// 每次change操作的数据
const recentData = useRef<AccountInfo>();
+ // 所有平台的账户数据
+ const getAllAccountList = useMemo(() => {
+ const allAccountList = [];
+ for (const [_, accountList] of accountMap) {
+ allAccountList.push(...accountList);
+ }
+ return allAccountList;
+ }, [accountMap]);
+
+ // 当前选择的所有平台的账户数据
+ const getChoosedAllAccountList = useMemo(() => {
+ const allAccountList = [];
+ for (const [_, accountList] of choosedAcountMap) {
+ allAccountList.push(...accountList);
+ }
+ return allAccountList;
+ }, [choosedAcountMap]);
+
// 当前平台的所有用户数据
const currAccountList = useMemo(
() => (activePlat && accountMap.get(activePlat)) || [],
@@ -81,14 +99,6 @@ const PlatChoose = memo(
[activePlat, choosedAcountMap],
);
- // 半选
- const indeterminate = useMemo(() => {
- return (
- currChoosedAcount.length > 0 &&
- currChoosedAcount.length < currAccountList.length
- );
- }, [activePlat, choosedAcountMap]);
-
const getAccountList = () => {
icpGetAccountList().then((res) => {
setAccountMap((prevMap) => {
@@ -157,51 +167,85 @@ const PlatChoose = memo(
return (
<div className={styles.platChoose}>
- <ConfigProvider
- theme={{
- components: {
- Segmented: {
- trackBg: '#fff',
- itemSelectedBg: cssVars['--colorPrimary1'],
- itemHoverBg: cssVars['--colorPrimary2'],
- itemActiveBg: cssVars['--colorPrimary3'],
- itemSelectedColor: cssVars['--colorPrimary9'],
+ <div className="platChoose-platSelect">
+ {!disableAllSelect && (
+ <Checkbox
+ indeterminate={
+ getChoosedAllAccountList.length > 0 &&
+ getChoosedAllAccountList.length < getAllAccountList.length
+ }
+ onChange={(e) => {
+ const { checked } = e.target;
+ setChoosedAcountMap((v) => {
+ const newMap = new Map(v);
+ recentData.current = currAccountList[0];
+
+ for (const [accountType, accountList] of accountMap) {
+ if (checked) {
+ newMap.set(accountType, accountList);
+ } else {
+ newMap.set(accountType, []);
+ }
+ }
+ return newMap;
+ });
+ }}
+ checked={
+ getAllAccountList.length === getChoosedAllAccountList.length
+ }
+ >
+ 选择所有平台账户
+ </Checkbox>
+ )}
+ <ConfigProvider
+ theme={{
+ components: {
+ Segmented: {
+ trackBg: '#fff',
+ itemSelectedBg: cssVars['--colorPrimary1'],
+ itemHoverBg: cssVars['--colorPrimary2'],
+ itemActiveBg: cssVars['--colorPrimary3'],
+ itemSelectedColor: cssVars['--colorPrimary9'],
+ },
},
- },
- }}
- >
- <Segmented
- vertical
- size="large"
- value={activePlat}
- options={Array.from(accountMap)
- .map(([key, value]) => {
- if (value.length === 0) return undefined;
- const platInfo = AccountPlatInfoMap.get(key)!;
- return {
- value: key,
- label: platInfo.name,
- icon: (
- <Badge
- count={choosedAcountMap.get(key)?.length}
- size="small"
- >
- <img src={platInfo.icon} />
- </Badge>
- ),
- };
- })
- .filter((v) => v !== undefined)}
- onChange={setActivePlat}
- />
- </ConfigProvider>
+ }}
+ >
+ <Segmented
+ vertical
+ size="large"
+ value={activePlat}
+ options={Array.from(accountMap)
+ .map(([key, value]) => {
+ if (value.length === 0) return undefined;
+ const platInfo = AccountPlatInfoMap.get(key)!;
+ return {
+ value: key,
+ label: platInfo.name,
+ icon: (
+ <Badge
+ count={choosedAcountMap.get(key)?.length}
+ size="small"
+ >
+ <img src={platInfo.icon} />
+ </Badge>
+ ),
+ };
+ })
+ .filter((v) => v !== undefined)}
+ onChange={setActivePlat}
+ />
+ </ConfigProvider>
+ </div>
<div className="platChoose-con">
{currAccountList && (
<>
{!disableAllSelect ? (
<Checkbox
- indeterminate={indeterminate}
+ indeterminate={
+ currChoosedAcount.length > 0 &&
+ currChoosedAcount.length < currAccountList.length
+ }
onChange={(e) => {
setChoosedAcountMap((v) => {
recentData.current = currAccountList[0];