mirror of https://git.tuxpa.in/a/code-server.git
Merge pull request #1920 from fxxjdedd/patch-1
feat: persist route query to local
This commit is contained in:
commit
cbf7c9556c
|
@ -183,11 +183,10 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
if (startPath) {
|
settings.write({
|
||||||
settings.write({
|
lastVisited: startPath || lastVisited, // If startpath is undefined, then fallback to lastVisited
|
||||||
lastVisited: startPath,
|
query: route.query,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.isDev) {
|
if (!this.isDev) {
|
||||||
response.content = response.content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "")
|
response.content = response.content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "")
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as fs from "fs-extra"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { extend, paths } from "./util"
|
import { extend, paths } from "./util"
|
||||||
import { logger } from "@coder/logger"
|
import { logger } from "@coder/logger"
|
||||||
|
import { Route } from "./http"
|
||||||
|
|
||||||
export type Settings = { [key: string]: Settings | string | boolean | number }
|
export type Settings = { [key: string]: Settings | string | boolean | number }
|
||||||
|
|
||||||
|
@ -29,11 +30,13 @@ export class SettingsProvider<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write settings combined with current settings. On failure log a warning.
|
* Write settings combined with current settings. On failure log a warning.
|
||||||
* Objects will be merged and everything else will be replaced.
|
* Settings can be shallow or deep merged.
|
||||||
*/
|
*/
|
||||||
public async write(settings: Partial<T>): Promise<void> {
|
public async write(settings: Partial<T>, shallow = true): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await fs.writeFile(this.settingsPath, JSON.stringify(extend(await this.read(), settings), null, 2))
|
const oldSettings = await this.read()
|
||||||
|
const nextSettings = shallow ? Object.assign({}, oldSettings, settings) : extend(oldSettings, settings)
|
||||||
|
await fs.writeFile(this.settingsPath, JSON.stringify(nextSettings, null, 2))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(error.message)
|
logger.warn(error.message)
|
||||||
}
|
}
|
||||||
|
@ -55,6 +58,7 @@ export interface CoderSettings extends UpdateSettings {
|
||||||
url: string
|
url: string
|
||||||
workspace: boolean
|
workspace: boolean
|
||||||
}
|
}
|
||||||
|
query: Route["query"]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue