Skip to content

Commit

Permalink
[kp-ads] 动态列表
Browse files Browse the repository at this point in the history
  • Loading branch information
masquevil committed Aug 25, 2024
1 parent 1eb1e7a commit 594fe05
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/apps/coc-card/sections/ControlSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import LA, { LAEventID, FeatureNames } from '@/plugins/51la';
import { usePC, useViewData, usePageData } from '../hooks/useProviders';
import usePrintPaper from '../hooks/usePrintPaper';
import useAppLs from '../hooks/useAppLs';
import { downloadFile } from '@/utils/file';
import type { COCCardViewData } from '../types/viewData';
Expand All @@ -56,6 +57,7 @@ interface Emits {
}
const emit = defineEmits<Emits>();
const ls = useAppLs();
const pc = usePC();
const viewData = useViewData();
const pageData = usePageData();
Expand Down Expand Up @@ -172,6 +174,10 @@ function actResetCard() {
pc.value = reactive(createPC());
// reset viewData
resetViewData(viewData);
// remove auto saved
nextTick(() => {
ls.removeItem('autoSaved');
});
ElMessage.info('已重置人物卡');
morePanelVisible.value = false;
Expand Down
33 changes: 32 additions & 1 deletion src/apps/kp-ads/AppView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
<script setup lang="ts">
import { ref, computed } from 'vue';
import qs from 'qs';
import StoryCard from './components/StoryCard.vue';
import keeperGroupTable from './tables/keeperGroup';
import KeeperGroupModel from './models/keeperGroup';
import type { KeeperGroupTableField_List } from './types/keeperGroup';
import { storyInfoOverrides } from './tables/storyInfoOverrides';
interface QsObjectByDynamicList {
'dl-t'?: string;
// overrides index list, format: `0-1-2`
'dl-oil'?: string;
}
const qsObject = qs.parse(location.search.slice(1));
const currentKey = ref('sox');
// TODO: move to model
const dynamicList = computed(() => {
const { 'dl-t': title, 'dl-oil': overridesIndexListStr } = qsObject as QsObjectByDynamicList;
if (!title || !overridesIndexListStr) return;
const overridesIndexList = overridesIndexListStr.split('-').map(Number) as number[];
const dynamicList: KeeperGroupTableField_List = {
key: '$dynamic',
title,
stories: overridesIndexList.map((index) => ['', storyInfoOverrides[index].title]),
};
return dynamicList;
});
const keeperGroup = computed(() => {
const keeperGroupRow = keeperGroupTable.find((row) => row.key === currentKey.value);
return keeperGroupRow && new KeeperGroupModel(keeperGroupRow);
return (
keeperGroupRow &&
new KeeperGroupModel({
...keeperGroupRow,
lists: dynamicList.value
? [dynamicList.value, ...keeperGroupRow.lists]
: keeperGroupRow.lists,
})
);
});
</script>

Expand Down
9 changes: 2 additions & 7 deletions src/apps/kp-ads/models/keeperGroup.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import type { Story } from '../types/story';
import type { KeeperGroupTableRow } from '../types/keeperGroup';
import type { KeeperGroupTableRow, KeeperGroupField_List } from '../types/keeperGroup';
import StoryModel from './story';

export default class KeeperGroupModel {
key?: string;
type?: string;
name?: string;
lists?: {
key: string;
title: string;
stories: Story[];
}[];
lists?: KeeperGroupField_List[];

constructor(row: KeeperGroupTableRow) {
this.key = row.key;
Expand Down
22 changes: 16 additions & 6 deletions src/apps/kp-ads/types/keeperGroup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import type { Story } from './story';

export interface KeeperGroupTableRow {
key: string;
type: 'personal' | 'group';
name: string;
lists: {
key: string;
title: string;
// [id, title], 任选一个即可
stories: [string?, string?][];
}[];
lists: KeeperGroupTableField_List[];
}

export interface KeeperGroupTableField_List {
key: string;
title: string;
// [id, title], 任选一个即可
stories: [string?, string?][];
}

export interface KeeperGroupField_List {
key: string;
title: string;
stories: Story[];
}

0 comments on commit 594fe05

Please sign in to comment.