Skip to content

Commit

Permalink
优化 stores 文件夹内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Sep 14, 2024
1 parent a0ce071 commit 9dbd8b4
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 48 deletions.
2 changes: 1 addition & 1 deletion _deprecated/LanLobby.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
<script setup>
import { ref } from 'vue'
import { get, post, deleteReq } from '@/utils/request'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/index'
import { sendSuccessDialog } from '@/utils/dialog'
const bodyStyle = {
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import MainNav from './components/MainNav.vue'
import GuestNav from './components/GuestNav.vue'
import Notification from './components/Notification.vue'
import { computed } from 'vue'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import hljs from 'highlight.js/lib/core'
import ini from 'highlight.js/lib/languages/ini'
import nginx from 'highlight.js/lib/languages/nginx'
Expand Down
2 changes: 1 addition & 1 deletion src/components/MainNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
import { h, ref, onMounted } from 'vue'
import { NGradientText } from 'naive-ui'
import SideBar from './MainSideBar.vue'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import router from '@/router/index'
import UserInfo, { changeUserInfoShow } from './UserInfo.vue'
import { get } from '@/utils/request'
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

<script setup>
import { logout } from '@/utils/profile'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendSuccessMessage } from '@/utils/message'
import { onMounted, ref } from 'vue'
import { useDialog } from 'naive-ui'
Expand Down
6 changes: 3 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import ndialog from './components/Dialog.vue'
import router from './router/index'
import axios from 'axios'
import VueAxios from 'vue-axios'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import userDataLocal from '@/utils/stores/userData/local'
import { printTitle } from '@/utils/title'
import Clipboard from 'v-clipboard'
import loadFromLocal from './utils/stores/loadFromLocal'

printTitle()

Expand All @@ -36,5 +36,5 @@ app.component('message', message)
app.component('loadingbar', loadingbar)
app.component('ndialog', ndialog)

loadFromLocal()
userDataLocal()
app.mount('#app')
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRouter, createWebHistory } from 'vue-router'
import { finishLoadingBar, startLoadingBar } from '@/utils/loadingbar'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { changeMainSideBarShow } from '../components/MainNav.vue'
import { changeShowGuestSideBar } from '../components/GuestNav.vue'
import { setSideBarActiveKey } from '../components/MainSideBar.vue'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/profile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import { ref } from 'vue'
import userData from './stores/userData'
import userData from './stores/userData/store'
import router from '@/router/index'
import { get } from './request'
import { sendWarningMessage } from './message'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios from 'axios'
// 序列化
import QS from 'qs'
// vuex
import userData from './stores/userData'
import userData from './stores/userData/store'
import router from '@/router/index'
import Base64 from 'qs/lib/utils'
import { sendErrorMessage } from './message'
Expand Down
11 changes: 11 additions & 0 deletions src/utils/stores/userData/def.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default {
token: '',
username: '',
email: '',
frptoken: '',
inbound: 0,
outbound: 0,
avatar: '',
traffic: '',
proxies_num: 0
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
import userData from './userData'

const defStateData = {
token: '',
username: '',
email: '',
frptoken: '',
inbound: 0,
outbound: 0,
avatar: '',
traffic: '',
proxies_num: 0
}
import userData from './store'
import defStateData from './def'

const loadFromLocal = () => {
userData.commit('set_token', localStorage.getItem('token') ?? defStateData.token)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import vuex from 'vuex'
import defStateData from './def'

const stateData = {
token: '',
Expand All @@ -11,20 +12,9 @@ const stateData = {
traffic: '',
proxies_num: 0
}
const defStateData = {
token: '',
username: '',
email: '',
frptoken: '',
inbound: 0,
outbound: 0,
avatar: '',
traffic: '',
proxies_num: 0
}

// 用Vuex.Store对象用来记录token
const userData = new vuex.Store({
export default new vuex.Store({
state: stateData,
getters: {
get_token(state) {
Expand Down Expand Up @@ -183,5 +173,3 @@ const userData = new vuex.Store({
// }
}
})

export default userData
2 changes: 1 addition & 1 deletion src/views/AddProxies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ n-input {
</style>
<script setup>
import { onMounted, ref } from 'vue'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendErrorMessage } from '@/utils/message'
import { sendErrorDialog, sendSuccessDialog } from '@/utils/dialog'
import api from '@/api'
Expand Down
2 changes: 1 addition & 1 deletion src/views/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ set_real_ip_from 127.0.0.1;"

<script setup>
import { ref } from 'vue'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendSuccessMessage, sendErrorMessage } from '@/utils/message'
// import clipboard from '@/utils/clipboard'
import api from '@/api'
Expand Down
2 changes: 1 addition & 1 deletion src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ import { ref, onMounted } from 'vue'
// import clipboard from '@/utils/clipboard'
import { get } from '@/utils/request'
import { AngleRight, Key } from '@vicons/fa'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { marked } from 'marked'
import { useDialog, useMessage } from 'naive-ui'
import { startLoadingBar } from '@/utils/loadingbar'
Expand Down
2 changes: 1 addition & 1 deletion src/views/Donate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<script setup>
import { onMounted, ref } from 'vue'
import { getUrlKey } from '@/utils/request'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendErrorMessage } from '@/utils/message'
import { sendSuccessDialog, sendWarningDialog } from '@/utils/dialog'
import api from '@/api'
Expand Down
2 changes: 1 addition & 1 deletion src/views/IcpCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</template>
<script setup>
import { ref } from 'vue'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { get, deleteReq } from '@/utils/request'
import { sendSuccessMessage, sendErrorMessage } from '@/utils/message'
import { sendErrorDialog, sendSuccessDialog } from '@/utils/dialog'
Expand Down
2 changes: 1 addition & 1 deletion src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { ref, onMounted } from 'vue'
import { useLoadingBar, useMessage } from 'naive-ui'
import { getUrlKey } from '@/utils/request'
import router from '@/router/index'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendErrorMessage } from '@/utils/message'
import logger from '@/utils/logger'
import api from '@/api'
Expand Down
2 changes: 1 addition & 1 deletion src/views/NewYear.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { ref } from 'vue'
import { sendErrorDialog, sendSuccessDialog, sendWarningDialog } from '@/utils/dialog'
import { finishLoadingBar, startLoadingBar } from '@/utils/loadingbar'
import { get } from '@/utils/request'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
const CommentList = ref([])
const formRef = ref(null)
Expand Down
2 changes: 1 addition & 1 deletion src/views/Prize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { ref } from 'vue'
import { sendSuccessDialog, sendWarningDialog } from '@/utils/dialog'
import { finishLoadingBar, startLoadingBar } from '@/utils/loadingbar'
import { get } from '@/utils/request'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { marked } from 'marked'

const PrizesList = ref([
Expand Down
2 changes: 1 addition & 1 deletion src/views/Proxies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
import { computed, ref } from 'vue'
import { useDialog } from 'naive-ui'
// import clipboard from '@/utils/clipboard'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import { sendErrorMessage, sendSuccessMessage } from '@/utils/message'
import { sendErrorDialog, sendSuccessDialog, sendWarningDialog } from '@/utils/dialog'
import downloadSoftPage from '../components/InstallCsApp.vue'
Expand Down
2 changes: 1 addition & 1 deletion src/views/RealName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ import { ref } from 'vue'
import { sendErrorMessage } from '@/utils/message'
import { sendSuccessDialog, sendWarningDialog } from '@/utils/dialog'
import { finishLoadingBar, startLoadingBar, errorLoadingBar } from '@/utils/loadingbar'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import api from '@/api'
import logger from '@/utils/logger'

Expand Down
2 changes: 1 addition & 1 deletion src/views/Sign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import { ref } from 'vue'
import { NButton, NCard, NGrid, NGridItem, NH1, NSkeleton, NSpace, NText } from 'naive-ui'
import { sendErrorMessage } from '@/utils/message'
import { sendSuccessDialog } from '@/utils/dialog'
import userData from '@/utils/stores/userData'
import userData from '@/utils/stores/userData/store'
import api from '@/api'

const loading = ref(true)
Expand Down

0 comments on commit 9dbd8b4

Please sign in to comment.