Skip to content

Commit

Permalink
style: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Apr 14, 2021
1 parent b604cb9 commit e163824
Show file tree
Hide file tree
Showing 31 changed files with 256 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {
// ],

"indent": "off",
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1 }],
"@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1, ignoredNodes: ['TSTypeParameterInstantiation'] }],
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
"semi": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/main/electron/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function checkUpdateTask (this: ElectronLauncherApp): Task<_UpdateInfo> {
this.log('Update available and set status to pending')
this.storeManager.store.commit('updateStatus', 'pending')
})
console.log(`check update task`)
console.log('check update task')
const info = await autoUpdater.checkForUpdates()

if (this.networkManager.isInGFW && !injectedUpdate) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/util/aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export interface Aggregator<T, A = T> {
(values: T[]): A
}

export function createArrayAggregator<T>() {}
export function createArrayAggregator<T>() {}
6 changes: 3 additions & 3 deletions src/renderer/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module '*.vue' {
import { ComponentOptions } from 'vue'
import { ComponentOptions, Component } from 'vue'
const component: ComponentOptions
export default component
}
Expand All @@ -12,7 +12,7 @@ declare module 'vue-particles' {
export default module
}
declare module 'vue-virtual-scroll-list' {
import { Component } from 'vue'
const component: Component<any, any, any, { size: number; remain: number }>

const component: import('vue').Component<any, any, any, { size: number; remain: number }>
export = component
}
6 changes: 3 additions & 3 deletions src/renderer/hooks/useBackgroundImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { useLocalStorageCacheInt, useLocalStorageCacheStringValue } from './useC

export function useBackgroundImage() {
const blur = useLocalStorageCacheInt('blur', 4)
const backgroundImage = useLocalStorageCacheStringValue('background', "")
const backgroundImage = useLocalStorageCacheStringValue('background', '')
async function setBackgroundImage(path: string) {
const img = document.createElement('img')
img.src = `image://${path}`
img.onload = () => {
const canvas = document.createElement('canvas')
canvas.height = img.naturalHeight;
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight
canvas.width = img.naturalWidth
const context = canvas.getContext('2d')
context?.drawImage(img, 0, 0)
const png = canvas.toDataURL((img as any).mimeType ?? 'image/png')
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/windows/main/MainWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
:style="{ filter: `blur(${blur}px)` }"
style="z-index: -0; filter: blur(4px); position: absolute; width: 100%; height: 100%;"
>
<!-- <video style="z-index:0; position: absolute;" autoplay>
<source :src="video">
</video> -->
<vue-particles
v-if="showParticle"
color="#dedede"
Expand Down Expand Up @@ -102,8 +99,6 @@ export default defineComponent({
provideAsyncRoute()
const { goBack } = provideRouterHistory()
const video = "video://D:\\asmr\\rn210308.mp4"
const { text, toggle } = provideSearch()
provideContextMenu()
Expand Down Expand Up @@ -159,7 +154,6 @@ export default defineComponent({
showParticle,
onHomePage,
goBack,
video,
}
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
<script lang=ts>
import { defineComponent } from '@vue/composition-api'
import { FabricArtifactVersion } from '@xmcl/installer'
import VirtualList from 'vue-virtual-scroll-list'
import { required } from '/@/util/props'
export default defineComponent({
components: { VirtualList },
props: {
statuses: required<Record<string, 'loading' | 'remote'>>(Object),
source: required<FabricArtifactVersion>(Object),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</v-list-tile-content> -->
<v-list-tile-action>
<v-chip
v-if="value.existed"
v-if="'date' in value"
label
>
{{ $t('existed') }} {{ typeName }}
Expand All @@ -48,7 +48,7 @@

<v-list-tile-action>
<v-checkbox
v-model="value.enabled"
v-model="enabled"
style="justify-content: flex-end"
:disabled="disabled"
hide-details
Expand Down Expand Up @@ -104,15 +104,20 @@ export default defineComponent({
props: {
value: required<FilePreview>(Object),
},
setup(props) {
emits: ['enable', 'remove'],
setup(props, context) {
const { $tc, $t } = useI18n()
const disabled = computed(() => props.value.type === 'unknown' ||
props.value.status !== 'idle')
const enabled = computed({
get() { return props.value.enabled },
set(v) { context.emit('enable', v) },
})
const icon = computed(() => iconMap[props.value.type] ?? 'device_unknown')
const tryEnable = () => {
if (!disabled.value) {
props.value.enabled = !props.value.enabled
context.emit('enable')
}
}
const typeName = computed(() => {
Expand All @@ -127,7 +132,7 @@ export default defineComponent({
case 'unknown': return $t('unknownResource')
}
})
return { disabled, tryEnable, icon, typeName }
return { disabled, tryEnable, icon, typeName, enabled }
},
})
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:key="file.name"
:value="file"
@remove="$emit('remove', file)"
@enable="setEnable(file, $event)"
/>
</v-list>
<v-spacer />
Expand Down Expand Up @@ -97,13 +98,17 @@ export default defineComponent({
}
Promise.all(promises).then(() => cancel())
}
function setEnable(file: FilePreview, enabled?: boolean) {
file.enabled = enabled ?? true
}
return {
enableMods,
remove,
cancel,
start,
loading,
disabled,
setEnable,
}
},
})
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/windows/main/hooks/useDialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { computed, inject, InjectionKey, provide, Ref, ref } from '@vue/composition-api'
import type { FileFilter } from 'electron'
import { useI18n } from '/@/hooks'

export type DialogNames = 'task' | 'java-wizard' | 'login' | 'detail' | ''
Expand All @@ -12,7 +13,7 @@ export const DIALOG_JAVA_ISSUE: InjectionKey<Ref<'incompatible' | 'missing'>> =

export function useZipFilter () {
const { $t } = useI18n()
const zipFilter: Electron.FileFilter = {
const zipFilter: FileFilter = {
extensions: ['zip'],
name: $t('zip'),
}
Expand Down
14 changes: 4 additions & 10 deletions src/renderer/windows/main/pages/CurseforgeProjectPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ import {
import ProjectDescription from './CurseforgeProjectPageDescription.vue'
import DestMenu from './CurseforgeProjectPageDestMenu.vue'
import ProjectFiles from './CurseforgeProjectPageFiles.vue'
import { withDefault } from '/@/util/props'
interface InstallOptions {
path?: string
Expand All @@ -224,16 +225,9 @@ interface InstallOptions {
export default defineComponent({
components: { ProjectDescription, ProjectFiles, DestMenu },
props: {
type: {
type: String,
default: 'mc-mods',
},
id: {
type: String,
required: true,
default: '',
},
from: String,
type: withDefault(String, () => 'mc-mods'),
id: withDefault(String, () => ''),
from: withDefault(String, () => ''),
},
setup(props) {
const projectId = computed(() => Number.parseInt(props.id, 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
<script lang=ts>
import { defineComponent } from '@vue/composition-api'
import { useCurseforgeProjectDescription } from '/@/hooks'
import { required } from '/@/util/props'
export default defineComponent<{ project: number }>({
props: { project: Number },
props: { project: required(Number) },
setup(props) {
const { loading, description } = useCurseforgeProjectDescription(props.project)
return { loading, description }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import { useI18n, useInstances } from '/@/hooks'
import { basename } from '/@/util/basename'
import { defineComponent, computed, inject, ref, reactive, toRefs, Ref } from '@vue/composition-api'
import { optional } from '/@/util/props'
interface Item {
name: string
Expand All @@ -52,7 +53,7 @@ interface Item {
export default defineComponent({
props: {
value: String,
value: optional(String),
},
setup(props, context) {
const { instances } = useInstances()
Expand Down
15 changes: 12 additions & 3 deletions src/renderer/windows/main/pages/CurseforgeProjectPageFiles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ import {
useCurseforgeProjectFiles,
useCurseforgeInstall,
} from '/@/hooks'
import { required } from '/@/util/props'
import { optional, required, withDefault } from '/@/util/props'
import Tile from './CurseforgeProjectPageFilesTile.vue'
import AddInstanceStepper from './InstancesPageAddInstanceStepper.vue'
import { useSearch } from '../hooks'
export default defineComponent({
components: { VirtualList, AddInstanceStepper },
props: { project: required(Number), type: required<ProjectType>(String as any), from: String },
props: {
project: required(Number),
type: required<ProjectType>(String as any),
from: optional(String),
},
setup(props) {
const { files, loading, refresh } = useCurseforgeProjectFiles(props.project)
const { install: installFile, getFileStatus, getFileResource } = useCurseforgeInstall(props.type, props.project)
Expand All @@ -72,7 +76,12 @@ export default defineComponent({
const resource = await installFile(file)
filePath = resource.path
} else {
filePath = getFileResource(file).path
const res = getFileResource(file)
if (res) {
filePath = res.path
} else {
throw new Error(`Cannot find installed curseforge file named ${file.displayName} fileId=${file.id} projectId=${file.projectId}`)
}
}
data.initialTemplate = filePath
data.isConfirmDialogShown = true
Expand Down
1 change: 1 addition & 0 deletions src/renderer/windows/main/pages/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
isExportingCurseforge = false;
"
/>
<launch-blocked-dialog />
</v-layout>
</template>

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/windows/main/pages/InstancesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<v-flex xs1>
<create-button @create="onCreate" />
</v-flex>
<v-flex xs1>
<v-flex xs1>
<import-button @import="onImport" />
</v-flex>
</v-layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ import {
} from '/@/hooks'
import { JavaRecord } from '/@shared/entities/java'
import { useSearch, useSearchToggles, useSearchToggle } from '../hooks'
import { optional, withDefault } from '/@/util/props'
interface InstanceTemplate {
type: 'instance'
Expand Down Expand Up @@ -446,11 +447,8 @@ function setupTemplates() {
export default defineComponent({
props: {
show: {
type: Boolean,
default: false,
},
initialTemplate: String,
show: withDefault(Boolean, () => false),
initialTemplate: optional(String),
},
setup(props, context) {
const { $t } = useI18n()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ import { required } from '/@/util/props'
import PreviewCard from './InstancesPagePreviewCard.vue'
export default defineComponent({
props: { instances: required<Instance[]>(Array) },
components: {
PreviewCard,
},
props: { instances: required<Instance[]>(Array) },
setup(props) {
const now = Date.now()
const oneDay = 1000 * 60 * 60 * 24
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/windows/main/pages/MCWikiPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
import { defineComponent, computed, ref, Ref, onMounted } from '@vue/composition-api'
import { WebviewTag } from 'electron'
import { useRouter } from '/@/hooks'
import { optional } from '/@/util/props'
export default defineComponent({
props: {
path: String,
path: optional(String),
},
setup(props) {
const view: Ref<WebviewTag | null> = ref(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</template>

<script lang=ts>
import { BlockStateJson } from '@shared/services/ResourcePackPreviewService'
import { BlockStateJson } from '/@shared/services/ResourcePackPreviewService'
import { computed, defineComponent, reactive, ref, Ref, toRefs, watch } from '@vue/composition-api'
import { BlockModel } from '@xmcl/resourcepack'
import { useSearch } from '../hooks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default defineComponent({
let currentObj: any
watch(computed(() => props.value), () => {
for (const [key, value] of Object.entries(props.value.model.textures)) {
// eslint-disable-next-line vue/no-mutating-props
props.value.model.textures[key] = findRealTexturePath(props.value.model, key)
}
const obj = new BlockModelFactory(props.value.textures).getObject(props.value.model)
Expand Down
13 changes: 4 additions & 9 deletions src/renderer/windows/main/pages/SaveViewPageDeleteDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,13 @@

<script>
import { defineComponent } from '@vue/composition-api'
import { required } from '/@/util/props'
export default defineComponent({
props: {
cancel: {
type: Function,
},
operate: {
type: Function,
},
value: {
type: String,
},
cancel: required(Function),
operate: required(Function),
value: required(String),
},
})
</script>
Expand Down
Loading

0 comments on commit e163824

Please sign in to comment.