diff --git a/src/router/index.ts b/src/router/index.ts index 843223c..be7cfec 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -17,25 +17,4 @@ const router = createRouter({ ], }) -if (import.meta.env.DEV) { - router.addRoute({ - path: '/dev', - component: Layout, - children: [ - { - path: 'items', - component: () => import('@/views/dev/ItemsView'), - }, - { - path: 'buildings', - component: () => import('@/views/dev/BuildingsView'), - }, - { - path: 'recipes', - component: () => import('@/views/dev/RecipesView'), - }, - ], - }) -} - export default router diff --git a/src/views/dev/BuildingsView.tsx b/src/views/dev/BuildingsView.tsx deleted file mode 100644 index 9d91f17..0000000 --- a/src/views/dev/BuildingsView.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { computed, defineComponent, ref } from 'vue' -import { useClipboard, useWindowSize } from '@vueuse/core' -import { - NButton, - NDataTable, - NFlex, - NModal, - useMessage, - type DataTableColumns, -} from 'naive-ui' - -import ShowOrEdit from '@/components/ShowOrEdit' -import { buildings } from '@/data' -import BuildingImage from '@/components/BuildingImage' - -interface OptionalBuilding { - id: string | null - name: string | null -} - -const columns: DataTableColumns = [ - { - title: '图片', - key: 'image', - width: 60, - render: (row) => { - return ( - - ) - }, - }, - { - title: '名称', - key: 'name', - minWidth: 200, - render: (row) => { - return ( - { - row.name = value - }} - /> - ) - }, - }, - { - title: 'ID', - key: 'id', - minWidth: 200, - render: (row) => { - return ( - { - row.id = value ? value.trim().replace(/\s+/g, '_') : null - }} - /> - ) - }, - }, -] - -export default defineComponent({ - setup() { - const data = ref(structuredClone(buildings)) - - const message = useMessage() - - const source = computed(() => JSON.stringify(data.value)) - const { copy } = useClipboard({ source }) - - const { height: windowHeight } = useWindowSize() - - return () => ( - <> - - - - { - data.value.push({ - id: '', - name: '', - }) - }} - > - 新增 - - - -
{data.value.length}条数据
- { - copy().then(() => { - message.success('复制成功') - }) - }} - > - 导出到剪贴板 - -
-
- -
- - - ) - }, -}) diff --git a/src/views/dev/ItemsView.tsx b/src/views/dev/ItemsView.tsx deleted file mode 100644 index 8030023..0000000 --- a/src/views/dev/ItemsView.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import { computed, defineComponent, ref } from 'vue' -import { useClipboard, useWindowSize } from '@vueuse/core' -import { - NButton, - NDataTable, - NFlex, - NModal, - useMessage, - type DataTableColumns, -} from 'naive-ui' - -import ShowOrEdit from '@/components/ShowOrEdit' -import type { Id } from '@/types' -import { items } from '@/data' -import ItemImage from '@/components/ItemImage' - -interface OptionalItem { - id: Id | null - name: string | null -} - -const columns: DataTableColumns = [ - { - title: '图片', - key: 'image', - width: 60, - render: (row) => { - return ( - - ) - }, - }, - { - title: '名称', - key: 'name', - minWidth: 200, - render: (row) => { - return ( - { - row.name = value - }} - /> - ) - }, - }, - { - title: 'ID', - key: 'id', - minWidth: 200, - render: (row) => { - return ( - { - row.id = value ? value.trim().replace(/\s+/g, '_') : null - }} - /> - ) - }, - }, -] - -export default defineComponent({ - setup() { - const data = ref(structuredClone(items)) - - const message = useMessage() - - const source = computed(() => JSON.stringify(data.value)) - const { copy } = useClipboard({ source }) - - const { height: windowHeight } = useWindowSize() - - return () => ( - <> - - - - { - data.value.push({ - id: '', - name: '', - }) - }} - > - 新增 - - - -
{data.value.length}条数据
- { - copy().then(() => { - message.success('复制成功') - }) - }} - > - 导出到剪贴板 - -
-
- -
- - - ) - }, -}) diff --git a/src/views/dev/RecipesView.tsx b/src/views/dev/RecipesView.tsx deleted file mode 100644 index 3b01159..0000000 --- a/src/views/dev/RecipesView.tsx +++ /dev/null @@ -1,311 +0,0 @@ -import { computed, defineComponent, ref } from 'vue' -import { useClipboard, useWindowSize } from '@vueuse/core' -import { - NButton, - NDataTable, - NFlex, - NInputNumber, - NModal, - NPopconfirm, - NSelect, - useMessage, - type DataTableColumns, -} from 'naive-ui' - -import ShowOrEdit from '@/components/ShowOrEdit' -import { buildings, recipes } from '@/data' -import ItemSelect from '@/components/ItemSelect' - -interface OptionalItemQuantity { - itemId: string | null - quantity: number | null -} - -interface OptionalRecipe { - id: string | null - name: string | null - inputs: OptionalItemQuantity[] - outputs: OptionalItemQuantity[] - producedIn: string | null - productionDuration: number | null -} - -const buildingsOptions = buildings.map((building) => { - return { - label: building.name, - value: building.id, - } -}) - -const createColumns = ({ - remove, -}: { - remove: (rowIndex: number) => void -}): DataTableColumns => { - return [ - { - type: 'selection', - }, - { - title: '名称', - key: 'name', - width: 200, - render: (row) => { - return ( - { - row.name = value - }} - /> - ) - }, - }, - { - title: 'ID', - key: 'id', - width: 200, - render: (row) => { - return ( - { - row.id = value ? value.trim().replace(/\s+/g, '_') : null - }} - /> - ) - }, - }, - { - title: '生产建筑', - key: 'producedIn', - width: 120, - render: (row) => { - return ( - { - row.producedIn = value - }} - options={buildingsOptions} - filterable - clearable - /> - ) - }, - }, - { - title: '输入', - key: 'input', - minWidth: 240, - render: (row) => { - return ( - - {row.inputs.map((item, index) => ( - - { - item.quantity = value - }} - /> - { - item.itemId = value - }} - /> - { - row.inputs.splice(index, 1) - }} - > - 删 - - - ))} - { - row.inputs.push({ - itemId: null, - quantity: null, - }) - }} - size="small" - dashed - > - 增加条目 - - - ) - }, - }, - { - title: '输出', - key: 'output', - minWidth: 240, - render: (row) => { - return ( - - {row.outputs.map((item, index) => ( - - { - item.quantity = value - }} - /> - { - item.itemId = value - }} - /> - { - row.outputs.splice(index, 1) - }} - > - 删 - - - ))} - { - row.outputs.push({ - itemId: null, - quantity: null, - }) - }} - size="small" - dashed - > - 增加条目 - - - ) - }, - }, - { - title: '生产周期', - key: 'productionDuration', - width: 160, - render: (row) => { - return ( - { - row.productionDuration = value ?? 0 - }} - > - {{ - suffix: () => '秒', - }} - - ) - }, - }, - { - title: '操作', - key: 'action', - width: 72, - render: (row, rowIndex) => { - return ( - - { - remove(rowIndex) - }} - > - {{ - default: () => '确认删除?', - trigger: () => ( - - 删除 - - ), - }} - - - ) - }, - }, - ] -} - -export default defineComponent({ - setup() { - const data = ref(structuredClone(recipes)) - - const message = useMessage() - - const source = computed(() => JSON.stringify(data.value)) - const { copy } = useClipboard({ source }) - - const { height: windowHeight } = useWindowSize() - - const vaildDataCount = computed(() => { - return new Set( - data.value.filter(({ name }) => name).map(({ name }) => name!), - ).size - }) - - return () => ( - <> - - - - { - data.value.push({ - id: null, - name: null, - inputs: [], - outputs: [], - producedIn: null, - productionDuration: null, - }) - }} - > - 新增 - - - -
- {vaildDataCount.value}/{data.value.length}条数据 -
- { - copy().then(() => { - message.success('复制成功') - }) - }} - > - 导出到剪贴板 - -
-
- data.value.indexOf(row)} - flexHeight - columns={createColumns({ - remove: (rowIndex) => { - data.value.splice(rowIndex, 1) - }, - })} - data={data.value} - /> -
- - - ) - }, -})