From 2a8eabe09dda50c53158f6deca4080b1d9f6db27 Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 20 Jan 2024 05:33:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20GitLab=20Snippet(?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=20>=202.14.186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/store/settings.ts | 3 +++ src/types/store/settings.d.ts | 1 + src/views/My.vue | 37 +++++++++++++++++++++++++++++++++-- src/views/Sync.vue | 3 ++- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5f4ccb647..d97212ced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sub-store-front-end", - "version": "2.14.85", + "version": "2.14.86", "private": true, "scripts": { "dev": "vite --host", diff --git a/src/store/settings.ts b/src/store/settings.ts index 1f4081f47..a2aef1c11 100644 --- a/src/store/settings.ts +++ b/src/store/settings.ts @@ -12,6 +12,7 @@ const { t } = i18n.global; export const useSettingsStore = defineStore('settingsStore', { state: (): SettingsStoreState => { return { + syncPlatform: '', gistToken: '', githubUser: '', defaultUserAgent: '', @@ -36,6 +37,7 @@ export const useSettingsStore = defineStore('settingsStore', { const { showNotify } = useAppNotifyStore(); const res = await settingsApi.getSettings(); if (res?.data?.status === 'success' && res?.data?.data) { + this.syncPlatform = res.data.data.syncPlatform || ''; this.gistToken = res.data.data.gistToken || ''; this.githubUser = res.data.data.githubUser || ''; this.defaultUserAgent = res.data.data.defaultUserAgent || ''; @@ -71,6 +73,7 @@ export const useSettingsStore = defineStore('settingsStore', { const { showNotify } = useAppNotifyStore(); const res = await settingsApi.setSettings(data); if (res?.data?.status === 'success' && res?.data?.data) { + this.syncPlatform = res.data.data.syncPlatform || ''; this.gistToken = res.data.data.gistToken || ''; this.githubUser = res.data.data.githubUser || ''; this.defaultUserAgent = res.data.data.defaultUserAgent || ''; diff --git a/src/types/store/settings.d.ts b/src/types/store/settings.d.ts index e5d283cde..3965935c3 100644 --- a/src/types/store/settings.d.ts +++ b/src/types/store/settings.d.ts @@ -9,6 +9,7 @@ interface SettingsBase { } interface SettingsPostData { + syncPlatform?: string; gistToken?: string; githubUser?: string; defaultUserAgent?: string; diff --git a/src/views/My.vue b/src/views/My.vue index 49dab47d5..e380b84f3 100644 --- a/src/views/My.vue +++ b/src/views/My.vue @@ -153,7 +153,11 @@ type="text" input-align="left" :left-icon="iconUser" - /> + > + + { @@ -278,7 +282,9 @@ const onClickAbout = () => { router.push(`/aboutUs`); }; + // 编辑 更新 +const syncPlatformInput = ref(""); const userInput = ref(""); const tokenInput = ref(""); const uaInput = ref(""); @@ -293,6 +299,7 @@ const toggleEditMode = async () => { isEditLoading.value = true; if (isEditing.value) { await settingsStore.editSettings({ + syncPlatform: syncPlatformInput.value, githubUser: userInput.value, gistToken: tokenInput.value, defaultUserAgent: uaInput.value, @@ -300,6 +307,7 @@ const toggleEditMode = async () => { }); setDisplayInfo(); } else { + syncPlatformInput.value = syncPlatform.value; userInput.value = githubUser.value; tokenInput.value = gistToken.value; uaInput.value = defaultUserAgent.value; @@ -314,7 +322,32 @@ const exitEditMode = () => { isEditing.value = false; isEditLoading.value = false; }; +const toggleSyncPlatform = () => { + if (syncPlatformInput.value === 'gitlab') { + syncPlatformInput.value = '' + Toast.text(`已切换到 ${syncPlatformInput.value === 'gitlab' ? 'GitLab Snippet' : 'Gist'}`); + } else { + Dialog({ + title: '切换同步平台', + content: 'GitLab Snippet 正在测试中, 相关文案仍然是 Gist, 请备份数据后使用', + popClass: 'auto-dialog', + okText: `使用 ${syncPlatformInput.value === 'gitlab' ? 'Gist' : ' Snippet'}`, + cancelText: '取消', + onOk: () => { + if (syncPlatformInput.value === 'gitlab') { + syncPlatformInput.value = '' + } else { + syncPlatformInput.value = 'gitlab' + } + Toast.text(`已切换到 ${syncPlatformInput.value === 'gitlab' ? 'GitLab Snippet' : 'Gist'}`); + }, + closeOnPopstate: true, + lockScroll: false, + }); + } + +}; const setDisplayInfo = () => { userInput.value = githubUser.value || t(`myPage.placeholder.noGithubUser`); tokenInput.value = gistToken.value diff --git a/src/views/Sync.vue b/src/views/Sync.vue index 1d57c6682..6c8ac63d0 100644 --- a/src/views/Sync.vue +++ b/src/views/Sync.vue @@ -50,6 +50,7 @@ />