|
@@ -1,61 +1,36 @@
|
|
<template>
|
|
<template>
|
|
- <p>Hello world</p>
|
|
|
|
-</template>
|
|
|
|
-<!-- <template>
|
|
|
|
<div class="max-w-2xl">
|
|
<div class="max-w-2xl">
|
|
<p class="font-semibold">
|
|
<p class="font-semibold">
|
|
{{ t('settings.editor.curvature.title') }}
|
|
{{ t('settings.editor.curvature.title') }}
|
|
</p>
|
|
</p>
|
|
<div class="flex items-center space-x-4 mt-2">
|
|
<div class="flex items-center space-x-4 mt-2">
|
|
<div
|
|
<div
|
|
- v-for="item in curvatureOptions"
|
|
|
|
|
|
+ v-for="item in lineTypes"
|
|
:key="item.id"
|
|
:key="item.id"
|
|
class="cursor-pointer"
|
|
class="cursor-pointer"
|
|
role="button"
|
|
role="button"
|
|
- @click="updateSetting('disableCurvature', item.value)"
|
|
|
|
|
|
+ @click="settings.lineType = item.id"
|
|
>
|
|
>
|
|
<div
|
|
<div
|
|
:class="{
|
|
:class="{
|
|
- 'ring ring-accent': item.value === settings.editor.disableCurvature,
|
|
|
|
|
|
+ 'ring ring-accent': item.id === settings.lineType,
|
|
}"
|
|
}"
|
|
class="p-0.5 rounded-lg"
|
|
class="p-0.5 rounded-lg"
|
|
>
|
|
>
|
|
<img
|
|
<img
|
|
- :src="require(`@/assets/images/${item.id}.png`)"
|
|
|
|
|
|
+ :src="require(`@/assets/images/${item.img}.png`)"
|
|
width="140"
|
|
width="140"
|
|
class="rounded-lg"
|
|
class="rounded-lg"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
<span class="text-sm text-gray-600 dark:text-gray-200 ml-1">
|
|
<span class="text-sm text-gray-600 dark:text-gray-200 ml-1">
|
|
- {{ t(`common.${item.name}`) }}
|
|
|
|
|
|
+ {{ item.name }}
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <transition-expand>
|
|
|
|
- <div
|
|
|
|
- v-if="!settings.editor.disableCurvature"
|
|
|
|
- class="flex space-x-2 items-end mt-1"
|
|
|
|
- >
|
|
|
|
- <ui-input
|
|
|
|
- v-for="item in curvatureSettings"
|
|
|
|
- :key="item.id"
|
|
|
|
- :model-value="settings.editor[item.key]"
|
|
|
|
- :label="t(`settings.editor.curvature.${item.id}`)"
|
|
|
|
- type="number"
|
|
|
|
- min="0"
|
|
|
|
- max="1"
|
|
|
|
- class="w-full"
|
|
|
|
- placeholder="0.5"
|
|
|
|
- @change="updateSetting(item.key, curvatureLimit($event))"
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
- </transition-expand>
|
|
|
|
- <ui-list class="mt-8">
|
|
|
|
|
|
+ <ui-list class="mt-8 space-y-2">
|
|
<ui-list-item small>
|
|
<ui-list-item small>
|
|
- <ui-switch
|
|
|
|
- :model-value="settings.editor.arrow"
|
|
|
|
- @change="updateSetting('arrow', $event)"
|
|
|
|
- />
|
|
|
|
|
|
+ <ui-switch v-model="settings.arrow" />
|
|
<div class="flex-1 ml-4">
|
|
<div class="flex-1 ml-4">
|
|
<p class="leading-tight">
|
|
<p class="leading-tight">
|
|
{{ t('settings.editor.arrow.title') }}
|
|
{{ t('settings.editor.arrow.title') }}
|
|
@@ -65,43 +40,62 @@
|
|
</p>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</ui-list-item>
|
|
</ui-list-item>
|
|
|
|
+ <ui-list-item small>
|
|
|
|
+ <ui-switch v-model="settings.snapToGrid" />
|
|
|
|
+ <div class="flex-1 ml-4">
|
|
|
|
+ <p class="leading-tight">
|
|
|
|
+ {{ t('settings.editor.snapGrid.title') }}
|
|
|
|
+ </p>
|
|
|
|
+ <p class="text-gray-600 text-sm leading-tight dark:text-gray-200">
|
|
|
|
+ {{ t('settings.editor.snapGrid.description') }}
|
|
|
|
+ </p>
|
|
|
|
+ </div>
|
|
|
|
+ </ui-list-item>
|
|
|
|
+ <transition-expand>
|
|
|
|
+ <div
|
|
|
|
+ v-if="settings.snapToGrid"
|
|
|
|
+ class="pl-16 ml-2 space-x-2"
|
|
|
|
+ style="margin-top: 0"
|
|
|
|
+ >
|
|
|
|
+ <ui-input
|
|
|
|
+ v-model.number="settings.snapGrid[0]"
|
|
|
|
+ type="number"
|
|
|
|
+ label="X Axis"
|
|
|
|
+ />
|
|
|
|
+ <ui-input
|
|
|
|
+ v-model.number="settings.snapGrid[1]"
|
|
|
|
+ type="number"
|
|
|
|
+ label="Y Axis"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ </transition-expand>
|
|
</ui-list>
|
|
</ui-list>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script setup>
|
|
<script setup>
|
|
-import { computed } from 'vue';
|
|
|
|
-import { useStore } from 'vuex';
|
|
|
|
|
|
+import { reactive, onMounted, watch } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useI18n } from 'vue-i18n';
|
|
-import browser from 'webextension-polyfill';
|
|
|
|
|
|
+import cloneDeep from 'lodash.clonedeep';
|
|
|
|
+import { useStore } from '@/stores/main';
|
|
|
|
|
|
-const curvatureSettings = [
|
|
|
|
- { id: 'line', key: 'curvature' },
|
|
|
|
- { id: 'reroute', key: 'reroute_curvature' },
|
|
|
|
- { id: 'rerouteFirstLast', key: 'reroute_curvature_start_end' },
|
|
|
|
-];
|
|
|
|
-const curvatureOptions = [
|
|
|
|
- { id: 'curvature', value: false, name: 'enable' },
|
|
|
|
- { id: 'no-curvature', value: true, name: 'disable' },
|
|
|
|
|
|
+const lineTypes = [
|
|
|
|
+ { id: 'default', name: 'Default', img: 'default' },
|
|
|
|
+ { id: 'step', name: 'Step', img: 'step' },
|
|
|
|
+ { id: 'straight', name: 'Straight', img: 'straight' },
|
|
|
|
+ { id: 'smoothstep', name: 'Smooth step', img: 'smooth-step' },
|
|
|
|
+ { id: 'simplebezier', name: 'Simple bezier', img: 'default' },
|
|
];
|
|
];
|
|
|
|
|
|
const { t } = useI18n();
|
|
const { t } = useI18n();
|
|
const store = useStore();
|
|
const store = useStore();
|
|
|
|
|
|
-const settings = computed(() => store.state.settings);
|
|
|
|
-
|
|
|
|
-function updateSetting(path, value) {
|
|
|
|
- store.commit('updateStateNested', {
|
|
|
|
- value,
|
|
|
|
- path: `settings.editor.${path}`,
|
|
|
|
- });
|
|
|
|
|
|
+const settings = reactive({});
|
|
|
|
|
|
- browser.storage.local.set({ settings: settings.value });
|
|
|
|
-}
|
|
|
|
-function curvatureLimit(value) {
|
|
|
|
- if (value > 1) return 1;
|
|
|
|
- if (value < 0) return 0;
|
|
|
|
|
|
+watch(settings, () => {
|
|
|
|
+ store.updateSettings({ editor: settings });
|
|
|
|
+});
|
|
|
|
|
|
- return value;
|
|
|
|
-}
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
+ Object.assign(settings, cloneDeep(store.settings.editor));
|
|
|
|
+});
|
|
</script>
|
|
</script>
|
|
- -->
|
|
|