浏览代码

feat: save

gemercheung 9 月之前
父节点
当前提交
de0cd135bd
共有 5 个文件被更改,包括 169 次插入41 次删除
  1. 11 4
      src/App.vue
  2. 21 3
      src/styles/index.sass
  3. 0 19
      src/styles/theme.js
  4. 33 0
      src/styles/theme.ts
  5. 104 15
      src/views/topicNavigation/index.vue

+ 11 - 4
src/App.vue

@@ -97,15 +97,23 @@ import {
   NMessageProvider,
   zhCN,
   dateZhCN,
-  useMessage
+  createDiscreteApi
 } from 'naive-ui'
 
 import { computed, ref, toRaw, watchEffect, h, onMounted, watch } from 'vue'
 import type { Component } from 'vue'
 import { useMainStore } from '@/store'
-import themeOverrides from '@/styles/theme.js'
+import { themeOverrides } from '@/styles/theme'
 import { editorSave } from '@/api/module/editor'
+import type { ConfigProviderProps } from 'naive-ui'
 
+const configProviderPropsRef = computed<ConfigProviderProps>(() => ({
+  theme: darkTheme
+}))
+
+const { message } = createDiscreteApi(['message'], {
+  configProviderProps: configProviderPropsRef
+})
 import { useRouter, useRoute } from 'vue-router'
 import {
   ChevronBackOutline,
@@ -128,7 +136,6 @@ const route = useRoute()
 const activeKey = ref(route.name)
 
 const showScene = ref(false)
-// const message = useMessage()
 
 watch(
   () => route.name,
@@ -280,7 +287,7 @@ onMounted(() => {
 const handleEditorSave = async () => {
   const data = main.getEditorData
   await editorSave(data)
-  // message.success('保存成功!')
+  message.success('保存成功!')
 }
 </script>
 

+ 21 - 3
src/styles/index.sass

@@ -7,13 +7,14 @@
 @import "fonts/index.sass"
 pointerNo
   pointer-events: none
+
 pointer
   pointer-events: auto
 
 
 :root
-  .n-layout-header,.n-layout-sider,.n-drawer
-    --n-color: rgba(0, 21, 41, 0.6)
+  //.n-layout-header, .n-layout-sider, .n-drawer
+  //  --n-color: rgba(0, 21, 41, 0.6)
 
 //  background: rgba(0, 21, 41, 1)
 //  border-color: rgb(0, 21, 41) !important
@@ -31,4 +32,21 @@ pointer
 //  a
 //   color: #fff !important
 //.n-menu-item-content__icon
-//  color: #fff
+//  color: #fff
+
+/* 滚动槽 */
+::-webkit-scrollbar
+  width: 6px
+  height: 6px
+
+::-webkit-scrollbar-track
+  border-radius: 3px
+  background: rgba(255, 255, 255, 0.06)
+  box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.08)
+/* 滚动条滑块 */
+::-webkit-scrollbar-thumb
+  border-radius: 3px
+  background: rgba(255, 255, 255, 0.42)
+  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5)
+
+

+ 0 - 19
src/styles/theme.js

@@ -1,19 +0,0 @@
-const themeOverrides = {
-  common: {
-    primaryColor: '#316c72',
-    primaryColorHover: '#316C72E3',
-    primaryColorPressed: '#2B4C59FF',
-    primaryColorSuppl: '#316C7263',
-    successColor: '#316C72FF',
-    successColorHover: '#316C72E3',
-    successColorPressed: '#2B4C59FF',
-    successColorSuppl: '#316C7263',
-    color: 'rgba(0, 21, 41, 0.2)'
-  }
-
-  // Button: {
-  //     textColor: '#FF0000'
-  // }
-}
-
-export default themeOverrides

+ 33 - 0
src/styles/theme.ts

@@ -0,0 +1,33 @@
+import { GlobalThemeOverrides } from 'naive-ui'
+
+export const themeOverrides: GlobalThemeOverrides = {
+  common: {
+    baseColor: '#ffffff',
+    primaryColor: '#0960bd',
+    primaryColorHover: '#1478e3',
+    primaryColorPressed: '#064282',
+    primaryColorSuppl: '#316C7263',
+    successColor: '#316C72FF',
+    successColorHover: '#316C72E3',
+    successColorPressed: '#2B4C59FF',
+    successColorSuppl: '#316C7263'
+  },
+  Drawer: {
+    color: 'rgb(24, 24, 28)'
+  },
+  Menu: {
+    itemTextColor: '#ffffff',
+    itemTextColorActive: '#ffffff',
+    pressedColor: '#ffffff',
+    itemColorHoverInverted: 'rgb(24, 24, 28)'
+  },
+
+  Button: {
+    // textColor: '#ffffff'
+  }
+  // Button: {
+  //     textColor: '#FF0000'
+  // }
+}
+
+export default themeOverrides

+ 104 - 15
src/views/topicNavigation/index.vue

@@ -14,7 +14,9 @@
       <n-drawer-content title="专题导航">
         <div class="drawerContent m-5"></div>
         <n-flex justify="center">
-          <n-button type="primary" @click="handleAdd">+ 添加</n-button>
+          <n-button v-if="!isPanoEditing" type="primary" @click="handleAdd"
+            >+ 添加
+          </n-button>
         </n-flex>
 
         <n-list
@@ -22,19 +24,39 @@
           clickable
           style="--n-color-modal: none; margin-top: 20px"
           :show-divider="false"
-          @select="handleSelect"
+          v-if="!isPanoEditing"
         >
           <n-list-item v-for="(nav, index) in dataList" :key="index" style="">
-            <n-flex justify="space-between">
+            <n-flex justify="space-between" align="center" :size="0">
               <n-flex align="center">
                 <n-icon size="20">
                   <WalkSharp />
                 </n-icon>
-                {{ nav.title }}
+                <template v-if="isShowEditing(index)">
+                  <n-flex style="flex: 1" align="center">
+                    <n-input-group>
+                      <n-input
+                        v-model:value="nav.title"
+                        style="max-width: 130px"
+                      />
+
+                      <n-button type="primary" @click="currentEditing = NaN">
+                        退出
+                      </n-button>
+                    </n-input-group>
+                  </n-flex>
+                </template>
+                <div v-else @click="handleItem(index)">
+                  {{ nav.title === '新增路线' ? nav.title + index : nav.title }}
+                </div>
               </n-flex>
 
-              <n-dropdown trigger="hover" :options="fullOptions">
-                <n-icon :size="20">
+              <n-dropdown
+                @select="(key) => handleSelect(key, index)"
+                trigger="hover"
+                :options="fullOptions"
+              >
+                <n-icon :size="20" v-show="!isShowEditing(index)">
                   <svg
                     xmlns="http://www.w3.org/2000/svg"
                     xmlns:xlink="http://www.w3.org/1999/xlink"
@@ -49,31 +71,71 @@
             </n-flex>
           </n-list-item>
         </n-list>
+
+        <template v-else>
+          <n-flex justify="center" align="center" vertical style="flex: 1">
+            <n-flex
+              justify="start"
+              align="start"
+              style="min-height: 400px; width: 100%"
+              vertical
+            >
+              <template v-if="panos.length > 0">
+                <n-list
+                  hoverable
+                  clickable
+                  style="--n-color-modal: none; width: 100%"
+                  :show-divider="false"
+                >
+                  <n-list-item v-for="(pano, index) in panos" :key="index">
+                    <n-flex justify="space-between">
+                      {{ pano }}
+                      <n-icon :size="20" @click="handlePanoDel">
+                        <TrashOutline />
+                      </n-icon>
+                    </n-flex>
+                  </n-list-item>
+                </n-list>
+              </template>
+              <n-flex v-else justify="center" style="width: 100%">
+                <span> 暂没数据,请选择线路</span>
+              </n-flex>
+            </n-flex>
+
+            <n-button
+              type="primary"
+              @click="handleItemSubmit"
+              style="width: 130px"
+              >确定并返回列表
+            </n-button>
+          </n-flex>
+        </template>
       </n-drawer-content>
     </n-drawer>
   </div>
 </template>
 
 <script setup lang="ts">
-import { ref } from 'vue'
+import { computed, ref } from 'vue'
 import { sdk, clearScreen } from '@/sdk'
 import { onMounted, onUnmounted } from 'vue'
 import {
-  NRadio,
-  NPopover,
+  // NRadio,
+  // NPopover,
   useDialog,
   useMessage,
   NDropdown,
   NList,
-  NListItem
+  NListItem,
+  NInputGroup
 } from 'naive-ui'
 import { WalkSharp, TrashOutline, EllipsisHorizontal } from '@vicons/ionicons5'
 
 const panos = ref([])
-const isEditing = ref({
-  index: NaN
-})
 
+const currentEditing = ref(NaN)
+const currentPanoEditing = ref()
+const isPanoEditing = ref(false)
 const dataList = ref<
   {
     title: string
@@ -128,7 +190,6 @@ const dialog = useDialog()
 const message = useMessage()
 
 const active = ref(true)
-// const show = ref(true)
 
 const fullOptions = ref([
   {
@@ -141,14 +202,42 @@ const fullOptions = ref([
   }
 ])
 
-const handleSelect = (key: string) => {
+const handleSelect = (key: string, index: number) => {
+  // console.log('handleSelect', key)
   switch (key) {
     case '1':
+      handleListEdit(index)
       break
     case '2':
+      handleListDel(index)
       break
   }
 }
+
+const handleListEdit = (index: number) => {
+  console.log('handleListEdit', index)
+  currentPanoEditing.value = index
+  isPanoEditing.value = true
+}
+
+const handleListDel = (index: number) => {
+  console.log('handleListDel', index)
+  dataList.value.splice(index, 1)
+}
+
+const isShowEditing = computed(() => (i: number) => currentEditing.value === i)
+
+const handleItem = (index: number) => {
+  console.log('handleItem', index)
+  currentEditing.value = index
+}
+
+const handleItemSubmit = () => {
+  isPanoEditing.value = false
+}
+const handlePanoDel = () => {
+  isPanoEditing.value = false
+}
 </script>
 
 <style lang="sass" scoped>